]> granicus.if.org Git - php/commitdiff
Split up "parent" test cases
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 24 May 2019 07:37:39 +0000 (09:37 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 24 May 2019 07:37:39 +0000 (09:37 +0200)
As the warnings are fatal errors in PHP 8, we can't test all of this
in a single file anymore.

Zend/tests/type_declarations/variance/parent_in_class.phpt [deleted file]
Zend/tests/type_declarations/variance/parent_in_class_failure1.phpt [new file with mode: 0644]
Zend/tests/type_declarations/variance/parent_in_class_failure2.phpt [new file with mode: 0644]
Zend/tests/type_declarations/variance/parent_in_class_success.phpt [new file with mode: 0644]

diff --git a/Zend/tests/type_declarations/variance/parent_in_class.phpt b/Zend/tests/type_declarations/variance/parent_in_class.phpt
deleted file mode 100644 (file)
index 88b711b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
---TEST--
-Use of parent inside a class that has / has no parent
---FILE--
-<?php
-
-// Illegal: A::parent is ill-defined
-class A {
-    public function method(parent $x) {}
-}
-class B extends A {
-    public function method(parent $x) {}
-}
-
-// Legal: A2::parent == P2
-class P2 {}
-class A2 extends P2 {
-    public function method(parent $x) {}
-}
-class B2 extends A2 {
-    public function method(P2 $x) {}
-}
-
-// Legal: B3::parent == A3 is subclass of A3::parent == P3 in covariant position
-class P3 {}
-class A3 extends P3 {
-    public function method($x): parent {}
-}
-class B3 extends A3 {
-    public function method($x): parent {}
-}
-
-// Illegal: B4::parent == A4 is subclass of A4::parent == P4 in contravariant position
-class P4 {}
-class A4 extends P4 {
-    public function method(parent $x) {}
-}
-class B4 extends A4 {
-    public function method(parent $x) {}
-}
-
-?>
---EXPECTF--
-Warning: Declaration of B4::method(A4 $x) should be compatible with A4::method(P4 $x) in %s on line %d
-
-Warning: Could not check compatibility between B::method(A $x) and A::method(parent $x), because class parent is not available in %s on line %d
diff --git a/Zend/tests/type_declarations/variance/parent_in_class_failure1.phpt b/Zend/tests/type_declarations/variance/parent_in_class_failure1.phpt
new file mode 100644 (file)
index 0000000..5e1f43d
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Use of parent inside a class that has / has no parent (failure case 1)
+--FILE--
+<?php
+
+// Illegal: A::parent is ill-defined
+class A {
+    public function method(parent $x) {}
+}
+class B extends A {
+    public function method(parent $x) {}
+}
+
+?>
+--EXPECTF--
+Fatal error: Could not check compatibility between B::method(A $x) and A::method(parent $x), because class parent is not available in %s on line %d
diff --git a/Zend/tests/type_declarations/variance/parent_in_class_failure2.phpt b/Zend/tests/type_declarations/variance/parent_in_class_failure2.phpt
new file mode 100644 (file)
index 0000000..f9902d8
--- /dev/null
@@ -0,0 +1,17 @@
+--TEST--
+Use of parent inside a class that has / has no parent (failure case 2)
+--FILE--
+<?php
+
+// Illegal: B4::parent == A4 is subclass of A4::parent == P4 in contravariant position
+class P4 {}
+class A4 extends P4 {
+    public function method(parent $x) {}
+}
+class B4 extends A4 {
+    public function method(parent $x) {}
+}
+
+?>
+--EXPECTF--
+Fatal error: Declaration of B4::method(A4 $x) must be compatible with A4::method(P4 $x) in %s on line %d
diff --git a/Zend/tests/type_declarations/variance/parent_in_class_success.phpt b/Zend/tests/type_declarations/variance/parent_in_class_success.phpt
new file mode 100644 (file)
index 0000000..c3edcea
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Use of parent inside a class that has / has no parent (success cases)
+--FILE--
+<?php
+
+// Legal: A2::parent == P2
+class P2 {}
+class A2 extends P2 {
+    public function method(parent $x) {}
+}
+class B2 extends A2 {
+    public function method(P2 $x) {}
+}
+
+// Legal: B3::parent == A3 is subclass of A3::parent == P3 in covariant position
+class P3 {}
+class A3 extends P3 {
+    public function method($x): parent {}
+}
+class B3 extends A3 {
+    public function method($x): parent {}
+}
+
+?>
+===DONE===
+--EXPECT--
+===DONE===