Commit 9c86e0433cf for php
commit 9c86e0433cffef5584a24a9ad33512ab96a15a89
Author: Gina Peter Banyard <girgias@php.net>
Date: Fri Nov 13 23:46:33 2026 +0000
tests: remove type declaration tests from tests/ folder (#25382)
This feature has more extensive tests in `Zend/tests/type_declarations/`.
diff --git a/tests/classes/type_hinting_001.phpt b/tests/classes/type_hinting_001.phpt
deleted file mode 100644
index f1c1973cf3d..00000000000
--- a/tests/classes/type_hinting_001.phpt
+++ /dev/null
@@ -1,39 +0,0 @@
---TEST--
-ZE2 class type hinting
---FILE--
-<?php
-
-interface Foo {
- function a(Foo $foo);
-}
-
-interface Bar {
- function b(Bar $bar);
-}
-
-class FooBar implements Foo, Bar {
- function a(Foo $foo) {
- // ...
- }
-
- function b(Bar $bar) {
- // ...
- }
-}
-
-class Blort {
-}
-
-$a = new FooBar;
-$b = new Blort;
-
-$a->a($b);
-$a->b($b);
-
-?>
---EXPECTF--
-Fatal error: Uncaught TypeError: FooBar::a(): Argument #1 ($foo) must be of type Foo, Blort given, called in %s on line 27 and defined in %s:12
-Stack trace:
-#0 %s(%d): FooBar->a(Object(Blort))
-#1 {main}
- thrown in %s on line 12
diff --git a/tests/classes/type_hinting_002.phpt b/tests/classes/type_hinting_002.phpt
deleted file mode 100644
index 765de66bab0..00000000000
--- a/tests/classes/type_hinting_002.phpt
+++ /dev/null
@@ -1,18 +0,0 @@
---TEST--
-ZE2 class type hinting non existing class
---FILE--
-<?php
-
-class Foo {
- function a(NonExisting $foo) {}
-}
-
-$o = new Foo;
-$o->a($o);
-?>
---EXPECTF--
-Fatal error: Uncaught TypeError: Foo::a(): Argument #1 ($foo) must be of type NonExisting, Foo given, called in %s on line %d and defined in %s:%d
-Stack trace:
-#0 %s(%d): Foo->a(Object(Foo))
-#1 {main}
- thrown in %s on line %d
diff --git a/tests/classes/type_hinting_003.phpt b/tests/classes/type_hinting_003.phpt
deleted file mode 100644
index 1c1f687c2c0..00000000000
--- a/tests/classes/type_hinting_003.phpt
+++ /dev/null
@@ -1,65 +0,0 @@
---TEST--
-ZE2 class type hinting with arrays
---FILE--
-<?php
-
-class Test
-{
- static function f1(array $ar)
- {
- echo __METHOD__ . "()\n";
- var_dump($ar);
- }
-
- static function f2(array $ar = NULL)
- {
- echo __METHOD__ . "()\n";
- var_dump($ar);
- }
-
- static function f3(array $ar = array())
- {
- echo __METHOD__ . "()\n";
- var_dump($ar);
- }
-
- static function f4(array $ar = array(25))
- {
- echo __METHOD__ . "()\n";
- var_dump($ar);
- }
-}
-
-Test::f1(array(42));
-Test::f2(NULL);
-Test::f2();
-Test::f3();
-Test::f4();
-Test::f1(1);
-
-?>
---EXPECTF--
-Deprecated: Test::f2(): Implicitly marking parameter $ar as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
-Test::f1()
-array(1) {
- [0]=>
- int(42)
-}
-Test::f2()
-NULL
-Test::f2()
-NULL
-Test::f3()
-array(0) {
-}
-Test::f4()
-array(1) {
- [0]=>
- int(25)
-}
-
-Fatal error: Uncaught TypeError: Test::f1(): Argument #1 ($ar) must be of type array, int given, called in %s on line %d and defined in %s:%d
-Stack trace:
-#0 %s(%d): Test::f1(1)
-#1 {main}
- thrown in %s on line %d
diff --git a/tests/classes/type_hinting_004.phpt b/tests/classes/type_hinting_004.phpt
deleted file mode 100644
index 99c11ebbade..00000000000
--- a/tests/classes/type_hinting_004.phpt
+++ /dev/null
@@ -1,175 +0,0 @@
---TEST--
-Ensure type hints are enforced for functions invoked as callbacks.
---FILE--
-<?php
-
- echo "---> Type hints with callback function:\n";
- class A { }
- function f1(A $a) {
- echo "in f1;\n";
- }
- function f2(A $a = null) {
- echo "in f2;\n";
- }
- try {
- call_user_func('f1', 1);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func('f1', new A);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func('f2', 1);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func('f2');
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func('f2', new A);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func('f2', null);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
-
- echo "\n\n---> Type hints with callback static method:\n";
- class C {
- static function f1(A $a) {
- if (isset($this)) {
- echo "in C::f1 (instance);\n";
- } else {
- echo "in C::f1 (static);\n";
- }
- }
- static function f2(A $a = null) {
- if (isset($this)) {
- echo "in C::f2 (instance);\n";
- } else {
- echo "in C::f2 (static);\n";
- }
- }
- }
-
- try {
- call_user_func(array('C', 'f1'), 1);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func(array('C', 'f1'), new A);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func(array('C', 'f2'), 1);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func(array('C', 'f2'));
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func(array('C', 'f2'), new A);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func(array('C', 'f2'), null);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
-
- echo "\n\n---> Type hints with callback instance method:\n";
- class D {
- function f1(A $a) {
- if (isset($this)) {
- echo "in C::f1 (instance);\n";
- } else {
- echo "in C::f1 (static);\n";
- }
- }
- function f2(A $a = null) {
- if (isset($this)) {
- echo "in C::f2 (instance);\n";
- } else {
- echo "in C::f2 (static);\n";
- }
- }
- }
- $d = new D;
-
- try {
- call_user_func(array($d, 'f1'), 1);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func(array($d, 'f1'), new A);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func(array($d, 'f2'), 1);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func(array($d, 'f2'));
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func(array($d, 'f2'), new A);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
- try {
- call_user_func(array($d, 'f2'), null);
- } catch (Error $ex) {
- echo $ex::class, ': ', $ex->getCode(), ': ', $ex->getMessage(), ' in ', $ex->getFile(), ' on line ', $ex->getLine(), "\n";
- }
-
-?>
---EXPECTF--
-Deprecated: f2(): Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
-
-Deprecated: C::f2(): Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
-
-Deprecated: D::f2(): Implicitly marking parameter $a as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
----> Type hints with callback function:
-TypeError: 0: f1(): Argument #1 ($a) must be of type A, int given%s in %s on line %d
-in f1;
-TypeError: 0: f2(): Argument #1 ($a) must be of type ?A, int given%s in %s on line %d
-in f2;
-in f2;
-in f2;
-
-
----> Type hints with callback static method:
-TypeError: 0: C::f1(): Argument #1 ($a) must be of type A, int given%s in %s on line %d
-in C::f1 (static);
-TypeError: 0: C::f2(): Argument #1 ($a) must be of type ?A, int given%s in %s on line %d
-in C::f2 (static);
-in C::f2 (static);
-in C::f2 (static);
-
-
----> Type hints with callback instance method:
-TypeError: 0: D::f1(): Argument #1 ($a) must be of type A, int given%s in %s on line %d
-in C::f1 (instance);
-TypeError: 0: D::f2(): Argument #1 ($a) must be of type ?A, int given%s in %s on line %d
-in C::f2 (instance);
-in C::f2 (instance);
-in C::f2 (instance);
diff --git a/tests/classes/type_hinting_005a.phpt b/tests/classes/type_hinting_005a.phpt
deleted file mode 100644
index 065ba70e8a5..00000000000
--- a/tests/classes/type_hinting_005a.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-Check type hint compatibility in overrides with array hints.
---FILE--
-<?php
-Class C { function f(array $a) {} }
-
-// Compatible hint.
-Class D1 extends C { function f(array $a) {} }
-
-// Class hint, should be array.
-Class D2 extends C { function f(SomeClass $a) {} }
-?>
---EXPECTF--
-Fatal error: Declaration of D2::f(SomeClass $a) must be compatible with C::f(array $a) in %s on line 8
diff --git a/tests/classes/type_hinting_005c.phpt b/tests/classes/type_hinting_005c.phpt
deleted file mode 100644
index 6cc3e3e369e..00000000000
--- a/tests/classes/type_hinting_005c.phpt
+++ /dev/null
@@ -1,11 +0,0 @@
---TEST--
-Check type hint compatibility in overrides with array hints.
---FILE--
-<?php
-Class C { function f(SomeClass $a) {} }
-
-// Array hint, should be class.
-Class D extends C { function f(array $a) {} }
-?>
---EXPECTF--
-Fatal error: Declaration of D::f(array $a) must be compatible with C::f(SomeClass $a) in %s on line 5
diff --git a/tests/classes/type_hinting_005d.phpt b/tests/classes/type_hinting_005d.phpt
deleted file mode 100644
index 51c2a5a995a..00000000000
--- a/tests/classes/type_hinting_005d.phpt
+++ /dev/null
@@ -1,11 +0,0 @@
---TEST--
-Check type hint compatibility in overrides with array hints.
---FILE--
-<?php
-Class C { function f($a) {} }
-
-// Array hint, should be nothing.
-Class D extends C { function f(array $a) {} }
-?>
---EXPECTF--
-Fatal error: Declaration of D::f(array $a) must be compatible with C::f($a) in %s on line 5
diff --git a/tests/lang/type_hints_001.phpt b/tests/lang/type_hints_001.phpt
deleted file mode 100644
index 293b469cd27..00000000000
--- a/tests/lang/type_hints_001.phpt
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-ZE2 type hinting
---FILE--
-<?php
-
-class Foo {
-}
-
-class Bar {
-}
-
-function type_hint_foo(Foo $a) {
-}
-
-$foo = new Foo;
-$bar = new Bar;
-
-type_hint_foo($foo);
-type_hint_foo($bar);
-
-?>
---EXPECTF--
-Fatal error: Uncaught TypeError: type_hint_foo(): Argument #1 ($a) must be of type Foo, Bar given, called in %s on line 16 and defined in %s:9
-Stack trace:
-#0 %s(%d): type_hint_foo(Object(Bar))
-#1 {main}
- thrown in %s on line 9
diff --git a/tests/lang/type_hints_002.phpt b/tests/lang/type_hints_002.phpt
deleted file mode 100644
index e3c327aab63..00000000000
--- a/tests/lang/type_hints_002.phpt
+++ /dev/null
@@ -1,26 +0,0 @@
---TEST--
-ZE2 type hinting
---FILE--
-<?php
-class P { }
-class T {
- function f(P $p = NULL) {
- var_dump($p);
- echo "-\n";
- }
-}
-
-$o=new T();
-$o->f(new P);
-$o->f();
-$o->f(NULL);
-?>
---EXPECTF--
-Deprecated: T::f(): Implicitly marking parameter $p as nullable is deprecated, the explicit nullable type must be used instead in %s on line %d
-object(P)#2 (0) {
-}
--
-NULL
--
-NULL
--
diff --git a/tests/lang/type_hints_003.phpt b/tests/lang/type_hints_003.phpt
deleted file mode 100644
index 1a90940f424..00000000000
--- a/tests/lang/type_hints_003.phpt
+++ /dev/null
@@ -1,11 +0,0 @@
---TEST--
-ZE2 type
---FILE--
-<?php
-class T {
- function f(P $p = 42) {
- }
-}
-?>
---EXPECTF--
-Fatal error: Cannot use int as default value for parameter $p of type P in %s on line %d