php_open_api_breaking_changes.md: minor edits

This commit is contained in:
Yann Cébron 2020-06-03 12:45:59 +02:00
parent dc84f241f5
commit 10095e7fed

View File

@ -4,17 +4,17 @@ title: Breaking Changes
<!-- Copyright 2000-2020 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -->
## Union Types Support
PhpStorm 2020.2 EAP introduced support for [PHP union types](https://wiki.php.net/rfc/union_types_v2), which resulted in some PSI-breaking changes.
PhpStorm 2020.2 introduced support for [PHP union types](https://wiki.php.net/rfc/union_types_v2), 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 `PhpReturnType` wrapper element, which contained the nullability question mark and the class reference of the actual type.
* Parameters and properties used no wrapper element: class references together with nullability question mark were plain children of `Parameter` or `CLASS_FIELDS`.
As of PhpStorm 2020.2 EAP, class references with the question mark are uniformly wrapped into the `PhpTypeDeclaration` element, which is the parent for `PhpReturnType`, `PhpFieldType`, and `PhpParameterType`.
As of PhpStorm 2020.2, class references with the question mark are uniformly wrapped into the `PhpTypeDeclaration` element, which is the parent for `PhpReturnType`, `PhpFieldType`, and `PhpParameterType`.
If your existing code fetches a class reference directly from the parent element, it is now required to get `PhpTypeDeclaration` first, and then call `PhpTypeDeclaration#getClassReferences()`.
Before 2020.2 EAP:
Before 2020.2:
```java
private void handleParameterBefore(Parameter parameter) {
@ -23,7 +23,7 @@ private void handleParameterBefore(Parameter parameter) {
}
```
After 2020.2 EAP:
After 2020.2:
```java
private void handleParameterAfter(Parameter parameter) {
@ -34,10 +34,10 @@ After 2020.2 EAP:
}
```
## Deprecated PhpReturnType#getClassReference
As of PhpStorm 2020.2 EAP, `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 `getClassReferences()`.
## Deprecated `PhpReturnType.getClassReference()`
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 `getClassReferences()`.
Before 2020.2 EAP:
Before 2020.2:
```java
private void handleReturnTypeBefore(PhpReturnType returnType) {
@ -46,7 +46,7 @@ Before 2020.2 EAP:
}
```
After 2020.2 EAP:
After 2020.2:
```java
private void handleReturnTypeAfter(PhpReturnType returnType) {