diff --git a/.phpunit.cache/test-results b/.phpunit.cache/test-results new file mode 100644 index 0000000..884ec28 --- /dev/null +++ b/.phpunit.cache/test-results @@ -0,0 +1 @@ +{"version":1,"defects":{"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions#\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:8":7,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions#\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:11":7,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions#\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:14":7,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions#\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:17":7,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions#\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:21":7,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions#\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:23":7},"times":{"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions#\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:8":0.003,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions#\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:11":0,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions#\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:14":0,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions#\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:17":0,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions#\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:21":0,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions#\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:23":0,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions with data set \"\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:8\"":0.002,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions with data set \"\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:11\"":0,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions with data set \"\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:14\"":0,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions with data set \"\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:17\"":0,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions with data set \"\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:21\"":0,"PHPStanCakePHP2\\Test\\Feature\\ClassRegistryInitTest::testControllerExtensions with data set \"\/var\/www\/phpstan-cakephp-2\/tests\/Feature\/data\/class_registry_init.php:23\"":0}} \ No newline at end of file diff --git a/composer.json b/composer.json index abfab10..bf705a5 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ "phpstan/phpstan-phpunit": "^1.3", "phpunit/phpunit": "^10.5", "phpstan/extension-installer": "^1.3", - "tracy/tracy": "^2.10" + "tracy/tracy": "^2.10", + "symplify/easy-coding-standard": "^12.1" }, "autoload": { "psr-4": { diff --git a/config/extension.neon b/config/extension.neon index 0bb5046..481cc17 100644 --- a/config/extension.neon +++ b/config/extension.neon @@ -16,21 +16,21 @@ parameters: - ../stubs/Utility.stub services: -# - -# class: PHPStanCakePHP2\ClassComponentsExtension -# tags: -# - phpstan.broker.propertiesClassReflectionExtension -# -# - -# class: PHPStanCakePHP2\ClassModelsExtension -# tags: -# - phpstan.broker.propertiesClassReflectionExtension -# -# # checked -# - -# class: PHPStanCakePHP2\ReturnTypeExtension\ClassRegistryInitExtension -# tags: -# - phpstan.broker.dynamicStaticMethodReturnTypeExtension + - + class: PHPStanCakePHP2\ClassPropertyExtension\ClassComponentPropertyExtension + tags: + - phpstan.broker.propertiesClassReflectionExtension + + - + class: PHPStanCakePHP2\ClassPropertyExtension\ClassModelsPropertyExtension + tags: + - phpstan.broker.propertiesClassReflectionExtension + + # checked + - + class: PHPStanCakePHP2\ReturnTypeExtension\ClassRegistryInitExtension + tags: + - phpstan.broker.dynamicStaticMethodReturnTypeExtension # checked - @@ -38,20 +38,20 @@ services: tags: - phpstan.broker.propertiesClassReflectionExtension -# - -# class: PHPStanCakePHP2\ModelBehaviorsExtension -# arguments: -# behaviorPaths: %behaviorPaths% -# tags: -# - phpstan.broker.methodsClassReflectionExtension - -# - -# class: PHPStanCakePHP2\Service\SchemaService -# arguments: -# schemaPaths: %schemaPaths% -# -# - -# class: PHPStanCakePHP2\LoadComponentOnFlyMethodReturnTypeExtension -# tags: -# - phpstan.broker.dynamicMethodReturnTypeExtension + - + class: PHPStanCakePHP2\ModelBehaviorsExtension + arguments: + behaviorPaths: %behaviorPaths% + tags: + - phpstan.broker.methodsClassReflectionExtension + + - + class: PHPStanCakePHP2\Service\SchemaService + arguments: + schemaPaths: %schemaPaths% + + - + class: PHPStanCakePHP2\LoadComponentOnFlyMethodReturnTypeExtension + tags: + - phpstan.broker.dynamicMethodReturnTypeExtension diff --git a/ecs.php b/ecs.php new file mode 100644 index 0000000..62958f6 --- /dev/null +++ b/ecs.php @@ -0,0 +1,28 @@ +withPaths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + + // add a single rule + ->withRules([ + NoUnusedImportsFixer::class, + ]) + + // add sets - group of rules + // ->withPreparedSets( + // arrays: true, + // namespaces: true, + // spaces: true, + // docblocks: true, + // comments: true, + // ) + + ; diff --git a/phpstan.neon b/phpstan.neon index f39cd43..1d8b9de 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,17 +10,7 @@ parameters: - */Fixture/* # ported from cacke - src/CakePHP/PortedInflector.php -<<<<<<< HEAD -<<<<<<< HEAD -======= ignoreErrors: # not practical as mixed - '#Method (.*?)::test(.*?)\(\) has parameter \$args with no type specified#' ->>>>>>> 514d1ac (fixup! mics) -======= - - ignoreErrors: - # not practical as mixed - - '#Method PHPStanCakePHP2\\Tests\\(.*?)::test(.*?)\(\) has parameter \$args with no type specified#' ->>>>>>> 9d38081 (misc) diff --git a/src/ClassPropertyExtension/AbstractClassPropertyExtension.php b/src/ClassPropertyExtension/AbstractClassPropertyExtension.php index 7392dae..efabba8 100644 --- a/src/ClassPropertyExtension/AbstractClassPropertyExtension.php +++ b/src/ClassPropertyExtension/AbstractClassPropertyExtension.php @@ -8,7 +8,7 @@ use PHPStan\Reflection\PropertiesClassReflectionExtension; use PHPStan\Reflection\PropertyReflection; use PHPStan\Reflection\ReflectionProvider; -use PHPStanCakePHP2\PublicReadOnlyPropertyReflection; +use PHPStanCakePHP2\Reflection\PublicReadOnlyPropertyReflection; abstract class AbstractClassPropertyExtension implements PropertiesClassReflectionExtension { @@ -45,11 +45,13 @@ public function getProperty( } /** + * @todo use constract instead to separate * Get the class name of the type of property. */ abstract protected function getPropertyParentClassName(): string; /** + * @todo use constract instead to separate * Get the class names which can contain the property. * * @return array @@ -57,6 +59,7 @@ abstract protected function getPropertyParentClassName(): string; abstract protected function getContainingClassNames(): array; /** + * @todo use constract instead to separate * Return the class name from the property name. */ abstract protected function getClassNameFromPropertyName( diff --git a/src/ClassComponentsExtension.php b/src/ClassPropertyExtension/ClassComponentPropertyExtension.php similarity index 89% rename from src/ClassComponentsExtension.php rename to src/ClassPropertyExtension/ClassComponentPropertyExtension.php index bc0bfa5..9ef1f5a 100644 --- a/src/ClassComponentsExtension.php +++ b/src/ClassPropertyExtension/ClassComponentPropertyExtension.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PHPStanCakePHP2; +namespace PHPStanCakePHP2\ClassPropertyExtension; use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\ClassConstFetch; @@ -12,8 +12,12 @@ use PHPStan\Reflection\PropertiesClassReflectionExtension; use PHPStan\Reflection\PropertyReflection; use PHPStan\Reflection\ReflectionProvider; +use PHPStanCakePHP2\Reflection\PublicReadOnlyPropertyReflection; -final class ClassComponentsExtension implements PropertiesClassReflectionExtension +/** + * @see \ClassPropertyExtension\ClassComponentPropertyExtension\ClassComponentPropertyExtensionTest + */ +final class ClassComponentPropertyExtension implements PropertiesClassReflectionExtension { private ReflectionProvider $reflectionProvider; @@ -28,6 +32,8 @@ public function hasProperty(ClassReflection $classReflection, string $propertyNa return false; } + + $isDefinedInComponentsProperty = (bool) array_filter( $this->getDefinedComponentsAsList($classReflection), static fn (string $componentName): bool => $componentName === $propertyName @@ -76,7 +82,7 @@ private function getDefinedComponentsAsList(ClassReflection $classReflection): a $definedComponents = []; foreach (array_merge([$classReflection], $classReflection->getParents()) as $class) { - if (!$class->hasProperty('components')) { + if (! $class->hasProperty('components')) { continue; } diff --git a/src/ClassModelsExtension.php b/src/ClassPropertyExtension/ClassModelsPropertyExtension.php similarity index 75% rename from src/ClassModelsExtension.php rename to src/ClassPropertyExtension/ClassModelsPropertyExtension.php index a77ba76..5423f8e 100644 --- a/src/ClassModelsExtension.php +++ b/src/ClassPropertyExtension/ClassModelsPropertyExtension.php @@ -2,14 +2,12 @@ declare(strict_types=1); -namespace PHPStanCakePHP2; - -use PHPStanCakePHP2\ClassPropertyExtension\AbstractClassPropertyExtension; +namespace PHPStanCakePHP2\ClassPropertyExtension; /** * Adds {@link Model}s as properties to {@link Shell}s */ -final class ClassModelsExtension extends AbstractClassPropertyExtension +final class ClassModelsPropertyExtension extends AbstractClassPropertyExtension { protected function getPropertyParentClassName(): string { diff --git a/src/ClassPropertyExtension/ShellClassPropertyExtension.php b/src/ClassPropertyExtension/ShellClassPropertyExtension.php index 8c365fa..c371689 100644 --- a/src/ClassPropertyExtension/ShellClassPropertyExtension.php +++ b/src/ClassPropertyExtension/ShellClassPropertyExtension.php @@ -4,15 +4,13 @@ namespace PHPStanCakePHP2\ClassPropertyExtension; -use PHPStan\Reflection\ClassReflection; -use PHPStan\Reflection\PropertiesClassReflectionExtension; /** * Adds {@link Model}s as properties to {@link Shell}s. * * @see \PHPStanCakePHP2\Tests\ClassPropertyExtension\ShellClassPropertyExtension\ShellClassPropertyExtensionTest */ -final class ShellClassPropertyExtension implements PropertiesClassReflectionExtension +final class ShellClassPropertyExtension extends AbstractClassPropertyExtension { protected function getPropertyParentClassName(): string { @@ -32,18 +30,4 @@ protected function getClassNameFromPropertyName( ): string { return $propertyName . 'Task'; } - - public function hasProperty(ClassReflection $classReflection, string $propertyName): bool - { - dump(1); - die; - // TODO: Implement hasProperty() method. - } - - public function getProperty(ClassReflection $classReflection, string $propertyName): \PHPStan\Reflection\PropertyReflection - { - dump(2); - die; - // TODO: Implement getProperty() method. - } } diff --git a/src/ModelBehaviorsExtension.php b/src/ModelBehaviorsExtension.php index 6350dfc..c8a6298 100644 --- a/src/ModelBehaviorsExtension.php +++ b/src/ModelBehaviorsExtension.php @@ -9,6 +9,7 @@ use PHPStan\Reflection\MethodReflection; use PHPStan\Reflection\MethodsClassReflectionExtension; use PHPStan\Reflection\ReflectionProvider; +use PHPStanCakePHP2\Reflection\ClassReflectionFinder; /** * Adds methods to {@link Model}s from {@link ModelBehavior} classes. diff --git a/src/ClassReflectionFinder.php b/src/Reflection/ClassReflectionFinder.php similarity index 98% rename from src/ClassReflectionFinder.php rename to src/Reflection/ClassReflectionFinder.php index cd8f679..3c321aa 100644 --- a/src/ClassReflectionFinder.php +++ b/src/Reflection/ClassReflectionFinder.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PHPStanCakePHP2; +namespace PHPStanCakePHP2\Reflection; use Exception; use PHPStan\Reflection\ClassReflection; diff --git a/src/PublicReadOnlyPropertyReflection.php b/src/Reflection/PublicReadOnlyPropertyReflection.php similarity index 97% rename from src/PublicReadOnlyPropertyReflection.php rename to src/Reflection/PublicReadOnlyPropertyReflection.php index a0818ae..4775405 100644 --- a/src/PublicReadOnlyPropertyReflection.php +++ b/src/Reflection/PublicReadOnlyPropertyReflection.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PHPStanCakePHP2; +namespace PHPStanCakePHP2\Reflection; use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\PropertyReflection; diff --git a/src/ReturnTypeExtension/ClassRegistryInitExtension.php b/src/ReturnTypeExtension/ClassRegistryInitExtension.php index 20b0320..d346c5c 100644 --- a/src/ReturnTypeExtension/ClassRegistryInitExtension.php +++ b/src/ReturnTypeExtension/ClassRegistryInitExtension.php @@ -21,8 +21,7 @@ /** * @see \PHPStanCakePHP2\Tests\ReturnTypeExtension\ClassRegistryInitExtension\ClassRegistryInitExtensionTest */ -final class -ClassRegistryInitExtension implements DynamicStaticMethodReturnTypeExtension +final class ClassRegistryInitExtension implements DynamicStaticMethodReturnTypeExtension { private ReflectionProvider $reflectionProvider; @@ -60,20 +59,8 @@ public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, return new ObjectType($value); } -<<<<<<< HEAD -<<<<<<< HEAD:src/ClassRegistryInitExtension.php - if ($this->schemaService->hasTable(PortedInflector::tableize($value))) { -======= $tableName = PortedInflector::tableize($value); if ($this->schemaService->hasTable($tableName)) { ->>>>>>> e0614d1 (fixup! misc):src/ReturnTypeExtension/ClassRegistryInitExtension.php -======= - $tableName = PortedInflector::tableize($value); - - var_dump($tableName); - - if ($this->schemaService->hasTable($tableName)) { ->>>>>>> 7e16f7f (tidy up) return new ObjectType('Model'); } diff --git a/src/Service/SchemaService.php b/src/Service/SchemaService.php index a7ecd00..01baad2 100644 --- a/src/Service/SchemaService.php +++ b/src/Service/SchemaService.php @@ -4,10 +4,10 @@ namespace PHPStanCakePHP2\Service; -use PHPStanCakePHP2\ClassReflectionFinder; use Exception; use PHPStan\BetterReflection\Reflection\Adapter\ReflectionProperty; use PHPStan\Reflection\ReflectionProvider; +use PHPStanCakePHP2\Reflection\ClassReflectionFinder; use ReflectionProperty as CoreReflectionProperty; /** diff --git a/stubs/CakePHP/Component.php b/stubs/CakePHP/Component.php index e7ce07a..fbfa57b 100644 --- a/stubs/CakePHP/Component.php +++ b/stubs/CakePHP/Component.php @@ -1,6 +1,19 @@ {$name})) { + return $this->{$name}; + } + + return 'some value'; + } } diff --git a/stubs/CakePHP/Model.php b/stubs/CakePHP/Model.php index 921a6bd..64e5252 100644 --- a/stubs/CakePHP/Model.php +++ b/stubs/CakePHP/Model.php @@ -2,5 +2,7 @@ class Model { - + public function __get(string $name) + { + } } diff --git a/stubs/CakePHP/Shell.php b/stubs/CakePHP/Shell.php index 359da2d..86358a7 100644 --- a/stubs/CakePHP/Shell.php +++ b/stubs/CakePHP/Shell.php @@ -1,6 +1,17 @@ {$name})) { + return $this->{$name}; + } + return 'some value'; + } } diff --git a/tests/ClassPropertyExtension/ClassComponentPropertyExtension/ClassComponentPropertyExtensionTest.php b/tests/ClassPropertyExtension/ClassComponentPropertyExtension/ClassComponentPropertyExtensionTest.php new file mode 100644 index 0000000..2ff250f --- /dev/null +++ b/tests/ClassPropertyExtension/ClassComponentPropertyExtension/ClassComponentPropertyExtensionTest.php @@ -0,0 +1,48 @@ +assertFileAsserts($assertType, $file, ...$args); + } + + /** + * @return mixed[] + */ + public static function dataFileAsserts(): iterable + { + yield from self::gatherAssertTypes(__DIR__ . '/Fixture/existing_component_component.php'); + yield from self::gatherAssertTypes(__DIR__ . '/Fixture/invalid_component_property.php'); + } + + public static function getAdditionalConfigFiles(): array + { + return [__DIR__ . '/../../config/phpstan.neon']; + } + + public function testExtensionIsLoaded(): void + { + // make sure the extension is loaded + $loadedExtensions = $this->getContainer()->getServicesByTag('phpstan.broker.propertiesClassReflectionExtension'); + + $extensionClasses = []; + foreach ($loadedExtensions as $loadedExtension) { + $extensionClasses[] = get_class($loadedExtension); + } + + $this->assertContains(ClassComponentPropertyExtension::class, $extensionClasses); + } +} diff --git a/tests/Feature/data/existing_component_component.php b/tests/ClassPropertyExtension/ClassComponentPropertyExtension/Fixture/existing_component_component.php similarity index 100% rename from tests/Feature/data/existing_component_component.php rename to tests/ClassPropertyExtension/ClassComponentPropertyExtension/Fixture/existing_component_component.php diff --git a/tests/Feature/data/invalid_component_property.php b/tests/ClassPropertyExtension/ClassComponentPropertyExtension/Fixture/invalid_component_property.php similarity index 100% rename from tests/Feature/data/invalid_component_property.php rename to tests/ClassPropertyExtension/ClassComponentPropertyExtension/Fixture/invalid_component_property.php diff --git a/tests/ClassPropertyExtension/ClassModelsPropertyExtension/ClassModelPropertyExtensionsTest.php b/tests/ClassPropertyExtension/ClassModelsPropertyExtension/ClassModelPropertyExtensionsTest.php new file mode 100644 index 0000000..c5e8cd0 --- /dev/null +++ b/tests/ClassPropertyExtension/ClassModelsPropertyExtension/ClassModelPropertyExtensionsTest.php @@ -0,0 +1,39 @@ +assertFileAsserts($assertType, $file, ...$args); + } + + /** + * @return mixed[] + */ + public static function dataFileAsserts(): iterable + { + yield from self::gatherAssertTypes(__DIR__ . '/Fixture/core_model_behavior.php'); + yield from self::gatherAssertTypes(__DIR__ . '/Fixture/custom_model_behavior.php'); + yield from self::gatherAssertTypes(__DIR__ . '/Fixture/invalid_model_property.php'); + yield from self::gatherAssertTypes(__DIR__ . '/Fixture/existing_model_model.php'); + } + + /** + * @return string[] + */ + public static function getAdditionalConfigFiles(): array + { + return [__DIR__ . '/../../config/phpstan.neon']; + } +} diff --git a/tests/Feature/data/core_model_behavior.php b/tests/ClassPropertyExtension/ClassModelsPropertyExtension/Fixture/core_model_behavior.php similarity index 100% rename from tests/Feature/data/core_model_behavior.php rename to tests/ClassPropertyExtension/ClassModelsPropertyExtension/Fixture/core_model_behavior.php diff --git a/tests/Feature/data/custom_model_behavior.php b/tests/ClassPropertyExtension/ClassModelsPropertyExtension/Fixture/custom_model_behavior.php similarity index 100% rename from tests/Feature/data/custom_model_behavior.php rename to tests/ClassPropertyExtension/ClassModelsPropertyExtension/Fixture/custom_model_behavior.php diff --git a/tests/Feature/data/existing_model_model.php b/tests/ClassPropertyExtension/ClassModelsPropertyExtension/Fixture/existing_model_model.php similarity index 100% rename from tests/Feature/data/existing_model_model.php rename to tests/ClassPropertyExtension/ClassModelsPropertyExtension/Fixture/existing_model_model.php diff --git a/tests/Feature/data/invalid_model_property.php b/tests/ClassPropertyExtension/ClassModelsPropertyExtension/Fixture/invalid_model_property.php similarity index 100% rename from tests/Feature/data/invalid_model_property.php rename to tests/ClassPropertyExtension/ClassModelsPropertyExtension/Fixture/invalid_model_property.php diff --git a/tests/ClassPropertyExtension/ShellClassPropertyExtension/ShellClassPropertyExtensionTest.php b/tests/ClassPropertyExtension/ShellClassPropertyExtension/ShellClassPropertyExtensionTest.php index 97ed471..358ace0 100644 --- a/tests/ClassPropertyExtension/ShellClassPropertyExtension/ShellClassPropertyExtensionTest.php +++ b/tests/ClassPropertyExtension/ShellClassPropertyExtension/ShellClassPropertyExtensionTest.php @@ -4,12 +4,8 @@ namespace PHPStanCakePHP2\Tests\ClassPropertyExtension\ShellClassPropertyExtension; -use PHPStan\DependencyInjection\Reflection\ClassReflectionExtensionRegistryProvider; use PHPStan\Testing\TypeInferenceTestCase; -<<<<<<< HEAD use PHPStanCakePHP2\ClassPropertyExtension\ShellClassPropertyExtension; -======= ->>>>>>> 9282ba2 (move shell property extension to correct namespace) use PHPUnit\Framework\Attributes\DataProvider; /** @@ -17,34 +13,17 @@ */ final class ShellClassPropertyExtensionTest extends TypeInferenceTestCase { -<<<<<<< HEAD -<<<<<<< HEAD #[DataProvider('dataFileAsserts')] public function test(string $assertType, string $file, ...$args): void -======= - /** - * @param mixed ...$args - */ -======= ->>>>>>> 9d38081 (misc) - #[DataProvider('dataFileAsserts')] - public function testShellExtensions(string $assertType, string $file, ...$args): void ->>>>>>> 9282ba2 (move shell property extension to correct namespace) { $this->assertFileAsserts($assertType, $file, ...$args); } -<<<<<<< HEAD -======= - /** - * @return mixed[] - */ ->>>>>>> 9282ba2 (move shell property extension to correct namespace) public static function dataFileAsserts(): iterable { -// yield from self::gatherAssertTypes(__DIR__ . '/Fixture/existing_shell_model.php'); + yield from self::gatherAssertTypes(__DIR__ . '/Fixture/existing_shell_model.php'); yield from self::gatherAssertTypes(__DIR__ . '/Fixture/existing_shell_task.php'); -// yield from self::gatherAssertTypes(__DIR__ . '/Fixture/invalid_shell_property.php'); + yield from self::gatherAssertTypes(__DIR__ . '/Fixture/invalid_shell_property.php'); } /** @@ -52,9 +31,8 @@ public static function dataFileAsserts(): iterable */ public static function getAdditionalConfigFiles(): array { - return [__DIR__ . '/../../../config/extension.neon']; + return [__DIR__ . '/../../config/phpstan.neon']; } -<<<<<<< HEAD public function testExtensionIsLoaded(): void { @@ -68,6 +46,4 @@ public function testExtensionIsLoaded(): void $this->assertContains(ShellClassPropertyExtension::class, $extensionClasses); } -======= ->>>>>>> 9282ba2 (move shell property extension to correct namespace) } diff --git a/tests/Feature/ComponentExtensionsTest.php b/tests/Feature/ComponentExtensionsTest.php deleted file mode 100644 index 27f4ec0..0000000 --- a/tests/Feature/ComponentExtensionsTest.php +++ /dev/null @@ -1,35 +0,0 @@ -assertFileAsserts($assertType, $file, ...$args); - } - - public static function getAdditionalConfigFiles(): array - { - return [ - __DIR__ . '/data/phpstan.neon', - ]; - } -} diff --git a/tests/Feature/ControllerExtensionsTest.php b/tests/Feature/ControllerExtensionsTest.php index 748c20d..ebaa894 100644 --- a/tests/Feature/ControllerExtensionsTest.php +++ b/tests/Feature/ControllerExtensionsTest.php @@ -22,7 +22,7 @@ public static function dataFileAsserts(): iterable } #[DataProvider('dataFileAsserts')] - public function testControllerExtensions(string $assertType, string $file, ...$args): void + public function test(string $assertType, string $file, ...$args): void { $this->assertFileAsserts($assertType, $file, ...$args); } diff --git a/tests/Feature/ModelExtensionsTest.php b/tests/Feature/ModelExtensionsTest.php deleted file mode 100644 index b0bbef1..0000000 --- a/tests/Feature/ModelExtensionsTest.php +++ /dev/null @@ -1,37 +0,0 @@ -assertFileAsserts($assertType, $file, ...$args); - } - - public static function getAdditionalConfigFiles(): array - { - return [ - __DIR__ . '/data/phpstan.neon', - ]; - } -} diff --git a/tests/ReturnTypeExtension/ClassRegistryInitExtension/ClassRegistryInitExtensionTest.php b/tests/ReturnTypeExtension/ClassRegistryInitExtension/ClassRegistryInitExtensionTest.php index a3b0f4e..6c25742 100644 --- a/tests/ReturnTypeExtension/ClassRegistryInitExtension/ClassRegistryInitExtensionTest.php +++ b/tests/ReturnTypeExtension/ClassRegistryInitExtension/ClassRegistryInitExtensionTest.php @@ -18,10 +18,12 @@ final class ClassRegistryInitExtensionTest extends TypeInferenceTestCase public static function dataFileAsserts(): iterable { yield from self::gatherAssertTypes(__DIR__ . '/Fixture/variable_reference.php'); - yield from self::gatherAssertTypes(__DIR__ . '/Fixture/table_without_model.php'); yield from self::gatherAssertTypes(__DIR__ . '/Fixture/not_a_class.php'); yield from self::gatherAssertTypes(__DIR__ . '/Fixture/basic_model_string.php'); yield from self::gatherAssertTypes(__DIR__ . '/Fixture/basic_model_class_const_fetch.php'); + + // this one depends on config path "parameters > schemaPaths" + yield from self::gatherAssertTypes(__DIR__ . '/Fixture/table_without_model.php'); } #[DataProvider('dataFileAsserts')] diff --git a/tests/config/phpstan.neon b/tests/config/phpstan.neon index 9fa8694..97839fa 100644 --- a/tests/config/phpstan.neon +++ b/tests/config/phpstan.neon @@ -2,6 +2,7 @@ parameters: behaviorPaths: - tests/Feature/classes/Model/Behavior/*.php + # @todo add exists validatoin to avoid misspaths schemaPaths: - tests/Feature/classes/Config/Schema/*.php