diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-05-24 09:37:39 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-05-24 09:37:39 +0200 |
commit | 299cf7e78a39fb6789c73dfe2e372f9cc55b83bb (patch) | |
tree | a448708407b73a9f1174bb7580a4080a3f3324df /Zend | |
parent | e06ec226bc661acbf4d705e5bf02a11690b31baa (diff) | |
download | php-git-299cf7e78a39fb6789c73dfe2e372f9cc55b83bb.tar.gz |
Split up "parent" test cases
As the warnings are fatal errors in PHP 8, we can't test all of this
in a single file anymore.
Diffstat (limited to 'Zend')
4 files changed, 60 insertions, 45 deletions
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 index 88b711bddd..0000000000 --- a/Zend/tests/type_declarations/variance/parent_in_class.phpt +++ /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 index 0000000000..5e1f43d875 --- /dev/null +++ b/Zend/tests/type_declarations/variance/parent_in_class_failure1.phpt @@ -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 index 0000000000..f9902d8073 --- /dev/null +++ b/Zend/tests/type_declarations/variance/parent_in_class_failure2.phpt @@ -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 index 0000000000..c3edceaf3b --- /dev/null +++ b/Zend/tests/type_declarations/variance/parent_in_class_success.phpt @@ -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=== |