Skip to content

Commit

Permalink
Add extended test for loophole
Browse files Browse the repository at this point in the history
  • Loading branch information
ebln committed Jun 4, 2024
1 parent 490a5f8 commit 435b0d3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions tests/AttribForceFactoryRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'], [
Expand Down
27 changes: 27 additions & 0 deletions tests/dataAttrib/LoopholeInvoker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Test\Ebln\PHPStan\EnforceFactory\dataAttrib;

class LoopholeInvoker
{
private LoopholeFactory $loopholeFactory;

public function __construct()
{
$this->loopholeFactory = new LoopholeFactory();
}

public function expectedFailingLoophole(): object
{
$loophole = $this->loopholeFactory->variableUninferable(true);

return $loophole;
}

public function expectedMissingClass()
{
return $this->loopholeFactory->variableUninferable(false);
}
}

0 comments on commit 435b0d3

Please sign in to comment.