Skip to content

Commit

Permalink
added failling coalesce test
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Nov 10, 2023
1 parent 3af5a0f commit 7663045
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/PHPStan/Analyser/NodeScopeResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,7 @@ public function dataFileAsserts(): iterable
}

yield from $this->gatherAssertTypes(__DIR__ . '/data/falsy-isset.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/falsey-coalesce.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-7915.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-9714.php');
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-9105.php');
Expand Down
37 changes: 37 additions & 0 deletions tests/PHPStan/Analyser/data/falsey-coalesce.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace FalseyCoalesce;

use PHPStan\TrinaryLogic;
use function PHPStan\Testing\assertVariableCertainty;

interface TipPluginInterface
{

/**
* Used for returning values by key.
*
* @return string
* Value of the key.
* @var string
* Key of the value.
*
*/
public function get($key);

}

abstract class TipPluginBase implements TipPluginInterface
{

public function getLocation(): void
{
$location = $this->get('position');
assertVariableCertainty(TrinaryLogic::createYes(), $location);

$location ?? '';
assertVariableCertainty(TrinaryLogic::createYes(), $location);
}

}

0 comments on commit 7663045

Please sign in to comment.