Innmind /
Neo4jBundle
| 1 | <?php |
||||
| 2 | declare(strict_types = 1); |
||||
| 3 | |||||
| 4 | namespace Innmind\Neo4jBundle\DependencyInjection\Compiler; |
||||
| 5 | |||||
| 6 | use Innmind\Neo4jBundle\Exception\NoEntityDefinitionFoundException; |
||||
| 7 | use Innmind\Filesystem\{ |
||||
| 8 | Adapter\FilesystemAdapter, |
||||
| 9 | Exception\FileNotFound, |
||||
| 10 | Directory |
||||
| 11 | }; |
||||
| 12 | use Symfony\Component\DependencyInjection\{ |
||||
| 13 | Compiler\CompilerPassInterface, |
||||
| 14 | ContainerBuilder |
||||
| 15 | }; |
||||
| 16 | use Symfony\Component\Yaml\Yaml; |
||||
| 17 | |||||
| 18 | final class InjectEntityDefinitionsPass implements CompilerPassInterface |
||||
| 19 | { |
||||
| 20 | /** |
||||
| 21 | * {@inheritdoc} |
||||
| 22 | */ |
||||
| 23 | 4 | public function process(ContainerBuilder $container) |
|||
| 24 | { |
||||
| 25 | 4 | $bundles = $container->getParameter('kernel.bundles'); |
|||
| 26 | 4 | $configs = []; |
|||
| 27 | |||||
| 28 | 4 | foreach ($bundles as $bundle => $class) { |
|||
| 29 | try { |
||||
| 30 | 4 | $configs[] = $this->computeConfig($class); |
|||
| 31 | 4 | } catch (NoEntityDefinitionFoundException $e) { |
|||
| 32 | //pass |
||||
| 33 | } |
||||
| 34 | } |
||||
| 35 | |||||
| 36 | $container |
||||
| 37 | 4 | ->getDefinition('innmind_neo4j.metadata_builder') |
|||
| 38 | 4 | ->addMethodCall( |
|||
| 39 | 4 | 'inject', |
|||
| 40 | 4 | [$configs] |
|||
| 41 | ); |
||||
| 42 | 4 | } |
|||
| 43 | |||||
| 44 | /** |
||||
| 45 | * Load the entity definitions for the given bundle |
||||
| 46 | * |
||||
| 47 | * @param string $class Bundle class FQCN |
||||
| 48 | * |
||||
| 49 | * @throws NoEntityDefinitionFoundException |
||||
| 50 | * |
||||
| 51 | * @return array |
||||
| 52 | */ |
||||
| 53 | 4 | private function computeConfig(string $class): array |
|||
| 54 | { |
||||
| 55 | try { |
||||
| 56 | 4 | $refl = new \ReflectionClass($class); |
|||
| 57 | 4 | $dir = (new FilesystemAdapter(dirname($refl->getFileName()))) |
|||
| 58 | 4 | ->get('Resources') |
|||
| 59 | 4 | ->get('config'); |
|||
|
0 ignored issues
–
show
|
|||||
| 60 | |||||
| 61 | 4 | if ($dir->has('neo4j.yml')) { |
|||
|
0 ignored issues
–
show
The method
has() does not exist on Innmind\Filesystem\File. It seems like you code against a sub-type of Innmind\Filesystem\File such as Innmind\Filesystem\Directory.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 62 | 4 | return Yaml::parse((string) $dir->get('neo4j.yml')->content()); |
|||
|
0 ignored issues
–
show
The method
get() does not exist on Innmind\Filesystem\File. It seems like you code against a sub-type of Innmind\Filesystem\File such as Innmind\Filesystem\Directory.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 63 | } |
||||
| 64 | |||||
| 65 | 4 | $dir = $dir->get('neo4j'); |
|||
| 66 | 4 | $config = []; |
|||
| 67 | |||||
| 68 | 4 | foreach ($dir as $file) { |
|||
| 69 | 4 | if ($file instanceof Directory) { |
|||
| 70 | 4 | continue; |
|||
| 71 | } |
||||
| 72 | |||||
| 73 | 4 | $config = array_merge( |
|||
| 74 | 4 | $config, |
|||
| 75 | 4 | Yaml::parse((string) $file->content()) |
|||
| 76 | ); |
||||
| 77 | } |
||||
| 78 | |||||
| 79 | 4 | return $config; |
|||
| 80 | 4 | } catch (FileNotFound $e) { |
|||
| 81 | 4 | throw new NoEntityDefinitionFoundException; |
|||
| 82 | } |
||||
| 83 | } |
||||
| 84 | } |
||||
| 85 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.