Skip to content
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

Fix counting null variable (PHP 7.2) #1809

Closed
wants to merge 1 commit into from

Conversation

scaytrase
Copy link
Contributor

No description provided.

@sagikazarmark
Copy link
Member

Thanks, looks great. There are a few more places though where I could imagine this fix:

  • static and normal constructor default value should be an empty array as well
  • queue empty checks should use empty instead of just evaluating it as a boolean value

Can you do these fixes as well?

@scaytrase
Copy link
Contributor Author

For more complex approach we should just add nightly php to travis test matrix (with allowed failures for some time) and see the failures. I can try it

@scaytrase
Copy link
Contributor Author

Not sure about changing signatures as soon as it might provide any kind of BC breaks, but hardening checks sounds good

@sagikazarmark
Copy link
Member

For more complex approach we should just add nightly php to travis test matrix (with allowed failures for some time) and see the failures.

Agreed

Not sure about changing signatures as soon as it might provide any kind of BC breaks, but hardening checks sounds good

Manually passing null to an array typehinted parameter is not possible in the first place, so I think changing the default value is safe in this case.

@scaytrase
Copy link
Contributor Author

Manually passing null to an array typehinted parameter is not possible in the first place, so I think changing the default value is safe in this case.

What about inheritance and parent calls? Most of classes are not final thus could be extended.

The following example fails on 7.1:

class A
{
    public function __construct(array $val = [])
    {
        var_dump($val);
    }
}

class B extends A
{
    public function __construct(array $val = null)
    {
        parent::__construct($val);
    }
}

$b = new B();
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to A::__construct() must be of the type array, null given

So changing signature should be considered BC-break

@scaytrase scaytrase mentioned this pull request Apr 14, 2017
@scaytrase
Copy link
Contributor Author

Closing in favor of #1811

@scaytrase scaytrase closed this Apr 14, 2017
@scaytrase scaytrase deleted the patch-1 branch April 14, 2017 07:31
@sagikazarmark
Copy link
Member

Hm, you are right :(

I thought this would fail too: https://3v4l.org/DWTTP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants