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

Skip to content

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Aug 10, 2020

If an object constructor exit()s, the object destructor will no longer be
called. This matches the behavior when the constructor throws.

Notes:

  • This sniff will throw an error, even when there is no destructor as a destructor may be declared in a parent class.
    👉 We could reduce the potential noise from this sniff a little further by only throwing the error when the class either contains a __destruct() method or extends a parent class. Should we ?
  • The name for the sniff feels a bit long. Suggestions for a better/shorter name welcome.

Opinions ?

Refs:

Related to #809

…estructAfterConstructorExit` sniff

> If an object constructor exit()s, the object destructor will no longer be
> called. This matches the behavior when the constructor throws.

Notes:
* This sniff will throw an error, even when there is no destructor as a destructor may be declared in a parent class.
    We could reduce the potential noise from this sniff a little further by only throwing the error when the class either contains a `__destruct()` method or extends a parent class.
* The name for the sniff feels a bit long. Suggestions for a better/shorter name welcome.

Opinions ?

Refs:
* https://github.com/php/php-src/blob/71bfa5344ab207072f4cd25745d7023096338385/UPGRADING#L200-L201
* php/php-src#5768 (I suspect, but not 100% sure)
* php/php-src@75a04ea
@wimg wimg merged commit 17cac7d into develop Aug 18, 2020
@wimg wimg deleted the php-8.0/new-removeddestructafterconstructorexit-sniff branch August 18, 2020 15:03
@jrfnl
Copy link
Member Author

jrfnl commented Aug 18, 2020

He @wimg We forgot to discuss the open question in this PR in our call. Opinions ?

@wimg
Copy link
Member

wimg commented Aug 18, 2020

He @wimg We forgot to discuss the open question in this PR in our call. Opinions ?

Sorry about that, I missed that. I believe this would be a valuable thing to do yes.

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.

3 participants