com php-src: Fix scalar type names with leading backslash: NEWS Zend/tests/typehints/fully_qualified_scalar.phpt Zend/z end_compile.c

From: Date: Tue, 24 Nov 2015 20:39:06 +0000
Subject: com php-src: Fix scalar type names with leading backslash: NEWS Zend/tests/typehints/fully_qualified_scalar.phpt Zend/z end_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89993@lists.php.net to get a copy of this message
Commit: 569763cb1ac67f56e7743062ca8b3b7c650c1254 Author: Bob Weinand <bobwei9@hotmail.com> Tue, 24 Nov 2015 21:39:06 +0100 Parents: d978e92d3d92d1544f8ec1dd0e8b57b837204b16 Branches: PHP-7.0 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=569763cb1ac67f56e7743062ca8b3b7c650c1254 Log: Fix scalar type names with leading backslash Changed paths: M NEWS A Zend/tests/typehints/fully_qualified_scalar.phpt M Zend/zend_compile.c Diff: diff --git a/NEWS b/NEWS index c774f0e..9428300 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,8 @@ PHP NEWS . Fixed bug #70899 (buildconf failure in extensions). (Bob, Reeze) . Fixed bug #61751 (SAPI build problem on AIX: Undefined symbol: php_register_internal_extensions). (Lior Kaplan) + . Fixed \int (or generally every scalar type name with leading backslash) + to not be accepted as type name. (Bob) - Mysqlnd: . Fixed bug #68077 (LOAD DATA LOCAL INFILE / open_basedir restriction). diff --git a/Zend/tests/typehints/fully_qualified_scalar.phpt b/Zend/tests/typehints/fully_qualified_scalar.phpt new file mode 100644 index 0000000..fcc4360 --- /dev/null +++ b/Zend/tests/typehints/fully_qualified_scalar.phpt @@ -0,0 +1,13 @@ +--TEST-- +Fully qualified (leading backslash) type names must fail +--FILE-- +<?php + +function foo(\int $foo) { + var_dump($foo); +} +foo(1); + +?> +--EXPECTF-- +Fatal error: Cannot use the scalar type 'int' as fully qualified with a leading backslash in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile..c index b91fdde..201afd0 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4383,6 +4383,9 @@ 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(class_name)); + } arg_info->type_hint = type; } else { uint32_t fetch_type = zend_get_class_fetch_type_ast(ast);

« previous php.cvs (#89993) next »