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

feat: Do not swallow exceptions when scoping #869

Merged
merged 4 commits into from
Nov 1, 2023

Conversation

theofidry
Copy link
Member

@theofidry theofidry commented Nov 1, 2023

Closes #847.

As reported in #847, the current strategy is not ideal: if a failure occurs, the file is preserved. You can only see that there was a failure by paying attention to the output or having a more verbose output, unless you pass the --stop-on-failure option.

I think historically it has been that way because in the early days of PHP-Scoper, a failure was non infrequent and it was very frustrating to not be able to examine the result despite the failure.

The tool is now more robust and the only exception that I can see regularly coming still is invalid PHP code (e.g. when it is a template). As such, this PR proposes to:

  • Leave the file unchanged if a PHP-Parser parsing error occurred (it is still marked as failed and appears in the logs as before).
  • Fail on any other failure (i.e. proceed as if --stop-on-failure was always provided).
  • Introduce a new counterpart option --continue-on-failure.

The option --stop-on-failure has now been deprecated and will be removed a future version as it is now useless.

Closes humbug#847.

Afer reviewing the linked issue, I think a better way to handle errors
is to leave alone non valid PHP files (i.e. files that PHP-Parser could
not parse) but otherwise fail.

This can cause problems however, I suspect mostly during tests, where
one may want to try the final scopped result depsite a failure. For this
reason, a new option `--continue-on-failure` has been added to the
`add-prefix` command.

The option `--stop-on-failure` has now been deprecated and will be
removed a future version.
@theofidry theofidry enabled auto-merge (squash) November 1, 2023 16:14
@theofidry theofidry merged commit fc1ac4e into humbug:main Nov 1, 2023
114 checks passed
@theofidry theofidry deleted the feat/user-patch branch November 1, 2023 16:41
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.

Patchers don't report errors to default error handler
1 participant