diff --git a/README.md b/README.md index d13b200..5844f24 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ return new class implements ConfigInterface }; ``` -### Configuration with Twig Extension +### Usage with Twig Extension If you're using Twig, register the extension and enable Twig integration: ```php diff --git a/composer.json b/composer.json index 9c5294c..5f1b3cd 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,7 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^v3.93", "phpstan/phpstan": "^2.1", + "phpstan/phpstan-strict-rules": "^2.0", "phpunit/phpunit": "^13", "twig/twig": "^3" }, diff --git a/phpstan.neon b/phpstan.neon index f1c72f5..22a4ef6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,3 +1,6 @@ +includes: + - vendor/phpstan/phpstan-strict-rules/rules.neon + parameters: level: 8 tmpDir: var/phpstan @@ -6,6 +9,11 @@ parameters: - tests reportUnmatchedIgnoredErrors: true + checkDynamicProperties: true + reportNonIntStringArrayKey: true + checkMissingOverrideMethodAttribute: true + checkStrictPrintfPlaceholderTypes: true + ignoreErrors: - identifier: missingType.iterableValue path: tests/*Test.php diff --git a/tests/Asset/AssetFactoryTest.php b/tests/Asset/AssetFactoryTest.php index 3dc4e8f..c17fe0f 100644 --- a/tests/Asset/AssetFactoryTest.php +++ b/tests/Asset/AssetFactoryTest.php @@ -13,6 +13,7 @@ final class AssetFactoryTest extends TestCase { private AssetFactory $factory; + #[\Override] protected function setUp(): void { $this->factory = new AssetFactory(); diff --git a/tests/Integration/TwigExtensionTest.php b/tests/Integration/TwigExtensionTest.php index b4ee604..2101928 100644 --- a/tests/Integration/TwigExtensionTest.php +++ b/tests/Integration/TwigExtensionTest.php @@ -17,6 +17,7 @@ final class TwigExtensionTest extends TestCase private TwigExtension $extension; private AssetMapperInterface&MockObject $assetMapper; + #[\Override] public function setUp(): void { $this->assetMapper = $this->createMock(AssetMapperInterface::class); diff --git a/tests/Manifest/ManifestTest.php b/tests/Manifest/ManifestTest.php index bd71cc9..8d1f179 100644 --- a/tests/Manifest/ManifestTest.php +++ b/tests/Manifest/ManifestTest.php @@ -12,6 +12,7 @@ final class ManifestTest extends TestCase { private Manifest $manifest; + #[\Override] protected function setUp(): void { $this->manifest = new Manifest(__DIR__ . '/../manifest.json'); diff --git a/tests/Mapper/AssetMapperFactoryTest.php b/tests/Mapper/AssetMapperFactoryTest.php index 102b2db..e75f803 100644 --- a/tests/Mapper/AssetMapperFactoryTest.php +++ b/tests/Mapper/AssetMapperFactoryTest.php @@ -15,7 +15,7 @@ final class AssetMapperFactoryTest extends TestCase public function testCreateManifest(): void { $manifestPath = __DIR__ . '/../manifest.json'; - $referenceParser = $this->createStub(ReferenceParserInterface::class); + $referenceParser = self::createStub(ReferenceParserInterface::class); $assetMapper = AssetMapperFactory::create($manifestPath, $referenceParser); self::assertInstanceOf(ManifestAssetMapper::class, $assetMapper); } @@ -24,7 +24,7 @@ public function testCreateDev(): void { putenv('APP_ENV=dev'); $manifestPath = __DIR__ . '/../manifest.json'; - $referenceParser = $this->createStub(ReferenceParserInterface::class); + $referenceParser = self::createStub(ReferenceParserInterface::class); $assetMapper = AssetMapperFactory::create($manifestPath, $referenceParser); putenv('APP_ENV'); self::assertInstanceOf(DevAssetMapper::class, $assetMapper); diff --git a/tests/Mapper/DevAssetMapperTest.php b/tests/Mapper/DevAssetMapperTest.php index 38698bf..36507a1 100644 --- a/tests/Mapper/DevAssetMapperTest.php +++ b/tests/Mapper/DevAssetMapperTest.php @@ -16,6 +16,7 @@ final class DevAssetMapperTest extends TestCase private MockObject&ReferenceParserInterface $referenceParser; private DevAssetMapper $mapper; + #[\Override] protected function setUp(): void { $this->referenceParser = $this->createMock(ReferenceParserInterface::class); diff --git a/tests/Mapper/ManifestAssetMapperTest.php b/tests/Mapper/ManifestAssetMapperTest.php index d1b3237..0491aac 100644 --- a/tests/Mapper/ManifestAssetMapperTest.php +++ b/tests/Mapper/ManifestAssetMapperTest.php @@ -17,6 +17,7 @@ final class ManifestAssetMapperTest extends TestCase private MockObject&ReferenceParserInterface $referenceParser; private ManifestAssetMapper $mapper; + #[\Override] protected function setUp(): void { $this->referenceParser = $this->createMock(ReferenceParserInterface::class); diff --git a/tests/Mapper/TagProviderTest.php b/tests/Mapper/TagProviderTest.php index ec405f2..6b8f990 100644 --- a/tests/Mapper/TagProviderTest.php +++ b/tests/Mapper/TagProviderTest.php @@ -11,6 +11,7 @@ class TagProviderTest extends TestCase { private TagProvider $provider; + #[\Override] protected function setUp(): void { $this->provider = new TagProvider(); diff --git a/tests/StasisViteExtensionTest.php b/tests/StasisViteExtensionTest.php index 176144d..2df7d4e 100644 --- a/tests/StasisViteExtensionTest.php +++ b/tests/StasisViteExtensionTest.php @@ -29,7 +29,7 @@ public function testCreate(): void public function testCreateWithReferenceParser(): void { - $referenceParser = $this->createStub(ReferenceParserInterface::class); + $referenceParser = self::createStub(ReferenceParserInterface::class); $extension = StasisViteExtension::createWithReferenceParser( assetsSourcePath: __DIR__ . '/dist_assets', @@ -48,7 +48,7 @@ public function testWithTwig(): void $twig ->expects($this->once()) ->method('addExtension') - ->with($this->isInstanceOf(AbstractExtension::class)); + ->with(self::isInstanceOf(AbstractExtension::class)); $extension = StasisViteExtension::create( assetsSourcePath: __DIR__ . '/dist_assets',