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

HeaderCommentFixer - throw exception on invalid header configuration #4099

Merged
merged 1 commit into from
Nov 27, 2018
Merged

HeaderCommentFixer - throw exception on invalid header configuration #4099

merged 1 commit into from
Nov 27, 2018

Conversation

SpacePossum
Copy link
Contributor

closes #4075

@SpacePossum SpacePossum added this to the 2.12.5 milestone Nov 13, 2018
@kubawerlos
Copy link
Contributor

What about comment type? It also cannot have */.

@SpacePossum
Copy link
Contributor Author

thanks @kubawerlos , updated 👍

if ('' === trim($value)) {
return '';
}

if (false !== strpos($value, '*/')) {
throw new InvalidFixerConfigurationException($fixerName, 'Cannot use \'*/\' in header.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't $this->getName() be instead of $fixerName here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I first thought the same, however, this is a static closure, thus not bound to $this. See http://php.net/manual/en/functions.anonymous.php#functions.anonymous-functions.static

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this closure to be static?

Copy link
Contributor Author

@SpacePossum SpacePossum Nov 13, 2018

Choose a reason for hiding this comment

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

even after dropping the static here won't bring the HeaderCommentFixer into the $this context

(Error: Using $this when not in object context)

we are in;
fixer > new FixerConfigurationResolver > new FixerOptionBuilder > closure

@SpacePossum SpacePossum merged commit 273fa48 into PHP-CS-Fixer:2.12 Nov 27, 2018
SpacePossum added a commit that referenced this pull request Nov 27, 2018
…iguration (SpacePossum)

This PR was squashed before being merged into the 2.12 branch (closes #4099).

Discussion
----------

HeaderCommentFixer - throw exception on invalid header configuration

closes #4075

Commits
-------

273fa48 HeaderCommentFixer - throw exception on invalid header configuration
@keradus keradus deleted the 2_12_throw_config_error_on_invalid_header branch November 28, 2018 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants