From 838a6855d767809a8ff1994cb809b606852e588c Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Mon, 6 Jul 2026 19:59:33 +0200 Subject: [PATCH] Throw exceptions in NodaTimeSplitterTest to ensure explicit typing for phpstan --- tests/NodaTimeSplitterTest.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/NodaTimeSplitterTest.php b/tests/NodaTimeSplitterTest.php index 8b6113e..01811d3 100644 --- a/tests/NodaTimeSplitterTest.php +++ b/tests/NodaTimeSplitterTest.php @@ -667,6 +667,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("02.1.25 v. Chr"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "-25", 1 => "-25", @@ -680,6 +681,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("2.01.25 v. Chr"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "-25", 1 => "-25", @@ -693,6 +695,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("02.01.25 v. Chr"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "-25", 1 => "-25", @@ -706,6 +709,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("2.1.25 v. Chr"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "-25", 1 => "-25", @@ -719,6 +723,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("02.01.2020"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "2020", 1 => "2020", @@ -732,6 +737,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting(".2020"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "2020", 1 => "2020", @@ -745,6 +751,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("0-2020"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "2020", 1 => "2020", @@ -758,6 +765,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("2021-0"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "2021", 1 => "2021", @@ -771,6 +779,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("1920-1929"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "1920", 1 => "1929", @@ -784,6 +793,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("2020 (terminus ante quem)"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "?", 1 => "2019", @@ -797,6 +807,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("Vor Dezember 2020"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "?", 1 => "2020", @@ -823,6 +834,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("Nach dem 02.1.25 v. Chr"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "-25", 1 => "?", @@ -849,6 +861,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("Januar 2020"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "2020", 1 => "2020", @@ -862,6 +875,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("Januar 1217"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "1217", 1 => "1217", @@ -876,6 +890,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("Januar 1520"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "1520", 1 => "1520", @@ -890,6 +905,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("Januar 1001"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "1001", 1 => "1001", @@ -904,6 +920,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("Januar 2780"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "2780", 1 => "2780", @@ -918,6 +935,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("Nach 60er Jahre"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "1970", 1 => "?", @@ -931,6 +949,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("Nach 2020"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "2021", 1 => "?", @@ -944,6 +963,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("Bis Januar 2020"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "?", 1 => "2020", @@ -971,6 +991,7 @@ final class NodaTimeSplitterTest extends TestCase { // Intl' month: 2020-01 $output = NodaTimeSplitter::attempt_splitting("2020-01"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "2020", 1 => "2020", @@ -984,6 +1005,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("Januar 2020 v. Chr."); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "-2020", 1 => "-2020", @@ -998,6 +1020,7 @@ final class NodaTimeSplitterTest extends TestCase { // 5-Digit timespans BCE $output = NodaTimeSplitter::attempt_splitting("40000-25000 vor Christus"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "-40000", 1 => "-25000", @@ -1012,6 +1035,7 @@ final class NodaTimeSplitterTest extends TestCase { // 5-Digit timespans BCE $output = NodaTimeSplitter::attempt_splitting("40000-25000 v.C."); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "-40000", 1 => "-25000", @@ -1025,6 +1049,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("20. Jahrhundert v. Chr."); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "-2000", 1 => "-1901", @@ -1051,6 +1076,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("Bis 20.-19. Jahrhundert v. Chr."); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "?", 1 => "-1801", @@ -1064,6 +1090,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("15. 11. 1978"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "1978", 1 => "1978", @@ -1077,6 +1104,7 @@ final class NodaTimeSplitterTest extends TestCase { $output = NodaTimeSplitter::attempt_splitting("6 November 1978"); self::assertNotEmpty($output); + if ($output === false) throw new Exception("Failed to split"); self::assertEquals($output->toOldFormat(), [ 0 => "1978", 1 => "1978",