Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/code_analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
# see https://github.com/shivammathur/setup-php
- uses: shivammathur/setup-php@v2
with:
php-version: 8.3
php-version: 8.4
coverage: none

# composer install cache - https://github.com/ramsey/composer-install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/downgraded_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
-
uses: "shivammathur/setup-php@v2"
with:
php-version: 8.3
php-version: 8.4
coverage: none

# invoke patches
Expand Down
3 changes: 1 addition & 2 deletions composer-dependency-analyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;
use ShipMonk\ComposerDependencyAnalyser\Config\ErrorType;

return (new Configuration())
return new Configuration()
->addPathToExclude(__DIR__ . '/tests/Rules/Rector/NoInstanceOfStaticReflectionRule/Fixture')
->addPathToExclude(__DIR__ . '/tests/Rules/Enum/RequireUniqueEnumConstantRule/Fixture')
->addPathToExclude(__DIR__ . '/tests/Rules/ForbiddenExtendOfNonAbstractClassRule/Fixture')
Expand All @@ -21,7 +21,6 @@
->ignoreErrorsOnPackage('symfony/service-contracts', [ErrorType::SHADOW_DEPENDENCY])
->ignoreErrorsOnPackage('symfony/http-kernel', [ErrorType::SHADOW_DEPENDENCY])
->ignoreErrorsOnPackage('symfony/event-dispatcher', [ErrorType::SHADOW_DEPENDENCY])
->ignoreErrorsOnPackage('symfony/deprecation-contracts', [ErrorType::SHADOW_DEPENDENCY])
->ignoreErrorsOnPackage('symfony/dependency-injection', [ErrorType::SHADOW_DEPENDENCY])
->ignoreErrorsOnPackage('symfony/config', [ErrorType::SHADOW_DEPENDENCY])

Expand Down
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
"description": "Set of Symplify rules for PHPStan",
"license": "MIT",
"require": {
"php": ">=8.3",
"webmozart/assert": "^1.12 || ^2.0",
"phpstan/phpstan": "^2.1.33",
"php": ">=8.4",
"webmozart/assert": " ^2.0",
"phpstan/phpstan": "^2.2",
"nette/utils": "^4.1",
"phpstan/phpdoc-parser": "^2.3"
},
"require-dev": {
"nikic/php-parser": "^5.7",
"phpunit/phpunit": "^12.5",
"symfony/framework-bundle": "6.1.*",
"phpecs/phpecs": "^2.2",
"phpunit/phpunit": "^13.0",
"symfony/framework-bundle": "^6.2",
"symplify/easy-coding-standard": "^13.0",
"tomasvotruba/class-leak": "^2.1",
"rector/rector": "^2.3.6",
"rector/rector": "^2.4",
"phpstan/extension-installer": "^1.4",
"symplify/phpstan-extensions": "^12.0",
"tomasvotruba/unused-public": "^2.1",
"tomasvotruba/type-coverage": "^2.1",
"tomasvotruba/unused-public": "^2.2",
"tomasvotruba/type-coverage": "^2.2",
"shipmonk/composer-dependency-analyser": "^1.8",
"rector/jack": "^0.4.0"
"rector/jack": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down
8 changes: 1 addition & 7 deletions src/Doctrine/DoctrineEntityDocumentAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ public static function isEntityClass(ClassReflection $classReflection): bool
return false;
}

foreach (self::ENTITY_DOCBLOCK_MARKERS as $entityDocBlockMarkers) {
if (str_contains($resolvedPhpDocBlock->getPhpDocString(), $entityDocBlockMarkers)) {
return true;
}
}

return false;
return array_any(self::ENTITY_DOCBLOCK_MARKERS, fn (string $entityDocBlockMarker): bool => str_contains($resolvedPhpDocBlock->getPhpDocString(), $entityDocBlockMarker));
}
}
8 changes: 1 addition & 7 deletions src/Helper/NamingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ public static function isName(Node $node, string $name): bool
*/
public static function isNames(Node $node, array $names): bool
{
foreach ($names as $name) {
if (self::isName($node, $name)) {
return true;
}
}

return false;
return array_any($names, fn (string $name): bool => self::isName($node, $name));
}
}
8 changes: 1 addition & 7 deletions src/Matcher/ArrayStringAndFnMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ public function isMatchWithIsA(string $currentValue, array $matchingValues): boo
return true;
}

foreach ($matchingValues as $matchingValue) {
if (is_a($currentValue, $matchingValue, true)) {
return true;
}
}

