[wp-trac] [WordPress Trac] #52996: Coding standard : Undefined varible $results
WordPress Trac
noreply at wordpress.org
Thu Apr 8 02:33:02 UTC 2021
#52996: Coding standard : Undefined varible $results
--------------------------+-------------------------------
Reporter: ravipatel | Owner: (none)
Type: defect (bug) | Status: new
Priority: low | Milestone: 5.8
Component: General | Version: trunk
Severity: trivial | Resolution:
Keywords: has-patch | Focuses: coding-standards
--------------------------+-------------------------------
Changes (by jrf):
* priority: normal => low
* version: => trunk
* severity: normal => trivial
* milestone: Awaiting Review => 5.8
Comment:
@ravipatel The report is valid and the patch good. Thanks for that.
Having said that, I think we may need to rethink the practice happening
here.
The first few functions in this file, all end with something along the
lines of:
{{{#!php
<?php
// Unset to save memory.
unset( $results, $r );
return $hashtable;
}}}
With how PHP memory management and garbage collection works, this, to me,
is ludicrous.
Variables created within the scope of a function are discarded
**automatically** when PHP leaves the scope of the function, i.e. on
`return`, so doing a call to `unset()` straight before a `return`
statement is absolutely unnecessary and useless.
These statements can, and should be, removed.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/52996#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list