From 6f413fccd08d0f79a9ee6b834bdfba54fb63ecd3 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 18 Jan 2026 09:37:16 +0100 Subject: [PATCH 1/2] make sure a class exist before asserting an object is an instance of it --- CHANGELOG.md | 6 ++++++ src/Runner/Assert/Objet.php | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebddcc9..77f0230 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [Unreleased] + +### Added + +- `$assert->object()->instance()` now check first if the class exist to allow to load aliases + ## 6.8.0 - 2026-01-11 ### Added diff --git a/src/Runner/Assert/Objet.php b/src/Runner/Assert/Objet.php index d3f1877..c7e2229 100644 --- a/src/Runner/Assert/Objet.php +++ b/src/Runner/Assert/Objet.php @@ -46,6 +46,17 @@ public function instance(string $class, ?string $message = null): self { $this->stats->incrementAssertions(); + // Making sure the class exists allows to use aliases and autoload them + if (!\class_exists($class) && !\interface_exists($class)) { + throw Failure::of(Property::of( + $this->object, + \sprintf( + 'Class, alias or interface %s does not exist', + $class, + ), + )); + } + if (!($this->object instanceof $class)) { throw Failure::of(Property::of( $this->object, From fe668f0fe59744a84fd13debebf4942611d6cd94 Mon Sep 17 00:00:00 2001 From: Baptiste Langlade Date: Sun, 18 Jan 2026 09:40:09 +0100 Subject: [PATCH 2/2] remove no longer used action input --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d285e31..bd8243d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,5 +45,3 @@ jobs: uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main cs: uses: innmind/github-workflows/.github/workflows/cs.yml@main - with: - php-version: '8.2'