Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -3431,13 +3431,19 @@ private function intersectConditionalExpressions(array $otherConditionalExpressi
}

$otherHolders = $otherConditionalExpressions[$exprString];
foreach (array_keys($holders) as $key) {
$intersectedHolders = [];
foreach ($holders as $key => $holder) {
if (!array_key_exists($key, $otherHolders)) {
continue 2;
continue;
}
$intersectedHolders[$key] = $holder;
}

if (count($intersectedHolders) === 0) {
continue;
}

$newConditionalExpressions[$exprString] = $holders;
$newConditionalExpressions[$exprString] = $intersectedHolders;
}

return $newConditionalExpressions;
Expand Down
60 changes: 60 additions & 0 deletions tests/PHPStan/Analyser/nsrt/bug-14269.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php declare(strict_types = 1);

namespace Bug14269;

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

class Package
{

public function isMultiDay(): bool
{
return true;
}

/**
* @return string[]
*/
public function getWorkspaces(): array
{
return [];
}

/**
* @return int[]|null
*/
public function getService(): ?array
{
return [];
}

}

class ReturnsSelf
{

public function subtract(): self
{
return $this;
}

}

function doFoo(Package $package, ReturnsSelf $s): void {
if (!$package->isMultiDay()) {
$packageDurationInMinutes = 60;
}

foreach ($package->getWorkspaces() as $workplace) {
$availableIntervals = $s->subtract();
if ($package->getService() !== null && !$package->isMultiDay()) {
assertVariableCertainty(TrinaryLogic::createYes(), $packageDurationInMinutes);
continue;
}

$availableIntervals = $package->isMultiDay()
? 'aaa'
: 'bbb';
}
}
Loading