mirror of
https://github.com/php/php-src.git
synced 2026-03-24 16:22:37 +01:00
Curly brace syntax for accessing array elements and string offsets is deprecated [1]; this should also be the case for respective `new` expressions. This issue has been reported by brzuchal@php.net. [1] <https://wiki.php.net/rfc/deprecate_curly_braces_array_access>
41 lines
840 B
PHP
41 lines
840 B
PHP
--TEST--
|
|
Variable as class name for new expression
|
|
--FILE--
|
|
<?php
|
|
|
|
$className = 'stdClass';
|
|
$array = ['className' => 'stdClass'];
|
|
$obj = (object) ['className' => 'stdClass'];
|
|
|
|
class Test {
|
|
public static $className = 'stdClass';
|
|
}
|
|
$test = 'Test';
|
|
$weird = [0 => (object) ['foo' => 'Test']];
|
|
|
|
var_dump(new $className);
|
|
var_dump(new $array['className']);
|
|
var_dump(new $array{'className'});
|
|
var_dump(new $obj->className);
|
|
var_dump(new Test::$className);
|
|
var_dump(new $test::$className);
|
|
var_dump(new $weird[0]->foo::$className);
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Deprecated: Array and string offset access syntax with curly braces is deprecated in %s on line %d
|
|
object(stdClass)#%d (0) {
|
|
}
|
|
object(stdClass)#%d (0) {
|
|
}
|
|
object(stdClass)#%d (0) {
|
|
}
|
|
object(stdClass)#%d (0) {
|
|
}
|
|
object(stdClass)#%d (0) {
|
|
}
|
|
object(stdClass)#%d (0) {
|
|
}
|
|
object(stdClass)#%d (0) {
|
|
}
|