return false;
return array_any($matchingValues, fn (string $matchingValue): bool => is_a($currentValue, $matchingValue, true));
}

/**
Expand Down
8 changes: 1 addition & 7 deletions src/PHPUnit/TestClassDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ final class TestClassDetector

public static function isTestClass(Scope $scope): bool
{
foreach (self::TEST_FILE_SUFFIXES as $testFileSuffix) {
if (str_ends_with($scope->getFile(), $testFileSuffix)) {
return true;
}
}

return false;
return array_any(self::TEST_FILE_SUFFIXES, fn (string $testFileSuffix): bool => str_ends_with($scope->getFile(), $testFileSuffix));
}
}
8 changes: 1 addition & 7 deletions src/Rules/SeeAnnotationToTestRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,7 @@ private function shouldSkipClassReflection(ClassReflection $classReflection): bo
return true;
}

foreach ($this->requiredSeeTypes as $requiredSeeType) {
if ($classReflection->is($requiredSeeType)) {
return false;
}
}

return true;
return array_all($this->requiredSeeTypes, fn (string $requiredSeeType): bool => ! $classReflection->is($requiredSeeType));
}

/**
Expand Down
8 changes: 1 addition & 7 deletions src/Rules/StringFileAbsolutePathExistsRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ private function getAbsoluteFilePath(Scope $scope, string $stringValue): string

private function isDesiredFileSuffix(string $stringValue): bool
{
foreach (self::SUFFIXES_TO_CHECK as $suffixToCheck) {
if (str_ends_with($stringValue, $suffixToCheck)) {
return true;
}
}

return false;
return array_any(self::SUFFIXES_TO_CHECK, fn (string $suffixToCheck): bool => str_ends_with($stringValue, $suffixToCheck));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,6 @@ private function isClassInExcludedPaths(string $serviceClass, array $excludedPat
return false;
}

foreach ($excludedPaths as $excludedPath) {
if (str_starts_with($serviceFilePath, $excludedPath)) {
return true;
}
}

return false;
return array_any($excludedPaths, fn (string $excludedPath): bool => str_starts_with($serviceFilePath, $excludedPath));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Symplify\PHPStanRules\Rules\Symfony\ConfigClosure;

use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\FuncCall;
Expand Down Expand Up @@ -105,13 +106,7 @@ public function processNode(Node $node, Scope $scope): array

private function hasPossibleParameterInject(MethodCall $methodCall): bool
{
foreach ($methodCall->getArgs() as $arg) {
if ($this->isParamFuncOrString($arg->value)) {
return true;
}
}

return false;
return array_any($methodCall->getArgs(), fn (Arg $arg): bool => $this->isParamFuncOrString($arg->value));
}

private function isParamFuncOrString(Expr $expr): bool
Expand Down
8 changes: 1 addition & 7 deletions src/Rules/Symfony/RequiredOnlyInAbstractRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,7 @@ private function shouldSkipClass(Scope $scope): bool
return true;
}

foreach (self::SKIPPED_PARENT_TYPES as $skippedParentType) {
if ($classReflection->is($skippedParentType)) {
return true;
}
}

return false;
return array_any(self::SKIPPED_PARENT_TYPES, fn (string $skippedParentType): bool => $classReflection->is($skippedParentType));
}

private function hasCircularDocNote(Node $node): bool
Expand Down
8 changes: 1 addition & 7 deletions src/Symfony/NodeAnalyzer/SymfonyControllerAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ public static function isControllerScope(Scope $scope): bool
}

$classReflection = $scope->getClassReflection();
foreach (self::CONTROLLER_TYPES as $controllerType) {
if ($classReflection->is($controllerType)) {
return true;
}
}

return false;
return array_any(self::CONTROLLER_TYPES, fn (string $controllerType): bool => $classReflection->is($controllerType));
}

public static function isControllerActionMethod(ClassMethod $classMethod): bool
Expand Down
8 changes: 1 addition & 7 deletions src/TypeAnalyzer/RectorAllowedAutoloadedTypeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,7 @@ final class RectorAllowedAutoloadedTypeAnalyzer
public static function isAllowedType(Type $type): bool
{
if ($type instanceof UnionType) {
foreach ($type->getTypes() as $unionedType) {
if (! self::isAllowedType($unionedType)) {
return false;
}
}

return true;
return array_all($type->getTypes(), fn (Type $unionedType): bool => self::isAllowedType($unionedType));
}

if ($type instanceof ConstantStringType) {
Expand Down
Loading