phpstan complains: PropertyPath (from symfony) does not specify iterable type

Philipp Scheit
Dec 21, 2021

--

Error shown when using the PropertyPath instead of the Interface

When you are using phpstan and the Symfony Component Property Access and you would get this error:

Method YAY\Sync\Subject::initPath() has parameter $path with no value type specified in iterable type Symfony\Component\PropertyAccess\PropertyPath

Make sure that you

a) have the phpstan symfony extension installed

b) you are using the interface:

private function initPath(PropertyPathInterface $path): void

instead of

private function initPath(PropertyPath $path): void

Just the plain path. The reason is, that in the phpstan symfony extension the interface is stubbed and has the iterable type applied.

--

--