Skip to content

Implement the unescaping of doc string delimiters#393

Merged
stof merged 1 commit intoBehat:masterfrom
stof:fix_docstring_escaping
Nov 5, 2025
Merged

Implement the unescaping of doc string delimiters#393
stof merged 1 commit intoBehat:masterfrom
stof:fix_docstring_escaping

Conversation

@stof
Copy link
Member

@stof stof commented Nov 5, 2025

Closes #326

@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.86%. Comparing base (78aa8df) to head (09c8f65).
⚠️ Report is 2 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #393      +/-   ##
============================================
+ Coverage     95.83%   95.86%   +0.02%     
- Complexity      667      669       +2     
============================================
  Files            44       44              
  Lines          1921     1934      +13     
============================================
+ Hits           1841     1854      +13     
  Misses           80       80              
Flag Coverage Δ
php8.1 95.86% <100.00%> (+0.02%) ⬆️
php8.1--with=symfony/yaml:^5.4 95.86% <100.00%> (+0.02%) ⬆️
php8.1--with=symfony/yaml:^6.4 95.86% <100.00%> (+0.02%) ⬆️
php8.2 95.86% <100.00%> (+0.02%) ⬆️
php8.3 95.86% <100.00%> (+0.02%) ⬆️
php8.4 95.86% <100.00%> (+0.02%) ⬆️
php8.5 95.86% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

private bool $allowMultilineArguments = false;
private bool $allowSteps = false;
/**
* @phpstan-var TDocStringSeparator|null
Copy link
Member Author

Choose a reason for hiding this comment

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

phpstan is smart enough to analyse the regex used to match the delimiter and figure out that the delimiter capturing group will only ever match one of the 2 supported delimiter strings.
Using a more precise type for the property in which we assign that value allows us to avoid a dead default branch in the match statement finding the corresponding escaped delimiter.

Behat\Gherkin\Node\PyStringNode:
strings:
- 'first line'
- '\"\"\"'
Copy link
Member Author

Choose a reason for hiding this comment

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

this is where we had a mismatch compared to the upstream expectation.

Copy link
Contributor

@acoulton acoulton left a comment

Choose a reason for hiding this comment

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

Great, thanks @stof

@stof stof merged commit a269823 into Behat:master Nov 5, 2025
11 checks passed
@stof stof deleted the fix_docstring_escaping branch November 5, 2025 16:17
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.

Escaped separators in PyStrings are not un-escaped

2 participants