@@ -78,12 +78,12 @@ public static function mergeTree(array $arr1, array $arr2): array
7878
7979 /**
8080 * Searches the array for a given key and returns the offset if successful.
81- * @return int|FALSE offset if it is found, FALSE otherwise
81+ * @return int|NULL offset if it is found, NULL otherwise
8282 */
8383 public static function searchKey (array $ arr , $ key )
8484 {
8585 $ foo = [$ key => NULL ];
86- return array_search (key ($ foo ), array_keys ($ arr ), TRUE );
86+ return ( $ tmp = array_search (key ($ foo ), array_keys ($ arr ), TRUE )) === FALSE ? NULL : $ tmp ;
8787 }
8888
8989
@@ -105,7 +105,7 @@ public static function insertBefore(array &$arr, $key, array $inserted)
105105 public static function insertAfter (array &$ arr , $ key , array $ inserted )
106106 {
107107 $ offset = self ::searchKey ($ arr , $ key );
108- $ offset = $ offset === FALSE ? count ($ arr ) : $ offset + 1 ;
108+ $ offset = $ offset === NULL ? count ($ arr ) : $ offset + 1 ;
109109 $ arr = array_slice ($ arr , 0 , $ offset , TRUE ) + $ inserted + array_slice ($ arr , $ offset , count ($ arr ), TRUE );
110110 }
111111
@@ -117,7 +117,7 @@ public static function insertAfter(array &$arr, $key, array $inserted)
117117 public static function renameKey (array &$ arr , $ oldKey , $ newKey )
118118 {
119119 $ offset = self ::searchKey ($ arr , $ oldKey );
120- if ($ offset !== FALSE ) {
120+ if ($ offset !== NULL ) {
121121 $ keys = array_keys ($ arr );
122122 $ keys [$ offset ] = $ newKey ;
123123 $ arr = array_combine ($ keys , $ arr );
0 commit comments