Skip to content

Commit 53a4038

Browse files
committed
Implement additional type reservations
* The class names false, true and null are now reserved. * The code dealing with reserved class names is now decoupled from scalar type hint handling. It also includes self, parent, and static, which are class names which were already reserved previously. * Reuse existing messages for reserved class names. Fallout: class_alias() can no longer alias self, parent and static. However this never really worked in the first place, as the test which was testing this shows.
1 parent 607b7d6 commit 53a4038

16 files changed

+72
-80
lines changed

Zend/tests/class_alias_003.phpt

Lines changed: 0 additions & 22 deletions
This file was deleted.

Zend/tests/typehints/scalar_relative_typehint_disallowed.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ foo(10);
1111

1212
?>
1313
--EXPECTF--
14-
Fatal error: "bar\int" cannot be used as a type declaration in %s on line %d
14+
Fatal error: Cannot use 'bar\int' as class name as it is reserved in %s on line %d

Zend/tests/typehints/scalar_reserved2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Scalar type hint names cannot be used as class, trait or interface names (2)
55

66
class int {}
77
--EXPECTF--
8-
Fatal error: "int" cannot be used as a class name in %s on line %d
8+
Fatal error: Cannot use 'int' as class name as it is reserved in %s on line %d

Zend/tests/typehints/scalar_reserved2_class_alias.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Scalar type hint names cannot be used as class, trait or interface names (2) - c
66
class foobar {}
77
class_alias("foobar", "int");
88
--EXPECTF--
9-
Fatal error: "int" cannot be used as a class name in %s on line %d
9+
Fatal error: Cannot use 'int' as class name as it is reserved in %s on line %d

Zend/tests/typehints/scalar_reserved2_use.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Scalar type hint names cannot be used as class, trait or interface names (2) - u
55

66
use foobar as int;
77
--EXPECTF--
8-
Fatal error: "int" cannot be used as a class name in %s on line %d
8+
Fatal error: Cannot use foobar as int because 'int' is a special class name in %s on line %d

Zend/tests/typehints/scalar_reserved3.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Scalar type hint names cannot be used as class, trait or interface names (3)
55

66
class float {}
77
--EXPECTF--
8-
Fatal error: "float" cannot be used as a class name in %s on line %d
8+
Fatal error: Cannot use 'float' as class name as it is reserved in %s on line %d

Zend/tests/typehints/scalar_reserved3_class_alias.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Scalar type hint names cannot be used as class, trait or interface names (3) - c
66
class foobar {}
77
class_alias("foobar", "float");
88
--EXPECTF--
9-
Fatal error: "float" cannot be used as a class name in %s on line %d
9+
Fatal error: Cannot use 'float' as class name as it is reserved in %s on line %d

Zend/tests/typehints/scalar_reserved3_use.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Scalar type hint names cannot be used as class, trait or interface names (3) - u
55

66
use foobar as float;
77
--EXPECTF--
8-
Fatal error: "float" cannot be used as a class name in %s on line %d
8+
Fatal error: Cannot use foobar as float because 'float' is a special class name in %s on line %d

Zend/tests/typehints/scalar_reserved4.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ Scalar type hint names cannot be used as class, trait or interface names (4)
55

66
class string {}
77
--EXPECTF--
8-
Fatal error: "string" cannot be used as a class name in %s on line %d
8+
Fatal error: Cannot use 'string' as class name as it is reserved in %s on line %d

Zend/tests/typehints/scalar_reserved4_class_alias.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Scalar type hint names cannot be used as class, trait or interface names (4) - c
66
class foobar {}
77
class_alias("foobar", "string");
88
--EXPECTF--
9-
Fatal error: "string" cannot be used as a class name in %s on line %d
9+
Fatal error: Cannot use 'string' as class name as it is reserved in %s on line %d

0 commit comments

Comments
 (0)