com php-src: fix mixing typed and untyped properties, add another test for that: Zend/tests/type_declarations/typed_properties_0 18.phpt
Zend/tests/type_declarations/typed_properti es_025.phpt Zend/zend_compile.c

From: Date: Thu, 10 Mar 2016 08:04:18 +0000
Subject: com php-src: fix mixing typed and untyped properties, add another test for that: Zend/tests/type_declarations/typed_properties_0 18.phpt
Zend/tests/type_declarations/typed_properti es_025.phpt Zend/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-95691@lists.php.net to get a copy of this message
Commit: 9a8fb9ee00b85f3ed160798f36998b5c5b629a39 Author: Joe Watkins <krakjoe@php.net> Thu, 10 Mar 2016 08:04:18 +0000 Parents: 86ea6ed1e5931b227a931828cafc7fbcc81dba6b Branches: typed_ref_properties Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9a8fb9ee00b85f3ed160798f36998b5c5b629a39 Log: fix mixing typed and untyped properties, add another test for that Changed paths: M Zend/tests/type_declarations/typed_properties_018.phpt A Zend/tests/type_declarations/typed_properties_025.phpt M Zend/zend_compile.c Diff: diff --git a/Zend/tests/type_declarations/typed_properties_018.phpt b/Zend/tests/type_declarations/typed_properties_018.phpt index c702458..f605255 100644 --- a/Zend/tests/type_declarations/typed_properties_018.phpt +++ b/Zend/tests/type_declarations/typed_properties_018.phpt @@ -8,7 +8,7 @@ class Foo { } ?> --EXPECTF-- -Fatal error: Property Foo::$qux is missing type information in %s on line 3 +Fatal error: Untyped property Foo::$qux must not be mixed with typed properties in %s on line 3 diff --git a/Zend/tests/type_declarations/typed_properties_025.phpt b/Zend/tests/type_declarations/typed_properties_025.phpt new file mode 100644 index 0000000..7979a33 --- /dev/null +++ b/Zend/tests/type_declarations/typed_properties_025.phpt @@ -0,0 +1,16 @@ +--TEST-- +Test typed properties disallow mixing typed and untyped declarations +--FILE-- +<?php +class Foo { + public $bar, + int $qux; +} +?> +--EXPECTF-- +Fatal error: Typed property Foo::$qux must not be mixed with untyped properties in %s on line 3 + + + + + diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index f212097..e87c212 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5334,6 +5334,13 @@ void zend_compile_prop_decl(zend_ast *ast) /* {{{ */ ZSTR_VAL(name)); } + if (!use_optional_types && i > 0) { + zend_error_noreturn(E_COMPILE_ERROR, + "Typed property %s::$%s must not be mixed with untyped properties", + ZSTR_VAL(ce->name), + ZSTR_VAL(name)); + } + use_optional_types = 1; if (type_ast->kind == ZEND_AST_TYPE) { optional_type = type_ast->attr; @@ -5373,7 +5380,7 @@ void zend_compile_prop_decl(zend_ast *ast) /* {{{ */ } } else if (use_optional_types) { zend_error_noreturn(E_COMPILE_ERROR, - "Property %s::$%s is missing type information", + "Untyped property %s::$%s must not be mixed with typed properties", ZSTR_VAL(ce->name), ZSTR_VAL(name)); }

« previous php.cvs (#95691) next »