Skip to content

Commit c2bb47b

Browse files
authored
tv bump (#3)
* misc * bump
1 parent 7e2ae36 commit c2bb47b

File tree

7 files changed

+34
-67
lines changed

7 files changed

+34
-67
lines changed

composer.json

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@
66
"bin/behastan"
77
],
88
"require": {
9-
"php": ">=8.2",
10-
"illuminate/container": "^11.41",
9+
"php": "^8.2",
10+
"illuminate/container": "^11.41|^12.0",
1111
"nette/utils": "^4.0",
1212
"nikic/php-parser": "^5.4",
13-
"symfony/console": "^6.4",
14-
"symfony/finder": "^6.4",
13+
"symfony/console": "^6.4|^7.0|^8.0",
14+
"symfony/finder": "^6.4|^7.0|^8.0",
1515
"webmozart/assert": "^1.11"
1616
},
1717
"require-dev": {
1818
"phpstan/extension-installer": "^1.4",
19-
"phpstan/phpstan": "^2.0",
19+
"phpstan/phpstan": "^2.1",
2020
"phpunit/phpunit": "^11.5",
21-
"rector/rector": "^2.0",
22-
"phpecs/phpecs": "^2.0",
23-
"symplify/vendor-patches": "^11.3",
21+
"rector/rector": "^2.2",
22+
"phpecs/phpecs": "^2.2",
2423
"tomasvotruba/class-leak": "^2.0",
2524
"tracy/tracy": "^2.10"
2625
},
@@ -46,7 +45,6 @@
4645
"sort-packages": true,
4746
"platform-check": false,
4847
"allow-plugins": {
49-
"cweagans/composer-patches": true,
5048
"phpstan/extension-installer": true
5149
}
5250
},
@@ -55,12 +53,5 @@
5553
"fix-cs": "vendor/bin/ecs check --fix --ansi",
5654
"phpstan": "vendor/bin/phpstan analyse --ansi",
5755
"rector": "vendor/bin/rector process --ansi"
58-
},
59-
"extra": {
60-
"patches": {
61-
"symfony/console": [
62-
"patches/symfony-console-helper-helper-php.patch"
63-
]
64-
}
6556
}
6657
}

patches/symfony-console-helper-helper-php.patch

Lines changed: 0 additions & 28 deletions
This file was deleted.

rector.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
earlyReturn: true,
1616
codingStyle: true,
1717
instanceOf: true,
18+
phpunitCodeQuality: true,
1819
naming: true
1920
)
2021
->withImportNames()

src/Analyzer/ClassMethodContextDefinitionsAnalyzer.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ public function resolve(array $contextFileInfos): array
3333
$classMethodContextDefinitionByClassMethodHash = $this->resolveAndGroupByContentHash($contextFileInfos);
3434

