From 6abecaec8a78ae7cee3c5c902e367b559ee49519 Mon Sep 17 00:00:00 2001 From: Go Kudo Date: Mon, 25 Nov 2024 11:58:31 +0900 Subject: [PATCH 1/3] test: fix PHPUnit ZTS detection --- tests/Extension/PHP70Test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Extension/PHP70Test.php b/tests/Extension/PHP70Test.php index 52d3b7f..891bec0 100644 --- a/tests/Extension/PHP70Test.php +++ b/tests/Extension/PHP70Test.php @@ -21,7 +21,7 @@ public function testSRand(): void { \Colopl\ColoplBc\Php70\srand(1234); - if (\PHP_ZTS === 0) { + if (\PHP_ZTS === 0 || \PHP_ZTS === false) { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 479142414); } else { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 1584308507); @@ -43,7 +43,7 @@ public function testSRandNull(): void * @psalm-suppress PossiblyNullArgument */ \Colopl\ColoplBc\Php70\srand($seed); - if (\PHP_ZTS === 0) { + if (\PHP_ZTS === 0 || \PHP_ZTS === false) { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 1804289383); } else { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 1012484); @@ -53,7 +53,7 @@ public function testSRandNull(): void public function testRand(): void { \Colopl\ColoplBc\Php70\srand(5678); - if (\PHP_ZTS === 0) { + if (\PHP_ZTS === 0 || \PHP_ZTS === false) { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 1860157456); } else { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 1173971923); @@ -71,7 +71,7 @@ public function testShuffle(): void \Colopl\ColoplBc\Php70\srand(1234); \Colopl\ColoplBc\Php70\shuffle($arr); - if (\PHP_ZTS === 0) { + if (\PHP_ZTS === 0 || \PHP_ZTS === false) { self::assertSame($arr, [2, 3, 4, 1]); } else { self::assertSame($arr, [4, 2, 1, 3]); @@ -83,7 +83,7 @@ public function testStrShuffle(): void $str = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; \Colopl\ColoplBc\Php70\srand(1234); - if (\PHP_ZTS === 0) { + if (\PHP_ZTS === 0 || \PHP_ZTS === false) { self::assertSame( \Colopl\ColoplBc\Php70\str_shuffle($str), 'cfapiqi uogi txnrdaeqvnataten ume v aiisalm isiatdaduaeudr eenteotscdm itdenrieuaicii loi aaot imxll ne luecat uri ipp a l moplaur tsarc.eptuisrccdlotep ecorU oeaceqsuerno .t li sa rerldulidieoor i n nd tloiii eeulds ithsnot btrnf ilm a,nuto umdscd viee.amndrueonmce ns dancratmamo inuios ilmo sg a neo ci. eispiisu pueoe umurt denaamlmiu ,loi ptctaurst lrinm usLrdto gru coaetucnuliittro, npemeDnpt s,efdlq q teoiabuEet ert ioinu tlbxoo o ' @@ -100,7 +100,7 @@ public function testArrayRand(): void { \Colopl\ColoplBc\Php70\srand(1234); - if (\PHP_ZTS === 0) { + if (\PHP_ZTS === 0 || \PHP_ZTS === false) { self::assertSame( \Colopl\ColoplBc\Php70\array_rand([1, 2, 3, 4, 5], 3), [0, 1, 3] From 4ccfc51b8cbef8aeca1918dfd0655062abb9f781 Mon Sep 17 00:00:00 2001 From: Go Kudo Date: Mon, 25 Nov 2024 12:04:30 +0900 Subject: [PATCH 2/3] test: ignore phpstan --- tests/Extension/PHP70Test.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/Extension/PHP70Test.php b/tests/Extension/PHP70Test.php index 891bec0..5226680 100644 --- a/tests/Extension/PHP70Test.php +++ b/tests/Extension/PHP70Test.php @@ -21,6 +21,7 @@ public function testSRand(): void { \Colopl\ColoplBc\Php70\srand(1234); + /** @phpstan-ignore-next-line */ if (\PHP_ZTS === 0 || \PHP_ZTS === false) { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 479142414); } else { @@ -43,6 +44,7 @@ public function testSRandNull(): void * @psalm-suppress PossiblyNullArgument */ \Colopl\ColoplBc\Php70\srand($seed); + /** @phpstan-ignore-next-line */ if (\PHP_ZTS === 0 || \PHP_ZTS === false) { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 1804289383); } else { @@ -53,6 +55,7 @@ public function testSRandNull(): void public function testRand(): void { \Colopl\ColoplBc\Php70\srand(5678); + /** @phpstan-ignore-next-line */ if (\PHP_ZTS === 0 || \PHP_ZTS === false) { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 1860157456); } else { @@ -71,6 +74,7 @@ public function testShuffle(): void \Colopl\ColoplBc\Php70\srand(1234); \Colopl\ColoplBc\Php70\shuffle($arr); + /** @phpstan-ignore-next-line */ if (\PHP_ZTS === 0 || \PHP_ZTS === false) { self::assertSame($arr, [2, 3, 4, 1]); } else { @@ -83,6 +87,7 @@ public function testStrShuffle(): void $str = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; \Colopl\ColoplBc\Php70\srand(1234); + /** @phpstan-ignore-next-line */ if (\PHP_ZTS === 0 || \PHP_ZTS === false) { self::assertSame( \Colopl\ColoplBc\Php70\str_shuffle($str), @@ -100,6 +105,7 @@ public function testArrayRand(): void { \Colopl\ColoplBc\Php70\srand(1234); + /** @phpstan-ignore-next-line */ if (\PHP_ZTS === 0 || \PHP_ZTS === false) { self::assertSame( \Colopl\ColoplBc\Php70\array_rand([1, 2, 3, 4, 5], 3), From b78489869f6e4540477e5f295665d18094b8e2ed Mon Sep 17 00:00:00 2001 From: Go Kudo Date: Mon, 25 Nov 2024 16:14:13 +0900 Subject: [PATCH 3/3] tests: more instead ZTS detection --- ext/tests/php70/array_rand.phpt | 2 +- ext/tests/php70/array_rand_zts.phpt | 2 +- ext/tests/php70/shuffle.phpt | 2 +- ext/tests/php70/shuffle_zts.phpt | 2 +- ext/tests/php70/str_shuffle.phpt | 2 +- ext/tests/php70/str_shuffle_zts.phpt | 2 +- .../undefined_behavior_compatibility.phpt | 2 +- tests/Extension/PHP70Test.php | 18 ++++++------------ 8 files changed, 13 insertions(+), 19 deletions(-) diff --git a/ext/tests/php70/array_rand.phpt b/ext/tests/php70/array_rand.phpt index 41efc25..6195004 100644 --- a/ext/tests/php70/array_rand.phpt +++ b/ext/tests/php70/array_rand.phpt @@ -6,7 +6,7 @@ colopl_bc date.timezone=UTC --SKIPIF-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- diff --git a/tests/Extension/PHP70Test.php b/tests/Extension/PHP70Test.php index 5226680..3eb76cc 100644 --- a/tests/Extension/PHP70Test.php +++ b/tests/Extension/PHP70Test.php @@ -21,8 +21,7 @@ public function testSRand(): void { \Colopl\ColoplBc\Php70\srand(1234); - /** @phpstan-ignore-next-line */ - if (\PHP_ZTS === 0 || \PHP_ZTS === false) { + if ((bool) \PHP_ZTS === false) { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 479142414); } else { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 1584308507); @@ -44,8 +43,7 @@ public function testSRandNull(): void * @psalm-suppress PossiblyNullArgument */ \Colopl\ColoplBc\Php70\srand($seed); - /** @phpstan-ignore-next-line */ - if (\PHP_ZTS === 0 || \PHP_ZTS === false) { + if ((bool) \PHP_ZTS === false) { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 1804289383); } else { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 1012484); @@ -55,8 +53,7 @@ public function testSRandNull(): void public function testRand(): void { \Colopl\ColoplBc\Php70\srand(5678); - /** @phpstan-ignore-next-line */ - if (\PHP_ZTS === 0 || \PHP_ZTS === false) { + if ((bool) \PHP_ZTS === false) { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 1860157456); } else { self::assertSame(\Colopl\ColoplBc\Php70\rand(), 1173971923); @@ -74,8 +71,7 @@ public function testShuffle(): void \Colopl\ColoplBc\Php70\srand(1234); \Colopl\ColoplBc\Php70\shuffle($arr); - /** @phpstan-ignore-next-line */ - if (\PHP_ZTS === 0 || \PHP_ZTS === false) { + if ((bool) \PHP_ZTS === false) { self::assertSame($arr, [2, 3, 4, 1]); } else { self::assertSame($arr, [4, 2, 1, 3]); @@ -87,8 +83,7 @@ public function testStrShuffle(): void $str = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'; \Colopl\ColoplBc\Php70\srand(1234); - /** @phpstan-ignore-next-line */ - if (\PHP_ZTS === 0 || \PHP_ZTS === false) { + if ((bool) \PHP_ZTS === false) { self::assertSame( \Colopl\ColoplBc\Php70\str_shuffle($str), 'cfapiqi uogi txnrdaeqvnataten ume v aiisalm isiatdaduaeudr eenteotscdm itdenrieuaicii loi aaot imxll ne luecat uri ipp a l moplaur tsarc.eptuisrccdlotep ecorU oeaceqsuerno .t li sa rerldulidieoor i n nd tloiii eeulds ithsnot btrnf ilm a,nuto umdscd viee.amndrueonmce ns dancratmamo inuios ilmo sg a neo ci. eispiisu pueoe umurt denaamlmiu ,loi ptctaurst lrinm usLrdto gru coaetucnuliittro, npemeDnpt s,efdlq q teoiabuEet ert ioinu tlbxoo o ' @@ -105,8 +100,7 @@ public function testArrayRand(): void { \Colopl\ColoplBc\Php70\srand(1234); - /** @phpstan-ignore-next-line */ - if (\PHP_ZTS === 0 || \PHP_ZTS === false) { + if ((bool) \PHP_ZTS === false) { self::assertSame( \Colopl\ColoplBc\Php70\array_rand([1, 2, 3, 4, 5], 3), [0, 1, 3]