Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2ce32f9
Implemented scalar type hints according to vatriation of version 0.1 …
dstogov Feb 2, 2015
0cb6670
Merge branch 'master' into scalar_type_hints
dstogov Feb 5, 2015
11c79d6
Support for scalar return types of internal functions
dstogov Feb 5, 2015
5e8872a
Make scalar type names case insensetive.
dstogov Feb 5, 2015
54aa377
Merge branch 'master' into scalar_type_hints
dstogov Feb 10, 2015
66fd52c
Fixed use after free on the following code
dstogov Feb 10, 2015
32493fa
Add zend_dval_is_integer()
flaupretre Feb 22, 2015
2814b1d
Add temporary config file
flaupretre Feb 22, 2015
6d106c1
Add sth_run.sh
flaupretre Feb 23, 2015
df1105a
Add STH configuration parameters
flaupretre Feb 23, 2015
733383b
Add 'null' ZPP type
flaupretre Feb 23, 2015
48f872d
Add xxx_TO_BOOL restrictions
flaupretre Feb 23, 2015
7b1e7c0
Implement FLOAT_TO_INT restrictions
flaupretre Feb 23, 2015
a60dd9d
Implement NULL_TO_INT, BOOL_TO_INT
flaupretre Feb 23, 2015
8a090aa
Implement NULL_TO_FLOAT, BOOL_TO_FLOAT restrictions
flaupretre Feb 23, 2015
2c42d37
Implement NULL_TO_STRING and BOOL_TO_STRING restrictions
flaupretre Feb 24, 2015
c378991
Pre-configure ruleset according to STH RFC
flaupretre Feb 24, 2015
e3504f8
Fix typo
flaupretre Feb 24, 2015
64a4174
Merge branch 'zpp_sth' of github.com:flaupretre/php-src into test
dstogov Feb 26, 2015
6e2cc49
Merge branch 'master' into test
dstogov Feb 26, 2015
eefed72
Removed temporary files
dstogov Feb 26, 2015
3237ef0
Merge branch 'master' into scalar_type_hints
dstogov Feb 26, 2015
95d3b99
Merge branch 'scalar_type_hints' into test
dstogov Feb 26, 2015
015dcfc
Fixed merge
dstogov Feb 26, 2015
5fb59dc
Emit E_DEPRECATED only for internal functions
dstogov Feb 26, 2015
0450737
Removed outdated comments
dstogov Feb 26, 2015
4ddba49
Fixed mess between NULL and BOOL
dstogov Feb 26, 2015
818c838
Fixed coercion rules
dstogov Feb 26, 2015
b80b595
Merge branch 'master' into sth
dstogov Mar 10, 2015
919f370
Change rules:
dstogov Mar 10, 2015
e4bf417
Merge branch 'master' into sth
dstogov Mar 11, 2015
71b30f7
Disabled trailing non blank characters in string->int ans string->float
dstogov Mar 11, 2015
1cabb37
Merge branch 'master' into sth
dstogov Mar 11, 2015
3dbdfc1
Restrict string ->float on INF/NAN
dstogov Mar 11, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Zend/tests/return_types/rfc002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function answer(): int {
}

answer();

--EXPECTF--
Fatal error: Return value of answer() must be an instance of int, integer returned in %s on line %d
?>
DONE
--EXPECT--
DONE
346 changes: 346 additions & 0 deletions Zend/tests/scalar_type_hints_001.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,346 @@
--TEST--
Scalar type hints 001
--FILE--
<?php
function error($code, $msg) {
$GLOBALS["error"] = "($code): $msg";
}
set_error_handler('error');
function bool_func(bool $x) {
if (isset($GLOBALS["error"])) {
echo $GLOBALS["error"] . "\n";
unset($GLOBALS["error"]);
} else {
var_dump($x);
}
}
function check_bool($x) {
var_dump($x);
try {
bool_func($x);
} catch (EngineException $e) {
error($e->getCode(), $e->getMessage());
if (isset($GLOBALS["error"])) {
echo $GLOBALS["error"] . "\n";
unset($GLOBALS["error"]);
}
}
echo "----\n";
}
function int_func(int $x) {
if (isset($GLOBALS["error"])) {
echo $GLOBALS["error"] . "\n";
unset($GLOBALS["error"]);
} else {
var_dump($x);
}
}
function check_int($x) {
var_dump($x);
try {
int_func($x);
} catch (EngineException $e) {
error($e->getCode(), $e->getMessage());
if (isset($GLOBALS["error"])) {
echo $GLOBALS["error"] . "\n";
unset($GLOBALS["error"]);
}
}
echo "----\n";
}
function float_func(float $x) {
if (isset($GLOBALS["error"])) {
echo $GLOBALS["error"] . "\n";
unset($GLOBALS["error"]);
} else {
var_dump($x);
}
}
function check_float($x) {
var_dump($x);
try {
float_func($x);
} catch (EngineException $e) {
error($e->getCode(), $e->getMessage());
if (isset($GLOBALS["error"])) {
echo $GLOBALS["error"] . "\n";
unset($GLOBALS["error"]);
}
}
echo "----\n";
}
function string_func(string $x) {
if (isset($GLOBALS["error"])) {
echo $GLOBALS["error"] . "\n";
unset($GLOBALS["error"]);
} else {
var_dump($x);
}
}
function check_string($x) {
var_dump($x);
try {
string_func($x);
} catch (EngineException $e) {
error($e->getCode(), $e->getMessage());
if (isset($GLOBALS["error"])) {
echo $GLOBALS["error"] . "\n";
unset($GLOBALS["error"]);
}
}
echo "----\n";
}

