From 07205a1b9a193d3b97dc6e42329e51f6a6cd0c0f Mon Sep 17 00:00:00 2001 From: neznaika0 Date: Wed, 8 Jan 2025 21:49:33 +0300 Subject: [PATCH] refactor: Fix phpstan codeigniter.frameworkExceptionInstance --- tests/system/Debug/ExceptionsTest.php | 2 +- tests/system/DebugTraceableTraitTest.php | 2 +- .../codeigniter.frameworkExceptionInstance.neon | 13 ------------- utils/phpstan-baseline/loader.neon | 1 - 4 files changed, 2 insertions(+), 16 deletions(-) delete mode 100644 utils/phpstan-baseline/codeigniter.frameworkExceptionInstance.neon diff --git a/tests/system/Debug/ExceptionsTest.php b/tests/system/Debug/ExceptionsTest.php index b8279fb8e190..8a8aba9083b4 100644 --- a/tests/system/Debug/ExceptionsTest.php +++ b/tests/system/Debug/ExceptionsTest.php @@ -124,7 +124,7 @@ public function testDetermineCodes(): void $this->assertSame([500, EXIT_ERROR], $determineCodes(new RuntimeException('There.', 404))); $this->assertSame([500, EXIT_ERROR], $determineCodes(new RuntimeException('This.', 167))); $this->assertSame([500, EXIT_CONFIG], $determineCodes(new ConfigException('This.'))); - $this->assertSame([500, EXIT_CONFIG], $determineCodes(new CastException('This.'))); + $this->assertSame([500, EXIT_CONFIG], $determineCodes(CastException::forInvalidInterface('This.'))); $this->assertSame([500, EXIT_DATABASE], $determineCodes(new DatabaseException('This.'))); } diff --git a/tests/system/DebugTraceableTraitTest.php b/tests/system/DebugTraceableTraitTest.php index 26161d8de683..728d0db24bb1 100644 --- a/tests/system/DebugTraceableTraitTest.php +++ b/tests/system/DebugTraceableTraitTest.php @@ -28,7 +28,7 @@ final class DebugTraceableTraitTest extends CIUnitTestCase { public function testFactoryInstanceReturnsWhereItIsRaised(): void { - $e1 = new FrameworkException('Hello.'); + $e1 = FrameworkException::forInvalidFile('./file.txt'); $e2 = FrameworkException::forEnabledZlibOutputCompression(); $this->assertContainsEquals(DebugTraceableTrait::class, class_uses(FrameworkException::class)); diff --git a/utils/phpstan-baseline/codeigniter.frameworkExceptionInstance.neon b/utils/phpstan-baseline/codeigniter.frameworkExceptionInstance.neon deleted file mode 100644 index 9ffb6b9d3a2f..000000000000 --- a/utils/phpstan-baseline/codeigniter.frameworkExceptionInstance.neon +++ /dev/null @@ -1,13 +0,0 @@ -# total 2 errors - -parameters: - ignoreErrors: - - - message: '#^Instantiating CastException using new is not allowed\. Use one of its named constructors instead\.$#' - count: 1 - path: ../../tests/system/Debug/ExceptionsTest.php - - - - message: '#^Instantiating FrameworkException using new is not allowed\. Use one of its named constructors instead\.$#' - count: 1 - path: ../../tests/system/DebugTraceableTraitTest.php diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 7301539443d0..04a8a1d85edb 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -4,7 +4,6 @@ includes: - booleanAnd.rightAlwaysTrue.neon - codeigniter.cacheHandlerInstance.neon - codeigniter.configArgumentInstanceof.neon - - codeigniter.frameworkExceptionInstance.neon - codeigniter.getReassignArray.neon - codeigniter.modelArgumentInstanceof.neon - codeigniter.modelArgumentType.neon