11 changed files with 98 additions and 35 deletions
-
10Zend/zend_compile.c
-
4Zend/zend_constants.c
-
6Zend/zend_inheritance.c
-
2Zend/zend_language_parser.y
-
1ext/opcache/Optimizer/pass1_5.c
-
12ext/opcache/zend_persist.c
-
33ext/reflection/php_reflection.c
-
34tests/classes/constants_comments_001.phpt
-
10tests/classes/constants_visibility_005.phpt
-
11tests/classes/constants_visibility_006.phpt
-
10tests/classes/constants_visibility_007.phpt
@ -0,0 +1,34 @@ |
|||
--TEST-- |
|||
Class constants and doc comments |
|||
--INI-- |
|||
opcache.save_comments=1 |
|||
--FILE-- |
|||
<?php |
|||
class X { |
|||
/** comment X1 */ |
|||
const X1 = 1; |
|||
const X2 = 2; |
|||
/** comment X3 */ |
|||
const X3 = 3; |
|||
} |
|||
class Y extends X { |
|||
/** comment Y1 */ |
|||
const Y1 = 1; |
|||
const Y2 = 2; |
|||
/** comment Y3 */ |
|||
const Y3 = 3; |
|||
} |
|||
$r = new ReflectionClass('Y'); |
|||
foreach ($r->getReflectionConstants() as $rc) { |
|||
echo $rc->getName() . " : " . $rc->getDocComment() . "\n"; |
|||
} |
|||
|
|||
|
|||
?> |
|||
--EXPECT-- |
|||
Y1 : /** comment Y1 */ |
|||
Y2 : |
|||
Y3 : /** comment Y3 */ |
|||
X1 : /** comment X1 */ |
|||
X2 : |
|||
X3 : /** comment X3 */ |
|||
@ -0,0 +1,10 @@ |
|||
--TEST-- |
|||
Static constants are not allowed |
|||
--FILE-- |
|||
<?php |
|||
class A { |
|||
static const X = 1; |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
Fatal error: Cannot use 'static' as constant modifier in %s on line 3 |
|||
@ -0,0 +1,11 @@ |
|||
--TEST-- |
|||
Abstract constants are not allowed |
|||
--FILE-- |
|||
<?php |
|||
class A { |
|||
abstract const X = 1; |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
Fatal error: Cannot use 'abstract' as constant modifier in %s on line 3 |
|||
|
|||
@ -0,0 +1,10 @@ |
|||
--TEST-- |
|||
Final constants are not allowed |
|||
--FILE-- |
|||
<?php |
|||
class A { |
|||
final const X = 1; |
|||
} |
|||
?> |
|||
--EXPECTF-- |
|||
Fatal error: Cannot use 'final' as constant modifier in %s on line 3 |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue