Skip to content

Commit e41b7f6

Browse files
committed
Deprecate (real) cast
1 parent 46b9824 commit e41b7f6

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

Zend/tests/real_cast_deprecation.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
The (real) cast is deprecated
3+
--FILE--
4+
<?php
5+
6+
var_dump((real) 42);
7+
8+
?>
9+
--EXPECTF--
10+
Deprecated: The (real) cast is deprecated, use (float) instead in %s on line %d
11+
float(42)

Zend/zend_language_scanner.l

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,14 @@ NEWLINE ("\r"|"\n"|"\r\n")
14811481
RETURN_TOKEN(T_INT_CAST);
14821482
}
14831483

1484-
<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("real"|"double"|"float"){TABS_AND_SPACES}")" {
1484+
<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("double"|"float"){TABS_AND_SPACES}")" {
1485+
RETURN_TOKEN(T_DOUBLE_CAST);
1486+
}
1487+
1488+
<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}"real"{TABS_AND_SPACES}")" {
1489+
if (PARSER_MODE()) {
1490+
zend_error(E_DEPRECATED, "The (real) cast is deprecated, use (float) instead");
1491+
}
14851492
RETURN_TOKEN(T_DOUBLE_CAST);
14861493
}
14871494

ext/standard/tests/network/bug76755.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Bug #76755 (setcookie does not accept "double" type for expire time)
33
--FILE--
44
<?php
5-
var_dump(setcookie('name', 'value', (real)(time() + 1296000)));
5+
var_dump(setcookie('name', 'value', (float)(time() + 1296000)));
66
?>
77
--EXPECT--
88
bool(true)

0 commit comments

Comments
 (0)