1 | <?php |
||
20 | class DelegateRegexMatcher implements MatcherInterface |
||
21 | { |
||
22 | private $regex; |
||
23 | private $callable; |
||
24 | |||
25 | /** |
||
26 | * RegexMatcher constructor. |
||
27 | * |
||
28 | * @param $regex |
||
29 | * @param callable $callable |
||
30 | */ |
||
31 | public function __construct($regex, callable $callable) |
||
36 | |||
37 | /** |
||
38 | * Matches all occurrences and returns token list |
||
39 | * |
||
40 | * @param string $source Source to match tokens |
||
41 | * |
||
42 | * @param TokenFactoryInterface $factory |
||
43 | * |
||
44 | * @return \Generator |
||
45 | */ |
||
46 | public function match($source, TokenFactoryInterface $factory) |
||
57 | } |
||
58 |
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.