php-src/Zend/tests/class_name_as_scalar_error_002.phpt
Nikita Popov a9e6667817 Detect invalid uses of parent:: during compilation
We already detect the case where we're entirely outside a class --
now also check whether there actually is a parent.

This is a minor BC break, in that code that was never executed
might have previously contained an invalid parent:: reference without
generating an error.
2019-01-04 11:55:41 +01:00

15 lines
311 B
PHP

--TEST--
class name as scalar from ::class keyword error using parent in class constant
--FILE--
<?php
namespace Foo\Bar {
class One {
const Baz = parent::class;
}
var_dump(One::Baz);
}
?>
--EXPECTF--
Fatal error: Cannot use "parent" when current class scope has no parent in %s on line %d