Skip to content

Conversation

acoulton
Copy link
Contributor

Requiring ^5.2 was causing dependency conflicts that were preventing end-users from upgrading to newer Behat versions.

We only actually require nikic/php-parser for running the convert-config command to generate PHP config from the old YAML files. I therefore explored making it a suggested dependency that was only used to run that command.

The problem is that it is also required indirectly by many of our dev dependencies (including PHPUnit, which we use to run our assertions). This means we can't configure a CI run where it is not installed, so would not have confidence that Behat does indeed work as expected without it.

The best compromise is to relax the constraint to ^4.19.2 (this version introduced enum support, which we need). That should resolve the conflict for the majority of users.

Refs #1637

Requiring ^5.2 was causing dependency conflicts that were preventing
end-users from upgrading to newer Behat versions.

We only actually *require* nikic/php-parser for running the
convert-config command to generate PHP config from the old YAML files.
I therefore explored making it a suggested dependency that was only used
to run that command.

The problem is that it is also required indirectly by many of our dev
dependencies (including PHPUnit, which we use to run our assertions).
This means we can't configure a CI run where it is **not** installed,
so would not have confidence that Behat does indeed work as expected
without it.

The best compromise is to relax the constraint to ^4.19.2 (this version
introduced enum support, which we need). That should resolve the
conflict for the majority of users.
'App\AnotherContext'
'AnotherContext'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only slight issue is that the 4.x series includes a double backslash in strings e.g. it would produce App\\AnotherContext rather than the App\AnotherContext that we get from 5.x.

The "Class references for known extensions and contexts" scenario already covers behaviour with namespaced classes that are defined and can therefore be converted to imports. This proves we're reading the namespaced class names correctly from YAML and passing them around internally without issues.

Other aspects of that scenario and of these ones cover rendering the class name as a string if it is not a defined class.

IMO therefore we don't need to specifically cover the case where it's a string that contains a namespace separator, so the simplest fix is to just change these examples to ones where both versions of php-parser produce the same output.

@acoulton acoulton requested a review from carlos-granados June 21, 2025 15:15
@acoulton acoulton merged commit 48e755c into Behat:master Jul 15, 2025
19 checks passed
@acoulton acoulton deleted the maint-optional-php-parser branch July 15, 2025 08:58
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.

2 participants