1 | <?php |
||
23 | final class Like implements Filter, Satisfiable |
||
24 | { |
||
25 | public const CONTAINS = LikePattern::CONTAINS; |
||
26 | |||
27 | public const ENDS_WITH = LikePattern::ENDS_WITH; |
||
28 | |||
29 | public const STARTS_WITH = LikePattern::STARTS_WITH; |
||
30 | |||
31 | /** |
||
32 | * @var Operand|string |
||
33 | */ |
||
34 | private $field; |
||
35 | |||
36 | /** |
||
37 | * @var LikePattern |
||
38 | */ |
||
39 | private $value; |
||
40 | |||
41 | /** |
||
42 | * @var string|null |
||
43 | */ |
||
44 | private $context; |
||
45 | |||
46 | /** |
||
47 | * @param Operand|string $field |
||
48 | * @param LikePattern|string $value |
||
49 | * @param string $format |
||
50 | * @param string|null $context |
||
51 | */ |
||
52 | public function __construct($field, $value, string $format = LikePattern::CONTAINS, ?string $context = null) |
||
62 | |||
63 | /** |
||
64 | * @param QueryBuilder $qb |
||
65 | * @param string $context |
||
66 | * |
||
67 | * @return string |
||
68 | */ |
||
69 | public function getFilter(QueryBuilder $qb, string $context): string |
||
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | public function filterCollection(iterable $collection, ?string $context = null): iterable |
||
98 | |||
99 | /** |
||
100 | * {@inheritdoc} |
||
101 | */ |
||
102 | public function isSatisfiedBy($candidate, ?string $context = null): bool |
||
110 | |||
111 | /** |
||
112 | * @param string|null $context |
||
113 | * |
||
114 | * @return string|null |
||
115 | */ |
||
116 | private function resolveContext(?string $context): ?string |
||
128 | |||
129 | /** |
||
130 | * @return string |
||
131 | */ |
||
132 | private function getUnescapedValue(): string |
||
137 | |||
138 | /** |
||
139 | * @param string $haystack |
||
140 | * @param string $needle |
||
141 | * |
||
142 | * @return bool |
||
143 | */ |
||
144 | private function isMatch(string $haystack, string $needle): bool |
||
157 | } |
||
158 |
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.