DIC parameter is interpreted as *never*

Open
#286 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start with commit 2063d60f1bfe97c5702a839b3bc68d7f3fa75318 and reproduce the report using the container or builder getParameter calls shown in the issue. Trace why the array parameters are inferred as NEVER, then verify the PHPUnit assertions no longer report an unresolvable type or an always-false comparison.

Written by the indexing model from the issue text.

Description

Since commit https://github.com/phpstan/phpstan-symfony/commit/2063d60f1bfe97c5702a839b3bc68d7f3fa75318 I have a error that a dic parameter is never.

I am doing in the test code:

static::assertNotSame($this->container->getParameter('shopware.filesystem.public'), $this->container->getParameter('shopware.filesystem.theme'));

That both parameter keys which are arrays are the same. Since that commit I get

Parameter #1 $expected of static method PHPUnit\Framework\Assert::assertSame() contains unresolvable type.

I took the parameter out and "over-typed" it with an var annotation

/** @var array{type: string, config: array{root: string}} $filesystemPublic */
        $filesystemPublic = $this->builder->getParameter('shopware.filesystem.public');
        static::assertNotSame($filesystemPublic, $this->builder->getParameter('shopware.filesystem.theme'));

This produces that next strange error

 72     Call to static method PHPUnit\Framework\Assert::assertSame() with *NEVER* and array{type: string, config: array{root: string}} will always evaluate to false.  
  72     Parameter #1 $expected of static method PHPUnit\Framework\Assert::assertSame() contains unresolvable type.
Dominant language
PHP
Stars
800
Forks
104
Avg merge
4m
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-symfony

All issues in phpstan/phpstan-symfony

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.