Browse Source
- Strip out the typehint *checks* only. They are still parsed, and they are
- Strip out the typehint *checks* only. They are still parsed, and they are
still accessible through the reflection API.experimental/with_scalar_types
14 changed files with 15 additions and 291 deletions
-
2NEWS
-
38Zend/tests/hint/param_type_hint_001.phpt
-
16Zend/tests/hint/param_type_hint_003.phpt
-
16Zend/tests/hint/param_type_hint_004.phpt
-
23Zend/tests/hint/param_type_hint_005.phpt
-
15Zend/tests/hint/param_type_hint_011.phpt
-
18Zend/tests/hint/param_type_hint_012.phpt
-
16Zend/tests/hint/param_type_hint_013.phpt
-
16Zend/tests/hint/param_type_hint_014.phpt
-
19Zend/tests/hint/param_type_hint_015.phpt
-
37Zend/tests/hint/param_type_hint_019.phpt
-
46Zend/tests/hint/param_type_hint_021.phpt
-
41Zend/zend_execute.c
-
3Zend/zend_execute.h
@ -1,38 +0,0 @@ |
|||
--TEST-- |
|||
Parameter type hint - Testing integer hint |
|||
--FILE-- |
|||
<?php |
|||
|
|||
function test_int($x, int $a = 1) { |
|||
} |
|||
|
|||
test_int(1); |
|||
print "Ok\n"; |
|||
|
|||
test_int('1211'); |
|||
print "Ok\n"; |
|||
|
|||
test_int(null); |
|||
print "Ok\n"; |
|||
|
|||
test_int(1, 1); |
|||
print "Ok\n"; |
|||
|
|||
test_int(null, '1211'); |
|||
print "Ok\n"; |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
Ok |
|||
Ok |
|||
Ok |
|||
Ok |
|||
|
|||
Catchable fatal error: Argument 2 passed to test_int() must be of the type integer, string given, called in %s on line %d and defined in %s on line %d |
|||
--UEXPECTF-- |
|||
Ok |
|||
Ok |
|||
Ok |
|||
Ok |
|||
|
|||
Catchable fatal error: Argument 2 passed to test_int() must be of the type integer, Unicode string given, called in %s on line %d and defined in %s on line %d |
|||
@ -1,16 +0,0 @@ |
|||
--TEST-- |
|||
Parameter type hint - Wrong parameter for integer |
|||
--FILE-- |
|||
<?php |
|||
|
|||
function test_int(int $a) { |
|||
echo $a, "\n"; |
|||
} |
|||
|
|||
test_int('+1'); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
Catchable fatal error: Argument 1 passed to test_int() must be of the type integer, string given, called in %s on line %d and defined in %s on line %d |
|||
--UEXPECTF-- |
|||
Catchable fatal error: Argument 1 passed to test_int() must be of the type integer, Unicode string given, called in %s on line %d and defined in %s on line %d |
|||
@ -1,16 +0,0 @@ |
|||
--TEST-- |
|||
Parameter type hint - Wrong parameter for double |
|||
--FILE-- |
|||
<?php |
|||
|
|||
function test_double(real $a) { |
|||
echo $a, "\n"; |
|||
} |
|||
|
|||
test_double('+1.1'); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
Catchable fatal error: Argument 1 passed to test_double() must be of the type double, string given, called in %s on line %d and defined in %s on line %d |
|||
--UEXPECTF-- |
|||
Catchable fatal error: Argument 1 passed to test_double() must be of the type double, Unicode string given, called in %s on line %d and defined in %s on line %d |
|||
@ -1,23 +0,0 @@ |
|||
--TEST-- |
|||
Parameter type hint - Wrong parameter for string |
|||
--FILE-- |
|||
<?php |
|||
|
|||
function test_str(string $a) { |
|||
echo $a, "\n"; |
|||
} |
|||
|
|||
test_str('+1.1'); |
|||
test_str('-.1'); |
|||
test_str('11213111112321312'); |
|||
test_str(''); |
|||
test_str(null); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
+1.1 |
|||
-.1 |
|||
11213111112321312 |
|||
|
|||
|
|||
Catchable fatal error: Argument 1 passed to test_str() must be of the type string, null given, called in %s on line %d and defined in %s on line %d |
|||
@ -1,15 +0,0 @@ |
|||
--TEST-- |
|||
Parameter type hint - Testing with undefined variable |
|||
--FILE-- |
|||
<?php |
|||
|
|||
function test(string $a) { |
|||
} |
|||
|
|||
test($x); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
Notice: Undefined variable: x in %s on line %d |
|||
|
|||
Catchable fatal error: Argument 1 passed to test() must be of the type string, null given, called in %s on line %d and defined in %s on line %d |
|||
@ -1,18 +0,0 @@ |
|||
--TEST-- |
|||
Parameter type hint - Testing with lambda function |
|||
--FILE-- |
|||
<?php |
|||
|
|||
$test = create_function('integer $i', 'return $i + 1;'); |
|||
var_dump($test(1)); |
|||
var_dump($test('foo')); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
int(2) |
|||
|
|||
Catchable fatal error: Argument 1 passed to __lambda_func() must be of the type integer, string given, called in %s on line %d and defined in %s(%d) : runtime-created function on line %d |
|||
--UEXPECTF-- |
|||
int(2) |
|||
|
|||
Catchable fatal error: Argument 1 passed to __lambda_func() must be of the type integer, Unicode string given, called in %s on line %d and defined in %s(%d) : runtime-created function on line %d |
|||
@ -1,16 +0,0 @@ |
|||
--TEST-- |
|||
Parameter type hint - Testing with lambda function using 2 parameters |
|||
--FILE-- |
|||
<?php |
|||
|
|||
$test = create_function('integer $i, string $j', 'return $i + $j;'); |
|||
var_dump($test(1, 'foo')); |
|||
var_dump($test(1, '1')); |
|||
var_dump($test(1, NULL)); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
int(1) |
|||
int(2) |
|||
|
|||
Catchable fatal error: Argument 2 passed to __lambda_func() must be of the type string, null given, called in %s on line %d and defined in %s(%d) : runtime-created function on line %d |
|||
@ -1,16 +0,0 @@ |
|||
--TEST-- |
|||
Parameter type hint - Testing in function inside function |
|||
--FILE-- |
|||
<?php |
|||
|
|||
function a() { |
|||
function b(real $c) { |
|||
} |
|||
return b(1); |
|||
} |
|||
|
|||
a(); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
Catchable fatal error: Argument 1 passed to b() must be of the type double, integer given, called in %s on line %d and defined in %s on line %d |
|||
@ -1,19 +0,0 @@ |
|||
--TEST-- |
|||
Parameter type hint - Testing with call_user_func() |
|||
--FILE-- |
|||
<?php |
|||
|
|||
function test(bool $b) { |
|||
print "ok\n"; |
|||
} |
|||
|
|||
call_user_func('test', true); |
|||
call_user_func('test', false); |
|||
call_user_func('test', NULL); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
ok |
|||
ok |
|||
|
|||
Catchable fatal error: Argument 1 passed to test() must be of the type boolean, null given in %s on line %d |
|||
@ -1,37 +0,0 @@ |
|||
--TEST-- |
|||
Parameter type hint - scalar type hints |
|||
--FILE-- |
|||
<?php |
|||
|
|||
function x($error, $msg) { var_dump($msg); } |
|||
set_error_handler('x', E_RECOVERABLE_ERROR); |
|||
|
|||
function foo(scalar $param) { var_dump($param); } |
|||
|
|||
foo(1); |
|||
foo(true); |
|||
foo(NULL); |
|||
foo(array(1)); |
|||
foo("foo"); |
|||
foo(111.222); |
|||
foo(new Stdclass); |
|||
foo(tmpfile()); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
int(1) |
|||
bool(true) |
|||
string(%d) "Argument 1 passed to foo() must be of the type scalar, null given, called in %s on line %d and defined" |
|||
NULL |
|||
string(%d) "Argument 1 passed to foo() must be of the type scalar, array given, called in %s on line %d and defined" |
|||
array(1) { |
|||
[0]=> |
|||
int(1) |
|||
} |
|||
string(3) "foo" |
|||
float(111.222) |
|||
string(%d) "Argument 1 passed to foo() must be of the type scalar, object given, called in %s on line %d and defined" |
|||
object(stdClass)#1 (0) { |
|||
} |
|||
string(%d) "Argument 1 passed to foo() must be of the type scalar, resource given, called in %s on line %d and defined" |
|||
resource(4) of type (stream) |
|||
@ -1,46 +0,0 @@ |
|||
--TEST-- |
|||
Parameter type hint - numeric type hints |
|||
--FILE-- |
|||
<?php |
|||
|
|||
function x($error, $msg) { var_dump($msg); } |
|||
set_error_handler('x', E_RECOVERABLE_ERROR); |
|||
|
|||
function foo(numeric $param) { var_dump($param); } |
|||
|
|||
foo(1); |
|||
foo(true); |
|||
foo(NULL); |
|||
foo(array(1)); |
|||
foo("foo"); |
|||
foo("123.33"); |
|||
foo("123"); |
|||
foo(""); |
|||
foo(111.222); |
|||
foo(new Stdclass); |
|||
foo(tmpfile()); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
int(1) |
|||
string(%d) "Argument 1 passed to foo() must be of the type numeric, boolean given, called in %s on line %d and defined" |
|||
bool(true) |
|||
string(%d) "Argument 1 passed to foo() must be of the type numeric, null given, called in %s on line %d and defined" |
|||
NULL |
|||
string(%d) "Argument 1 passed to foo() must be of the type numeric, array given, called in %s on line %d and defined" |
|||
array(1) { |
|||
[0]=> |
|||
int(1) |
|||
} |
|||
string(%d) "Argument 1 passed to foo() must be of the type numeric, string given, called in %s on line %d and defined" |
|||
string(3) "foo" |
|||
string(6) "123.33" |
|||
string(3) "123" |
|||
string(%d) "Argument 1 passed to foo() must be of the type numeric, string given, called in %s on line %d and defined" |
|||
string(0) "" |
|||
float(111.222) |
|||
string(%d) "Argument 1 passed to foo() must be of the type numeric, object given, called in %s on line %d and defined" |
|||
object(stdClass)#1 (0) { |
|||
} |
|||
string(%d) "Argument 1 passed to foo() must be of the type numeric, resource given, called in %s on line %d and defined" |
|||
resource(4) of type (stream) |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue