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
ClassMapGenerator: fix two bugs (long heredocs + markers in text) #10050
Merged
Seldaek
merged 3 commits into
composer:master
from
jrfnl:feature/10037-classmapgenerator-bug-fixes
Aug 12, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/StripNoise.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
namespace Foo; | ||
|
||
/** | ||
* class StripNoise { } | ||
*/ | ||
class StripNoise | ||
{ | ||
public function test_heredoc() | ||
{ | ||
return <<<HEREDOC | ||
class FailHeredocBasic | ||
{ | ||
} | ||
HEREDOC . <<< WHITESPACE | ||
class FailHeredocWhitespace | ||
{ | ||
} | ||
WHITESPACE . <<<"DOUBLEQUOTES" | ||
class FailHeredocDoubleQuotes | ||
{ | ||
} | ||
DOUBLEQUOTES . <<< "DOUBLEQUOTESTABBED" | ||
class FailHeredocDoubleQuotesTabbed | ||
{ | ||
} | ||
DOUBLEQUOTESTABBED . <<<HEREDOCPHP73 | ||
class FailHeredocPHP73 | ||
{ | ||
} | ||
HEREDOCPHP73; | ||
} | ||
|
||
public function test_nowdoc() | ||
{ | ||
return <<<'NOWDOC' | ||
class FailNowdocBasic | ||
{ | ||
} | ||
NOWDOC . <<< 'WHITESPACE' | ||
class FailNowdocWhitespace | ||
{ | ||
} | ||
WHITESPACE . <<< 'NOWDOCTABBED' | ||
class FailNowdocTabbed | ||
{ | ||
} | ||
NOWDOCTABBED . <<<'NOWDOCPHP73' | ||
class FailNowdocPHP73 | ||
{ | ||
} | ||
NOWDOCPHP73; | ||
} | ||
|
||
public function test_followed_by_parentheses() | ||
{ | ||
return array(<<<PARENTHESES | ||
class FailParentheses | ||
{ | ||
} | ||
PARENTHESES); | ||
} | ||
|
||
public function test_followed_by_comma() | ||
{ | ||
return array(1, 2, <<<COMMA | ||
class FailComma | ||
{ | ||
} | ||
COMMA, 3, 4); | ||
} | ||
|
||
public function test_followed_by_period() | ||
{ | ||
return <<<PERIOD | ||
class FailPeriod | ||
{ | ||
} | ||
PERIOD.'?>'; | ||
} | ||
|
||
public function test_simple_string() | ||
{ | ||
return 'class FailSimpleString {}'; | ||
} | ||
} |
464 changes: 464 additions & 0 deletions
464
tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/VeryLongHeredoc.php
Large diffs are not rendered by default.
Oops, something went wrong.
327 changes: 327 additions & 0 deletions
327
tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/VeryLongNowdoc.php
Large diffs are not rendered by default.
Oops, something went wrong.
307 changes: 307 additions & 0 deletions
307
tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/VeryLongPHP73Heredoc.php
Large diffs are not rendered by default.
Oops, something went wrong.
1,018 changes: 1,018 additions & 0 deletions
1,018
tests/Composer/Test/Autoload/Fixtures/pcrebacktracelimit/VeryLongPHP73Nowdoc.php
Large diffs are not rendered by default.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this use a try/finally, so in case of exceptions the value gets properly restored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this retrieve the previous value and re-set it instead of restoring the initial value, which might not be the expected one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@staabm Good question. I'd done it like this to ensure that, even if the assertion fails, restore will still happen, but yes, in case of exceptions it may not.
I'm not a fan of using
try/catch
in test methods. Moving it to thetearDown()
would be more appropriate IMO, or even moving the method to its own test class and then having the ini changes insetUp()
andtearDown()
.What do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considered that too (actually started with that when I was writing the test), but couldn't find any other tests doing anything with
ini_set()
, let alone with this configuration setting, so I figured I may as well use the PHP native restore option. Happy to change that though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's fine as is. Low chances of problems, and tests only, so not really worth a debate :)