-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Bug #81160: isset/empty doesn't throw a TypeError on invalid stri…
…ng offset
- Loading branch information
Showing
12 changed files
with
372 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--TEST-- | ||
Bug #81160: isset/empty doesn't throw a TypeError on invalid string offset | ||
--FILE-- | ||
<?php | ||
|
||
$s = 'Hello'; | ||
$o = new stdClass(); | ||
$a = []; | ||
|
||
try { | ||
var_dump(isset($s[$o])); | ||
} catch (\Throwable $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
try { | ||
var_dump(empty($s[$o])); | ||
} catch (\Throwable $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
try { | ||
var_dump($s[$o] ?? 'default'); | ||
} catch (\Throwable $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
try { | ||
var_dump(isset($s[$a])); | ||
} catch (\Throwable $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
try { | ||
var_dump(empty($s[$a])); | ||
} catch (\Throwable $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
try { | ||
var_dump($s[$a] ?? 'default'); | ||
} catch (\Throwable $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
try { | ||
var_dump(isset($s[[]])); | ||
} catch (\Throwable $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
try { | ||
var_dump(empty($s[[]])); | ||
} catch (\Throwable $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
try { | ||
var_dump($s[[]] ?? 'default'); | ||
} catch (\Throwable $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
|
||
?> | ||
--EXPECT-- | ||
Cannot access offset of type stdClass on string | ||
Cannot access offset of type stdClass on string | ||
Cannot access offset of type stdClass on string | ||
Cannot access offset of type array on string | ||
Cannot access offset of type array on string | ||
Cannot access offset of type array on string | ||
Cannot access offset of type array on string | ||
Cannot access offset of type array on string | ||
Cannot access offset of type array on string |
Oops, something went wrong.