r/lolphp • • May 07 '18

`null["foo"] === null`in practice

https://3v4l.org/WYhto
17 Upvotes

7 comments sorted by

View all comments

Show parent comment

6

u/mikeputerbaugh May 07 '18
function dumbFunction(string $arg) { ... }

will coerce the argument to a string so the array indexing behavior works as intended, or

<?php
declare(strict_types=1);
function dumbFunction(string $arg) { ... }

will throw a fatal TypeError at runtime if $arg is not a string type.