| Conditions | 3 |
| Paths | 3 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | public function serializeSiteAccess(SiteAccess $siteAccess, ControllerReference $uri): void |
||
| 20 | { |
||
| 21 | // Serialize the siteaccess to get it back after. |
||
| 22 | // @see eZ\Publish\Core\MVC\Symfony\EventListener\SiteAccessMatchListener |
||
| 23 | $uri->attributes['serialized_siteaccess'] = json_encode($siteAccess); |
||
| 24 | $uri->attributes['serialized_siteaccess_matcher'] = $this->getSerializer()->serialize( |
||
| 25 | $siteAccess->matcher, |
||
| 26 | 'json' |
||
| 27 | ); |
||
| 28 | if ($siteAccess->matcher instanceof SiteAccess\Matcher\CompoundInterface) { |
||
| 29 | $subMatchers = $siteAccess->matcher->getSubMatchers() ?? null; |
||
| 30 | foreach ($subMatchers as $subMatcher) { |
||
|
|
|||
| 31 | $uri->attributes['serialized_siteaccess_sub_matchers'][get_class($subMatcher)] = $this->getSerializer()->serialize( |
||
| 32 | $subMatcher, |
||
| 33 | 'json' |
||
| 34 | ); |
||
| 35 | } |
||
| 36 | } |
||
| 37 | } |
||
| 38 | } |
||
| 39 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.