Skip to content

Upgrade phpstan and laravel, revert reveal/template-phpstan-compiler #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"phpstan/phpstan": "^1.7",
"reveal/template-phpstan-compiler": "^0.2"
"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"
Expand Down
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/Compiler/BladeToPHPCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/ErrorReporting/Blade/TemplateErrorsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand Down
2 changes: 1 addition & 1 deletion src/NodeAnalyzer/BladeViewMethodsMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/NodeAnalyzer/LaravelViewFunctionMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use PhpParser\Node;
use PHPStan\Analyser\Scope;
use Reveal\TemplatePHPStanCompiler\ValueObject\RenderTemplateWithParameters;
use Symplify\TemplatePHPStanCompiler\ValueObject\RenderTemplateWithParameters;

use function count;

Expand Down
2 changes: 1 addition & 1 deletion src/NodeAnalyzer/TemplateFilePathResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/Rules/BladeRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
12 changes: 7 additions & 5 deletions src/Rules/ViewRuleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Registry;
use PHPStan\Rules\RuleError;
use PHPStan\Collectors\Registry as CollectorRegistry;
Comment on lines 8 to +11
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Registry;
use PHPStan\Rules\RuleError;
use PHPStan\Collectors\Registry as CollectorRegistry;
use PHPStan\Analyser\Scope;
use PHPStan\Collectors\Registry as CollectorRegistry;
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;

Expand All @@ -38,6 +39,7 @@ public function __construct(
private FileAnalyserProvider $fileAnalyserProvider,
private TemplateErrorsFactory $templateErrorsFactory,
private BladeToPHPCompiler $bladeToPhpCompiler,
private CollectorRegistry $collectorRegistry
) {
}

Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/ValueObject/PhpFileContentsWithLineMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Vural\PHPStanBladeRule\ValueObject;

/** @see \Reveal\TemplatePHPStanCompiler\ValueObject\PhpFileContentsWithLineMap */
/** @see \Symplify\TemplatePHPStanCompiler\ValueObject\PhpFileContentsWithLineMap */
final class PhpFileContentsWithLineMap
{
/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Compiler/BladeToPHPCompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
}}
-----
<?php
/** file: foo.blade.php, line: 1 */ echo e(/** @var string $foo */
/** file: foo.blade.php, line: 1 */ echo e(/** @var string $foo */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fixture for a test and should not be styled

Suggested change
/** file: foo.blade.php, line: 1 */ echo e(/** @var string $foo */
/** file: foo.blade.php, line: 1 */ echo e(/** @var string $foo */

/** file: foo.blade.php, line: 3 */ $foo + 10
/** file: foo.blade.php, line: 4 */);
11 changes: 3 additions & 8 deletions tests/Rules/BladeViewRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment on lines +10 to 13
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Expand All @@ -29,12 +29,7 @@ protected function getRule(): Rule
[self::getContainer()->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),
);
}

Expand Down
11 changes: 3 additions & 8 deletions tests/Rules/LaravelViewFunctionRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment on lines +12 to 15
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Expand All @@ -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),
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/tests.neon
Original file line number Diff line number Diff line change
@@ -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