1 | <?php |
||
25 | class FilesystemLocation implements LocationInterface |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * Path that this location points to. |
||
30 | * |
||
31 | * @since 0.1.0 |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $path; |
||
36 | |||
37 | /** |
||
38 | * Extensions that this location can accept. |
||
39 | * |
||
40 | * @since 0.1.0 |
||
41 | * |
||
42 | * @var ExtensionCollection |
||
43 | */ |
||
44 | protected $extensions; |
||
45 | |||
46 | /** |
||
47 | * Instantiate a FilesystemLocation object. |
||
48 | * |
||
49 | * @since 0.1.0 |
||
50 | * |
||
51 | * @param string $path Path that this location points to. |
||
52 | * @param ExtensionCollection|array|string $extensions Extensions that this location can accept. |
||
|
|||
53 | */ |
||
54 | 21 | public function __construct($path, $extensions = null) |
|
59 | |||
60 | /** |
||
61 | * Get the first URI that matches the given criteria. |
||
62 | * |
||
63 | * @since 0.1.0 |
||
64 | * |
||
65 | * @param array $criteria Criteria to match. |
||
66 | * |
||
67 | * @return string|false URI that matches the criteria or false if none found. |
||
68 | */ |
||
69 | 21 | public function getURI(array $criteria) |
|
79 | |||
80 | /** |
||
81 | * Get all URIs that match the given criteria. |
||
82 | * |
||
83 | * @since 0.1.1 |
||
84 | * |
||
85 | * @param array $criteria Criteria to match. |
||
86 | * |
||
87 | * @return array URIs that match the criteria or empty array if none found. |
||
88 | */ |
||
89 | 3 | public function getURIs(array $criteria) |
|
101 | |||
102 | /** |
||
103 | * Validate the extensions and return a collection. |
||
104 | * |
||
105 | * @since 0.1.1 |
||
106 | * |
||
107 | * @param ExtensionCollection|array|string $extensions Extensions to validate. |
||
108 | * |
||
109 | * @return ExtensionCollection Validated extensions collection. |
||
110 | */ |
||
111 | 21 | protected function validateExtensions($extensions) |
|
120 | |||
121 | /** |
||
122 | * Try to transform the entry into possible URIs. |
||
123 | * |
||
124 | * @since 0.1.0 |
||
125 | * |
||
126 | * @param string $entry Entry to transform. |
||
127 | * @param bool $firstOnly Return the first result only. |
||
128 | * |
||
129 | * @return array|string|false If $firstOnly is true, returns a string with the URI of the view, or false if none |
||
130 | * found. |
||
131 | * If $firstOnly is false, returns an array with all matching URIs, or an empty array if |
||
132 | * none found. |
||
133 | */ |
||
134 | 21 | protected function transform($entry, $firstOnly = true) |
|
153 | |||
154 | /** |
||
155 | * Get the individual variants that could be matched for the location. |
||
156 | * |
||
157 | * @since 0.1.1 |
||
158 | * |
||
159 | * @param string $entry Entry to get the variants for. |
||
160 | * |
||
161 | * @return array Array of variants to check. |
||
162 | */ |
||
163 | 21 | protected function getVariants($entry) |
|
174 | } |
||
175 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type
array
and suggests a stricter type likearray<String>
.Most often this is a case of a parameter that can be null in addition to its declared types.