diff --git a/Zend/tests/instanceof_003.phpt b/Zend/tests/instanceof_003.phpt new file mode 100644 index 0000000000000..afc9b43c9f7e4 --- /dev/null +++ b/Zend/tests/instanceof_003.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing instanceof operator with expression +--FILE-- + +--EXPECTF-- +bool(true) +bool(false) +Done diff --git a/Zend/tests/new_001.phpt b/Zend/tests/new_001.phpt new file mode 100644 index 0000000000000..c2df6c4755acd --- /dev/null +++ b/Zend/tests/new_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +Create a class instance with a string +--FILE-- + +--EXPECTF-- +bool(true) +Foo +Done diff --git a/Zend/tests/new_002.phpt b/Zend/tests/new_002.phpt new file mode 100644 index 0000000000000..e282c7fcc7a09 --- /dev/null +++ b/Zend/tests/new_002.phpt @@ -0,0 +1,21 @@ +--TEST-- +Create a class instance from a variable +--FILE-- + +--EXPECTF-- +bool(true) +Foo +Done diff --git a/Zend/tests/new_003.phpt b/Zend/tests/new_003.phpt new file mode 100644 index 0000000000000..dbc050ebffb92 --- /dev/null +++ b/Zend/tests/new_003.phpt @@ -0,0 +1,21 @@ +--TEST-- +Create a class instance from an expression +--FILE-- + +--EXPECTF-- +bool(true) +Foo +Done diff --git a/Zend/tests/new_004.phpt b/Zend/tests/new_004.phpt new file mode 100644 index 0000000000000..4331898a61cbd --- /dev/null +++ b/Zend/tests/new_004.phpt @@ -0,0 +1,36 @@ +--TEST-- +Create a class instance from an expression which is a string +--FILE-- +arg1 = $arg1; + $this->arg2 = $arg2; + } + + public function getArg1() { return $this->arg1; } + public function getArg2() { return $this->arg2; } +} + +$oo = 'oo'; + +$foo = new {'f' . $oo}('this is arg1', 'this is arg2'); + +var_dump(is_object($foo)); +echo get_class($foo) . PHP_EOL; +var_dump($foo->getArg1()); +var_dump($foo->getArg2()); + +echo 'Done' . PHP_EOL; +?> +--EXPECTF-- +bool(true) +Foo +string(12) "this is arg1" +string(12) "this is arg2" +Done diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 893e0133efe0f..fc8f22867797f 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -869,6 +869,7 @@ fully_qualified_class_name: class_name_reference: class_name { zend_do_fetch_class(&$$, &$1 TSRMLS_CC); } | dynamic_class_name_reference { zend_do_end_variable_parse(&$1, BP_VAR_R, 0 TSRMLS_CC); zend_do_fetch_class(&$$, &$1 TSRMLS_CC); } + | '{' expr '}' { zend_do_fetch_class(&$$, &$2 TSRMLS_CC); } ;