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

ob_implicit_flush int doesn't cause error #1450

Open
afilina opened this issue Dec 26, 2022 · 3 comments
Open

ob_implicit_flush int doesn't cause error #1450

afilina opened this issue Dec 26, 2022 · 3 comments
Labels

Comments

@afilina
Copy link
Contributor

afilina commented Dec 26, 2022

I tried to use an int with ob_implicit_flush, and it did not cause an error in any version (3v4l):

ob_implicit_flush(1);

However, the sniff marks it as an error:

$phpcsFile->addError($error, $target['start'], $code, $data);

If the change is not backwards-incompatible in practice, should we highlight this as an error?

@jrfnl jrfnl added the question label Dec 26, 2022
@jrfnl
Copy link
Member

jrfnl commented Dec 26, 2022

@afilina Good question.

There are a couple of reasons why I believe the sniff is correctly throwing an error, but I am open to suggestions on how to improve the sniff further.

  1. It is an explicitly marked change in both the PHP 8.0 changelog and the function changelog.
  2. Whether it is a problematic change depends on whether or not strict_types is enabled.
    If it is, this change will cause a fatal TypeError: https://3v4l.org/o8mcK
    If it is not, then the non-strict-type type juggling for scalar values will silently "auto-mitigate" the change, but that doesn't take anything away from the fact that the wrong parameter type was passed.

Maybe it should be a warning if the file doesn't declare strict_types and an error when it does ?

Note: the same applies to the sem_get() function, which this sniff also handles.

@afilina
Copy link
Contributor Author

afilina commented Dec 26, 2022

Maybe it should be a warning if the file doesn't declare strict_types and an error when it does

This is exactly what I had in mind. Mark it as a warning without strict_types, mark as error with strict_types.

@jrfnl
Copy link
Member

jrfnl commented Dec 26, 2022

@afilina Want to try your hand at that change ?

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

No branches or pull requests

2 participants