From a3704a1df4e78e55d17b33b5e13ad9f45a4b6a69 Mon Sep 17 00:00:00 2001 From: neznaika0 Date: Mon, 13 Jan 2025 07:49:37 +0300 Subject: [PATCH] refactor: Fix phpstan codeigniter.frameworkExceptionInstance (#9389) --- 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 25601e1f39d0..86b4b061ff0e 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..611f3f3374f5 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 = new FrameworkException('Hello.'); // @phpstan-ignore codeigniter.frameworkExceptionInstance $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 1cf2cabd4ea7..966a2311fcba 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -2,7 +2,6 @@ includes: - argument.type.neon - assign.propertyType.neon - codeigniter.cacheHandlerInstance.neon - - codeigniter.frameworkExceptionInstance.neon - codeigniter.getReassignArray.neon - codeigniter.modelArgumentInstanceof.neon - codeigniter.modelArgumentType.neon