You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 1, 2024. It is now read-only.
If the return value of a constructor is not used, the constructor is only called for its side effect or the intent was to do something with the value, but the author forgot.
Constructors with side effects that the caller cares about (without caring about the newly constructed object) are very rare and possibly bad form. Let's require that the new object is used in some manner. This makes statements that only contain a NewExpression a lint error.
Example of error that this linter would prevent.
if ($permission->hasNotBeenGrantedToUser($user)){
newPermissionDeniedException(...);
}
The intent was probably to throw the exception, but throw was left out.
See #412 for an example of this exact bug in hhast. fe8a322
If the return value of a constructor is not used, the constructor is only called for its side effect or the intent was to do something with the value, but the author forgot.
Constructors with side effects that the caller cares about (without caring about the newly constructed object) are very rare and possibly bad form. Let's require that the new object is used in some manner. This makes statements that only contain a NewExpression a lint error.
Example of error that this linter would prevent.
The intent was probably to throw the exception, but
throwwas left out.See #412 for an example of this exact bug in hhast.
fe8a322