1111final class ArrayReader
1212{
1313 /**
14- * @var array<mixed> The data
14+ * @var array
1515 */
16- private $ data ;
16+ private array $ data ;
1717
1818 /**
1919 * The constructor.
2020 *
21- * @param array<mixed> $data Data
21+ * @param array $data Data
2222 */
2323 public function __construct (array $ data = [])
2424 {
@@ -28,7 +28,7 @@ public function __construct(array $data = [])
2828 /**
2929 * Crate instance from array.
3030 *
31- * @param array<mixed> $data The data
31+ * @param array $data The data
3232 *
3333 * @return self The new instance
3434 */
@@ -66,7 +66,7 @@ public function getInt(string $key, int $default = null): int
6666 *
6767 * @return int|null The value
6868 */
69- public function findInt (string $ key , int $ default = null )
69+ public function findInt (string $ key , int $ default = null ): ? int
7070 {
7171 $ value = $ this ->find ($ key , $ default );
7272
@@ -102,11 +102,11 @@ public function getString(string $key, string $default = null): string
102102 * Get value as string or null.
103103 *
104104 * @param string $key The key
105- * @param string $default The default value
105+ * @param string|null $default The default value
106106 *
107107 * @return string|null The value
108108 */
109- public function findString (string $ key , string $ default = null )
109+ public function findString (string $ key , string $ default = null ): ? string
110110 {
111111 $ value = $ this ->find ($ key , $ default );
112112
@@ -121,11 +121,11 @@ public function findString(string $key, string $default = null)
121121 * Get value as array.
122122 *
123123 * @param string $key The key
124- * @param array<mixed> |null $default The default value
124+ * @param array|null $default The default value
125125 *
126126 * @throws InvalidArgumentException
127127 *
128- * @return array<mixed> The value
128+ * @return array The value
129129 */
130130 public function getArray (string $ key , array $ default = null ): array
131131 {
@@ -142,11 +142,11 @@ public function getArray(string $key, array $default = null): array
142142 * Get value as array or null.
143143 *
144144 * @param string $key The key
145- * @param array<mixed> $default The default value
145+ * @param array|null $default The default value
146146 *
147- * @return array<mixed> |null The value
147+ * @return array|null The value
148148 */
149- public function findArray (string $ key , array $ default = null )
149+ public function findArray (string $ key , array $ default = null ): ? array
150150 {
151151 $ value = $ this ->find ($ key , $ default );
152152
@@ -182,11 +182,11 @@ public function getFloat(string $key, float $default = null): float
182182 * Get value as float or null.
183183 *
184184 * @param string $key The key
185- * @param float $default The default value
185+ * @param float|null $default The default value
186186 *
187187 * @return float|null The value
188188 */
189- public function findFloat (string $ key , float $ default = null )
189+ public function findFloat (string $ key , float $ default = null ): ? float
190190 {
191191 $ value = $ this ->find ($ key , $ default );
192192
@@ -226,7 +226,7 @@ public function getBool(string $key, bool $default = null): bool
226226 *
227227 * @return bool|null The value
228228 */
229- public function findBool (string $ key , bool $ default = null )
229+ public function findBool (string $ key , bool $ default = null ): ? bool
230230 {
231231 $ value = $ this ->find ($ key , $ default );
232232
@@ -266,11 +266,11 @@ public function getChronos(string $key, Chronos $default = null): Chronos
266266 * Get value as Chronos or null.
267267 *
268268 * @param string $key The key
269- * @param Chronos $default The default value
269+ * @param Chronos|null $default The default value
270270 *
271271 * @return Chronos|null The value
272272 */
273- public function findChronos (string $ key , Chronos $ default = null )
273+ public function findChronos (string $ key , Chronos $ default = null ): ? Chronos
274274 {
275275 $ value = $ this ->find ($ key , $ default );
276276
@@ -293,13 +293,13 @@ public function findChronos(string $key, Chronos $default = null)
293293 *
294294 * @return mixed|null The value
295295 */
296- public function find (string $ path , $ default = null )
296+ public function find (string $ path , mixed $ default = null ): mixed
297297 {
298298 if (array_key_exists ($ path , $ this ->data )) {
299299 return $ this ->data [$ path ] ?? $ default ;
300300 }
301301
302- if (strpos ($ path , '. ' ) === false ) {
302+ if (! str_contains ($ path , '. ' )) {
303303 return $ default ;
304304 }
305305
@@ -320,15 +320,15 @@ public function find(string $path, $default = null)
320320 /**
321321 * Return all data as array.
322322 *
323- * @return array<mixed> The data
323+ * @return array The data
324324 */
325325 public function all (): array
326326 {
327327 return $ this ->data ;
328328 }
329329
330330 /**
331- * Test whether or not a given path exists in $data.
331+ * Test whether a given path exists in $data.
332332 * This method uses the same path syntax as Hash::extract().
333333 *
334334 * Checking for paths that could target more than one element will
@@ -373,7 +373,7 @@ public function isEmpty(string $path): bool
373373 *
374374 * @return bool The status
375375 */
376- private function isNullOrBlank ($ value ): bool
376+ private function isNullOrBlank (mixed $ value ): bool
377377 {
378378 return $ value === null || $ value === '' ;
379379 }
0 commit comments