echo "== bool ==\n";
check_bool(null);
check_bool(false);
check_bool(true);
check_bool(0);
check_bool(1);
check_bool(2);
check_bool(0.0);
check_bool(1.0);
check_bool(0.2);
check_bool("");
check_bool("0");
check_bool("1");
check_bool(" 0");
check_bool("0 ");
check_bool("0d");
check_bool(" 1");
check_bool("1 ");
check_bool("1d");

echo "== int ==\n";
check_int(null);
check_int(false);
check_int(true);
check_int(0);
check_int(1);
check_int(0.0);
check_int(1.0);
check_int(0.2);
check_int("");
check_int("0");
check_int("1");
check_int(" 1");
check_int("1 ");
check_int("1d");
check_int("1111111111111111111111111111111111111");
check_int("1.0");
check_int("1.1");

echo "== float ==\n";
check_float(null);
check_float(false);
check_float(true);
check_float(0);
check_float(1);
check_float(0.0);
check_float(1.1);
check_float("");
check_float("0");
check_float("1");
check_float(" 1");
check_float("1 ");
check_float("1d");
check_float("1111111111111111111111111111111111111");
check_float("1E+3600");
check_float("1.0");
check_float("1.1");

echo "== string ==\n";
check_string(null);
check_string(false);
check_string(true);
check_string(0);
check_string(1);
check_string(0.0);
check_string(1.0);
check_string(1.1);
?>
--EXPECTF--
== bool ==
NULL
(1): Argument 1 passed to bool_func() must be of the type boolean, null given, called in %s on line %d and defined
----
bool(false)
bool(false)
----
bool(true)
bool(true)
----
int(0)
bool(false)
----
int(1)
bool(true)
----
int(2)
bool(true)
----
float(0)
(1): Argument 1 passed to bool_func() must be of the type boolean, float given, called in %s on line %d and defined
----
float(1)
(1): Argument 1 passed to bool_func() must be of the type boolean, float given, called in %s on line %d and defined
----
float(0.2)
(1): Argument 1 passed to bool_func() must be of the type boolean, float given, called in %s on line %d and defined
----
string(0) ""
bool(false)
----
string(1) "0"
bool(false)
----
string(1) "1"
bool(true)
----
string(2) " 0"
bool(true)
----
string(2) "0 "
bool(true)
----
string(2) "0d"
bool(true)
----
string(2) " 1"
bool(true)
----
string(2) "1 "
bool(true)
----
string(2) "1d"
bool(true)
----
== int ==
NULL
(1): Argument 1 passed to int_func() must be of the type integer, null given, called in %s on line %d and defined
----
bool(false)
(1): Argument 1 passed to int_func() must be of the type integer, boolean given, called in %s on line %d and defined
----
bool(true)
(1): Argument 1 passed to int_func() must be of the type integer, boolean given, called in %s on line %d and defined
----
int(0)
int(0)
----
int(1)
int(1)
----
float(0)
int(0)
----
float(1)
int(1)
----
float(0.2)
(1): Argument 1 passed to int_func() must be of the type integer, float given, called in %s on line %d and defined
----
string(0) ""
(1): Argument 1 passed to int_func() must be of the type integer, string given, called in %s on line %d and defined
----
string(1) "0"
int(0)
----
string(1) "1"
int(1)
----
string(2) " 1"
int(1)
----
string(2) "1 "
(8): A non well formed numeric value encountered
----
string(2) "1d"
(1): Argument 1 passed to int_func() must be of the type integer, string given, called in %s on line %d and defined
----
string(37) "1111111111111111111111111111111111111"
(1): Argument 1 passed to int_func() must be of the type integer, string given, called in %s on line %d and defined
----
string(3) "1.0"
int(1)
----
string(3) "1.1"
(1): Argument 1 passed to int_func() must be of the type integer, string given, called in %s on line %d and defined
----
== float ==
NULL
(1): Argument 1 passed to float_func() must be of the type float, null given, called in %s on line %d and defined
----
bool(false)
(1): Argument 1 passed to float_func() must be of the type float, boolean given, called in %s on line %d and defined
----
bool(true)
(1): Argument 1 passed to float_func() must be of the type float, boolean given, called in %s on line %d and defined
----
int(0)
float(0)
----
int(1)
float(1)
----
float(0)
float(0)
----
float(1.1)
float(1.1)
----
string(0) ""
(1): Argument 1 passed to float_func() must be of the type float, string given, called in %s on line %d and defined
----
string(1) "0"
float(0)
----
string(1) "1"
float(1)
----
string(2) " 1"
float(1)
----
string(2) "1 "
(8): A non well formed numeric value encountered
----
string(2) "1d"
(1): Argument 1 passed to float_func() must be of the type float, string given, called in %s on line %d and defined
----
string(37) "1111111111111111111111111111111111111"
float(1.1111111111111E+36)
----
string(7) "1E+3600"
(1): Argument 1 passed to float_func() must be of the type float, string given, called in %s on line %d and defined
----
string(3) "1.0"
float(1)
----
string(3) "1.1"
float(1.1)
----
== string ==
NULL
(1): Argument 1 passed to string_func() must be of the type string, null given, called in %s on line %d and defined
----
bool(false)
(1): Argument 1 passed to string_func() must be of the type string, boolean given, called in %s on line %d and defined
----
bool(true)
(1): Argument 1 passed to string_func() must be of the type string, boolean given, called in %s on line %d and defined
----
int(0)
string(1) "0"
----
int(1)
string(1) "1"
----
float(0)
string(1) "0"
----
float(1)
string(1) "1"
----
float(1.1)
string(3) "1.1"
----
Loading