1 | <?php |
||
26 | class Registry |
||
27 | { |
||
28 | /** |
||
29 | * @var array<string,callable> Associative array of definition name to function callback |
||
30 | */ |
||
31 | protected $definitions; |
||
32 | |||
33 | /** |
||
34 | * @var array<string,callable> Associative array of definition name to function callback |
||
35 | */ |
||
36 | private static $defaultDefinitions = [ |
||
37 | 'trim' => ['Caridea\Filter\Strings', 'trim'], |
||
38 | 'lowercase' => ['Caridea\Filter\Strings', 'lowerCase'], |
||
39 | 'uppercase' => ['Caridea\Filter\Strings', 'upperCase'], |
||
40 | 'titlecase' => ['Caridea\Filter\Strings', 'titleCase'], |
||
41 | 'string' => ['Caridea\Filter\Strings', 'toString'], |
||
42 | 'replace' => ['Caridea\Filter\Strings', 'replace'], |
||
43 | 'regex' => ['Caridea\Filter\Strings', 'regex'], |
||
44 | 'cut' => ['Caridea\Filter\Strings', 'cut'], |
||
45 | 'alnum' => ['Caridea\Filter\Strings', 'alnum'], |
||
46 | 'alpha' => ['Caridea\Filter\Strings', 'alpha'], |
||
47 | 'numeric' => ['Caridea\Filter\Strings', 'numeric'], |
||
48 | 'nl' => ['Caridea\Filter\Strings', 'unixNewlines'], |
||
49 | 'compactnl' => ['Caridea\Filter\Strings', 'compactNewlines'], |
||
50 | 'bool' => ['Caridea\Filter\Casts', 'toBoolean'], |
||
51 | 'int' => ['Caridea\Filter\Casts', 'toInteger'], |
||
52 | 'float' => ['Caridea\Filter\Casts', 'toFloat'], |
||
53 | 'array' => ['Caridea\Filter\Casts', 'toArray'], |
||
54 | 'default' => ['Caridea\Filter\Casts', 'toDefault'], |
||
55 | 'split' => ['Caridea\Filter\Arrays', 'split'], |
||
56 | 'explode' => ['Caridea\Filter\Arrays', 'explode'], |
||
57 | 'join' => ['Caridea\Filter\Arrays', 'join'], |
||
58 | 'slice' => ['Caridea\Filter\Arrays', 'slice'], |
||
59 | ]; |
||
60 | |||
61 | /** |
||
62 | * Creates a new filter Builder. |
||
63 | */ |
||
64 | 4 | public function __construct() |
|
68 | |||
69 | /** |
||
70 | * Registers rule definitions. |
||
71 | * |
||
72 | * ```php |
||
73 | * $registry = new \Caridea\Filter\Registry(); |
||
74 | * $registry->register([ |
||
75 | * 'gzip' => ['My\Gzip', 'compressor'], |
||
76 | * 'password' => function($hash){return new Hasher($hash);}, |
||
77 | * 'something' => 'my_function_that_returns_a_closure' |
||
78 | * ]); |
||
79 | * ``` |
||
80 | * |
||
81 | * @param array<string,callable> $definitions Associative array of definition name to function callback |
||
82 | * @return $this provides a fluent interface |
||
83 | */ |
||
84 | 2 | public function register(array $definitions): self |
|
94 | |||
95 | /** |
||
96 | * Constructs a filter. |
||
97 | * |
||
98 | * @param string $name The name of the filter |
||
99 | * @param array $args Any filter arguments |
||
100 | * @return callable The filter |
||
101 | * @throws \InvalidArgumentException if the filter name is not registered |
||
102 | * @throws \UnexpectedValueException if the factory returns a non-callable value |
||
103 | */ |
||
104 | 3 | public function factory(string $name, array $args): callable |
|
116 | |||
117 | /** |
||
118 | * Creates a new Builder using this Repository. |
||
119 | * |
||
120 | * @return \Caridea\Filter\Builder The builder |
||
121 | */ |
||
122 | 1 | public function builder(): Builder |
|
126 | } |
||
127 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..