Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Fixed unnecessary nullable method signature BC breaks in PHP 7.1+ #835

Merged
merged 2 commits into from Feb 22, 2018

Conversation

dktapps
Copy link
Contributor

@dktapps dktapps commented Feb 19, 2018

In PHP 7.1+, these resulted in the signatures becoming ?typehint, which raises warnings when upgrading old code which overrides these methods. As it turns out, these parameters are not supposed to accept null at all (see the implementation).
These nullable flags are not necessary; it is sufficient to declare that only X parameters are needed.

This will break code written for pthreads 3.1.7dev which gave null explicitly to these methods; however the fact that these methods accept null is not documented anywhere and I think it is a bug.

This is backwards compatible with code which overrides these methods since parameter type widening allows this.

In PHP 7.1+, these resulted in the signatures becoming `?typehint`, which raises warnings when upgrading old code which overrides these methods. As it turns out, these parameters are not supposed to accept null at all (see the arginfo).
These nullable flags are not necessary; it is sufficient to declare that only X parameters are needed.

This will break code written for pthreads 3.1.7dev which gave null explicitly to these methods; however the fact that these methods accept null is not documented anywhere and I think it is a bug.
This is backwards compatible with code which overrides these methods since parameter type widening allows this.
@sirsnyder
Copy link
Collaborator

Yes, it's undocumented and buggy behavior. I think these changes are ok, also with a BC break.

@sirsnyder
Copy link
Collaborator

@tpunt what's your opinion about the BC break? Ok, not ok?

@dktapps
Copy link
Contributor Author

dktapps commented Feb 21, 2018

@sirsnyder The 3.1.6 release doesn't have these issues since it was only compatible with PHP 7.0 anyway. The bug only exists in versions of pthreads compatible with PHP 7.1 (3.1.7dev only), which since it doesn't have a release, these fixes are technically not a BC break anyway (it doesn't break the released public API).

Also as discussed in #814 there are other BC breaks here which also haven't been covered in a new release, so this can be wrapped as a bugfix.

Copy link
Collaborator

@tpunt tpunt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@dktapps
Copy link
Contributor Author

dktapps commented Feb 21, 2018

I've pushed an additional fix to address the Pool::__construct() nulled typehints noted in #838 .

dktapps referenced this pull request in pmmp/ext-pmmpthread Feb 21, 2018
This updates the stub to match pthreads v3 properly, as per the arginfo of the extension. Some issues were discovered in the process (see #835 and #836), so method signatures have been adjusted to match the documentation where there are mismatches.

The formatting in this file is very inconsistent, I went to great pains to avoid reformatting it to avoid polluting the diff.
@tpunt tpunt merged commit cfd57cf into krakjoe:master Feb 22, 2018
@tpunt
Copy link
Collaborator

tpunt commented Feb 22, 2018

Merged, thanks.

@dktapps dktapps deleted the bad-nullable-signatures branch February 22, 2018 10:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants