diff --git a/composer.json b/composer.json index 2623b8f..b3f9810 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ }, "require-dev": { "symfony/phpunit-bridge": "^5.4 || ^6.4 || ^7.0 || ^8.0", + "symfony/form": "^5.4 || ^6.4 || ^7.0 || ^8.0", "symfony/translation": "^5.4 || ^6.4 || ^7.0 || ^8.0", "symfony/validator": "^5.4 || ^6.4 || ^7.0 || ^8.0", "symfony/twig-bridge": "^5.4 || ^6.4 || ^7.0 || ^8.0", diff --git a/src/Visitor/Php/Symfony/FormTrait.php b/src/Visitor/Php/Symfony/FormTrait.php index 71015a2..dbbf834 100644 --- a/src/Visitor/Php/Symfony/FormTrait.php +++ b/src/Visitor/Php/Symfony/FormTrait.php @@ -70,7 +70,8 @@ protected function loadParentInterfaces(string $parentFqcn): array $loading[$parentFqcn] = true; try { - $filePath = $this->findClassFile($parentFqcn); + $reflector = new \ReflectionClass($parentFqcn); + $filePath = $reflector->getFileName(); if (!$filePath || !file_exists($filePath)) { unset($loading[$parentFqcn]); @@ -111,17 +112,4 @@ protected function loadParentInterfaces(string $parentFqcn): array return $interfaces; } - - private function findClassFile(string $fqcn): ?string - { - $autoloadFile = __DIR__.'/../../../../vendor/autoload.php'; - - if (!file_exists($autoloadFile)) { - return null; - } - - $loader = require $autoloadFile; - - return $loader->findFile($fqcn) ?: null; - } } diff --git a/tests/Resources/Php/Symfony/ParentType.php b/tests/Resources/Php/Symfony/ParentType.php index 46fdc86..8a794f1 100644 --- a/tests/Resources/Php/Symfony/ParentType.php +++ b/tests/Resources/Php/Symfony/ParentType.php @@ -2,7 +2,10 @@ namespace Translation\Extractor\Tests\Resources\Php\Symfony; -class ParentType implements FormTypeInterface +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; + +class ParentType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void {