Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- Bug #79839: array_walk() does not respect property types --FILE-- <?php class Te..

Decoded Output download

--TEST--
Bug #79839: array_walk() does not respect property types
--FILE--
<?php

class Test {
    public int $prop = 42;
}

$test = new Test;
try {
    array_walk($test, function(&$ref) {
        $ref = []; // Should throw
    });
} catch (TypeError $e) {
    echo $e->getMessage(), "
";
}
var_dump($test);

?>
--EXPECT--
Cannot assign array to reference held by property Test::$prop of type int
object(Test)#1 (1) {
  ["prop"]=>
  int(42)
}

Did this file decode correctly?

Original Code

--TEST--
Bug #79839: array_walk() does not respect property types
--FILE--
<?php

class Test {
    public int $prop = 42;
}

$test = new Test;
try {
    array_walk($test, function(&$ref) {
        $ref = []; // Should throw
    });
} catch (TypeError $e) {
    echo $e->getMessage(), "\n";
}
var_dump($test);

?>
--EXPECT--
Cannot assign array to reference held by property Test::$prop of type int
object(Test)#1 (1) {
  ["prop"]=>
  int(42)
}

Function Calls

None

Variables

None

Stats

MD5 90c0d09370115cf60bfd14b7c6f3008a
Eval Count 0
Decode Time 75 ms