com php-src: Forbid namespace\int type hint as well: Zend/tests/typehints/fully_qualified_scalar.phpt Zend/t
ests/typehints/namespace_relative_scalar.phpt Zend/zend _compile.c
| From: | Nikita Popov | Date: | Thu, 26 Nov 2015 15:56:08 +0000 |
| Subject: | com php-src: Forbid namespace\int type hint as well: Zend/tests/typehints/fully_qualified_scalar.phpt Zend/t ests/typehints/namespace_relative_scalar.phpt Zend/zend _compile.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-90042@lists.php.net to get a copy of this message | ||
Commit: 99dd7ee80ba6865dfbf742935f9aadab1d65801c
Author: Nikita Popov <nikic@php.net> Thu, 26 Nov 2015 16:56:08 +0100
Parents: 0e91e5fb909591a8d57587eeb19314e4a4ee01d9
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=99dd7ee80ba6865dfbf742935f9aadab1d65801c
Log:
Forbid namespace\int type hint as well
Changed paths:
M Zend/tests/typehints/fully_qualified_scalar..phpt
A Zend/tests/typehints/namespace_relative_scalar.phpt
M Zend/zend_compile.c
Diff:
diff --git a/Zend/tests/typehints/fully_qualified_scalar.phpt
b/Zend/tests/typehints/fully_qualified_scalar.phpt
index fcc4360..d780b44 100644
--- a/Zend/tests/typehints/fully_qualified_scalar.phpt
+++ b/Zend/tests/typehints/fully_qualified_scalar.phpt
@@ -10,4 +10,4 @@ foo(1);
?>
--EXPECTF--
-Fatal error: Cannot use the scalar type 'int' as fully qualified with a leading backslash
in %s on line %d
+Fatal error: Scalar type declaration 'int' must be unqualified in %s on line %d
diff --git a/Zend/tests/typehints/namespace_relative_scalar.phpt
b/Zend/tests/typehints/namespace_relative_scalar.phpt
new file mode 100644
index 0000000..1bc9178
--- /dev/null
+++ b/Zend/tests/typehints/namespace_relative_scalar.phpt
@@ -0,0 +1,11 @@
+--TEST--
+namespace\int is not a valid type hint
+--FILE--
+<?php
+
+function test(namespace\int $i) {}
+test(0);
+
+?>
+--EXPECTF--
+Fatal error: Scalar type declaration 'int' must be unqualified in %s on line %d
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 9805df0..0e633b7 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4383,8 +4383,10 @@ static void zend_compile_typename(zend_ast *ast, zend_arg_info *arg_info) /*
{{{
zend_uchar type = zend_lookup_builtin_type_by_name(class_name);
if (type != 0) {
- if (ast->attr == ZEND_NAME_FQ) {
- zend_error_noreturn(E_COMPILE_ERROR, "Cannot use the scalar type '%s' as fully
qualified with a leading backslash", ZSTR_VAL(zend_string_tolower(class_name)));
+ if (ast->attr != ZEND_NAME_NOT_FQ) {
+ zend_error_noreturn(E_COMPILE_ERROR,
+ "Scalar type declaration '%s' must be unqualified",
+ ZSTR_VAL(zend_string_tolower(class_name)));
}
arg_info->type_hint = type;
} else {