mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-26 20:04:48 +01:00
Error on final or abstract properties
This commit is contained in:
parent
0f69f12b94
commit
e26e63e9b0
@ -3,6 +3,7 @@
|
|||||||
namespace PhpParser\Node\Stmt;
|
namespace PhpParser\Node\Stmt;
|
||||||
|
|
||||||
use PhpParser\Node;
|
use PhpParser\Node;
|
||||||
|
use PhpParser\Error;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $type Modifiers
|
* @property int $type Modifiers
|
||||||
@ -23,6 +24,14 @@ class Property extends Node\Stmt
|
|||||||
$type |= Class_::MODIFIER_PUBLIC;
|
$type |= Class_::MODIFIER_PUBLIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($type & Class_::MODIFIER_ABSTRACT) {
|
||||||
|
throw new Error('Properties cannot be declared abstract');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type & Class_::MODIFIER_FINAL) {
|
||||||
|
throw new Error('Properties cannot be declared final');
|
||||||
|
}
|
||||||
|
|
||||||
parent::__construct(
|
parent::__construct(
|
||||||
array(
|
array(
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
|
@ -27,3 +27,11 @@ Cannot use the final modifier on an abstract class member on line 1
|
|||||||
<?php abstract final class A { }
|
<?php abstract final class A { }
|
||||||
-----
|
-----
|
||||||
Syntax error, unexpected T_FINAL, expecting T_CLASS on line 1
|
Syntax error, unexpected T_FINAL, expecting T_CLASS on line 1
|
||||||
|
-----
|
||||||
|
<?php class A { abstract $a; }
|
||||||
|
-----
|
||||||
|
Properties cannot be declared abstract on line 1
|
||||||
|
-----
|
||||||
|
<?php class A { final $a; }
|
||||||
|
-----
|
||||||
|
Properties cannot be declared final on line 1
|
||||||
|
Loading…
Reference in New Issue
Block a user