|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-10-13 08:40 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2020-10-13 08:40 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 16:00:01 2025 UTC |
Description: ------------ Strict types seem to throw compile-time fatal error on retrieving data, if you pass integer in quotes. It defines string as integer. I guess, it's working like this: <?php $string = '12345'; $arr = [$string => 1]; var_dump(array_keys($arr)); which returns: array(1) { [0] => int(12345) } Bug was discovered after clear php install, no ini files was edited. Test script: --------------- <?php declare(strict_types=1); class Test { private $storage = []; public function setData(string $key, int $value): void { $this->storage[$key] = $value; } public function getAllData(): array { return array_keys($this->storage); } } $test = new Test; $test->setData('key', 1); $test->setData('123', 2); foreach ($test->getAllData() as $data) { echo gettype($data) . "\n"; } Expected result: ---------------- string string Actual result: -------------- string integer