-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #5560, Allow the keys of a map to be boolean, resource, or floa…
…t types. When the key is of string type, determine whether it represents a number.
- Loading branch information
Showing
4 changed files
with
100 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--TEST-- | ||
swoole_thread: numeric key | ||
--SKIPIF-- | ||
<?php | ||
require __DIR__ . '/../include/skipif.inc'; | ||
skip_if_nts(); | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
use Swoole\Thread\Map; | ||
|
||
require __DIR__ . '/../include/bootstrap.php'; | ||
$uuid = uniqid(); | ||
|
||
const I_KEY = 6666; | ||
const S_KEY = '6666'; | ||
|
||
$arr = new Map([S_KEY => 2222, 'test' => $uuid]); | ||
Assert::eq($arr[S_KEY], 2222); | ||
Assert::eq($arr[6666], 2222); | ||
Assert::eq($arr['test'], $uuid); | ||
|
||
unset($arr[S_KEY]); | ||
Assert::false(isset($arr[S_KEY])); | ||
Assert::keyNotExists($arr->toArray(), I_KEY); | ||
|
||
$uuid2 = uniqid(); | ||
$arr[6666.66] = $uuid2; | ||
$arr['6666.66'] = $uuid2; | ||
Assert::eq($arr[6666], $uuid2); | ||
|
||
$arr[true] = $uuid2; | ||
$arr[false] = $uuid2; | ||
$arr[null] = $uuid2; | ||
|
||
$stream = fopen('php://stdin', 'r+'); | ||
@$arr[$stream] = $uuid2; | ||
|
||
Assert::eq($arr[true], $uuid2); | ||
Assert::eq($arr[false], $uuid2); | ||
Assert::eq($arr[null], $uuid2); | ||
Assert::eq(@$arr[$stream], $uuid2); | ||
|
||
?> | ||
--EXPECTF-- |