@@ -52,7 +52,7 @@ |
||
52 | 52 | * @since 3.5.3 |
53 | 53 | * @return string The site language. |
54 | 54 | */ |
55 | - static public function getSiteLanguage( $sDefault='en_US' ) { |
|
55 | + static public function getSiteLanguage( $sDefault = 'en_US' ) { |
|
56 | 56 | return defined( 'WPLANG' ) && WPLANG ? WPLANG : $sDefault; |
57 | 57 | } |
58 | 58 |
@@ -140,7 +140,8 @@ discard block |
||
140 | 140 | $_aExcludeDirNames = ( array ) $aSearchOptions['exclude_dir_names']; |
141 | 141 | $_bIsRecursive = $aSearchOptions[ 'is_recursive' ]; |
142 | 142 | |
143 | - if ( defined( 'GLOB_BRACE' ) ) { // in some OSes this flag constant is not available. |
|
143 | + if ( defined( 'GLOB_BRACE' ) ) { |
|
144 | +// in some OSes this flag constant is not available. |
|
144 | 145 | $_aFilePaths = $_bIsRecursive |
145 | 146 | ? $this->doRecursiveGlob( $sClassDirPath . '*.' . $this->_getGlobPatternExtensionPart( $_aAllowedExtensions ), GLOB_BRACE, $_aExcludeDirPaths, $_aExcludeDirNames ) |
146 | 147 | : ( array ) glob( $sClassDirPath . '*.' . $this->_getGlobPatternExtensionPart( $_aAllowedExtensions ), GLOB_BRACE ); |
@@ -204,26 +205,26 @@ discard block |
||
204 | 205 | /** |
205 | 206 | * Responds to the PHP auto-loader and includes the passed class based on the previously stored path associated with the class name in the constructor. |
206 | 207 | */ |
207 | - public function _replyToAutoLoad_include( $sCalledUnknownClassName ) { |
|
208 | - if ( ! isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
208 | + public function _replyToAutoLoad_include( $sCalledUnknownClassName ) { |
|
209 | + if ( ! isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
209 | 210 | return; |
210 | 211 | } |
211 | 212 | include( $this->_aClasses[ $sCalledUnknownClassName ] ); |
212 | 213 | } |
213 | - public function _replyToAutoLoad_include_once( $sCalledUnknownClassName ) { |
|
214 | - if ( ! isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
214 | + public function _replyToAutoLoad_include_once( $sCalledUnknownClassName ) { |
|
215 | + if ( ! isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
215 | 216 | return; |
216 | 217 | } |
217 | 218 | include_once( $this->_aClasses[ $sCalledUnknownClassName ] ); |
218 | 219 | } |
219 | - public function _replyToAutoLoad_require( $sCalledUnknownClassName ) { |
|
220 | - if ( ! isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
220 | + public function _replyToAutoLoad_require( $sCalledUnknownClassName ) { |
|
221 | + if ( ! isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
221 | 222 | return; |
222 | 223 | } |
223 | 224 | require( $this->_aClasses[ $sCalledUnknownClassName ] ); |
224 | 225 | } |
225 | - public function _replyToAutoLoad_require_once( $sCalledUnknownClassName ) { |
|
226 | - if ( ! isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
226 | + public function _replyToAutoLoad_require_once( $sCalledUnknownClassName ) { |
|
227 | + if ( ! isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
227 | 228 | return; |
228 | 229 | } |
229 | 230 | require_once( $this->_aClasses[ $sCalledUnknownClassName ] ); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * Sets up properties and performs registering classes. |
76 | 76 | * |
77 | 77 | * |
78 | - * @param array|string $asScanDirPath the target directory path to scan |
|
78 | + * @param array|string $asScanDirPaths the target directory path to scan |
|
79 | 79 | * @param array $aOptions The recursive settings. |
80 | 80 | * <ul> |
81 | 81 | * <li><code>is_recursive</code> - (boolean) determines whether the scan should be performed recursively.</li> |
@@ -217,6 +217,7 @@ discard block |
||
217 | 217 | /** |
218 | 218 | * The recursive version of the glob() function. |
219 | 219 | * @internal |
220 | + * @param string $sPathPatten |
|
220 | 221 | */ |
221 | 222 | protected function doRecursiveGlob( $sPathPatten, $nFlags=0, array $aExcludeDirs=array(), array $aExcludeDirNames=array() ) { |
222 | 223 |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | 'is_recursive' => true, |
67 | 67 | 'exclude_dir_paths' => array(), |
68 | 68 | 'exclude_dir_names' => array( 'asset', 'assets', 'css', 'js', 'image', 'images', 'license', 'document', 'documents' ), |
69 | - 'allowed_extensions' => array( 'php', ), // 'inc' |
|
69 | + 'allowed_extensions' => array( 'php',), // 'inc' |
|
70 | 70 | 'include_function' => 'include', |
71 | 71 | 'exclude_class_names' => array( /* 'SomeClass', 'SomeOtherClass' */ ), |
72 | 72 | ); |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @remark The directory paths set for the 'exclude_dir_paths' option should use the system directory separator. |
107 | 107 | */ |
108 | - public function __construct( $asScanDirPaths, array $aOptions=array(), array $aClasses=array() ) { |
|
108 | + public function __construct( $asScanDirPaths, array $aOptions = array(), array $aClasses = array() ) { |
|
109 | 109 | |
110 | 110 | $_aOptions = $aOptions + self::$_aStructure_Options; |
111 | - $this->_aClasses = $aClasses + $this->_getClassArray( $asScanDirPaths, $_aOptions ); |
|
111 | + $this->_aClasses = $aClasses + $this->_getClassArray( $asScanDirPaths, $_aOptions ); |
|
112 | 112 | $this->_registerClasses( $_aOptions[ 'include_function' ] ); |
113 | 113 | |
114 | 114 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | return array(); |
135 | 135 | } |
136 | 136 | $_aFilePaths = array(); |
137 | - foreach( ( array ) $asScanDirPaths as $_sClassDirPath ) { |
|
137 | + foreach ( ( array ) $asScanDirPaths as $_sClassDirPath ) { |
|
138 | 138 | if ( realpath( $_sClassDirPath ) ) { |
139 | 139 | $_aFilePaths = array_merge( $this->getFilePaths( $_sClassDirPath, $aSearchOptions ), $_aFilePaths ); |
140 | 140 | } |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | |
143 | 143 | // Store classes in an array. |
144 | 144 | $_aClasses = array(); |
145 | - foreach( $_aFilePaths as $_sFilePath ) { |
|
145 | + foreach ( $_aFilePaths as $_sFilePath ) { |
|
146 | 146 | |
147 | 147 | // Class name without a file extension. |
148 | 148 | $_sClassNameWOExt = pathinfo( $_sFilePath, PATHINFO_FILENAME ); |
149 | - if ( in_array( $_sClassNameWOExt, $aSearchOptions['exclude_class_names'] ) ) { |
|
149 | + if ( in_array( $_sClassNameWOExt, $aSearchOptions[ 'exclude_class_names' ] ) ) { |
|
150 | 150 | continue; |
151 | 151 | } |
152 | 152 | $_aClasses[ $_sClassNameWOExt ] = $_sFilePath; |
@@ -176,26 +176,26 @@ discard block |
||
176 | 176 | */ |
177 | 177 | protected function getFilePaths( $sClassDirPath, array $aSearchOptions ) { |
178 | 178 | |
179 | - $sClassDirPath = rtrim( $sClassDirPath, '\\/' ) . DIRECTORY_SEPARATOR; // ensures the trailing (back/)slash exists. |
|
180 | - $_aAllowedExtensions = $aSearchOptions['allowed_extensions']; |
|
181 | - $_aExcludeDirPaths = ( array ) $aSearchOptions['exclude_dir_paths']; |
|
182 | - $_aExcludeDirNames = ( array ) $aSearchOptions['exclude_dir_names']; |
|
179 | + $sClassDirPath = rtrim( $sClassDirPath, '\\/' ).DIRECTORY_SEPARATOR; // ensures the trailing (back/)slash exists. |
|
180 | + $_aAllowedExtensions = $aSearchOptions[ 'allowed_extensions' ]; |
|
181 | + $_aExcludeDirPaths = ( array ) $aSearchOptions[ 'exclude_dir_paths' ]; |
|
182 | + $_aExcludeDirNames = ( array ) $aSearchOptions[ 'exclude_dir_names' ]; |
|
183 | 183 | $_bIsRecursive = $aSearchOptions[ 'is_recursive' ]; |
184 | 184 | |
185 | 185 | if ( defined( 'GLOB_BRACE' ) ) { // in some OSes this flag constant is not available. |
186 | 186 | $_aFilePaths = $_bIsRecursive |
187 | - ? $this->doRecursiveGlob( $sClassDirPath . '*.' . $this->_getGlobPatternExtensionPart( $_aAllowedExtensions ), GLOB_BRACE, $_aExcludeDirPaths, $_aExcludeDirNames ) |
|
188 | - : ( array ) glob( $sClassDirPath . '*.' . $this->_getGlobPatternExtensionPart( $_aAllowedExtensions ), GLOB_BRACE ); |
|
187 | + ? $this->doRecursiveGlob( $sClassDirPath.'*.'.$this->_getGlobPatternExtensionPart( $_aAllowedExtensions ), GLOB_BRACE, $_aExcludeDirPaths, $_aExcludeDirNames ) |
|
188 | + : ( array ) glob( $sClassDirPath.'*.'.$this->_getGlobPatternExtensionPart( $_aAllowedExtensions ), GLOB_BRACE ); |
|
189 | 189 | return array_filter( $_aFilePaths ); // drop non-value elements. |
190 | 190 | } |
191 | 191 | |
192 | 192 | // For the Solaris operation system. |
193 | 193 | $_aFilePaths = array(); |
194 | - foreach( $_aAllowedExtensions as $__sAllowedExtension ) { |
|
194 | + foreach ( $_aAllowedExtensions as $__sAllowedExtension ) { |
|
195 | 195 | |
196 | 196 | $__aFilePaths = $_bIsRecursive |
197 | - ? $this->doRecursiveGlob( $sClassDirPath . '*.' . $__sAllowedExtension, 0, $_aExcludeDirPaths, $_aExcludeDirNames ) |
|
198 | - : ( array ) glob( $sClassDirPath . '*.' . $__sAllowedExtension ); |
|
197 | + ? $this->doRecursiveGlob( $sClassDirPath.'*.'.$__sAllowedExtension, 0, $_aExcludeDirPaths, $_aExcludeDirNames ) |
|
198 | + : ( array ) glob( $sClassDirPath.'*.'.$__sAllowedExtension ); |
|
199 | 199 | |
200 | 200 | $_aFilePaths = array_merge( $__aFilePaths, $_aFilePaths ); |
201 | 201 | |
@@ -208,28 +208,28 @@ discard block |
||
208 | 208 | * Constructs the file pattern of the file extension part used for the glob() function with the given file extensions. |
209 | 209 | * @internal |
210 | 210 | */ |
211 | - protected function _getGlobPatternExtensionPart( array $aExtensions=array( 'php', 'inc' ) ) { |
|
211 | + protected function _getGlobPatternExtensionPart( array $aExtensions = array( 'php', 'inc' ) ) { |
|
212 | 212 | return empty( $aExtensions ) |
213 | 213 | ? '*' |
214 | - : '{' . implode( ',', $aExtensions ) . '}'; |
|
214 | + : '{'.implode( ',', $aExtensions ).'}'; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
218 | 218 | * The recursive version of the glob() function. |
219 | 219 | * @internal |
220 | 220 | */ |
221 | - protected function doRecursiveGlob( $sPathPatten, $nFlags=0, array $aExcludeDirs=array(), array $aExcludeDirNames=array() ) { |
|
221 | + protected function doRecursiveGlob( $sPathPatten, $nFlags = 0, array $aExcludeDirs = array(), array $aExcludeDirNames = array() ) { |
|
222 | 222 | |
223 | 223 | $_aFiles = glob( $sPathPatten, $nFlags ); |
224 | 224 | $_aFiles = is_array( $_aFiles ) ? $_aFiles : array(); // glob() can return false. |
225 | - $_aDirs = glob( dirname( $sPathPatten ) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR|GLOB_NOSORT ); |
|
225 | + $_aDirs = glob( dirname( $sPathPatten ).DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR | GLOB_NOSORT ); |
|
226 | 226 | $_aDirs = is_array( $_aDirs ) ? $_aDirs : array(); |
227 | 227 | foreach ( $_aDirs as $_sDirPath ) { |
228 | 228 | |
229 | 229 | if ( in_array( $_sDirPath, $aExcludeDirs ) ) { continue; } |
230 | 230 | if ( in_array( pathinfo( $_sDirPath, PATHINFO_DIRNAME ), $aExcludeDirNames ) ) { continue; } |
231 | 231 | |
232 | - $_aFiles = array_merge( $_aFiles, $this->doRecursiveGlob( $_sDirPath . DIRECTORY_SEPARATOR . basename( $sPathPatten ), $nFlags, $aExcludeDirs ) ); |
|
232 | + $_aFiles = array_merge( $_aFiles, $this->doRecursiveGlob( $_sDirPath.DIRECTORY_SEPARATOR.basename( $sPathPatten ), $nFlags, $aExcludeDirs ) ); |
|
233 | 233 | |
234 | 234 | } |
235 | 235 | return $_aFiles; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @return void |
245 | 245 | */ |
246 | 246 | protected function _registerClasses( $sIncludeFunction ) { |
247 | - spl_autoload_register( array( $this, '_replyToAutoLoad_' . $sIncludeFunction ) ); |
|
247 | + spl_autoload_register( array( $this, '_replyToAutoLoad_'.$sIncludeFunction ) ); |
|
248 | 248 | } |
249 | 249 | /**#@+ |
250 | 250 | * Responds to the PHP auto-loader and includes the passed class based on the previously stored path associated with the class name in the constructor. |
@@ -252,25 +252,25 @@ discard block |
||
252 | 252 | * @return void |
253 | 253 | */ |
254 | 254 | public function _replyToAutoLoad_include( $sCalledUnknownClassName ) { |
255 | - if ( ! isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
255 | + if ( !isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | 258 | include( $this->_aClasses[ $sCalledUnknownClassName ] ); |
259 | 259 | } |
260 | 260 | public function _replyToAutoLoad_include_once( $sCalledUnknownClassName ) { |
261 | - if ( ! isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
261 | + if ( !isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
262 | 262 | return; |
263 | 263 | } |
264 | 264 | include_once( $this->_aClasses[ $sCalledUnknownClassName ] ); |
265 | 265 | } |
266 | 266 | public function _replyToAutoLoad_require( $sCalledUnknownClassName ) { |
267 | - if ( ! isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
267 | + if ( !isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
268 | 268 | return; |
269 | 269 | } |
270 | 270 | require( $this->_aClasses[ $sCalledUnknownClassName ] ); |
271 | 271 | } |
272 | 272 | public function _replyToAutoLoad_require_once( $sCalledUnknownClassName ) { |
273 | - if ( ! isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
273 | + if ( !isset( $this->_aClasses[ $sCalledUnknownClassName ] ) ) { |
|
274 | 274 | return; |
275 | 275 | } |
276 | 276 | require_once( $this->_aClasses[ $sCalledUnknownClassName ] ); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @return integer |
35 | 35 | * @internal |
36 | 36 | */ |
37 | - static public function sortArrayByKey( $a, $b, $sKey='order' ) { |
|
37 | + static public function sortArrayByKey( $a, $b, $sKey = 'order' ) { |
|
38 | 38 | return isset( $a[ $sKey ], $b[ $sKey ] ) |
39 | 39 | ? $a[ $sKey ] - $b[ $sKey ] |
40 | 40 | : 1; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | static public function unsetDimensionalArrayElement( &$mSubject, array $aKeys ) { |
78 | 78 | |
79 | 79 | $_sKey = array_shift( $aKeys ); |
80 | - if ( ! empty( $aKeys ) ) { |
|
80 | + if ( !empty( $aKeys ) ) { |
|
81 | 81 | if ( isset( $mSubject[ $_sKey ] ) && is_array( $mSubject[ $_sKey ] ) ) { |
82 | 82 | self::unsetDimensionalArrayElement( $mSubject[ $_sKey ], $aKeys ); |
83 | 83 | } |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | static public function setMultiDimensionalArray( &$mSubject, array $aKeys, $mValue ) { |
99 | 99 | |
100 | 100 | $_sKey = array_shift( $aKeys ); |
101 | - if ( ! empty( $aKeys ) ) { |
|
102 | - if( ! isset( $mSubject[ $_sKey ] ) || ! is_array( $mSubject[ $_sKey ] ) ) { |
|
101 | + if ( !empty( $aKeys ) ) { |
|
102 | + if ( !isset( $mSubject[ $_sKey ] ) || !is_array( $mSubject[ $_sKey ] ) ) { |
|
103 | 103 | $mSubject[ $_sKey ] = array(); |
104 | 104 | } |
105 | 105 | self::setMultiDimensionalArray( $mSubject[ $_sKey ], $aKeys, $mValue ); |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | |
154 | 154 | $_aNumeric = self::getIntegerKeyElements( $aSubject ); |
155 | 155 | $_aAssociative = self::invertCastArrayContents( $aSubject, $_aNumeric ); |
156 | - foreach( $_aNumeric as &$_aElem ) { |
|
156 | + foreach ( $_aNumeric as &$_aElem ) { |
|
157 | 157 | $_aElem = self::uniteArrays( $_aElem, $_aAssociative ); |
158 | 158 | } |
159 | - if ( ! empty( $_aAssociative ) ) { |
|
159 | + if ( !empty( $_aAssociative ) ) { |
|
160 | 160 | array_unshift( $_aNumeric, $_aAssociative ); // insert the main section to the beginning of the array. |
161 | 161 | } |
162 | 162 | return $_aNumeric; |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | public static function castArrayContents( array $aModel, array $aSubject ) { |
180 | 180 | |
181 | 181 | $_aCast = array(); |
182 | - foreach( $aModel as $_isKey => $_v ) { |
|
182 | + foreach ( $aModel as $_isKey => $_v ) { |
|
183 | 183 | $_aCast[ $_isKey ] = self::getElement( |
184 | - $aSubject, // subject array |
|
185 | - $_isKey, // key |
|
184 | + $aSubject, // subject array |
|
185 | + $_isKey, // key |
|
186 | 186 | null // default |
187 | 187 | ); |
188 | 188 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | public static function invertCastArrayContents( array $aModel, array $aSubject ) { |
204 | 204 | |
205 | 205 | $_aInvert = array(); |
206 | - foreach( $aModel as $_isKey => $_v ) { |
|
206 | + foreach ( $aModel as $_isKey => $_v ) { |
|
207 | 207 | if ( array_key_exists( $_isKey, $aSubject ) ) { |
208 | 208 | continue; |
209 | 209 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | public static function uniteArrays( /* $aPrecedence, $aArray1, $aArray2, ... */ ) { |
230 | 230 | |
231 | 231 | $_aArray = array(); |
232 | - foreach( array_reverse( func_get_args() ) as $_aArg ) { |
|
232 | + foreach ( array_reverse( func_get_args() ) as $_aArg ) { |
|
233 | 233 | $_aArray = self::uniteArraysRecursive( |
234 | 234 | self::getAsArray( $_aArg ), |
235 | 235 | $_aArray |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | $aPrecedence = array(); |
261 | 261 | } |
262 | 262 | |
263 | - if ( ! is_array( $aDefault ) || ! is_array( $aPrecedence ) ) { |
|
263 | + if ( !is_array( $aDefault ) || !is_array( $aPrecedence ) ) { |
|
264 | 264 | return $aPrecedence; |
265 | 265 | } |
266 | 266 | |
267 | - foreach( $aDefault as $sKey => $v ) { |
|
267 | + foreach ( $aDefault as $sKey => $v ) { |
|
268 | 268 | |
269 | 269 | // If the precedence does not have the key, assign the default's value. |
270 | - if ( ! array_key_exists( $sKey, $aPrecedence ) || is_null( $aPrecedence[ $sKey ] ) ) { |
|
270 | + if ( !array_key_exists( $sKey, $aPrecedence ) || is_null( $aPrecedence[ $sKey ] ) ) { |
|
271 | 271 | $aPrecedence[ $sKey ] = $v; |
272 | 272 | } else { |
273 | 273 | |
@@ -298,9 +298,9 @@ discard block |
||
298 | 298 | * - NULL |
299 | 299 | * @return array The modified array. |
300 | 300 | */ |
301 | - static public function dropElementsByType( array $aArray, $aTypes=array( 'array' ) ) { |
|
301 | + static public function dropElementsByType( array $aArray, $aTypes = array( 'array' ) ) { |
|
302 | 302 | |
303 | - foreach( $aArray as $isKey => $vValue ) { |
|
303 | + foreach ( $aArray as $isKey => $vValue ) { |
|
304 | 304 | if ( in_array( gettype( $vValue ), $aTypes ) ) { |
305 | 305 | unset( $aArray[ $isKey ] ); |
306 | 306 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | */ |
317 | 317 | static public function dropElementByValue( array $aArray, $vValue ) { |
318 | 318 | |
319 | - foreach( self::getAsArray( $vValue, true ) as $_vValue ) { |
|
319 | + foreach ( self::getAsArray( $vValue, true ) as $_vValue ) { |
|
320 | 320 | $_sKey = array_search( $_vValue, $aArray, true ); |
321 | 321 | if ( $_sKey === false ) { |
322 | 322 | continue; |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | */ |
339 | 339 | static public function dropElementsByKey( array $aArray, $asKeys ) { |
340 | 340 | |
341 | - foreach( self::getAsArray( $asKeys, true ) as $_isKey ) { |
|
341 | + foreach ( self::getAsArray( $asKeys, true ) as $_isKey ) { |
|
342 | 342 | unset( $aArray[ $_isKey ] ); |
343 | 343 | } |
344 | 344 | return $aArray; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | $_aInvert = array(); |
206 | 206 | foreach( $aModel as $_isKey => $_v ) { |
207 | - if ( array_key_exists( $_isKey, $aSubject ) ) { |
|
207 | + if ( array_key_exists( $_isKey, $aSubject ) ) { |
|
208 | 208 | continue; |
209 | 209 | } |
210 | 210 | $_aInvert[ $_isKey ] = $_v; |
@@ -256,11 +256,11 @@ discard block |
||
256 | 256 | */ |
257 | 257 | public static function uniteArraysRecursive( $aPrecedence, $aDefault ) { |
258 | 258 | |
259 | - if ( is_null( $aPrecedence ) ) { |
|
259 | + if ( is_null( $aPrecedence ) ) { |
|
260 | 260 | $aPrecedence = array(); |
261 | 261 | } |
262 | 262 | |
263 | - if ( ! is_array( $aDefault ) || ! is_array( $aPrecedence ) ) { |
|
263 | + if ( ! is_array( $aDefault ) || ! is_array( $aPrecedence ) ) { |
|
264 | 264 | return $aPrecedence; |
265 | 265 | } |
266 | 266 |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | * @param integer $iLines The number of lines to read. |
29 | 29 | * @return string |
30 | 30 | */ |
31 | - static public function getFileTailContents( $asPath=array(), $iLines=1 ) { |
|
31 | + static public function getFileTailContents( $asPath = array(), $iLines = 1 ) { |
|
32 | 32 | |
33 | - $_sPath = self::_getFirstItem( $asPath ); |
|
34 | - if ( ! @is_readable( $_sPath ) ) { |
|
33 | + $_sPath = self::_getFirstItem( $asPath ); |
|
34 | + if ( !@is_readable( $_sPath ) ) { |
|
35 | 35 | return ''; |
36 | 36 | } |
37 | 37 | return trim( |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @since 3.4.6 |
62 | 62 | * @return string |
63 | 63 | */ |
64 | - static public function sanitizeFileName( $sFileName, $sReplacement='_' ) { |
|
64 | + static public function sanitizeFileName( $sFileName, $sReplacement = '_' ) { |
|
65 | 65 | |
66 | 66 | // Remove anything which isn't a word, white space, number |
67 | 67 | // or any of the following characters -_~,;:[](). |
@@ -48,8 +48,8 @@ |
||
48 | 48 | * @since 3.6.3 |
49 | 49 | * @return boolean If the passed value is not null, true; otherwise, false. |
50 | 50 | */ |
51 | - static public function isNotNull( $mValue=null ) { |
|
52 | - return ! is_null( $mValue ); |
|
51 | + static public function isNotNull( $mValue = null ) { |
|
52 | + return !is_null( $mValue ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @since DVVER Moved from `AdminPageFramework_Utility_Array`. |
27 | 27 | */ |
28 | 28 | static public function getFirstElement( array $aArray ) { |
29 | - foreach( $aArray as $_mElement ) { |
|
29 | + foreach ( $aArray as $_mElement ) { |
|
30 | 30 | return $_mElement; |
31 | 31 | } |
32 | 32 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param string|array $asToDefault When the returning value matches oen of the set values here, the value(s) will be discarded and the default value will be applied. |
46 | 46 | * @return mixed The set value or the default value. |
47 | 47 | */ |
48 | - static public function getElement( $aSubject, $aisKey, $mDefault=null, $asToDefault=array( null ) ) { |
|
48 | + static public function getElement( $aSubject, $aisKey, $mDefault = null, $asToDefault = array( null ) ) { |
|
49 | 49 | |
50 | 50 | $_aToDefault = is_null( $asToDefault ) |
51 | 51 | ? array( null ) |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @since DVVER Moved from `AdminPageFramework_Utility_Array`. |
73 | 73 | * @return array The cast retrieved element value. |
74 | 74 | */ |
75 | - static public function getElementAsArray( $aSubject, $aisKey, $mDefault=null, $asToDefault=array( null ) ) { |
|
75 | + static public function getElementAsArray( $aSubject, $aisKey, $mDefault = null, $asToDefault = array( null ) ) { |
|
76 | 76 | return self::getAsArray( |
77 | 77 | self::getElement( $aSubject, $aisKey, $mDefault, $asToDefault ), |
78 | 78 | true // preserve an empty value |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | foreach ( $aParse as $_isKey => $_v ) { |
93 | 93 | |
94 | - if ( ! is_numeric( $_isKey ) ) { |
|
94 | + if ( !is_numeric( $_isKey ) ) { |
|
95 | 95 | unset( $aParse[ $_isKey ] ); |
96 | 96 | continue; |
97 | 97 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | // Convert string numeric value to integer or float. |
100 | 100 | $_isKey = $_isKey + 0; |
101 | 101 | |
102 | - if ( ! is_int( $_isKey ) ) { |
|
102 | + if ( !is_int( $_isKey ) ) { |
|
103 | 103 | unset( $aParse[ $_isKey ] ); |
104 | 104 | } |
105 | 105 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | static public function getNonIntegerKeyElements( array $aParse ) { |
119 | 119 | |
120 | 120 | foreach ( $aParse as $_isKey => $_v ) { |
121 | - if ( is_numeric( $_isKey ) && is_int( $_isKey+ 0 ) ) { |
|
121 | + if ( is_numeric( $_isKey ) && is_int( $_isKey + 0 ) ) { |
|
122 | 122 | unset( $aParse[ $_isKey ] ); |
123 | 123 | } |
124 | 124 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @since DVVER Moved from `AdminPageFramework_Utility_Array`. |
152 | 152 | * @return mixed |
153 | 153 | */ |
154 | - static public function getArrayValueByArrayKeys( $aArray, $aKeys, $vDefault=null ) { |
|
154 | + static public function getArrayValueByArrayKeys( $aArray, $aKeys, $vDefault = null ) { |
|
155 | 155 | |
156 | 156 | $_sKey = array_shift( $aKeys ); |
157 | 157 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @param boolean bPreserveEmpty If `false` is given, a value that yields `false` such as `false`, an empty sttring `''`, or `0` will not create an element such as `array( false )`. It will be just `array()`. |
191 | 191 | * @return array The cast array. |
192 | 192 | */ |
193 | - static public function getAsArray( $mValue, $bPreserveEmpty=false ) { |
|
193 | + static public function getAsArray( $mValue, $bPreserveEmpty = false ) { |
|
194 | 194 | |
195 | 195 | if ( is_array( $mValue ) ) { |
196 | 196 | return $mValue; |
@@ -158,7 +158,8 @@ |
||
158 | 158 | // array_key_exists( $_sKey, $aArray ) caused warnings in some occasions |
159 | 159 | if ( isset( $aArray[ $_sKey ] ) ) { |
160 | 160 | |
161 | - if ( empty( $aKeys ) ) { // no more keys |
|
161 | + if ( empty( $aKeys ) ) { |
|
162 | +// no more keys |
|
162 | 163 | return $aArray[ $_sKey ]; |
163 | 164 | } |
164 | 165 |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | * @return numeric |
26 | 26 | * @since 3.7.4 |
27 | 27 | */ |
28 | - static public function getUnusedNumericIndex( $aArray, $nIndex, $iOffset=1 ) { |
|
28 | + static public function getUnusedNumericIndex( $aArray, $nIndex, $iOffset = 1 ) { |
|
29 | 29 | |
30 | 30 | // Check if the order value is not used. |
31 | - if ( ! isset( $aArray[ $nIndex ] ) ) { |
|
31 | + if ( !isset( $aArray[ $nIndex ] ) ) { |
|
32 | 32 | return $nIndex; |
33 | 33 | } |
34 | 34 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return boolean |
44 | 44 | */ |
45 | 45 | static public function isAssociative( array $aArray ) { |
46 | - return array_keys ( $aArray ) !== range( 0, count( $aArray ) - 1 ); |
|
46 | + return array_keys( $aArray ) !== range( 0, count( $aArray ) - 1 ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | */ |
77 | 77 | static public function getReadableListOfArray( array $aArray ) { |
78 | 78 | |
79 | - $_aOutput = array(); |
|
80 | - foreach( $aArray as $_sKey => $_vValue ) { |
|
81 | - $_aOutput[] = self::getReadableArrayContents( $_sKey, $_vValue, 32 ) . PHP_EOL; |
|
79 | + $_aOutput = array(); |
|
80 | + foreach ( $aArray as $_sKey => $_vValue ) { |
|
81 | + $_aOutput[ ] = self::getReadableArrayContents( $_sKey, $_vValue, 32 ).PHP_EOL; |
|
82 | 82 | } |
83 | 83 | return implode( PHP_EOL, $_aOutput ); |
84 | 84 | |
@@ -89,37 +89,37 @@ discard block |
||
89 | 89 | * @since 3.3.0 |
90 | 90 | * @return string The generated human readable array contents. |
91 | 91 | */ |
92 | - static public function getReadableArrayContents( $sKey, $vValue, $sLabelCharLengths=16, $iOffset=0 ) { |
|
92 | + static public function getReadableArrayContents( $sKey, $vValue, $sLabelCharLengths = 16, $iOffset = 0 ) { |
|
93 | 93 | |
94 | 94 | $_aOutput = array(); |
95 | - $_aOutput[] = ( $iOffset |
|
96 | - ? str_pad( ' ', $iOffset ) |
|
95 | + $_aOutput[ ] = ( $iOffset |
|
96 | + ? str_pad( ' ', $iOffset ) |
|
97 | 97 | : '' |
98 | 98 | ) |
99 | 99 | . ( $sKey |
100 | - ? '[' . $sKey . ']' |
|
100 | + ? '['.$sKey.']' |
|
101 | 101 | : '' |
102 | 102 | ); |
103 | 103 | |
104 | - if ( ! in_array( gettype( $vValue ), array( 'array', 'object' ) ) ) { |
|
105 | - $_aOutput[] = $vValue; |
|
104 | + if ( !in_array( gettype( $vValue ), array( 'array', 'object' ) ) ) { |
|
105 | + $_aOutput[ ] = $vValue; |
|
106 | 106 | return implode( PHP_EOL, $_aOutput ); |
107 | 107 | } |
108 | 108 | |
109 | 109 | foreach ( $vValue as $_sTitle => $_asDescription ) { |
110 | - if ( ! in_array( gettype( $_asDescription ), array( 'array', 'object' ) ) ) { |
|
111 | - $_aOutput[] = str_pad( ' ', $iOffset ) |
|
110 | + if ( !in_array( gettype( $_asDescription ), array( 'array', 'object' ) ) ) { |
|
111 | + $_aOutput[ ] = str_pad( ' ', $iOffset ) |
|
112 | 112 | . $_sTitle |
113 | 113 | . str_pad( ':', $sLabelCharLengths - self::getStringLength( $_sTitle ) ) |
114 | 114 | . $_asDescription; |
115 | 115 | continue; |
116 | 116 | } |
117 | - $_aOutput[] = str_pad( ' ', $iOffset ) |
|
117 | + $_aOutput[ ] = str_pad( ' ', $iOffset ) |
|
118 | 118 | . $_sTitle |
119 | 119 | . ": {" |
120 | 120 | . self::getReadableArrayContents( '', $_asDescription, 16, $iOffset + 4 ) |
121 | 121 | . PHP_EOL |
122 | - . str_pad( ' ', $iOffset ) . "}"; |
|
122 | + . str_pad( ' ', $iOffset )."}"; |
|
123 | 123 | } |
124 | 124 | return implode( PHP_EOL, $_aOutput ); |
125 | 125 | |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | */ |
133 | 133 | static public function getReadableListOfArrayAsHTML( array $aArray ) { |
134 | 134 | |
135 | - $_aOutput = array(); |
|
136 | - foreach( $aArray as $_sKey => $_vValue ) { |
|
137 | - $_aOutput[] = "<ul class='array-contents'>" |
|
135 | + $_aOutput = array(); |
|
136 | + foreach ( $aArray as $_sKey => $_vValue ) { |
|
137 | + $_aOutput[ ] = "<ul class='array-contents'>" |
|
138 | 138 | . self::getReadableArrayContentsHTML( $_sKey, $_vValue ) |
139 | - . "</ul>" . PHP_EOL; |
|
139 | + . "</ul>".PHP_EOL; |
|
140 | 140 | } |
141 | 141 | return implode( PHP_EOL, $_aOutput ); |
142 | 142 | |
@@ -153,25 +153,25 @@ discard block |
||
153 | 153 | $_aOutput = array(); |
154 | 154 | |
155 | 155 | // Title - array key |
156 | - $_aOutput[] = $sKey |
|
157 | - ? "<h3 class='array-key'>" . $sKey . "</h3>" |
|
156 | + $_aOutput[ ] = $sKey |
|
157 | + ? "<h3 class='array-key'>".$sKey."</h3>" |
|
158 | 158 | : ""; |
159 | 159 | |
160 | 160 | // If it does not have a nested array or object, |
161 | - if ( ! in_array( gettype( $vValue ), array( 'array', 'object' ) ) ) { |
|
162 | - $_aOutput[] = "<div class='array-value'>" |
|
161 | + if ( !in_array( gettype( $vValue ), array( 'array', 'object' ) ) ) { |
|
162 | + $_aOutput[ ] = "<div class='array-value'>" |
|
163 | 163 | . html_entity_decode( nl2br( str_replace( ' ', ' ', $vValue ) ), ENT_QUOTES ) |
164 | 164 | . "</div>"; |
165 | - return "<li>" . implode( PHP_EOL, $_aOutput ) . "</li>"; |
|
165 | + return "<li>".implode( PHP_EOL, $_aOutput )."</li>"; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | // Now it is a nested item. |
169 | 169 | foreach ( $vValue as $_sKey => $_vValue ) { |
170 | - $_aOutput[] = "<ul class='array-contents'>" |
|
170 | + $_aOutput[ ] = "<ul class='array-contents'>" |
|
171 | 171 | . self::getReadableArrayContentsHTML( $_sKey, $_vValue ) |
172 | 172 | . "</ul>"; |
173 | 173 | } |
174 | - return implode( PHP_EOL, $_aOutput ) ; |
|
174 | + return implode( PHP_EOL, $_aOutput ); |
|
175 | 175 | |
176 | 176 | } |
177 | 177 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | static public function getReadableListOfArray( array $aArray ) { |
59 | 59 | |
60 | 60 | $_aOutput = array(); |
61 | - foreach( $aArray as $_sKey => $_vValue ) { |
|
61 | + foreach( $aArray as $_sKey => $_vValue ) { |
|
62 | 62 | $_aOutput[] = self::getReadableArrayContents( $_sKey, $_vValue, 32 ) . PHP_EOL; |
63 | 63 | } |
64 | 64 | return implode( PHP_EOL, $_aOutput ); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | static public function getReadableListOfArrayAsHTML( array $aArray ) { |
115 | 115 | |
116 | 116 | $_aOutput = array(); |
117 | - foreach( $aArray as $_sKey => $_vValue ) { |
|
117 | + foreach( $aArray as $_sKey => $_vValue ) { |
|
118 | 118 | $_aOutput[] = "<ul class='array-contents'>" |
119 | 119 | . self::getReadableArrayContentsHTML( $_sKey, $_vValue ) |
120 | 120 | . "</ul>" . PHP_EOL; |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | // Now it is a nested item. |
150 | - foreach ( $vValue as $_sKey => $_vValue ) { |
|
150 | + foreach ( $vValue as $_sKey => $_vValue ) { |
|
151 | 151 | $_aOutput[] = "<ul class='array-contents'>" |
152 | 152 | . self::getReadableArrayContentsHTML( $_sKey, $_vValue ) |
153 | 153 | . "</ul>"; |
@@ -44,11 +44,11 @@ |
||
44 | 44 | */ |
45 | 45 | public function _isInThePage() { |
46 | 46 | |
47 | - if ( ! $this->oProp->bIsAdmin ) { |
|
47 | + if ( !$this->oProp->bIsAdmin ) { |
|
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | |
51 | - if ( ! isset( $_GET[ 'page' ] ) ) { |
|
51 | + if ( !isset( $_GET[ 'page' ] ) ) { |
|
52 | 52 | return false; |
53 | 53 | } |
54 | 54 |
@@ -170,7 +170,7 @@ |
||
170 | 170 | * @since 3.5.3 |
171 | 171 | * @return string The found page slug. An empty string if not found. |
172 | 172 | * @remark Do not return `null` when not found as some framework methods check the retuened value with `isset()` and if null is given, `isset()` yields `false` while it does `true` for an emtpy string (''). |
173 | - */ |
|
173 | + */ |
|
174 | 174 | public function getCurrentPageSlug() { |
175 | 175 | return isset( $_GET[ 'page' ] ) |
176 | 176 | ? $_GET[ 'page' ] |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | /** |
58 | 58 | * Sets up hooks and properties. |
59 | 59 | */ |
60 | - public function __construct( $oCaller, $sClassName, $sCapability='manage_options', $sTextDomain='admin-page-framework', $sStructureType='page_meta_box' ) { |
|
60 | + public function __construct( $oCaller, $sClassName, $sCapability = 'manage_options', $sTextDomain = 'admin-page-framework', $sStructureType = 'page_meta_box' ) { |
|
61 | 61 | |
62 | 62 | // Let them overload. |
63 | 63 | unset( |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | public function _getScreenIDOfPage( $sPageSlug ) { |
107 | 107 | $_oAdminPage = $this->_getOwnerObjectOfPage( $sPageSlug ); |
108 | 108 | return $_oAdminPage |
109 | - ? $_oAdminPage->oProp->aPages[ $sPageSlug ][ '_page_hook' ] . ( is_network_admin() ? '-network' : '' ) |
|
109 | + ? $_oAdminPage->oProp->aPages[ $sPageSlug ][ '_page_hook' ].( is_network_admin() ? '-network' : '' ) |
|
110 | 110 | : ''; |
111 | 111 | } |
112 | 112 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @since 3.0.0 |
117 | 117 | * @return boolean Returns true if it is of framework's added page; otherwise, false. |
118 | 118 | */ |
119 | - public function isPageAdded( $sPageSlug='' ) { |
|
119 | + public function isPageAdded( $sPageSlug = '' ) { |
|
120 | 120 | $_oAdminPage = $this->_getOwnerObjectOfPage( $sPageSlug ); |
121 | 121 | return $_oAdminPage |
122 | 122 | ? $_oAdminPage->oProp->isPageAdded( $sPageSlug ) |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | public function isCurrentTab( $sTabSlug ) { |
134 | 134 | |
135 | 135 | $_sCurrentPageSlug = $this->getElement( $_GET, 'page' ); |
136 | - if ( ! $_sCurrentPageSlug ) { |
|
136 | + if ( !$_sCurrentPageSlug ) { |
|
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | $_sCurrentTabSlug = $this->getElement( |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function getDefaultInPageTab( $sPageSlug ) { |
188 | 188 | |
189 | - if ( ! $sPageSlug ) { |
|
189 | + if ( !$sPageSlug ) { |
|
190 | 190 | return ''; |
191 | 191 | } |
192 | 192 | return ( $_oAdminPage = $this->_getOwnerObjectOfPage( $sPageSlug ) ) |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function getOptionKey( $sPageSlug ) { |
203 | 203 | |
204 | - if ( ! $sPageSlug ) { |
|
204 | + if ( !$sPageSlug ) { |
|
205 | 205 | return ''; |
206 | 206 | } |
207 | 207 | return ( $_oAdminPage = $this->_getOwnerObjectOfPage( $sPageSlug ) ) |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $GLOBALS, |
229 | 229 | array( 'aAdminPageFramework', 'aPageClasses' ) |
230 | 230 | ); |
231 | - foreach( $_aPageClasses as $_oAdminPage ) { |
|
231 | + foreach ( $_aPageClasses as $_oAdminPage ) { |
|
232 | 232 | if ( $_oAdminPage->oProp->isPageAdded( $sPageSlug ) ) { |
233 | 233 | return $_oAdminPage; |
234 | 234 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | /** |
58 | 58 | * Sets up hooks and properties. |
59 | 59 | */ |
60 | - public function __construct( $oCaller, $sClassName, $sCapability='manage_options', $sTextDomain='admin-page-framework', $sStructureType='page_meta_box' ) { |
|
60 | + public function __construct( $oCaller, $sClassName, $sCapability='manage_options', $sTextDomain='admin-page-framework', $sStructureType='page_meta_box' ) { |
|
61 | 61 | |
62 | 62 | // Let them overload. |
63 | 63 | unset( |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @since 3.0.0 |
117 | 117 | * @return boolean Returns true if it is of framework's added page; otherwise, false. |
118 | 118 | */ |
119 | - public function isPageAdded( $sPageSlug='' ) { |
|
119 | + public function isPageAdded( $sPageSlug='' ) { |
|
120 | 120 | $_oAdminPage = $this->_getOwnerObjectOfPage( $sPageSlug ); |
121 | 121 | return $_oAdminPage |
122 | 122 | ? $_oAdminPage->oProp->isPageAdded( $sPageSlug ) |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | public function isCurrentTab( $sTabSlug ) { |
134 | 134 | |
135 | 135 | $_sCurrentPageSlug = $this->getElement( $_GET, 'page' ); |
136 | - if ( ! $_sCurrentPageSlug ) { |
|
136 | + if ( ! $_sCurrentPageSlug ) { |
|
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | $_sCurrentTabSlug = $this->getElement( |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function getDefaultInPageTab( $sPageSlug ) { |
188 | 188 | |
189 | - if ( ! $sPageSlug ) { |
|
189 | + if ( ! $sPageSlug ) { |
|
190 | 190 | return ''; |
191 | 191 | } |
192 | 192 | return ( $_oAdminPage = $this->_getOwnerObjectOfPage( $sPageSlug ) ) |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function getOptionKey( $sPageSlug ) { |
203 | 203 | |
204 | - if ( ! $sPageSlug ) { |
|
204 | + if ( ! $sPageSlug ) { |
|
205 | 205 | return ''; |
206 | 206 | } |
207 | 207 | return ( $_oAdminPage = $this->_getOwnerObjectOfPage( $sPageSlug ) ) |