Skip to content

Commit b5c5ea0

Browse files
simbigclaude
andcommitted
feat(phpstan): treat no-arg method calls as accessors in OneThingPerLineRule
A method call without arguments (e.g. ->relation()) is treated like a property access and does not count as "a thing". This allows patterns like $item->magnaPure()->associate($x) on a single line. Also excludes method chains inside string interpolation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 94480f8 commit b5c5ea0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1344
-191
lines changed

phpstan/include-by-php-version.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
$includes[] = __DIR__ . '/../rules.neon';
99
}
1010

11-
// PHP < 8.0: exclude test fixtures using nullsafe operator syntax
12-
if (version_compare(PHP_VERSION, '8.0', '<')) {
13-
$includes[] = __DIR__ . '/php-below-8.0.neon';
14-
}
15-
1611
// PHP < 8.1: exclude enums, add ignores for older PHPStan versions
1712
if (version_compare(PHP_VERSION, '8.1', '<')) {
1813
$includes[] = __DIR__ . '/php-below-8.1.neon';

phpstan/php-below-8.1.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ parameters:
3030

3131
# Return type differences in older PHPStan rule interfaces
3232
- '#Method MLL\\Utils\\PHPStan\\Rules\\MissingClosureParameterTypehintRule::processNode\(\) should return array<int, PHPStan\\Rules\\IdentifierRuleError> but returns array<int, PHPStan\\Rules\\RuleError>\.#'
33-
- '#Method MLL\\Utils\\PHPStan\\Rules\\OneThingPerLineRule::processNode\(\) should return array<int, PHPStan\\Rules\\IdentifierRuleError> but returns array<int, PHPStan\\Rules\\RuleError>\.#'
3433

3534
# Existing code with @phpstan-ignore that older versions don't understand
3635
- message: '#Cannot access property \$name on SimpleXMLElement\|null\.#'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace MLL\Utils\Flowcells;
4+
5+
class FlowcellLaneNotExistsException extends \Exception {}

src/Flowcells/FlowcellType.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace MLL\Utils\Flowcells;
4+
5+
abstract class FlowcellType
6+
{
7+
abstract public function name(): string;
8+
9+
abstract public function totalLaneCount(): int;
10+
11+
/** @var array<int, int> */
12+
public array $lanes;
13+
14+
/** @param array<int, int>|null $lanes */
15+
public function __construct(?array $lanes)
16+
{
17+
if ($lanes === null) {
18+
$lanes = range(1, $this->totalLaneCount());
19+
}
20+
$this->validate($lanes);
21+
$this->lanes = $lanes;
22+
}
23+
24+
/** @param array<int, int> $specificLanes */
25+
public function validate(array $specificLanes): void
26+
{
27+
if (count(array_intersect($specificLanes, range(1, $this->totalLaneCount()))) !== count($specificLanes)) {
28+
throw new FlowcellLaneNotExistsException("Der FlowcellTyp: '{$this->name()}' besitzt keine Lane: " . implode(', ', array_diff($specificLanes, range(1, $this->totalLaneCount()))));
29+
}
30+
}
31+
}

src/Flowcells/Miseqi100_100M.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace MLL\Utils\Flowcells;
4+
5+
class Miseqi100_100M extends FlowcellType
6+
{
7+
public function totalLaneCount(): int
8+
{
9+
return 1;
10+
}
11+
12+
public function name(): string
13+
{
14+
return '100M';
15+
}
16+
}

src/Flowcells/Miseqi100_25M.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace MLL\Utils\Flowcells;
4+
5+
class Miseqi100_25M extends FlowcellType
6+
{
7+
public function totalLaneCount(): int
8+
{
9+
return 1;
10+
}
11+
12+
public function name(): string
13+
{
14+
return '25M';
15+
}
16+
}

src/Flowcells/Miseqi100_50M.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace MLL\Utils\Flowcells;
4+
5+
class Miseqi100_50M extends FlowcellType
6+
{
7+
public function totalLaneCount(): int
8+
{
9+
return 1;
10+
}
11+
12+
public function name(): string
13+
{
14+
return '50M';
15+
}
16+
}

src/Flowcells/Miseqi100_5M.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace MLL\Utils\Flowcells;
4+
5+
class Miseqi1005M extends FlowcellType
6+
{
7+
public function totalLaneCount(): int
8+
{
9+
return 1;
10+
}
11+
12+
public function name(): string
13+
{
14+
return '5M';
15+
}
16+
}

src/Flowcells/NovaSeqX10B.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace MLL\Utils\Flowcells;
4+
5+
class NovaSeqX10B extends FlowcellType
6+
{
7+
public function totalLaneCount(): int
8+
{
9+
return 8;
10+
}
11+
12+
public function name(): string
13+
{
14+
return '10B';
15+
}
16+
}

src/Flowcells/NovaSeqX1_5B.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace MLL\Utils\Flowcells;
4+
5+
class NovaSeqX1_5B extends FlowcellType
6+
{
7+
public function totalLaneCount(): int
8+
{
9+
return 2;
10+
}
11+
12+
public function name(): string
13+
{
14+
return '1.5B';
15+
}
16+
}

0 commit comments

Comments
 (0)