-
-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing types #202
base: 3.6.x
Are you sure you want to change the base?
Add missing types #202
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch @ADmad but there are a few BC breaks that need reverting
src/MessageTrait.php
Outdated
* @var array | ||
* @psalm-var array<non-empty-string, list<string>> | ||
*/ | ||
protected $headers = []; | ||
protected array $headers = []; | ||
|
||
/** | ||
* Map of normalized header name to original name used to register header. | ||
* | ||
* @var array | ||
* @psalm-var array<non-empty-string, non-empty-string> | ||
*/ | ||
protected $headerNames = []; | ||
protected array $headerNames = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding types to protected properties is a BC break, also, removing @var array
is fine - it would be good to rename the @psalm-var
annotations to @var
- the psalm prefix is unnecessary
src/Response/JsonResponse.php
Outdated
* @return mixed | ||
*/ | ||
public function getPayload() | ||
public function getPayload(): mixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the return type is a BC break for inheritors: https://3v4l.org/BH4qV
src/Uri.php
Outdated
@@ -53,7 +53,7 @@ class Uri implements UriInterface, Stringable | |||
public const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~\pL'; | |||
|
|||
/** @var int[] Array indexed by valid scheme names to their corresponding ports. */ | |||
protected $allowedSchemes = [ | |||
protected array $allowedSchemes = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding types to protected members is a BC break: https://3v4l.org/frBrF
The documented type could be improved with /** @var array<string, positive-int> */
13a55f3
to
d523243
Compare
All these are private properties, shouldn't it be safe to change them?
Constructors can be changed with impunity, changing the type shouldn't cause any error even if the constructor was overridden in a child class.
|
The change in JsonResponse constructor is fine IMO, but it is a technical BC break, just because PHP lets us change the signature of __construct, it's still part of the public API. The private property changes to the traits are indeed a BC break if users have re-implemented a property without a type hint: https://3v4l.org/aaQTo - if they were class properties, it'd be fine, so very little of this can go into a 3.x release |
Thank you for the trait example, I'll revert the related changes. I am still not convinced the constructor change is a BC break :) |
3d44e31
to
5244e00
Compare
Signed-off-by: ADmad <[email protected]>
5244e00
to
88ac87d
Compare
I don't think the test failures are related to the changes in this PR. |
No, but whatever they are, they'll need to be addressed separately 🤔 |
See #205 |
That's not a "me" problem, so I'll let you guys tackle that :) |
Description
Some properties and methods were missing type declarations.