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

setPattern should accept string values #483

Open
CrazyMuffin opened this issue Mar 13, 2018 · 0 comments · May be fixed by #484
Open

setPattern should accept string values #483

CrazyMuffin opened this issue Mar 13, 2018 · 0 comments · May be fixed by #484

Comments

@CrazyMuffin
Copy link

When I attempt to extend class and set my own pattern, application crashes because:

  1. When trying to set string, setPattern declines the value because of invalid typehint.
  2. When I set the string value into array, application crashes further down as values in Finder::names should be string only. (they are later passed into preg_match function).

Invalid typehint:

public function setPattern(array $pattern)
{
$this->pattern = $pattern;
}

Function call that expects string:

if ($this->pattern) {
$finder->name($this->pattern);
}

Function itself:
https://github.com/symfony/symfony/blob/9e82562948253bf547243aa1c4cf6ec734d608da/src/Symfony/Component/Finder/Finder.php#L150-L170

Solution:

  1. Change argument typehint to string
  2. Allow array, but iterate values on $finder::name call

Workaround:
Copy class but reimplement everything

CrazyMuffin added a commit to CrazyMuffin/JMSTranslationBundle that referenced this issue Mar 13, 2018
@CrazyMuffin CrazyMuffin linked a pull request Mar 13, 2018 that will close this issue
1 task
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 a pull request may close this issue.

1 participant