From e26e63e9b011d23890a0986e209cf3dc95e0647a Mon Sep 17 00:00:00 2001 From: nikic Date: Thu, 13 Nov 2014 20:25:52 +0100 Subject: [PATCH] Error on final or abstract properties --- lib/PhpParser/Node/Stmt/Property.php | 9 +++++++++ test/code/parser/stmt/class/modifier.test-fail | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/PhpParser/Node/Stmt/Property.php b/lib/PhpParser/Node/Stmt/Property.php index d886d50..7ed034b 100644 --- a/lib/PhpParser/Node/Stmt/Property.php +++ b/lib/PhpParser/Node/Stmt/Property.php @@ -3,6 +3,7 @@ namespace PhpParser\Node\Stmt; use PhpParser\Node; +use PhpParser\Error; /** * @property int $type Modifiers @@ -23,6 +24,14 @@ class Property extends Node\Stmt $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( array( 'type' => $type, diff --git a/test/code/parser/stmt/class/modifier.test-fail b/test/code/parser/stmt/class/modifier.test-fail index 7272b4c..fbe4e26 100644 --- a/test/code/parser/stmt/class/modifier.test-fail +++ b/test/code/parser/stmt/class/modifier.test-fail @@ -27,3 +27,11 @@ Cannot use the final modifier on an abstract class member on line 1