Skip to content

Allow variadic arguments to replace non-variadic ones - #5059

Closed
nikic wants to merge 1 commit into
php:masterfrom
nikic:variadic-variance
Closed

nikic wants to merge 1 commit into
php:masterfrom
nikic:variadic-variance

Conversation

@nikic

@nikic nikic commented Jan 6, 2020

Copy link
Copy Markdown
Member

Any number of arguments can be replaced by a variadic one, so
long as the variadic argument is compatible (in the sense of
contravariance) with the subsumed arguments.

In particular this means that function(...$args) becomes a
near-universal signature: It is compatible with any function
signature that does not accept parameters by-reference.

This also fixes bug #70839, which describes a special case.

Any number of arguments can be replaced by a variadic one, so
long as the variadic argument is compatible (in the sense of
contravariance) with the subsumed arguments.

In particular this means that function(...$args) becomes a
near-universal signature: It is compatible with any function
signature that does not accept parameters by-reference.

This also fixes bug #70839, which describes a special case.
Comment thread Zend/zend_inheritance.c
continue;
}
if (!fe_arg_info) {
/* An argument has been removed. This is considered illegal, because arity checks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P]arity?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In this case, it's indeed arity.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for educating me.

@php-pulls php-pulls closed this in e72bf63 Jan 23, 2020
@carusogabriel carusogabriel added this to the PHP 8.0 milestone May 29, 2020
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.

3 participants