foreach ($functions as $type => $function) {
echo "Testing $type:", PHP_EOL;
- var_dump($function());
+ try {
+ var_dump($function());
+ } catch (TypeException $e) {
+ echo "*** Caught " . $e->getMessage() . PHP_EOL;
+ }
}
+echo PHP_EOL . "Done";
--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
+*** Caught Argument 1 passed to {closure}() must be of the type integer, none given, called in %s on line %d and defined in %s on line %d
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
+*** Caught Argument 1 passed to {closure}() must be of the type float, none given, called in %s on line %d and defined in %s on line %d
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
+*** Caught Argument 1 passed to {closure}() must be of the type string, none given, called in %s on line %d and defined in %s on line %d
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
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, none given, called in %s on line %d and defined in %s on line %d
Testing int nullable:
NULL
Testing float nullable:
NULL
Testing bool nullable:
NULL
+
+Done
\ No newline at end of file
foreach ($functions as $type => $function) {
echo "Testing $type:", PHP_EOL;
- var_dump($function(NULL));
+ try {
+ var_dump($function(null));
+ } catch (TypeException $e) {
+ echo "*** Caught " . $e->getMessage() . PHP_EOL;
+ }
}
+
+echo PHP_EOL . "Done";
+?>
--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
+*** Caught Argument 1 passed to {closure}() must be of the type integer, null given, called in %s on line %d and defined in %s on line %d
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
+*** Caught Argument 1 passed to {closure}() must be of the type float, null given, called in %s on line %d and defined in %s on line %d
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
+*** Caught Argument 1 passed to {closure}() must be of the type string, null given, called in %s on line %d and defined in %s on line %d
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
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, null given, called in %s on line %d and defined in %s on line %d
Testing int nullable:
NULL
Testing float nullable:
NULL
Testing bool nullable:
NULL
+
+Done
\ No newline at end of file
foreach ($values as $value) {
echo "*** Trying ";
var_dump($value);
- var_dump($function($value));
+ try {
+ var_dump($function($value));
+ } catch (TypeException $e) {
+ echo "*** Caught " . $e->getMessage() . PHP_EOL;
+ }
}
}
---EXPECTF--
+echo PHP_EOL . "Done";
+?>
+--EXPECTF--
Testing 'int' typehint:
*** Trying int(1)
int(1)
E_NOTICE: A non well formed numeric value encountered on line %d
int(1)
*** Trying string(1) "a"
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type integer, string returned on line %d
-string(1) "a"
+*** Caught Return value of {closure}() must be of the type integer, string returned in %s on line %d
*** Trying string(0) ""
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type integer, string returned on line %d
-string(0) ""
-*** Trying int(%d)
-int(%d)
+*** Caught Return value of {closure}() must be of the type integer, string returned in %s on line %d
+*** Trying int(9223372036854775807)
+int(9223372036854775807)
*** Trying float(NAN)
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type integer, float returned on line %d
-float(NAN)
+*** Caught Return value of {closure}() must be of the type integer, float returned in %s on line %d
*** Trying bool(true)
int(1)
*** Trying bool(false)
int(0)
*** Trying NULL
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type integer, null returned on line %d
-NULL
+*** Caught Return value of {closure}() must be of the type integer, null returned in %s on line %d
*** Trying array(0) {
}
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type integer, array returned on line %d
-array(0) {
+*** Caught Return value of {closure}() must be of the type integer, array returned in %s on line %d
+*** Trying object(stdClass)#6 (0) {
}
-*** Trying object(stdClass)#%s (0) {
+*** Caught Return value of {closure}() must be of the type integer, object returned in %s on line %d
+*** Trying object(Stringable)#7 (0) {
}
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type integer, object returned on line %d
-object(stdClass)#%s (0) {
-}
-*** Trying object(Stringable)#%s (0) {
-}
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type integer, object returned on line %d
-object(Stringable)#%s (0) {
-}
-*** Trying resource(%d) of type (stream)
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type integer, resource returned on line %d
-resource(%d) of type (stream)
+*** Caught Return value of {closure}() must be of the type integer, object returned in %s on line %d
+*** Trying resource(5) of type (stream)
+*** Caught Return value of {closure}() must be of the type integer, resource returned in %s on line %d
Testing 'float' typehint:
*** Trying int(1)
E_NOTICE: A non well formed numeric value encountered on line %d
float(1)
*** Trying string(1) "a"
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type float, string returned on line %d
-string(1) "a"
+*** Caught Return value of {closure}() must be of the type float, string returned in %s on line %d
*** Trying string(0) ""
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type float, string returned on line %d
-string(0) ""
-*** Trying int(%d)
-float(%s)
+*** Caught Return value of {closure}() must be of the type float, string returned in %s on line %d
+*** Trying int(9223372036854775807)
+float(9.2233720368548E+18)
*** Trying float(NAN)
float(NAN)
*** Trying bool(true)
*** Trying bool(false)
float(0)
*** Trying NULL
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type float, null returned on line %d
-NULL
+*** Caught Return value of {closure}() must be of the type float, null returned in %s on line %d
*** Trying array(0) {
}
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type float, array returned on line %d
-array(0) {
+*** Caught Return value of {closure}() must be of the type float, array returned in %s on line %d
+*** Trying object(stdClass)#6 (0) {
}
-*** Trying object(stdClass)#%s (0) {
+*** Caught Return value of {closure}() must be of the type float, object returned in %s on line %d
+*** Trying object(Stringable)#7 (0) {
}
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type float, object returned on line %d
-object(stdClass)#%s (0) {
-}
-*** Trying object(Stringable)#%s (0) {
-}
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type float, object returned on line %d
-object(Stringable)#%s (0) {
-}
-*** Trying resource(%d) of type (stream)
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type float, resource returned on line %d
-resource(%d) of type (stream)
+*** Caught Return value of {closure}() must be of the type float, object returned in %s on line %d
+*** Trying resource(5) of type (stream)
+*** Caught Return value of {closure}() must be of the type float, resource returned in %s on line %d
Testing 'string' typehint:
*** Trying int(1)
string(1) "a"
*** Trying string(0) ""
string(0) ""
-*** Trying int(%d)
-string(%d) "%d"
+*** Trying int(9223372036854775807)
+string(19) "9223372036854775807"
*** Trying float(NAN)
string(3) "NAN"
*** Trying bool(true)
*** Trying bool(false)
string(0) ""
*** Trying NULL
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type string, null returned on line %d
-NULL
+*** Caught Return value of {closure}() must be of the type string, null returned in %s on line %d
*** Trying array(0) {
}
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type string, array returned on line %d
-array(0) {
-}
-*** Trying object(stdClass)#%s (0) {
-}
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type string, object returned on line %d
-object(stdClass)#%s (0) {
+*** Caught Return value of {closure}() must be of the type string, array returned in %s on line %d
+*** Trying object(stdClass)#6 (0) {
}
-*** Trying object(Stringable)#%s (0) {
+*** Caught Return value of {closure}() must be of the type string, object returned in %s on line %d
+*** Trying object(Stringable)#7 (0) {
}
string(6) "foobar"
-*** Trying resource(%d) of type (stream)
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type string, resource returned on line %d
-resource(%d) of type (stream)
+*** Trying resource(5) of type (stream)
+*** Caught Return value of {closure}() must be of the type string, resource returned in %s on line %d
Testing 'bool' typehint:
*** Trying int(1)
bool(true)
*** Trying string(0) ""
bool(false)
-*** Trying int(%d)
+*** Trying int(9223372036854775807)
bool(true)
*** Trying float(NAN)
bool(true)
*** Trying bool(false)
bool(false)
*** Trying NULL
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type boolean, null returned on line %d
-NULL
+*** Caught Return value of {closure}() must be of the type boolean, null returned in %s on line %d
*** Trying array(0) {
}
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type boolean, array returned on line %d
-array(0) {
+*** Caught Return value of {closure}() must be of the type boolean, array returned in %s on line %d
+*** Trying object(stdClass)#6 (0) {
}
-*** Trying object(stdClass)#%s (0) {
+*** Caught Return value of {closure}() must be of the type boolean, object returned in %s on line %d
+*** Trying object(Stringable)#7 (0) {
}
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type boolean, object returned on line %d
-object(stdClass)#%s (0) {
-}
-*** Trying object(Stringable)#%s (0) {
-}
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type boolean, object returned on line %d
-object(Stringable)#%s (0) {
-}
-*** Trying resource(%d) of type (stream)
-E_RECOVERABLE_ERROR: Return value of {closure}() must be of the type boolean, resource returned on line %d
-resource(%d) of type (stream)
+*** Caught Return value of {closure}() must be of the type boolean, object returned in %s on line %d
+*** Trying resource(5) of type (stream)
+*** Caught Return value of {closure}() must be of the type boolean, resource returned in %s on line %d
+
+Done
\ No newline at end of file
foreach ($functions as $type => $function) {
echo PHP_EOL, "Testing '$type' typehint:", PHP_EOL;
foreach ($values as $value) {
- echo "*** Trying ";
+ echo PHP_EOL . "*** Trying ";
var_dump($value);
- var_dump($function($value));
+ try {
+ var_dump($function($value));
+ } catch (TypeException $e) {
+ echo "*** Caught " . $e->getMessage() . PHP_EOL;
+ }
}
}
---EXPECTF--
+echo PHP_EOL . "Done";
+?>
+--EXPECTF--
Testing 'int' typehint:
+
*** Trying int(1)
int(1)
+
*** Trying string(1) "1"
-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) "1"
+*** Caught Argument 1 passed to {closure}() must be of the type integer, string given, called in %s on line %d and defined in %s on line %d
+
*** Trying float(1)
-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(1)
+*** Caught Argument 1 passed to {closure}() must be of the type integer, float given, called in %s on line %d and defined in %s on line %d
+
*** Trying float(1.5)
-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(1.5)
+*** Caught Argument 1 passed to {closure}() must be of the type integer, float given, called in %s on line %d and defined in %s on line %d
+
*** Trying string(2) "1a"
-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(2) "1a"
+*** Caught Argument 1 passed to {closure}() must be of the type integer, string given, called in %s on line %d and defined in %s on line %d
+
*** 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"
+*** Caught Argument 1 passed to {closure}() must be of the type integer, string given, called in %s on line %d and defined in %s on line %d
+
*** 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) ""
+*** Caught Argument 1 passed to {closure}() must be of the type integer, string given, called in %s on line %d and defined in %s on line %d
+
*** Trying int(9223372036854775807)
int(9223372036854775807)
+
*** 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)
+*** Caught Argument 1 passed to {closure}() must be of the type integer, float given, called in %s on line %d and defined in %s on line %d
+
*** Trying bool(true)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, boolean given, called in %s on line %d and defined on line %d
-bool(true)
+*** Caught Argument 1 passed to {closure}() must be of the type integer, boolean given, called in %s on line %d and defined in %s on line %d
+
*** Trying bool(false)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, boolean given, called in %s on line %d and defined on line %d
-bool(false)
+*** Caught Argument 1 passed to {closure}() must be of the type integer, boolean given, called in %s on line %d and defined in %s on line %d
+
*** 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
+*** Caught Argument 1 passed to {closure}() must be of the type integer, null given, called in %s on line %d and defined in %s on line %d
+
*** 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) {
-}
+*** Caught Argument 1 passed to {closure}() must be of the type integer, array given, called in %s on line %d and defined in %s on line %d
+
*** Trying object(stdClass)#6 (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)#6 (0) {
-}
+*** Caught Argument 1 passed to {closure}() must be of the type integer, object given, called in %s on line %d and defined in %s on line %d
+
*** Trying object(Stringable)#7 (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)#7 (0) {
-}
+*** Caught Argument 1 passed to {closure}() must be of the type integer, object given, called in %s on line %d and defined in %s on line %d
+
*** Trying resource(5) 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(5) of type (stream)
+*** Caught Argument 1 passed to {closure}() must be of the type integer, resource given, called in %s on line %d and defined in %s on line %d
Testing 'float' typehint:
+
*** Trying int(1)
float(1)
+
*** Trying string(1) "1"
-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) "1"
+*** Caught Argument 1 passed to {closure}() must be of the type float, string given, called in %s on line %d and defined in %s on line %d
+
*** Trying float(1)
float(1)
+
*** Trying float(1.5)
float(1.5)
+
*** Trying string(2) "1a"
-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(2) "1a"
+*** Caught Argument 1 passed to {closure}() must be of the type float, string given, called in %s on line %d and defined in %s on line %d
+
*** 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"
+*** Caught Argument 1 passed to {closure}() must be of the type float, string given, called in %s on line %d and defined in %s on line %d
+
*** 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) ""
+*** Caught Argument 1 passed to {closure}() must be of the type float, string given, called in %s on line %d and defined in %s on line %d
+
*** Trying int(9223372036854775807)
float(9.2233720368548E+18)
+
*** Trying float(NAN)
float(NAN)
+
*** Trying bool(true)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, boolean given, called in %s on line %d and defined on line %d
-bool(true)
+*** Caught Argument 1 passed to {closure}() must be of the type float, boolean given, called in %s on line %d and defined in %s on line %d
+
*** Trying bool(false)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, boolean given, called in %s on line %d and defined on line %d
-bool(false)
+*** Caught Argument 1 passed to {closure}() must be of the type float, boolean given, called in %s on line %d and defined in %s on line %d
+
*** 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
+*** Caught Argument 1 passed to {closure}() must be of the type float, null given, called in %s on line %d and defined in %s on line %d
+
*** 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) {
-}
+*** Caught Argument 1 passed to {closure}() must be of the type float, array given, called in %s on line %d and defined in %s on line %d
+
*** Trying object(stdClass)#6 (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)#6 (0) {
-}
+*** Caught Argument 1 passed to {closure}() must be of the type float, object given, called in %s on line %d and defined in %s on line %d
+
*** Trying object(Stringable)#7 (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)#7 (0) {
-}
+*** Caught Argument 1 passed to {closure}() must be of the type float, object given, called in %s on line %d and defined in %s on line %d
+
*** Trying resource(5) 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(5) of type (stream)
+*** Caught Argument 1 passed to {closure}() must be of the type float, resource given, called in %s on line %d and defined in %s on line %d
Testing 'string' typehint:
+
*** Trying int(1)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, integer given, called in %s on line %d and defined on line %d
-int(1)
+*** Caught Argument 1 passed to {closure}() must be of the type string, integer given, called in %s on line %d and defined in %s on line %d
+
*** Trying string(1) "1"
string(1) "1"
+
*** Trying float(1)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, float given, called in %s on line %d and defined on line %d
-float(1)
+*** Caught Argument 1 passed to {closure}() must be of the type string, float given, called in %s on line %d and defined in %s on line %d
+
*** Trying float(1.5)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, float given, called in %s on line %d and defined on line %d
-float(1.5)
+*** Caught Argument 1 passed to {closure}() must be of the type string, float given, called in %s on line %d and defined in %s on line %d
+
*** Trying string(2) "1a"
string(2) "1a"
+
*** Trying string(1) "a"
string(1) "a"
+
*** Trying string(0) ""
string(0) ""
+
*** Trying int(9223372036854775807)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, integer given, called in %s on line %d and defined on line %d
-int(9223372036854775807)
+*** Caught Argument 1 passed to {closure}() must be of the type string, integer given, called in %s on line %d and defined in %s on line %d
+
*** Trying float(NAN)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, float given, called in %s on line %d and defined on line %d
-float(NAN)
+*** Caught Argument 1 passed to {closure}() must be of the type string, float given, called in %s on line %d and defined in %s on line %d
+
*** Trying bool(true)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, boolean given, called in %s on line %d and defined on line %d
-bool(true)
+*** Caught Argument 1 passed to {closure}() must be of the type string, boolean given, called in %s on line %d and defined in %s on line %d
+
*** Trying bool(false)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, boolean given, called in %s on line %d and defined on line %d
-bool(false)
+*** Caught Argument 1 passed to {closure}() must be of the type string, boolean given, called in %s on line %d and defined in %s on line %d
+
*** 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
+*** Caught Argument 1 passed to {closure}() must be of the type string, null given, called in %s on line %d and defined in %s on line %d
+
*** 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) {
-}
+*** Caught Argument 1 passed to {closure}() must be of the type string, array given, called in %s on line %d and defined in %s on line %d
+
*** Trying object(stdClass)#6 (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)#6 (0) {
-}
+*** Caught Argument 1 passed to {closure}() must be of the type string, object given, called in %s on line %d and defined in %s on line %d
+
*** Trying object(Stringable)#7 (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(Stringable)#7 (0) {
-}
+*** Caught Argument 1 passed to {closure}() must be of the type string, object given, called in %s on line %d and defined in %s on line %d
+
*** Trying resource(5) 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(5) of type (stream)
+*** Caught Argument 1 passed to {closure}() must be of the type string, resource given, called in %s on line %d and defined in %s on line %d
Testing 'bool' typehint:
+
*** Trying int(1)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, integer given, called in %s on line %d and defined on line %d
-int(1)
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, integer given, called in %s on line %d and defined in %s on line %d
+
*** Trying string(1) "1"
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, string given, called in %s on line %d and defined on line %d
-string(1) "1"
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, string given, called in %s on line %d and defined in %s on line %d
+
*** Trying float(1)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, float given, called in %s on line %d and defined on line %d
-float(1)
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, float given, called in %s on line %d and defined in %s on line %d
+
*** Trying float(1.5)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, float given, called in %s on line %d and defined on line %d
-float(1.5)
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, float given, called in %s on line %d and defined in %s on line %d
+
*** Trying string(2) "1a"
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, string given, called in %s on line %d and defined on line %d
-string(2) "1a"
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, string given, called in %s on line %d and defined in %s on line %d
+
*** Trying string(1) "a"
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, string given, called in %s on line %d and defined on line %d
-string(1) "a"
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, string given, called in %s on line %d and defined in %s on line %d
+
*** Trying string(0) ""
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, string given, called in %s on line %d and defined on line %d
-string(0) ""
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, string given, called in %s on line %d and defined in %s on line %d
+
*** Trying int(9223372036854775807)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, integer given, called in %s on line %d and defined on line %d
-int(9223372036854775807)
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, integer given, called in %s on line %d and defined in %s on line %d
+
*** Trying float(NAN)
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, float given, called in %s on line %d and defined on line %d
-float(NAN)
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, float given, called in %s on line %d and defined in %s on line %d
+
*** 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
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, null given, called in %s on line %d and defined in %s on line %d
+
*** 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) {
-}
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, array given, called in %s on line %d and defined in %s on line %d
+
*** Trying object(stdClass)#6 (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)#6 (0) {
-}
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, object given, called in %s on line %d and defined in %s on line %d
+
*** Trying object(Stringable)#7 (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)#7 (0) {
-}
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, object given, called in %s on line %d and defined in %s on line %d
+
*** Trying resource(5) 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(5) of type (stream)
\ No newline at end of file
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, resource given, called in %s on line %d and defined in %s on line %d
+
+Done
\ No newline at end of file
E_WARNING => 'E_WARNING',
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR'
];
-$errored = true;
-set_error_handler(function (int $errno, string $errmsg, string $file, int $line) use ($errnames, &$errored) {
+
+set_error_handler(function (int $errno, string $errmsg, string $file, int $line) use ($errnames) {
echo "$errnames[$errno]: $errmsg on line $line\n";
- $errored = true;
return true;
});
echo PHP_EOL, "Testing '$type' typehint:", PHP_EOL;
foreach ($values as $value) {
$errored = false;
- echo "*** Trying ", type($value), " value", PHP_EOL;
- $result = $function($value);
- if (!$errored) {
- var_dump($result);
+ echo PHP_EOL . "*** Trying ", type($value), " value", PHP_EOL;
+ try {
+ var_dump($function($value));
+ } catch (TypeException $e) {
+ echo "*** Caught " . $e->getMessage() . PHP_EOL;
}
}
}
+echo PHP_EOL . "Done";
+?>
--EXPECTF--
-
Testing 'int' typehint:
+
*** Trying integer value
int(1)
+
*** Trying float value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, float given, called in %s on line 53 and defined on line 18
+*** Caught Argument 1 passed to {closure}() must be of the type integer, float given, called in %s on line %d and defined in %s on line %d
+
*** Trying string value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, string given, called in %s on line 53 and defined on line 18
+*** Caught Argument 1 passed to {closure}() must be of the type integer, string given, called in %s on line %d and defined in %s on line %d
+
*** Trying true value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, boolean given, called in %s on line 53 and defined on line 18
+*** Caught Argument 1 passed to {closure}() must be of the type integer, boolean given, called in %s on line %d and defined in %s on line %d
+
*** Trying false value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, boolean given, called in %s on line 53 and defined on line 18
+*** Caught Argument 1 passed to {closure}() must be of the type integer, boolean given, called in %s on line %d and defined in %s on line %d
+
*** Trying null value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, null given, called in %s on line 53 and defined on line 18
+*** Caught Argument 1 passed to {closure}() must be of the type integer, null given, called in %s on line %d and defined in %s on line %d
+
*** Trying array value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, array given, called in %s on line 53 and defined on line 18
+*** Caught Argument 1 passed to {closure}() must be of the type integer, array given, called in %s on line %d and defined in %s on line %d
+
*** Trying object value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, object given, called in %s on line 53 and defined on line 18
+*** Caught Argument 1 passed to {closure}() must be of the type integer, object given, called in %s on line %d and defined in %s on line %d
+
*** Trying resource value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type integer, resource given, called in %s on line 53 and defined on line 18
+*** Caught Argument 1 passed to {closure}() must be of the type integer, resource given, called in %s on line %d and defined in %s on line %d
Testing 'float' typehint:
+
*** Trying integer value
float(1)
+
*** Trying float value
float(1)
+
*** Trying string value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, string given, called in %s on line 53 and defined on line 19
+*** Caught Argument 1 passed to {closure}() must be of the type float, string given, called in %s on line %d and defined in %s on line %d
+
*** Trying true value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, boolean given, called in %s on line 53 and defined on line 19
+*** Caught Argument 1 passed to {closure}() must be of the type float, boolean given, called in %s on line %d and defined in %s on line %d
+
*** Trying false value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, boolean given, called in %s on line 53 and defined on line 19
+*** Caught Argument 1 passed to {closure}() must be of the type float, boolean given, called in %s on line %d and defined in %s on line %d
+
*** Trying null value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, null given, called in %s on line 53 and defined on line 19
+*** Caught Argument 1 passed to {closure}() must be of the type float, null given, called in %s on line %d and defined in %s on line %d
+
*** Trying array value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, array given, called in %s on line 53 and defined on line 19
+*** Caught Argument 1 passed to {closure}() must be of the type float, array given, called in %s on line %d and defined in %s on line %d
+
*** Trying object value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, object given, called in %s on line 53 and defined on line 19
+*** Caught Argument 1 passed to {closure}() must be of the type float, object given, called in %s on line %d and defined in %s on line %d
+
*** Trying resource value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type float, resource given, called in %s on line 53 and defined on line 19
+*** Caught Argument 1 passed to {closure}() must be of the type float, resource given, called in %s on line %d and defined in %s on line %d
Testing 'string' typehint:
+
*** Trying integer value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, integer given, called in %s on line 53 and defined on line 20
+*** Caught Argument 1 passed to {closure}() must be of the type string, integer given, called in %s on line %d and defined in %s on line %d
+
*** Trying float value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, float given, called in %s on line 53 and defined on line 20
+*** Caught Argument 1 passed to {closure}() must be of the type string, float given, called in %s on line %d and defined in %s on line %d
+
*** Trying string value
string(1) "1"
+
*** Trying true value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, boolean given, called in %s on line 53 and defined on line 20
+*** Caught Argument 1 passed to {closure}() must be of the type string, boolean given, called in %s on line %d and defined in %s on line %d
+
*** Trying false value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, boolean given, called in %s on line 53 and defined on line 20
+*** Caught Argument 1 passed to {closure}() must be of the type string, boolean given, called in %s on line %d and defined in %s on line %d
+
*** Trying null value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, null given, called in %s on line 53 and defined on line 20
+*** Caught Argument 1 passed to {closure}() must be of the type string, null given, called in %s on line %d and defined in %s on line %d
+
*** Trying array value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, array given, called in %s on line 53 and defined on line 20
+*** Caught Argument 1 passed to {closure}() must be of the type string, array given, called in %s on line %d and defined in %s on line %d
+
*** Trying object value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, object given, called in %s on line 53 and defined on line 20
+*** Caught Argument 1 passed to {closure}() must be of the type string, object given, called in %s on line %d and defined in %s on line %d
+
*** Trying resource value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type string, resource given, called in %s on line 53 and defined on line 20
+*** Caught Argument 1 passed to {closure}() must be of the type string, resource given, called in %s on line %d and defined in %s on line %d
Testing 'bool' typehint:
+
*** Trying integer value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, integer given, called in %s on line 53 and defined on line 21
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, integer given, called in %s on line %d and defined in %s on line %d
+
*** Trying float value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, float given, called in %s on line 53 and defined on line 21
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, float given, called in %s on line %d and defined in %s on line %d
+
*** Trying string value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, string given, called in %s on line 53 and defined on line 21
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, string given, called in %s on line %d and defined in %s on line %d
+
*** Trying true value
bool(true)
+
*** Trying false value
bool(false)
+
*** Trying null value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, null given, called in %s on line 53 and defined on line 21
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, null given, called in %s on line %d and defined in %s on line %d
+
*** Trying array value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, array given, called in %s on line 53 and defined on line 21
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, array given, called in %s on line %d and defined in %s on line %d
+
*** Trying object value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, object given, called in %s on line 53 and defined on line 21
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, object given, called in %s on line %d and defined in %s on line %d
+
*** Trying resource value
-E_RECOVERABLE_ERROR: Argument 1 passed to {closure}() must be of the type boolean, resource given, called in %s on line 53 and defined on line 21
+*** Caught Argument 1 passed to {closure}() must be of the type boolean, resource given, called in %s on line %d and defined in %s on line %d
+
+Done
\ No newline at end of file
fclass = "";
}
- zend_type_error("Return value of %s%s%s() must %s%s, %s%s returned",
- fclass, fsep, fname, need_msg, need_kind, returned_msg, returned_kind);
+ zend_type_error("Return value of %s%s%s() must %s%s, %s%s returned in %s on line %d",
+ fclass, fsep, fname, need_msg, need_kind, returned_msg, returned_kind,
+ zf->op_array.filename->val, EG(current_execute_data)->opline->lineno);
}
#if ZEND_DEBUG