| Conditions | 5 |
| Paths | 5 |
| Total Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | public function getPostConstructMethod(WeavedInterface $weavedInstance): string |
||
| 37 | { |
||
| 38 | $methods = unserialize($weavedInstance->methodAnnotations); |
||
|
|
|||
| 39 | if (!is_array($methods)) { |
||
| 40 | return ''; |
||
| 41 | } |
||
| 42 | foreach ($methods as $method => $annotations) { |
||
| 43 | foreach ($annotations as $annotation) { |
||
| 44 | if ($annotation instanceof PostConstruct) { |
||
| 45 | return $method; |
||
| 46 | } |
||
| 47 | } |
||
| 48 | } |
||
| 49 | return ''; |
||
| 50 | } |
||
| 51 | } |
||
| 52 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: