diff options
author | Andrea Faulds <ajf@ajf.me> | 2014-12-13 03:35:51 +0000 |
---|---|---|
committer | Andrea Faulds <ajf@ajf.me> | 2015-02-10 15:48:04 +0000 |
commit | c3c0f531a2c1436a8061f393ab0f328f63bbb203 (patch) | |
tree | 34eee1248f289357615b3e746687f96f0e6ff441 | |
parent | 400e65e955f08ad6ae57c1a15be04d5852107252 (diff) | |
download | php-git-c3c0f531a2c1436a8061f393ab0f328f63bbb203.tar.gz |
Scalar type hints with ZPP casting rules
21 files changed, 578 insertions, 123 deletions
diff --git a/Zend/tests/is_a.phpt b/Zend/tests/is_a.phpt index 0a01eb756e..f4161f2390 100644 --- a/Zend/tests/is_a.phpt +++ b/Zend/tests/is_a.phpt @@ -12,21 +12,21 @@ function __autoload($name) { class BASE { } -interface INT { +interface I { } -class A extends BASE implements INT { +class A extends BASE implements I { } $a = new A; var_dump(is_a($a, "B1")); var_dump(is_a($a, "A")); var_dump(is_a($a, "BASE")); -var_dump(is_a($a, "INT")); +var_dump(is_a($a, "I")); var_dump(is_subclass_of($a, "B2")); var_dump(is_subclass_of($a, "A")); var_dump(is_subclass_of($a, "BASE")); -var_dump(is_subclass_of($a, "INT")); +var_dump(is_subclass_of($a, "I")); var_dump(is_subclass_of("X1", "X2")); ?> diff --git a/Zend/tests/typehints/scalar_aliases.phpt b/Zend/tests/typehints/scalar_aliases.phpt new file mode 100644 index 0000000000..500e5da399 --- /dev/null +++ b/Zend/tests/typehints/scalar_aliases.phpt @@ -0,0 +1,20 @@ +--TEST-- +Scalar type hint aliases +--FILE-- +<?php + +function foo(integer $a, boolean $b) { + var_dump($a, $b); +} + +function bar(int $a, bool $b) { + var_dump($a, $b); +} + +foo(1, true); +bar(1, true); +--EXPECT-- +int(1) +bool(true) +int(1) +bool(true) diff --git a/Zend/tests/typehints/scalar_basic.phpt b/Zend/tests/typehints/scalar_basic.phpt new file mode 100644 index 0000000000..af10b559ef --- /dev/null +++ b/Zend/tests/typehints/scalar_basic.phpt @@ -0,0 +1,241 @@ +--TEST-- +Scalar type hint basics +--FILE-- +<?php + +$errnames = [ + E_NOTICE => 'E_NOTICE', + E_WARNING => 'E_WARNING', + E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR' +]; +set_error_handler(function (int $errno, string $errmsg, string $file, int $line) use ($errnames) { + echo "$errnames[$errno]: $errmsg on line $line\n"; + return true; +}); + +$functions = [ + 'int' => function (int $i) { return $i; }, + 'float' => function (float $f) { return $f; }, + 'string' => function (string $s) { return $s; }, + 'bool' => function (bool $b) { return $b; } +]; + +class Stringable { + public function __toString() { + return "foobar"; + } +} + +$values = [ + 1, + "1", + 1.0, + 1.5, + "1a", + "a", + "", + PHP_INT_MAX, + NAN, + TRUE, + FALSE, + NULL, + [], + new StdClass, + new Stringable, + fopen("data:text/plain,foobar", "r") +]; + +foreach ($functions as $type => $function) { + echo PHP_EOL, "Testing '$type' typehint:", PHP_EOL; + foreach ($values as $value) { + echo "*** Trying "; + var_dump($value); + var_dump($function($value)); + } +} +--EXPECTF-- + +Testing 'int' typehint: +*** Trying int(1) +int(1) +*** Trying string(1) "1" +int(1) +*** Trying float(1) +int(1) +*** Trying float(1.5) +int(1) +*** Trying string(2) "1a" +E_NOTICE: A non well formed numeric value encountered on line %d +int(1) +*** Trying string(1) "a" +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, string given, called in %s on line %d and defined on line %d +string(1) "a" +*** Trying string(0) "" +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, string given, called in %s on line %d and defined on line %d +string(0) "" +*** Trying int(%d) +int(%d) +*** Trying float(NAN) +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, float given, called in %s on line %d and defined on line %d +float(NAN) +*** Trying bool(true) +int(1) +*** Trying bool(false) +int(0) +*** Trying NULL +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, null given, called in %s on line %d and defined on line %d +NULL +*** Trying array(0) { +} +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, array given, called in %s on line %d and defined on line %d +array(0) { +} +*** Trying object(stdClass)#%s (0) { +} +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, object given, called in %s on line %d and defined on line %d +object(stdClass)#%s (0) { +} +*** Trying object(Stringable)#%s (0) { +} +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, object given, called in %s on line %d and defined on line %d +object(Stringable)#%s (0) { +} +*** Trying resource(%d) of type (stream) +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, resource given, called in %s on line %d and defined on line %d +resource(%d) of type (stream) + +Testing 'float' typehint: +*** Trying int(1) +float(1) +*** Trying string(1) "1" +float(1) +*** Trying float(1) +float(1) +*** Trying float(1.5) +float(1.5) +*** Trying string(2) "1a" +E_NOTICE: A non well formed numeric value encountered on line %d +float(1) +*** Trying string(1) "a" +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, string given, called in %s on line %d and defined on line %d +string(1) "a" +*** Trying string(0) "" +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, string given, called in %s on line %d and defined on line %d +string(0) "" +*** Trying int(%d) +float(%s) +*** Trying float(NAN) +float(NAN) +*** Trying bool(true) +float(1) +*** Trying bool(false) +float(0) +*** Trying NULL +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, null given, called in %s on line %d and defined on line %d +NULL +*** Trying array(0) { +} +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, array given, called in %s on line %d and defined on line %d +array(0) { +} +*** Trying object(stdClass)#%s (0) { +} +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, object given, called in %s on line %d and defined on line %d +object(stdClass)#%s (0) { +} +*** Trying object(Stringable)#%s (0) { +} +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, object given, called in %s on line %d and defined on line %d +object(Stringable)#%s (0) { +} +*** Trying resource(%d) of type (stream) +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, resource given, called in %s on line %d and defined on line %d +resource(%d) of type (stream) + +Testing 'string' typehint: +*** Trying int(1) +string(1) "1" +*** Trying string(1) "1" +string(1) "1" +*** Trying float(1) +string(1) "1" +*** Trying float(1.5) +string(3) "1.5" +*** Trying string(2) "1a" +string(2) "1a" +*** Trying string(1) "a" +string(1) "a" +*** Trying string(0) "" +string(0) "" +*** Trying int(%d) +string(%d) "%d" +*** Trying float(NAN) +string(3) "NAN" +*** Trying bool(true) +string(1) "1" +*** Trying bool(false) +string(0) "" +*** Trying NULL +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, null given, called in %s on line %d and defined on line %d +NULL +*** Trying array(0) { +} +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, array given, called in %s on line %d and defined on line %d +array(0) { +} +*** Trying object(stdClass)#%s (0) { +} +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, object given, called in %s on line %d and defined on line %d +object(stdClass)#%s (0) { +} +*** Trying object(Stringable)#%s (0) { +} +string(6) "foobar" +*** Trying resource(%d) of type (stream) +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, resource given, called in %s on line %d and defined on line %d +resource(%d) of type (stream) + +Testing 'bool' typehint: +*** Trying int(1) +bool(true) +*** Trying string(1) "1" +bool(true) +*** Trying float(1) +bool(true) +*** Trying float(1.5) +bool(true) +*** Trying string(2) "1a" +bool(true) +*** Trying string(1) "a" +bool(true) +*** Trying string(0) "" +bool(false) +*** Trying int(%d) +bool(true) +*** Trying float(NAN) +bool(true) +*** Trying bool(true) +bool(true) +*** Trying bool(false) +bool(false) +*** Trying NULL +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, null given, called in %s on line %d and defined on line %d +NULL +*** Trying array(0) { +} +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, array given, called in %s on line %d and defined on line %d +array(0) { +} +*** Trying object(stdClass)#%s (0) { +} +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, object given, called in %s on line %d and defined on line %d +object(stdClass)#%s (0) { +} +*** Trying object(Stringable)#%s (0) { +} +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, object given, called in %s on line %d and defined on line %d +object(Stringable)#%s (0) { +} +*** Trying resource(%d) of type (stream) +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, resource given, called in %s on line %d and defined on line %d +resource(%d) of type (stream) diff --git a/Zend/tests/typehints/scalar_none.phpt b/Zend/tests/typehints/scalar_none.phpt new file mode 100644 index 0000000000..0b7f7ec9a2 --- /dev/null +++ b/Zend/tests/typehints/scalar_none.phpt @@ -0,0 +1,55 @@ +--TEST-- +Scalar type hint missing parameters +--FILE-- +<?php + +$errnames = [ + E_NOTICE => 'E_NOTICE', + E_WARNING => 'E_WARNING', + E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR' +]; +set_error_handler(function (int $errno, string $errmsg, string $file, int $line) use ($errnames) { + echo "$errnames[$errno]: $errmsg on line $line\n"; + return true; +}); + +$functions = [ + 'int' => function (int $i) { return $i; }, + 'float' => function (float $f) { return $f; }, + 'string' => function (string $s) { return $s; }, + 'bool' => function (bool $b) { return $b; }, + 'int nullable' => function (int $i = NULL) { return $i; }, + 'float nullable' => function (float $f = NULL) { return $f; }, + 'string nullable' => function (string $s = NULL) { return $s; }, + 'bool nullable' => function (bool $b = NULL) { return $b; } +]; + +foreach ($functions as $type => $function) { + echo "Testing $type:", PHP_EOL; + var_dump($function()); +} +--EXPECTF-- +Testing int: +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, none given, called in %s on line %d and defined on line %d +E_NOTICE: Undefined variable: i on line %d +NULL +Testing float: +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, none given, called in %s on line %d and defined on line %d +E_NOTICE: Undefined variable: f on line %d +NULL +Testing string: +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, none given, called in %s on line %d and defined on line %d +E_NOTICE: Undefined variable: s on line %d +NULL +Testing bool: +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, none given, called in %s on line %d and defined on line %d +E_NOTICE: Undefined variable: b on line %d +NULL +Testing int nullable: +NULL +Testing float nullable: +NULL +Testing string nullable: +NULL +Testing bool nullable: +NULL diff --git a/Zend/tests/typehints/scalar_null.phpt b/Zend/tests/typehints/scalar_null.phpt new file mode 100644 index 0000000000..c5aa1ce986 --- /dev/null +++ b/Zend/tests/typehints/scalar_null.phpt @@ -0,0 +1,51 @@ +--TEST-- +Scalar type hint nullability +--FILE-- +<?php + +$errnames = [ + E_NOTICE => 'E_NOTICE', + E_WARNING => 'E_WARNING', + E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR' +]; +set_error_handler(function (int $errno, string $errmsg, string $file, int $line) use ($errnames) { + echo "$errnames[$errno]: $errmsg on line $line\n"; + return true; +}); + +$functions = [ + 'int' => function (int $i) { return $i; }, + 'float' => function (float $f) { return $f; }, + 'string' => function (string $s) { return $s; }, + 'bool' => function (bool $b) { return $b; }, + 'int nullable' => function (int $i = NULL) { return $i; }, + 'float nullable' => function (float $f = NULL) { return $f; }, + 'string nullable' => function (string $s = NULL) { return $s; }, + 'bool nullable' => function (bool $b = NULL) { return $b; } +]; + +foreach ($functions as $type => $function) { + echo "Testing $type:", PHP_EOL; + var_dump($function(NULL)); +} +--EXPECTF-- +Testing int: +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, null given, called in %s on line %d and defined on line %d +NULL +Testing float: +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, null given, called in %s on line %d and defined on line %d +NULL +Testing string: +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, null given, called in %s on line %d and defined on line %d +NULL +Testing bool: +E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, null given, called in %s on line %d and defined on line %d +NULL +Testing int nullable: +NULL +Testing float nullable: +NULL +Testing string nullable: +NULL +Testing bool nullable: +NULL diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 69327778e3..9fcd9cb434 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -164,6 +164,7 @@ ZEND_API char *zend_get_type_by_const(int type) /* {{{ */ switch(type) { case IS_FALSE: case IS_TRUE: + case _IS_BOOL: return "boolean"; case IS_LONG: return "integer"; diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 62064dcd5f..c10506db33 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -692,10 +692,72 @@ static void zend_verify_arg_type(zend_function *zf, uint32_t arg_num, zval *arg, if (!zend_is_callable(arg, IS_CALLABLE_CHECK_SILENT, NULL) && (Z_TYPE_P(arg) != IS_NULL || !(cur_arg_info->allow_null || (default_value && is_null_constant(default_value))))) { zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be callable", "", zend_zval_type_name(arg), "", arg); } -#if ZEND_DEBUG } else { - zend_error(E_ERROR, "Unknown typehint"); + ZVAL_DEREF(arg); + + if (Z_TYPE_P(arg) == IS_NULL) { + if (!(cur_arg_info->allow_null || (default_value && is_null_constant(default_value)))) { +failure: + zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be of the type ", zend_get_type_by_const(cur_arg_info->type_hint), zend_zval_type_name(arg), "", arg); + } + return; + } + + switch (cur_arg_info->type_hint) { + case IS_LONG: { + zend_long dest; + if (_z_param_long(arg, &dest, NULL, 0, 0)) { + if (Z_TYPE_P(arg) != IS_LONG) { + zval_dtor(arg); + } + ZVAL_LONG(arg, dest); + } else { + goto failure; + } + } + break; + case IS_DOUBLE: { + double dest; + if (_z_param_double(arg, &dest, NULL, 0)) { + if (Z_TYPE_P(arg) != IS_DOUBLE) { + zval_dtor(arg); + } + ZVAL_DOUBLE(arg, dest); + } else { + goto failure; + } + } + break; + case IS_STRING: { + zend_string *dest; + if (_z_param_str(arg, &dest, 0)) { + if (Z_TYPE_P(arg) != IS_STRING) { + zval_dtor(arg); + } + ZVAL_STR(arg, dest); + } else { + goto failure; + } + } + break; + case _IS_BOOL: { + zend_bool dest; + if (_z_param_bool(arg, &dest, NULL, 0)) { + if (Z_TYPE_P(arg) != IS_TRUE && Z_TYPE_P(arg) != IS_FALSE) { + zval_dtor(arg); + } + ZVAL_BOOL(arg, dest); + } else { + goto failure; + } + } + break; + default: +#if ZEND_DEBUG + zend_error(E_ERROR, "Unknown typehint"); #endif + break; + } } } } @@ -725,6 +787,11 @@ static inline int zend_verify_missing_arg_type(zend_function *zf, uint32_t arg_n zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be of the type array", "", "none", "", NULL); } else if (cur_arg_info->type_hint == IS_CALLABLE) { zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be callable", "", "none", "", NULL); + } else if (cur_arg_info->type_hint == IS_LONG + || cur_arg_info->type_hint == IS_DOUBLE + || cur_arg_info->type_hint == IS_STRING + || cur_arg_info->type_hint == _IS_BOOL) { + zend_verify_arg_error(E_RECOVERABLE_ERROR, zf, arg_num, "be of the type ", zend_get_type_by_const(cur_arg_info->type_hint), "none", "", NULL); #if ZEND_DEBUG } else { zend_error(E_ERROR, "Unknown typehint"); diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index 009d7bae0b..bfb7787677 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -82,7 +82,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*); %left '*' '/' '%' %right '!' %nonassoc T_INSTANCEOF -%right '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@' +%right '~' T_INC T_DEC T_DOUBLE_CAST T_STRING_CAST T_OBJECT_CAST cast_operator '@' %right T_POW %right '[' %nonassoc T_NEW T_CLONE @@ -136,13 +136,13 @@ static YYSIZE_T zend_yytnamerr(char*, const char*); %token T_INSTANCEOF "instanceof (T_INSTANCEOF)" %token T_INC "++ (T_INC)" %token T_DEC "-- (T_DEC)" -%token T_INT_CAST "(int) (T_INT_CAST)" +%token T_INT_TYPE "int (T_INT_TYPE)" +%token T_FLOAT_TYPE "float (T_FLOAT_TYPE)" +%token T_STRING_TYPE "string (T_STRING_TYPE)" +%token T_BOOL_TYPE "bool (T_BOOL_TYPE)" %token T_DOUBLE_CAST "(double) (T_DOUBLE_CAST)" %token T_STRING_CAST "(string) (T_STRING_CAST)" -%token T_ARRAY_CAST "(array) (T_ARRAY_CAST)" %token T_OBJECT_CAST "(object) (T_OBJECT_CAST)" -%token T_BOOL_CAST "(bool) (T_BOOL_CAST)" -%token T_UNSET_CAST "(unset) (T_UNSET_CAST)" %token T_NEW "new (T_NEW)" %token T_CLONE "clone (T_CLONE)" %token T_EXIT "exit (T_EXIT)" @@ -573,9 +573,15 @@ optional_type: ; type: - T_ARRAY { $$ = zend_ast_create_ex(ZEND_AST_TYPE, IS_ARRAY); } - | T_CALLABLE { $$ = zend_ast_create_ex(ZEND_AST_TYPE, IS_CALLABLE); } - | name { $$ = $1; } + T_ARRAY { $$ = zend_ast_create_ex(ZEND_AST_TYPE, IS_ARRAY); } + | T_CALLABLE { $$ = zend_ast_create_ex(ZEND_AST_TYPE, IS_CALLABLE); } + | T_INT_TYPE { $$ = zend_ast_create_ex(ZEND_AST_TYPE, IS_LONG); } + | T_FLOAT_TYPE { $$ = zend_ast_create_ex(ZEND_AST_TYPE, IS_DOUBLE); } + | T_STRING_TYPE { $$ = zend_ast_create_ex(ZEND_AST_TYPE, IS_STRING); } + | T_BOOL_TYPE { $$ = zend_ast_create_ex(ZEND_AST_TYPE, _IS_BOOL); } + | T_ARRAY { $$ = zend_ast_create_ex(ZEND_AST_TYPE, IS_ARRAY); } + | T_CALLABLE { $$ = zend_ast_create_ex(ZEND_AST_TYPE, IS_CALLABLE); } + | name { $$ = $1; } ; return_type: @@ -857,13 +863,27 @@ expr_without_variable: | expr T_COALESCE expr { $$ = zend_ast_create(ZEND_AST_COALESCE, $1, $3); } | internal_functions_in_yacc { $$ = $1; } - | T_INT_CAST expr { $$ = zend_ast_create_cast(IS_LONG, $2); } + | '(' T_INT_TYPE ')' expr + %prec cast_operator + { $$ = zend_ast_create_cast(IS_LONG, $4); } + | '(' T_FLOAT_TYPE ')' expr + %prec cast_operator + { $$ = zend_ast_create_cast(IS_DOUBLE, $4); } + | '(' T_STRING_TYPE ')' expr + %prec cast_operator + { $$ = zend_ast_create_cast(IS_STRING, $4); } + | '(' T_BOOL_TYPE ')' expr + %prec cast_operator + { $$ = zend_ast_create_cast(_IS_BOOL, $4); } + | '(' T_ARRAY ')' expr + %prec cast_operator + { $$ = zend_ast_create_cast(IS_ARRAY, $4); } + | '(' T_UNSET ')' expr + %prec cast_operator + { $$ = zend_ast_create_cast(IS_NULL, $4); } | T_DOUBLE_CAST expr { $$ = zend_ast_create_cast(IS_DOUBLE, $2); } | T_STRING_CAST expr { $$ = zend_ast_create_cast(IS_STRING, $2); } - | T_ARRAY_CAST expr { $$ = zend_ast_create_cast(IS_ARRAY, $2); } | T_OBJECT_CAST expr { $$ = zend_ast_create_cast(IS_OBJECT, $2); } - | T_BOOL_CAST expr { $$ = zend_ast_create_cast(_IS_BOOL, $2); } - | T_UNSET_CAST expr { $$ = zend_ast_create_cast(IS_NULL, $2); } | T_EXIT exit_expr { $$ = zend_ast_create(ZEND_AST_EXIT, $2); } | '@' expr { $$ = zend_ast_create(ZEND_AST_SILENCE, $2); } | scalar { $$ = $1; } diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index 0081192d40..9c87c18833 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -1309,32 +1309,32 @@ NEWLINE ("\r"|"\n"|"\r\n") return T_VAR; } -<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("int"|"integer"){TABS_AND_SPACES}")" { - return T_INT_CAST; +<ST_IN_SCRIPTING>("int"|"integer") { + return T_INT_TYPE; } -<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("real"|"double"|"float"){TABS_AND_SPACES}")" { - return T_DOUBLE_CAST; +<ST_IN_SCRIPTING>"float" { + return T_FLOAT_TYPE; } -<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("string"|"binary"){TABS_AND_SPACES}")" { - return T_STRING_CAST; +<ST_IN_SCRIPTING>"string" { + return T_STRING_TYPE; } -<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}"array"{TABS_AND_SPACES}")" { - return T_ARRAY_CAST; +<ST_IN_SCRIPTING>("bool"|"boolean") { + return T_BOOL_TYPE; } -<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}"object"{TABS_AND_SPACES}")" { - return T_OBJECT_CAST; +<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("real"|"double"){TABS_AND_SPACES}")" { + return T_DOUBLE_CAST; } -<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("bool"|"boolean"){TABS_AND_SPACES}")" { - return T_BOOL_CAST; +<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("binary"){TABS_AND_SPACES}")" { + return T_STRING_CAST; } -<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("unset"){TABS_AND_SPACES}")" { - return T_UNSET_CAST; +<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}"object"{TABS_AND_SPACES}")" { + return T_OBJECT_CAST; } <ST_IN_SCRIPTING>"eval" { diff --git a/ext/reflection/tests/ReflectionMethod_basic1.phpt b/ext/reflection/tests/ReflectionMethod_basic1.phpt index 75ab957690..aeabcc6a01 100644 --- a/ext/reflection/tests/ReflectionMethod_basic1.phpt +++ b/ext/reflection/tests/ReflectionMethod_basic1.phpt @@ -48,7 +48,7 @@ class TestClass class DerivedClass extends TestClass {} interface TestInterface { - public function int(); + public function inter(); } reflectMethod("DerivedClass", "foo"); @@ -56,7 +56,7 @@ reflectMethod("TestClass", "stat"); reflectMethod("TestClass", "priv"); reflectMethod("TestClass", "prot"); reflectMethod("DerivedClass", "prot"); -reflectMethod("TestInterface", "int"); +reflectMethod("TestInterface", "inter"); reflectMethod("ReflectionProperty", "__construct"); reflectMethod("TestClass", "__destruct"); @@ -208,7 +208,7 @@ bool(false) ********************************** ********************************** -Reflecting on method TestInterface::int() +Reflecting on method TestInterface::inter() isFinal(): diff --git a/ext/reflection/tests/ReflectionMethod_basic2.phpt b/ext/reflection/tests/ReflectionMethod_basic2.phpt index c91af67701..8bc7705eb6 100644 --- a/ext/reflection/tests/ReflectionMethod_basic2.phpt +++ b/ext/reflection/tests/ReflectionMethod_basic2.phpt @@ -36,7 +36,7 @@ class TestClass class DerivedClass extends TestClass {} interface TestInterface { - public function int(); + public function inter(); } reflectMethod("DerivedClass", "foo"); @@ -44,7 +44,7 @@ reflectMethod("TestClass", "stat"); reflectMethod("TestClass", "priv"); reflectMethod("TestClass", "prot"); reflectMethod("DerivedClass", "prot"); -reflectMethod("TestInterface", "int"); +reflectMethod("TestInterface", "inter"); reflectMethod("ReflectionProperty", "__construct"); reflectMethod("TestClass", "__destruct"); @@ -131,16 +131,16 @@ string(%d) "Method [ <user, inherits TestClass> protected method prot ] { ********************************** ********************************** -Reflecting on method TestInterface::int() +Reflecting on method TestInterface::inter() __toString(): -string(%d) "Method [ <user> abstract public method int ] { +string(%d) "Method [ <user> abstract public method inter ] { @@ %s 36 - 36 } " export(): -string(%d) "Method [ <user> abstract public method int ] { +string(%d) "Method [ <user> abstract public method inter ] { @@ %s 36 - 36 } " diff --git a/ext/reflection/tests/ReflectionMethod_basic3.phpt b/ext/reflection/tests/ReflectionMethod_basic3.phpt index 7b65927667..ad6c663818 100644 --- a/ext/reflection/tests/ReflectionMethod_basic3.phpt +++ b/ext/reflection/tests/ReflectionMethod_basic3.phpt @@ -38,7 +38,7 @@ class TestClass class DerivedClass extends TestClass {} interface TestInterface { - public function int(); + public function inter(); } reflectMethod("DerivedClass", "foo"); @@ -46,7 +46,7 @@ reflectMethod("TestClass", "stat"); reflectMethod("TestClass", "priv"); reflectMethod("TestClass", "prot"); reflectMethod("DerivedClass", "prot"); -reflectMethod("TestInterface", "int"); +reflectMethod("TestInterface", "inter"); reflectMethod("ReflectionProperty", "__construct"); reflectMethod("TestClass", "__destruct"); @@ -124,11 +124,11 @@ bool(true) ********************************** ********************************** -Reflecting on method TestInterface::int() +Reflecting on method TestInterface::inter() getName(): -string(3) "int" +string(5) "inter" isInternal(): bool(false) diff --git a/ext/reflection/tests/ReflectionMethod_basic4.phpt b/ext/reflection/tests/ReflectionMethod_basic4.phpt index 82672e44f5..a0c2ddcf17 100644 --- a/ext/reflection/tests/ReflectionMethod_basic4.phpt +++ b/ext/reflection/tests/ReflectionMethod_basic4.phpt @@ -42,7 +42,7 @@ class TestClass class DerivedClass extends TestClass {} interface TestInterface { - public function int(); + public function inter(); } reflectMethod("DerivedClass", "foo"); @@ -50,7 +50,7 @@ reflectMethod("TestClass", "stat"); reflectMethod("TestClass", "priv"); reflectMethod("TestClass", "prot"); reflectMethod("DerivedClass", "prot"); -reflectMethod("TestInterface", "int"); +reflectMethod("TestInterface", "inter"); reflectMethod("ReflectionProperty", "__construct"); reflectMethod("TestClass", "__destruct"); @@ -127,7 +127,7 @@ int(34) ********************************** ********************************** -Reflecting on method TestInterface::int() +Reflecting on method TestInterface::inter() getFileName(): diff --git a/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt index 72baa53fda..bb43be078d 100644 --- a/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt +++ b/ext/reflection/tests/ReflectionMethod_getModifiers_basic.phpt @@ -60,7 +60,7 @@ class TestClass class DerivedClass extends TestClass {} interface TestInterface { - public function int(); + public function inter(); public function __clone(); } @@ -222,7 +222,7 @@ Modifiers for method TestClass::__autoload(): 0x08010100 -Modifiers for method TestInterface::int(): +Modifiers for method TestInterface::inter(): 0x08000102 diff --git a/ext/standard/tests/array/krsort_object.phpt b/ext/standard/tests/array/krsort_object.phpt index 36d8589a82..6236595796 100644 --- a/ext/standard/tests/array/krsort_object.phpt +++ b/ext/standard/tests/array/krsort_object.phpt @@ -15,7 +15,7 @@ Test krsort() function : object functionality - sort objects echo "*** Testing krsort() : object functionality ***\n"; // class declaration for integer objects -class Integer +class IntegerObject { public $class_value; // initializing object member value @@ -25,7 +25,7 @@ class Integer } // class declaration for string objects -class String +class StringObject { public $class_value; // initializing object member value @@ -42,17 +42,17 @@ class String // array of integer objects with different key values $unsorted_int_obj = array ( - 10 => new Integer(11), 20 => new Integer(66), - 3 => new Integer(23), 4 => new Integer(-5), - 50 => new Integer(0.001), 6 => new Integer(0) + 10 => new IntegerObject(11), 20 => new IntegerObject(66), + 3 => new IntegerObject(23), 4 => new IntegerObject(-5), + 50 => new IntegerObject(0.001), 6 => new IntegerObject(0) ); // array of string objects with different key values $unsorted_str_obj = array ( - "axx" => new String("axx"), "t" => new String("t"), - "w" => new String("w"), "py" => new String("py"), - "apple" => new String("apple"), "Orange" => new String("Orange"), - "Lemon" => new String("Lemon"), "aPPle" => new String("aPPle") + "axx" => new StringObject("axx"), "t" => new StringObject("t"), + "w" => new StringObject("w"), "py" => new StringObject("py"), + "apple" => new StringObject("apple"), "Orange" => new StringObject("Orange"), + "Lemon" => new StringObject("Lemon"), "aPPle" => new StringObject("aPPle") ); @@ -88,32 +88,32 @@ echo "Done\n"; bool(true) array(6) { [50]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> float(0.001) } [20]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(66) } [10]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(11) } [6]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(0) } [4]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(-5) } [3]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(23) } @@ -121,42 +121,42 @@ array(6) { bool(true) array(8) { ["w"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(1) "w" } ["t"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(1) "t" } ["py"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(2) "py" } ["axx"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(3) "axx" } ["apple"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(5) "apple" } ["aPPle"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(5) "aPPle" } ["Orange"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(6) "Orange" } ["Lemon"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(5) "Lemon" } @@ -166,32 +166,32 @@ array(8) { bool(true) array(6) { [50]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> float(0.001) } [20]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(66) } [10]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(11) } [6]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(0) } [4]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(-5) } [3]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(23) } @@ -199,42 +199,42 @@ array(6) { bool(true) array(8) { ["w"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(1) "w" } ["t"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(1) "t" } ["py"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(2) "py" } ["axx"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(3) "axx" } ["apple"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(5) "apple" } ["aPPle"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(5) "aPPle" } ["Orange"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(6) "Orange" } ["Lemon"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(5) "Lemon" } diff --git a/ext/standard/tests/array/ksort_object.phpt b/ext/standard/tests/array/ksort_object.phpt index 20e8ba26eb..2d76026aa4 100644 --- a/ext/standard/tests/array/ksort_object.phpt +++ b/ext/standard/tests/array/ksort_object.phpt @@ -15,7 +15,7 @@ Test ksort() function : object functionality - sort objects echo "*** Testing ksort() : object functionality ***\n"; // class declaration for integer objects -class Integer +class IntegerObject { public $class_value; // initializing object member value @@ -26,7 +26,7 @@ class Integer } // class declaration for string objects -class String +class StringObject { public $class_value; // initializing object member value @@ -43,17 +43,17 @@ class String // array of integer objects $unsorted_int_obj = array ( - 11 => new Integer(11), 66 => new Integer(66), - 23 => new Integer(23), -5 => new Integer(-5), - 1 => new Integer(0.001), 0 => new Integer(0) + 11 => new IntegerObject(11), 66 => new IntegerObject(66), + 23 => new IntegerObject(23), -5 => new IntegerObject(-5), + 1 => new IntegerObject(0.001), 0 => new IntegerObject(0) ); // array of string objects $unsorted_str_obj = array ( - "axx" => new String("axx"), "t" => new String("t"), - "w" => new String("w"), "py" => new String("py"), - "apple" => new String("apple"), "Orange" => new String("Orange"), - "Lemon" => new String("Lemon"), "aPPle" => new String("aPPle") + "axx" => new StringObject("axx"), "t" => new StringObject("t"), + "w" => new StringObject("w"), "py" => new StringObject("py"), + "apple" => new StringObject("apple"), "Orange" => new StringObject("Orange"), + "Lemon" => new StringObject("Lemon"), "aPPle" => new StringObject("aPPle") ); echo "\n-- Testing ksort() by supplying various object arrays, 'flag' value is defualt --\n"; @@ -87,32 +87,32 @@ echo "Done\n"; bool(true) array(6) { [-5]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(-5) } [0]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(0) } [1]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> float(0.001) } [11]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(11) } [23]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(23) } [66]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(66) } @@ -120,42 +120,42 @@ array(6) { bool(true) array(8) { ["Lemon"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(5) "Lemon" } ["Orange"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(6) "Orange" } ["aPPle"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(5) "aPPle" } ["apple"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(5) "apple" } ["axx"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(3) "axx" } ["py"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(2) "py" } ["t"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(1) "t" } ["w"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(1) "w" } @@ -165,32 +165,32 @@ array(8) { bool(true) array(6) { [-5]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(-5) } [0]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(0) } [1]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> float(0.001) } [11]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(11) } [23]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(23) } [66]=> - object(Integer)#%d (1) { + object(IntegerObject)#%d (1) { ["class_value"]=> int(66) } @@ -198,42 +198,42 @@ array(6) { bool(true) array(8) { ["Lemon"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(5) "Lemon" } ["Orange"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(6) "Orange" } ["aPPle"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(5) "aPPle" } ["apple"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(5) "apple" } ["axx"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(3) "axx" } ["py"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(2) "py" } ["t"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(1) "t" } ["w"]=> - object(String)#%d (1) { + object(StringObject)#%d (1) { ["class_value"]=> string(1) "w" } diff --git a/ext/standard/tests/strings/lcfirst.phpt b/ext/standard/tests/strings/lcfirst.phpt Binary files differindex e603f4bbf8..6cbd213fbe 100644 --- a/ext/standard/tests/strings/lcfirst.phpt +++ b/ext/standard/tests/strings/lcfirst.phpt diff --git a/ext/standard/tests/strings/strlen.phpt b/ext/standard/tests/strings/strlen.phpt Binary files differindex df39f2469c..ab54445943 100644 --- a/ext/standard/tests/strings/strlen.phpt +++ b/ext/standard/tests/strings/strlen.phpt diff --git a/ext/standard/tests/strings/strpos.phpt b/ext/standard/tests/strings/strpos.phpt Binary files differindex b2bfedeb87..36854d1b37 100644 --- a/ext/standard/tests/strings/strpos.phpt +++ b/ext/standard/tests/strings/strpos.phpt diff --git a/ext/standard/tests/strings/strstr.phpt b/ext/standard/tests/strings/strstr.phpt Binary files differindex bdedb7e9f6..fd7f58ef1a 100644 --- a/ext/standard/tests/strings/strstr.phpt +++ b/ext/standard/tests/strings/strstr.phpt diff --git a/ext/standard/tests/strings/ucfirst.phpt b/ext/standard/tests/strings/ucfirst.phpt Binary files differindex 468f7f034e..8fb1a156b4 100644 --- a/ext/standard/tests/strings/ucfirst.phpt +++ b/ext/standard/tests/strings/ucfirst.phpt |