3535
$classMethodContextDefinitions = [];
36-
foreach ($classMethodContextDefinitionByClassMethodHash as $currentClassMethodContextDefinitions) {
36+
foreach ($classMethodContextDefinitionByClassMethodHash as $classMethodContextDefinition) {
3737
$classMethodContextDefinitions = array_merge(
3838
$classMethodContextDefinitions,
39-
$currentClassMethodContextDefinitions
39+
$classMethodContextDefinition
4040
);
4141
}
4242

@@ -55,23 +55,28 @@ public function resolveAndGroupByContentHash(array $contextFileInfos): array
5555
$contextClassStmts = $this->simplePhpParser->parseFilePath($contextFileInfo->getRealPath());
5656

5757
$class = $this->nodeFinder->findFirstInstanceOf($contextClassStmts, Class_::class);
58-
if (! $class instanceof Class_ || ! $class->namespacedName instanceof Name) {
58+
if (! $class instanceof Class_) {
59+
continue;
60+
}
61+
if (! $class->namespacedName instanceof Name) {
5962
continue;
6063
}
6164

6265
$className = $class->namespacedName->toString();
6366

6467
foreach ($class->getMethods() as $classMethod) {
65-
if (! $classMethod->isPublic() || $classMethod->isMagic()) {
68+
if (! $classMethod->isPublic()) {
69+
continue;
70+
}
71+
if ($classMethod->isMagic()) {
6672
continue;
6773
}
68-
6974
$classMethodHash = $this->createClassMethodHash($classMethod);
7075

7176
$rawMasks = $this->classMethodMasksResolver->resolve($classMethod);
7277

7378
// no masks :(
74-
if (count($rawMasks) === 0) {
79+
if ($rawMasks === []) {
7580
continue;
7681
}
7782

src/Command/DuplicatedDefinitionsCommand.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Behastan\Analyzer\ClassMethodContextDefinitionsAnalyzer;
88
use Behastan\Enum\Option;
99
use Behastan\Finder\BehatMetafilesFinder;
10-
use Behastan\ValueObject\ClassMethodContextDefinition;
1110
use Symfony\Component\Console\Command\Command;
1211
use Symfony\Component\Console\Input\InputArgument;
1312
use Symfony\Component\Console\Input\InputInterface;
@@ -60,21 +59,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6059
);
6160

6261
$i = 0;
63-
foreach ($classMethodContextDefinitionByClassMethodHash as $classAndMethods) {
62+
foreach ($classMethodContextDefinitionByClassMethodHash as $classMethodContextDefinition) {
6463
$this->symfonyStyle->section(sprintf('%d)', $i + 1));
6564

66-
foreach ($classAndMethods as $classMethodContextDefinition) {
67-
/** @var ClassMethodContextDefinition $classMethodContextDefinition */
65+
foreach ($classMethodContextDefinition as $classAndMethod) {
6866
$relativeFilePath = substr(
69-
$classMethodContextDefinition->getFilePath(),
70-
strlen($testDirectories[0]) + 1
67+
$classAndMethod->getFilePath(),
68+
strlen((string) $testDirectories[0]) + 1
7169
);
7270

73-
$this->symfonyStyle->writeln(
74-
$relativeFilePath . ':' . $classMethodContextDefinition->getMethodLine()
75-
);
71+
$this->symfonyStyle->writeln($relativeFilePath . ':' . $classAndMethod->getMethodLine());
7672

77-
$this->symfonyStyle->writeln('Mask: <fg=green>"' . $classMethodContextDefinition->getMask() . '"</>');
73+
$this->symfonyStyle->writeln('Mask: <fg=green>"' . $classAndMethod->getMask() . '"</>');
7874
$this->symfonyStyle->newLine();
7975
}
8076

src/DefinitionMasksResolver.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
use PhpParser\NodeFinder;
1919
use SplFileInfo;
2020

21-
final class DefinitionMasksResolver
21+
final readonly class DefinitionMasksResolver
2222
{
2323
public function __construct(
24-
private readonly SimplePhpParser $simplePhpParser,
25-
private readonly NodeFinder $nodeFinder,
26-
private readonly ClassMethodMasksResolver $classMethodMasksResolver,
24+
private SimplePhpParser $simplePhpParser,
25+
private NodeFinder $nodeFinder,
26+
private ClassMethodMasksResolver $classMethodMasksResolver,
2727
) {
2828
}
2929

@@ -100,9 +100,11 @@ private function resolveMasksFromFiles(array $fileInfos): array
100100
if (! $class instanceof Class_) {
101101
continue;
102102
}
103-
104103
// is magic class?
105-
if ($class->isAnonymous() || ! $class->namespacedName instanceof Name) {
104+
if ($class->isAnonymous()) {
105+
continue;
106+
}
107+
if (! $class->namespacedName instanceof Name) {
106108
continue;
107109
}
108110

src/PhpParser/SimplePhpParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use PhpParser\ParserFactory;
1212
use Webmozart\Assert\Assert;
1313

14-
final class SimplePhpParser
14+
final readonly class SimplePhpParser
1515
{
1616
private Parser $phpParser;
1717

0 commit comments

Comments
 (0)