Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@acoulton
Copy link
Contributor

@acoulton acoulton commented Apr 17, 2025

This branch is based on #1625 so that should be reviewed and merged first.

Adds support for configuring the tester and error_reporting options through PHP, and for converting those configs from YAML.

This includes automatically removing default arguments when generating PHP config methods from YAML so that you get e.g. ->withStopOnFailure() rather than ->withStopOnFailure(true). That change also applies to a couple of existing methods - as shown in the updated convert_config feature file - and as a byproduct means that the config conversion process is now stricter internally about making sure that called methods exist and have been provided with the correct argument list.

Fixes #1624

Adds PHP config support for the `error_reporting`, `strict`,
`stop_on_failure` and `skip` configuration options.

Due to implementation details in Behat, these are internally split
between the `testers` and `calls` config keys. However, from a user
perspective it feels more logical to configure them together -
particularly if we in future add support for handling deprecations
differently to other PHP errors.

This internal split between keys makes the implementation - particularly
for config conversion - slightly different from the other objects. I
have tried to keep the implementation knowledge encapsulated as much
as possible.
This makes the converted configuration cleaner particularly for
boolean methods like `withStopOnFailure()`.

This commit also makes the config conversion process stricter - it will
now fail if a config object attempts to generate a method that does not
exist, or provides arguments that do not match the method signature.
This will help us to keep the `->toPhpExpr` in sync with any changes to
the config objects over time.
If the user has defined error_reporting integers in their YAML
config files, we can attempt to convert these to appropriate PHP
constant expressions. This will make the configuration clearer
(and help with the fact that the user may have a comment in the
YAML explaining the value, which will be lost in conversion).
Copy link
Contributor

@carlos-granados carlos-granados left a comment

Choose a reason for hiding this comment

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

@acoulton outstanding job, love what you have done in the removeDefaultArguments() and the errorReportingToConstants functions. 👍

@acoulton
Copy link
Contributor Author

@carlos-granados thanks - they were interesting problems to get stuck into :-)

It was really satisfying migrating the old features to your fixtures style, that works very well.

Do you mind approving #1625 as well and then I can get that merged first? Thanks!

@acoulton acoulton merged commit 953a552 into Behat:master Apr 17, 2025
18 checks passed
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.

Support PHP config for "tester" options

2 participants