com php-src: Shorten syntax to strict_types=1: Zend/t ests/typehints/scalar_strict_basic.phpt Zend/zend_com pile.c Zend/zend_globals.h

From: Date: Tue, 10 Feb 2015 15:48:07 +0000
Subject: com php-src: Shorten syntax to strict_types=1: Zend/t ests/typehints/scalar_strict_basic.phpt Zend/zend_com pile.c Zend/zend_globals.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-85725@lists.php.net to get a copy of this message
Commit: e1a238670c940ea6c017de0cada52e76528db64b Author: Andrea Faulds <ajf@ajf.me> Sun, 25 Jan 2015 01:40:54 +0000 Parents: ca4901254b4428bb1715a740951f5df73d43b9f8 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e1a238670c940ea6c017de0cada52e76528db64b Log: Shorten syntax to strict_types=1 Changed paths: M Zend/tests/typehints/scalar_strict_basic.phpt M Zend/zend_compile.c M Zend/zend_globals.h Diff: diff --git a/Zend/tests/typehints/scalar_strict_basic.phpt b/Zend/tests/typehints/scalar_strict_basic.phpt index ab7a54a..b52fa70 100644 --- a/Zend/tests/typehints/scalar_strict_basic.phpt +++ b/Zend/tests/typehints/scalar_strict_basic..phpt @@ -3,7 +3,7 @@ Strict scalar type hint basics --FILE-- <?php -declare(strict_typehints = TRUE); +declare(strict_types=1); $errnames = [ E_NOTICE => 'E_NOTICE', diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 1b75036..1d5466b 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -142,7 +142,7 @@ static zend_bool zend_get_unqualified_name(const zend_string *name, const char * static void init_compiler_declarables(void) /* {{{ */ { ZVAL_LONG(&CG(declarables).ticks, 0); - CG(declarables).strict_typehints = 0; + CG(declarables).strict_types = 0; } /* }}} */ @@ -1532,7 +1532,7 @@ void zend_do_end_compilation(void) /* {{{ */ CG(has_bracketed_namespaces) = 0; zend_end_namespace(); /* strict typehinting is per-file */ - CG(declarables).strict_typehints = 0; + CG(declarables).strict_types = 0; } /* }}} */ @@ -2552,7 +2552,7 @@ void zend_compile_call_common(znode *result, zend_ast *args_ast, zend_function * } call_flags = ((opline->opcode == ZEND_NEW) ? ZEND_CALL_CTOR : 0) - | (CG(declarables).strict_typehints ? ZEND_CALL_STRICT_TYPEHINTS : 0); + | (CG(declarables).strict_types ? ZEND_CALL_STRICT_TYPEHINTS : 0); opline = zend_emit_op(result, ZEND_DO_FCALL, NULL, NULL); opline->op1.num = call_flags; @@ -3791,15 +3791,15 @@ void zend_compile_declare(zend_ast *ast) /* {{{ */ zend_error_noreturn(E_COMPILE_ERROR, "Encoding declaration pragma must be " "the very first statement in the script"); } - } else if (zend_string_equals_literal_ci(name, "strict_typehints")) { + } else if (zend_string_equals_literal_ci(name, "strict_types")) { zval value_zv; zend_const_expr_to_zval(&value_zv, value_ast); - if (Z_TYPE(value_zv) != IS_FALSE && Z_TYPE(value_zv) != IS_TRUE) { - zend_error_noreturn(E_COMPILE_ERROR, "strict_typehints declaration must have a boolean value"); + if (Z_TYPE(value_zv) != IS_LONG || (Z_LVAL(value_zv) != 0 && Z_LVAL(value_zv) != 1)) { + zend_error_noreturn(E_COMPILE_ERROR, "strict_types declaration must have 0 or 1 as its value"); } - CG(declarables).strict_typehints = (Z_TYPE(value_zv) == IS_TRUE) ? 1 : 0; + CG(declarables).strict_types = Z_LVAL(value_zv); } else { zend_error(E_COMPILE_WARNING, "Unsupported declare '%s'", name->val); } diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index 7295eae..630d0f4 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -64,7 +64,7 @@ END_EXTERN_C() typedef struct _zend_declarables { zval ticks; - zend_bool strict_typehints; + zend_bool strict_types; } zend_declarables; typedef struct _zend_vm_stack *zend_vm_stack;

« previous php.cvs (#85725) next »