Assert::that conditions are not working as expected

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
devtools

Research direction

Start with the linked PHPStan playground case and reproduce the diagnostic involving the host offset after withAssert. Compare that behavior with withIf, then inspect the extension's assertion handling and add coverage showing that the reported false-or-array type is narrowed as expected.

Written by the indexing model from the issue text.

Description

Given this case https://phpstan.org/r/ea5dfda5-33b6-49e7-8e5f-1db4214533e4 I'd expect that method withAssertwill work just like withIf. PhpStan will however throw following error

Offset 'host' does not exist on false|array('scheme' => string, ?'host' => string, ?'port' => int, ?'user' => string, ?'pass' => string, ?'query' => string, ?'fragment' => string). |

I know that phpstan/phpstan-beberlei-assert is not integrated in the web-tester, but the same will happen locally when it is.

Dominant language
PHP
Stars
43
Forks
16
Avg merge
10d 5h
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from phpstan/phpstan-beberlei-assert

All issues in phpstan/phpstan-beberlei-assert

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.