1 | <?php |
||
18 | trait AccessorByString |
||
19 | { |
||
20 | use Accessor { |
||
21 | find as parentFind; |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @return string |
||
26 | */ |
||
27 | abstract protected static function stringProperty(): string; |
||
28 | |||
29 | /******************************************* |
||
30 | * OVERRIDE |
||
31 | *******************************************/ |
||
32 | |||
33 | /** |
||
34 | * @param $identifier |
||
35 | * @param string|null $toScenario |
||
36 | * @return Record|null |
||
37 | */ |
||
38 | public function find($identifier, string $toScenario = null) |
||
39 | { |
||
40 | if (!is_numeric($identifier) && is_string($identifier)) { |
||
41 | return $this->findByString($identifier, $toScenario); |
||
|
|||
42 | } |
||
43 | |||
44 | return $this->parentFind($identifier, $toScenario); |
||
45 | } |
||
46 | |||
47 | /******************************************* |
||
48 | * FIND STRING |
||
49 | *******************************************/ |
||
50 | |||
51 | /** |
||
52 | * @param string $string |
||
53 | * @return Record|null |
||
54 | */ |
||
55 | public function findByString(string $string) |
||
61 | |||
62 | /** |
||
63 | * @param string $string |
||
64 | * @throws RecordNotFoundException |
||
65 | * @return Record|null |
||
66 | */ |
||
67 | public function getByString(string $string) |
||
75 | |||
76 | /** |
||
77 | * @param string|null $string |
||
78 | * @throws RecordNotFoundException |
||
79 | */ |
||
80 | protected function notFoundByStringException(string $string = null) |
||
89 | |||
90 | } |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.