From 5296bddf5f32ee9503f25bb156ab54d011c8b108 Mon Sep 17 00:00:00 2001 From: John Boehr Date: Tue, 21 Feb 2023 16:57:50 -0800 Subject: [PATCH 1/3] Revert "Update dependencies to use reveal/template-phpstan-compiler" This reverts commit 4944f89fafc4745275f9c11015cfefb6dd4bcf55. --- composer.json | 2 +- src/Compiler/BladeToPHPCompiler.php | 4 ++-- src/ErrorReporting/Blade/TemplateErrorsFactory.php | 2 +- src/NodeAnalyzer/BladeViewMethodsMatcher.php | 2 +- src/NodeAnalyzer/LaravelViewFunctionMatcher.php | 2 +- src/NodeAnalyzer/TemplateFilePathResolver.php | 2 +- src/Rules/ViewRuleHelper.php | 8 ++++---- src/ValueObject/PhpFileContentsWithLineMap.php | 2 +- tests/Compiler/BladeToPHPCompilerTest.php | 4 ++-- tests/Rules/BladeViewRuleTest.php | 4 ++-- tests/Rules/LaravelViewFunctionRuleTest.php | 4 ++-- tests/tests.neon | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index 35e0803..ab7f695 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "illuminate/filesystem": "^8.82 || ^9.0", "illuminate/view": "^8.82 || ^9", "phpstan/phpstan": "^1.7", - "reveal/template-phpstan-compiler": "^0.2" + "symplify/template-phpstan-compiler": "^10.0.20" }, "require-dev": { "doctrine/coding-standard": "^9.0", diff --git a/src/Compiler/BladeToPHPCompiler.php b/src/Compiler/BladeToPHPCompiler.php index 39ab6ed..7c4f877 100644 --- a/src/Compiler/BladeToPHPCompiler.php +++ b/src/Compiler/BladeToPHPCompiler.php @@ -20,8 +20,8 @@ use PhpParser\ParserFactory; use PhpParser\PrettyPrinter\Standard; use PHPStan\ShouldNotHappenException; -use Reveal\TemplatePHPStanCompiler\NodeFactory\VarDocNodeFactory; -use Reveal\TemplatePHPStanCompiler\ValueObject\VariableAndType; +use Symplify\TemplatePHPStanCompiler\NodeFactory\VarDocNodeFactory; +use Symplify\TemplatePHPStanCompiler\ValueObject\VariableAndType; use Throwable; use Vural\PHPStanBladeRule\Blade\PhpLineToTemplateLineResolver; use Vural\PHPStanBladeRule\PHPParser\ConvertArrayStringToArray; diff --git a/src/ErrorReporting/Blade/TemplateErrorsFactory.php b/src/ErrorReporting/Blade/TemplateErrorsFactory.php index c440c22..ef3317b 100644 --- a/src/ErrorReporting/Blade/TemplateErrorsFactory.php +++ b/src/ErrorReporting/Blade/TemplateErrorsFactory.php @@ -13,7 +13,7 @@ use function array_key_first; use function current; -/** @see \Reveal\TemplatePHPStanCompiler\Reporting\TemplateErrorsFactory */ +/** @see \Symplify\TemplatePHPStanCompiler\Reporting\TemplateErrorsFactory */ final class TemplateErrorsFactory { /** diff --git a/src/NodeAnalyzer/BladeViewMethodsMatcher.php b/src/NodeAnalyzer/BladeViewMethodsMatcher.php index 8637274..c22e309 100644 --- a/src/NodeAnalyzer/BladeViewMethodsMatcher.php +++ b/src/NodeAnalyzer/BladeViewMethodsMatcher.php @@ -10,7 +10,7 @@ use PHPStan\Analyser\Scope; use PHPStan\Type\ObjectType; use PHPStan\Type\ThisType; -use Reveal\TemplatePHPStanCompiler\ValueObject\RenderTemplateWithParameters; +use Symplify\TemplatePHPStanCompiler\ValueObject\RenderTemplateWithParameters; use function count; use function in_array; diff --git a/src/NodeAnalyzer/LaravelViewFunctionMatcher.php b/src/NodeAnalyzer/LaravelViewFunctionMatcher.php index 73c309a..1fa828b 100644 --- a/src/NodeAnalyzer/LaravelViewFunctionMatcher.php +++ b/src/NodeAnalyzer/LaravelViewFunctionMatcher.php @@ -6,7 +6,7 @@ use PhpParser\Node; use PHPStan\Analyser\Scope; -use Reveal\TemplatePHPStanCompiler\ValueObject\RenderTemplateWithParameters; +use Symplify\TemplatePHPStanCompiler\ValueObject\RenderTemplateWithParameters; use function count; diff --git a/src/NodeAnalyzer/TemplateFilePathResolver.php b/src/NodeAnalyzer/TemplateFilePathResolver.php index 2244481..cc0b516 100644 --- a/src/NodeAnalyzer/TemplateFilePathResolver.php +++ b/src/NodeAnalyzer/TemplateFilePathResolver.php @@ -16,7 +16,7 @@ use function str_contains; use function str_replace; -/** @see \Reveal\TemplatePHPStanCompiler\NodeAnalyzer\TemplateFilePathResolver */ +/** @see \Symplify\TemplatePHPStanCompiler\NodeAnalyzer\TemplateFilePathResolver */ final class TemplateFilePathResolver { public function __construct( diff --git a/src/Rules/ViewRuleHelper.php b/src/Rules/ViewRuleHelper.php index d70973a..4cb89e9 100644 --- a/src/Rules/ViewRuleHelper.php +++ b/src/Rules/ViewRuleHelper.php @@ -9,10 +9,10 @@ use PHPStan\Rules\Registry; use PHPStan\Rules\RuleError; use PHPStan\ShouldNotHappenException; -use Reveal\TemplatePHPStanCompiler\PHPStan\FileAnalyserProvider; -use Reveal\TemplatePHPStanCompiler\TypeAnalyzer\TemplateVariableTypesResolver; -use Reveal\TemplatePHPStanCompiler\ValueObject\RenderTemplateWithParameters; -use Reveal\TemplatePHPStanCompiler\ValueObject\VariableAndType; +use Symplify\TemplatePHPStanCompiler\PHPStan\FileAnalyserProvider; +use Symplify\TemplatePHPStanCompiler\TypeAnalyzer\TemplateVariableTypesResolver; +use Symplify\TemplatePHPStanCompiler\ValueObject\RenderTemplateWithParameters; +use Symplify\TemplatePHPStanCompiler\ValueObject\VariableAndType; use Vural\PHPStanBladeRule\Compiler\BladeToPHPCompiler; use Vural\PHPStanBladeRule\ErrorReporting\Blade\TemplateErrorsFactory; diff --git a/src/ValueObject/PhpFileContentsWithLineMap.php b/src/ValueObject/PhpFileContentsWithLineMap.php index d5e0b1d..1de3c39 100644 --- a/src/ValueObject/PhpFileContentsWithLineMap.php +++ b/src/ValueObject/PhpFileContentsWithLineMap.php @@ -4,7 +4,7 @@ namespace Vural\PHPStanBladeRule\ValueObject; -/** @see \Reveal\TemplatePHPStanCompiler\ValueObject\PhpFileContentsWithLineMap */ +/** @see \Symplify\TemplatePHPStanCompiler\ValueObject\PhpFileContentsWithLineMap */ final class PhpFileContentsWithLineMap { /** diff --git a/tests/Compiler/BladeToPHPCompilerTest.php b/tests/Compiler/BladeToPHPCompilerTest.php index 1eccde1..f30c1f3 100644 --- a/tests/Compiler/BladeToPHPCompilerTest.php +++ b/tests/Compiler/BladeToPHPCompilerTest.php @@ -11,12 +11,12 @@ use PhpParser\ConstExprEvaluator; use PhpParser\PrettyPrinter\Standard; use PHPUnit\Framework\TestCase; -use Reveal\TemplatePHPStanCompiler\NodeFactory\VarDocNodeFactory; -use Reveal\TemplatePHPStanCompiler\ValueObject\VariableAndType; use Symplify\EasyTesting\DataProvider\StaticFixtureFinder; use Symplify\EasyTesting\DataProvider\StaticFixtureUpdater; use Symplify\EasyTesting\StaticFixtureSplitter; use Symplify\SmartFileSystem\SmartFileInfo; +use Symplify\TemplatePHPStanCompiler\NodeFactory\VarDocNodeFactory; +use Symplify\TemplatePHPStanCompiler\ValueObject\VariableAndType; use Vural\PHPStanBladeRule\Blade\PhpLineToTemplateLineResolver; use Vural\PHPStanBladeRule\Compiler\BladeToPHPCompiler; use Vural\PHPStanBladeRule\Compiler\FileNameAndLineNumberAddingPreCompiler; diff --git a/tests/Rules/BladeViewRuleTest.php b/tests/Rules/BladeViewRuleTest.php index 2b3df6b..bda4e64 100644 --- a/tests/Rules/BladeViewRuleTest.php +++ b/tests/Rules/BladeViewRuleTest.php @@ -7,8 +7,8 @@ use PHPStan\Rules\Operators\InvalidBinaryOperationRule; use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; -use Reveal\TemplatePHPStanCompiler\PHPStan\FileAnalyserProvider; -use Reveal\TemplatePHPStanCompiler\TypeAnalyzer\TemplateVariableTypesResolver; +use Symplify\TemplatePHPStanCompiler\PHPStan\FileAnalyserProvider; +use Symplify\TemplatePHPStanCompiler\TypeAnalyzer\TemplateVariableTypesResolver; use Vural\PHPStanBladeRule\Compiler\BladeToPHPCompiler; use Vural\PHPStanBladeRule\ErrorReporting\Blade\TemplateErrorsFactory; use Vural\PHPStanBladeRule\NodeAnalyzer\BladeViewMethodsMatcher; diff --git a/tests/Rules/LaravelViewFunctionRuleTest.php b/tests/Rules/LaravelViewFunctionRuleTest.php index 2ba1204..ef12c1e 100644 --- a/tests/Rules/LaravelViewFunctionRuleTest.php +++ b/tests/Rules/LaravelViewFunctionRuleTest.php @@ -9,8 +9,8 @@ use PHPStan\Rules\Rule; use PHPStan\Rules\Variables\DefinedVariableRule; use PHPStan\Testing\RuleTestCase; -use Reveal\TemplatePHPStanCompiler\PHPStan\FileAnalyserProvider; -use Reveal\TemplatePHPStanCompiler\TypeAnalyzer\TemplateVariableTypesResolver; +use Symplify\TemplatePHPStanCompiler\PHPStan\FileAnalyserProvider; +use Symplify\TemplatePHPStanCompiler\TypeAnalyzer\TemplateVariableTypesResolver; use Vural\PHPStanBladeRule\Compiler\BladeToPHPCompiler; use Vural\PHPStanBladeRule\ErrorReporting\Blade\TemplateErrorsFactory; use Vural\PHPStanBladeRule\NodeAnalyzer\BladeViewMethodsMatcher; diff --git a/tests/tests.neon b/tests/tests.neon index 3b8fa8d..3489b81 100644 --- a/tests/tests.neon +++ b/tests/tests.neon @@ -1,6 +1,6 @@ includes: - ../config/extension.neon - - ../vendor/reveal/template-phpstan-compiler/config/services.neon + - ../vendor/symplify/template-phpstan-compiler/config/services.neon - ../vendor/symplify/astral/config/services.neon parameters: checkExplicitMixed: true \ No newline at end of file From 8ccd6116dba0b9e4f95c32a53234ed2039d0a2e6 Mon Sep 17 00:00:00 2001 From: John Boehr Date: Tue, 21 Feb 2023 17:11:46 -0800 Subject: [PATCH 2/3] Upgrade phpstan --- composer.json | 2 +- phpstan-baseline.neon | 2 +- src/Rules/BladeRule.php | 4 ++-- src/Rules/ViewRuleHelper.php | 4 +++- .../echo_variable_with_comments.blade.php | 2 +- tests/Rules/BladeViewRuleTest.php | 7 +------ tests/Rules/LaravelViewFunctionRuleTest.php | 7 +------ 7 files changed, 10 insertions(+), 18 deletions(-) diff --git a/composer.json b/composer.json index ab7f695..15532b6 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "illuminate/contracts": "^8.82 || ^9.0", "illuminate/filesystem": "^8.82 || ^9.0", "illuminate/view": "^8.82 || ^9", - "phpstan/phpstan": "^1.7", + "phpstan/phpstan": "^1.8.9", "symplify/template-phpstan-compiler": "^10.0.20" }, "require-dev": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 69b2c73..9a6934c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -11,7 +11,7 @@ parameters: path: src/PHPParser/NodeVisitor/ViewFunctionArgumentsNodeVisitor.php - - message: "#^Creating new PHPStan\\\\Rules\\\\Registry is not covered by backward compatibility promise\\. The class might change in a minor PHPStan version\\.$#" + message: "#^Creating new PHPStan\\\\Rules\\\\DirectRegistry is not covered by backward compatibility promise\\. The class might change in a minor PHPStan version\\.$#" count: 1 path: src/Rules/BladeRule.php diff --git a/src/Rules/BladeRule.php b/src/Rules/BladeRule.php index 957cd14..da0b287 100644 --- a/src/Rules/BladeRule.php +++ b/src/Rules/BladeRule.php @@ -6,7 +6,7 @@ use PhpParser\Node; use PHPStan\Analyser\Scope; -use PHPStan\Rules\Registry; +use PHPStan\Rules\DirectRegistry; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleError; use Vural\PHPStanBladeRule\NodeAnalyzer\BladeViewMethodsMatcher; @@ -25,7 +25,7 @@ public function __construct( private LaravelViewFunctionMatcher $laravelViewFunctionMatcher, private ViewRuleHelper $ruleHelper ) { - $this->ruleHelper->setRegistry(new Registry($rules)); + $this->ruleHelper->setRegistry(new DirectRegistry($rules)); } public function getNodeType(): string diff --git a/src/Rules/ViewRuleHelper.php b/src/Rules/ViewRuleHelper.php index 4cb89e9..71cd3cc 100644 --- a/src/Rules/ViewRuleHelper.php +++ b/src/Rules/ViewRuleHelper.php @@ -8,6 +8,7 @@ use PHPStan\Analyser\Scope; use PHPStan\Rules\Registry; use PHPStan\Rules\RuleError; +use PHPStan\Collectors\Registry as CollectorRegistry; use PHPStan\ShouldNotHappenException; use Symplify\TemplatePHPStanCompiler\PHPStan\FileAnalyserProvider; use Symplify\TemplatePHPStanCompiler\TypeAnalyzer\TemplateVariableTypesResolver; @@ -38,6 +39,7 @@ public function __construct( private FileAnalyserProvider $fileAnalyserProvider, private TemplateErrorsFactory $templateErrorsFactory, private BladeToPHPCompiler $bladeToPhpCompiler, + private CollectorRegistry $collectorRegistry ) { } @@ -98,7 +100,7 @@ private function processTemplateFilePath( $fileAnalyser = $this->fileAnalyserProvider->provide(); - $fileAnalyserResult = $fileAnalyser->analyseFile($tmpFilePath, [], $this->registry, null); + $fileAnalyserResult = $fileAnalyser->analyseFile($tmpFilePath, [], $this->registry, $this->collectorRegistry, null); $ruleErrors = $fileAnalyserResult->getErrors(); diff --git a/tests/Compiler/Fixture/PhpContentExtractor/echo_variable_with_comments.blade.php b/tests/Compiler/Fixture/PhpContentExtractor/echo_variable_with_comments.blade.php index 074a814..b365de7 100644 --- a/tests/Compiler/Fixture/PhpContentExtractor/echo_variable_with_comments.blade.php +++ b/tests/Compiler/Fixture/PhpContentExtractor/echo_variable_with_comments.blade.php @@ -4,6 +4,6 @@ }} ----- getByType(InvalidBinaryOperationRule::class)], self::getContainer()->getByType(BladeViewMethodsMatcher::class), self::getContainer()->getByType(LaravelViewFunctionMatcher::class), - new ViewRuleHelper( - self::getContainer()->getByType(TemplateVariableTypesResolver::class), - self::getContainer()->getByType(FileAnalyserProvider::class), - self::getContainer()->getByType(TemplateErrorsFactory::class), - self::getContainer()->getByType(BladeToPHPCompiler::class), - ) + self::getContainer()->getByType(ViewRuleHelper::class), ); } diff --git a/tests/Rules/LaravelViewFunctionRuleTest.php b/tests/Rules/LaravelViewFunctionRuleTest.php index ef12c1e..b3affe7 100644 --- a/tests/Rules/LaravelViewFunctionRuleTest.php +++ b/tests/Rules/LaravelViewFunctionRuleTest.php @@ -35,12 +35,7 @@ protected function getRule(): Rule ], self::getContainer()->getByType(BladeViewMethodsMatcher::class), self::getContainer()->getByType(LaravelViewFunctionMatcher::class), - new ViewRuleHelper( - self::getContainer()->getByType(TemplateVariableTypesResolver::class), - self::getContainer()->getByType(FileAnalyserProvider::class), - self::getContainer()->getByType(TemplateErrorsFactory::class), - self::getContainer()->getByType(BladeToPHPCompiler::class), - ) + self::getContainer()->getByType(ViewRuleHelper::class), ); } From 20c161b1bae70c26f75b306713c703ce705c8246 Mon Sep 17 00:00:00 2001 From: John Boehr Date: Tue, 21 Feb 2023 17:19:45 -0800 Subject: [PATCH 3/3] Allow laravel v10 --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 15532b6..8310897 100644 --- a/composer.json +++ b/composer.json @@ -11,16 +11,16 @@ ], "require": { "php": "^8.0", - "illuminate/contracts": "^8.82 || ^9.0", - "illuminate/filesystem": "^8.82 || ^9.0", - "illuminate/view": "^8.82 || ^9", + "illuminate/contracts": "^8.82 || ^9.0 || ^10.0", + "illuminate/filesystem": "^8.82 || ^9.0 || ^10.0", + "illuminate/view": "^8.82 || ^9.9 || ^10.0", "phpstan/phpstan": "^1.8.9", "symplify/template-phpstan-compiler": "^10.0.20" }, "require-dev": { "doctrine/coding-standard": "^9.0", "ergebnis/composer-normalize": "^2.24", - "orchestra/testbench": "^6.24 || ^7.0", + "orchestra/testbench": "^6.24 || ^7.0 || ^8.0", "phpunit/phpunit": "^9.5", "roave/security-advisories": "dev-latest", "symplify/easy-testing": "^10.0"