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

Make sure variadic parameter does not have default value #72

Conversation

mchekin
Copy link
Contributor

@mchekin mchekin commented Jan 30, 2021

Q A
Documentation no
Bugfix yes
BC Break no
New Feature no
RFC no
QA yes

Description

Related to issue #35

Signed-off-by: Michael Chekin <mchekin@gmail.com>
This reverts commit 6c6eae8.

Signed-off-by: Michael Chekin <mchekin@gmail.com>
…nges)

Signed-off-by: Michael Chekin <mchekin@gmail.com>
Signed-off-by: Michael Chekin <mchekin@gmail.com>
…aultValueThrowsInvalidArgumentException

Signed-off-by: Michael Chekin <mchekin@gmail.com>
Signed-off-by: Michael Chekin <mchekin@gmail.com>
… of during the parameter generation.

Signed-off-by: Michael Chekin <mchekin@gmail.com>
@mchekin mchekin force-pushed the make-sure-variadic-parameter-does-not-have-default-value branch from 3ec81d9 to d031130 Compare March 30, 2021 10:37
@mchekin mchekin requested a review from Ocramius March 30, 2021 10:41
@mchekin
Copy link
Contributor Author

mchekin commented Apr 7, 2021

@Ocramius
Please review again.

Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @mchekin!

@Ocramius Ocramius added this to the 4.1.1 milestone Apr 14, 2021
@Ocramius Ocramius changed the base branch from 4.1.x to 4.2.x April 14, 2021 22:03
@Ocramius Ocramius modified the milestones: 4.1.1, 4.2.0 Apr 14, 2021
@Ocramius Ocramius self-assigned this Apr 14, 2021
@Ocramius Ocramius merged commit 30376bb into laminas:4.2.x Apr 14, 2021
@lisachenko
Copy link
Contributor

Almost one year after )
This PR has introduced a BC break in minor version, related to the goaop/framework#476

@Ocramius
Copy link
Member

Ocramius commented Feb 4, 2022

@lisachenko test cases please :)

@sakhunzai
Copy link
Contributor

@lisachenko is right and I am unable to use the goaop framework due to this issue. Please fix it, thanks. The issues seems simple

namespace Laminas\Code\Generator;
....
class ParameterGenerator extends AbstractGenerator
{ 
 /**
     * @param bool $variadic
     * @return ParameterGenerator
     */
    public function setVariadic($variadic)
    {
        if (isset($this->defaultValue)) {
            throw new Exception\InvalidArgumentException('Variadic parameter cannot have a default value');
        }

        $this->variadic = (bool) $variadic;

        return $this;
    }

The function should not throw exception, when $variadic is false. e. g

 public function setVariadic($variadic)
    {

       $this->variadic = (bool) $variadic;
        if ($this->variadic && isset($this->defaultValue)) {
            throw new Exception\InvalidArgumentException('Variadic parameter cannot have a default value');
        }

        return $this;
    }

@Ocramius
Copy link
Member

Ocramius commented Mar 3, 2023

@sakhunzai send a patch with an attached test, please.

@sakhunzai
Copy link
Contributor

@Ocramius would you please review the PR #173 and merge, this is blocking my work, thanks

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

Successfully merging this pull request may close these issues.

4 participants