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

Signature is valid if there are less args #424

Closed
wants to merge 1 commit into from

Conversation

nikic
Copy link
Member

@nikic nikic commented Aug 29, 2013

@lstrojny
Copy link
Contributor

YES, PLEASE! :)

@dsp
Copy link
Member

dsp commented Sep 16, 2013

This needs an RFC.

Also think about the following:

error_reporting(E_STRICT);
Class X
{
    function cleanup($recurse, $unlink=False) {
    }
}

class Z extends X
{
    function cleanup($unlink) {
    }
}

$x = getInstanceOfX(); // returns Z
$x->cleanup(true); // woops..suddenly everything gone

@Trainmaster
Copy link

From a userland perspective:

class Parents
{
    public function doSomething($x)
    {
    }
}

class ChildA extends Parents
{
    public function doSomething()
    {
    }
}
// Strict Standards: Declaration of ChildC::doSomething() should be compatible with that of Parents::doSomething()

class ChildB extends Parents
{
    public function doSomething($x, $y)
    {
    }
}
// Strict Standards: Declaration of ChildB::doSomething() should be compatible with that of Parents::doSomething()

class ChildC extends Parents
{
    public function doSomething($x)
    {
    }
}
// Works

No matter if ChildA, ChildB oder ChildC, doSomething() should always be callable with one argument.

Another thing, see the following code:

interface BazInterface
{
    public function doSomething($x);
}

class BazA implements BazInterface
{
    public function doSomething()
    {
    }
}
// Fatal error: Declaration of BazA::doSomething() must be compatible with that of BazInterface::doSomething()

class BazB implements BazInterface
{
    public function doSomething($x, $y)
    {
    }
}
// Fatal error: Declaration of BazB::doSomething() must be compatible with that of BazInterface::doSomething()

Will this affect interfaces, too?

@nikic
Copy link
Member Author

nikic commented Sep 18, 2013

In light of a possible addition of named parameters in the future it's likely better not to allow this. Withdrawing this proposal.

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.

4 participants