Incompatible PHP OpenAPI changes in PhpStorm 2020.2
Union Types Support
PhpStorm 2020.2 introduced support for PHP union types, which resulted in some PSI-breaking changes.
In earlier versions, type hints in parameters, properties, and return types were parsed inconsistently:
Return types used a separate
PhpReturnTypewrapper element, which contained the nullability question mark and the actual type's class reference.
Parameters and properties used no wrapper element: class references and nullability question mark were plain children of
As of PhpStorm 2020.2, class references with the question mark are uniformly wrapped into the
PhpTypeDeclaration element, which is the parent for
If your existing code fetches a class reference directly from the parent element, it is now required to get
PhpTypeDeclaration first, and then call
As of PhpStorm 2020.2,
PhpReturnType.getClassReference() is deprecated, since there can be multiple class references. This method also became nullable, since in earlier versions an incomplete
? type was parsed just as a question mark, but now it is parsed as
PhpTypeDeclaration with empty