From 435b0d31576c1f217415f82dc76cfaa3267acc88 Mon Sep 17 00:00:00 2001 From: ebln <34722048+ebln@users.noreply.github.com> Date: Wed, 5 Jun 2024 00:36:25 +0200 Subject: [PATCH] Add extended test for loophole --- CHANGELOG.md | 4 ++++ tests/AttribForceFactoryRuleTest.php | 6 ++++++ tests/dataAttrib/LoopholeInvoker.php | 27 +++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 tests/dataAttrib/LoopholeInvoker.php diff --git a/CHANGELOG.md b/CHANGELOG.md index ca17bb9..791899b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,15 @@ Intended to follow [«Keep a Changelog»](https://keepachangelog.com/en/) ---- +## TODO +- TODO: remove variableUnpredictable` in favour of `variableUninferable` + ## Upcoming ### Added - Support for attributes * missing stand-alone attribute ??? +- Extended test case for Loophole (still failing) ### Removed * Support for PHP < 7.4 diff --git a/tests/AttribForceFactoryRuleTest.php b/tests/AttribForceFactoryRuleTest.php index 018a56e..379c5c2 100644 --- a/tests/AttribForceFactoryRuleTest.php +++ b/tests/AttribForceFactoryRuleTest.php @@ -22,6 +22,12 @@ public function testLoopholeFactory(): void $this->analyse([__DIR__ . '/dataAttrib/LoopholeFactory.php'], []); } + // Sadly this remains a vector, as phpstan fails to infer the created class name + public function testLoopholeInvoker(): void + { + $this->analyse([__DIR__ . '/dataAttrib/LoopholeFactory.php', __DIR__ . '/dataAttrib/LoopholeInvoker.php'], []); + } + public function testEmptyAllowedClasses(): void { $this->analyse([__DIR__ . '/dataAttrib/EmptyFactory.php'], [ diff --git a/tests/dataAttrib/LoopholeInvoker.php b/tests/dataAttrib/LoopholeInvoker.php new file mode 100644 index 0000000..f4d708c --- /dev/null +++ b/tests/dataAttrib/LoopholeInvoker.php @@ -0,0 +1,27 @@ +loopholeFactory = new LoopholeFactory(); + } + + public function expectedFailingLoophole(): object + { + $loophole = $this->loopholeFactory->variableUninferable(true); + + return $loophole; + } + + public function expectedMissingClass() + { + return $this->loopholeFactory->variableUninferable(false); + } +}