1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
From: "Christoph M. Becker" <cmbecker69@gmx.de>
Date: Fri, 2 Aug 2024 23:52:58 +0200
Subject: Fix 007.phpt for PHP 8.3
Since the behavior changed as of PHP 8.3.0, we split the test case, so
every PHP version can be checked for the expected behavior. While we
could use a regex to stick with a single test case, we want to precise
about what to expect.
uopz-7.1.1/tests/007.phpt | 5 ++
uopz-7.1.1/tests/007_1.phpt | 114 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 119 insertions(+)
create mode 100644 uopz-7.1.1/tests/007_1.phpt
diff --git a/uopz-7.1.1/tests/007.phpt b/uopz-7.1.1/tests/007.phpt
index a195901..bf862f6 100644
@@ -2,6 +2,11 @@
uopz_get_static
--EXTENSIONS--
uopz
+--SKIPIF--
+<?php
+uopz_allow_exit(true);
+if (version_compare(PHP_VERSION, "8.3.0") >= 0) die("skip only for PHP < 8.3.0");
+?>
--INI--
uopz.disable=0
--FILE--
diff --git a/uopz-7.1.1/tests/007_1.phpt b/uopz-7.1.1/tests/007_1.phpt
new file mode 100644
index 0000000..b4942cc
@@ -0,0 +1,114 @@
+--TEST--
+uopz_get_static
+--EXTENSIONS--
+uopz
+--SKIPIF--
+<?php
+uopz_allow_exit(true);
+if (version_compare(PHP_VERSION, "8.3.0") < 0) die("skip only for PHP >= 8.3.0");
+?>
+--INI--
+uopz.disable=0
+--FILE--
+<?php
+class Foo {
+ public function method() {
+ static $vars = [1,2,3,4,5];
+ static $bar = FOO;
+
+ $vars[] = 6;
+ }
+
+ public function nostatics() {}
+}
+const FOO = "bar";
+
+function nostatics() {}
+
+$foo = new Foo();
+
+var_dump(uopz_get_static(Foo::class, "method"));
+
+$foo->method();
+
+var_dump(uopz_get_static(Foo::class, "method"));
+
+try {
+ uopz_get_static(Foo::class, "none");
+} catch (RuntimeException $ex) {
+ var_dump($ex->getMessage());
+}
+
+try {
+ uopz_get_static("none");
+} catch (RuntimeException $ex) {
+ var_dump($ex->getMessage());
+}
+
+try {
+ uopz_get_static(DateTime::class, "__construct");
+} catch(RuntimeException $ex) {
+ var_dump($ex->getMessage());
+}
+
+try {
+ uopz_get_static("phpversion");
+} catch(RuntimeException $ex) {
+ var_dump($ex->getMessage());
+}
+
+try {
+ uopz_get_static(Foo::class, "nostatics");
+} catch(RuntimeException $ex) {
+ var_dump($ex->getMessage());
+}
+
+try {
+ uopz_get_static("nostatics");
+} catch(RuntimeException $ex) {
+ var_dump($ex->getMessage());
+}
+?>
+--EXPECTF--
+array(2) {
+ ["vars"]=>
+ array(5) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(4)
+ [4]=>
+ int(5)
+ }
+ ["bar"]=>
+ NULL
+}
+array(2) {
+ ["vars"]=>
+ array(6) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+ [3]=>
+ int(4)
+ [4]=>
+ int(5)
+ [5]=>
+ int(6)
+ }
+ ["bar"]=>
+ string(3) "bar"
+}
+string(%d) "failed to get statics from method %s::%s, it does not exist"
+string(%d) "failed to get statics from function %s, it does not exist"
+string(%d) "failed to get statics from internal method %s::%s"
+string(%d) "failed to get statics from internal function %s"
+string(%d) "failed to set statics in method %s::%s, no statics declared"
+string(%d) "failed to set statics in function %s, no statics declared"
|