1 | <?php |
||
8 | final class Symfony4EntityRepositoryGenerator |
||
9 | { |
||
10 | protected static $_template = |
||
11 | '<?php |
||
12 | |||
13 | namespace <namespace>; |
||
14 | |||
15 | use <entityClassName>; |
||
16 | use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
||
17 | use Symfony\Bridge\Doctrine\RegistryInterface; |
||
18 | |||
19 | class <repository> extends ServiceEntityRepository |
||
20 | { |
||
21 | public function __construct(RegistryInterface $registry) |
||
22 | { |
||
23 | parent::__construct($registry, <entity>::class); |
||
24 | } |
||
25 | } |
||
26 | '; |
||
27 | |||
28 | /** |
||
29 | * @param string $entityClassName |
||
|
|||
30 | * @param string $repositoryClassName |
||
31 | * |
||
32 | * @return string |
||
33 | */ |
||
34 | public function generateEntityRepositoryClass(string $entityClass, string $repositoryClass) |
||
45 | |||
46 | /** |
||
47 | * @param string $fullClassName |
||
48 | * @param string $outputDirectory |
||
49 | */ |
||
50 | public function writeEntityRepositoryClass($entityClass, $repositoryClass, $outputDirectory) |
||
70 | |||
71 | /** |
||
72 | * @param string $repositoryClassName |
||
73 | * |
||
74 | * @return bool|string |
||
75 | */ |
||
76 | private function generateEntityRepositoryNamespace(string $repositoryClassName) |
||
80 | |||
81 | /** |
||
82 | * @param string $entityClassName |
||
83 | * |
||
84 | * @return bool|string |
||
85 | */ |
||
86 | private function generateEntityName(string $entityClassName) |
||
90 | |||
91 | /** |
||
92 | * Generates the class name |
||
93 | * |
||
94 | * @param string $fullClassName |
||
95 | * |
||
96 | * @return string |
||
97 | */ |
||
98 | private function generateClassName($fullClassName) |
||
110 | |||
111 | /** |
||
112 | * Generates the namespace, if class do not have namespace, return empty string instead. |
||
113 | * |
||
114 | * @param string $fullClassName |
||
115 | * |
||
116 | * @return string $namespace |
||
117 | */ |
||
118 | private function getClassNamespace($fullClassName) |
||
124 | } |
||
125 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.