Skip to content

Commit dc772d8

Browse files
authored
fix: prevent php warning in looks_like_json function
If $thing only contains a space it will generate a php warning when doing ltrim( $thing )[0]. This fixes the issue while still being compatible with php 5.4+.
1 parent 20dc1ec commit dc772d8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

php/class-utils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ public static function pathinfo( $path, $flags = 15 ) {
543543
* @return bool
544544
*/
545545
public static function looks_like_json( $thing ) {
546-
return ! empty( $thing ) && is_string( $thing ) && in_array( ltrim( $thing )[0], array( '{', '[' ), true );
546+
return is_string( $thing ) && ! empty( ltrim( $thing ) ) && in_array( $thing[0], array( '{', '[' ), true );
547547
}
548548

549549
/**

0 commit comments

Comments
 (0)