Skip to content

[Debug] simplify error_reporting levels given php version > 5.3 #16916

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

Merged
merged 1 commit into from
Dec 18, 2015

Conversation

Tobion
Copy link
Contributor

@Tobion Tobion commented Dec 9, 2015

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

Since PHP 5.4 E_ALL contains E_STRICT. This allows us to simplify and clean up some code.

@@ -42,7 +42,7 @@ public static function enable($errorReportingLevel = null, $displayErrors = true
if (null !== $errorReportingLevel) {
error_reporting($errorReportingLevel);
} else {
error_reporting(-1);
error_reporting(E_ALL);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add a deprecation for the null case in 3.1 as it is useless now.

Copy link
Member

Choose a reason for hiding this comment

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

This might become an issue in the future when new constants are introduced in future PHP versions (similar to the introduction of the E_STRICT constant).

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 E_ALL is supposed to include everything which is why it was changed in 5.4

@Tobion
Copy link
Contributor Author

Tobion commented Dec 9, 2015

@nicolas-grekas this is for you to review :)

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Dec 9, 2015 via email

@xabbuh
Copy link
Member

xabbuh commented Dec 9, 2015

What about defining the E_STRICT constant in the PHP 5.4 polyfill (or do we already do that?)? Then we could already simplify the code in previous versions.

@Tobion
Copy link
Contributor Author

Tobion commented Dec 9, 2015

E_ALL has a different meaning in PHP 5.3 and >= 5.4. That is problem. So we cannot do anything in Polyfill.

@xabbuh
Copy link
Member

xabbuh commented Dec 9, 2015

@Tobion I see, but then treating -1 now like E_ALL could become tricky in the future (see my inline comment), couldn't it?

@nicolas-grekas
Copy link
Member

Since PHP 7 introduced exceptions in the core, I seriously doubt that any new E_* will ever be introduced.
👍 for me

@fabpot
Copy link
Member

fabpot commented Dec 18, 2015

Thank you @Tobion.

@fabpot fabpot merged commit b1c774f into symfony:3.0 Dec 18, 2015
fabpot added a commit that referenced this pull request Dec 18, 2015
…n > 5.3 (Tobion)

This PR was merged into the 3.0 branch.

Discussion
----------

[Debug] simplify error_reporting levels given php version > 5.3

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Since PHP 5.4 `E_ALL` contains `E_STRICT`. This allows us to simplify and clean up some code.

Commits
-------

b1c774f simplify debug error_reporting levels given php version > 5.3
@Tobion Tobion deleted the error-reporting-e-all branch December 18, 2015 16:26
@GrahamCampbell
Copy link
Contributor

I thought symfony always used null for default values out of principle, like PHP does, so people can skip them by passing null. This breaks that principle. ;(

@Tobion
Copy link
Contributor Author

Tobion commented Dec 18, 2015

Neither symfony nor php itself uses null by default when it doesn't make sense. E.g. http://php.net/manual/en/function.trigger-error.php

@GrahamCampbell
Copy link
Contributor

PHP does in other cases, where the param might end up being an int though.

@GrahamCampbell
Copy link
Contributor

Meh. I'm inclined to agree with you I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants