Currently our coding conventions have major prohibitions on the use of
isset() and empty(). I can understand isset(), because sometimes it makes
more sense logically to have boolean casting or strict type checking, but
in the case of empty(), it's significantly faster than boolean casting and
is mo
On 06/02/13 15:18, Tyler Romeo wrote:
> If you're checking for *whether an array is empty*, which is more intuitive:
>
> if( !$array ) // If the boolean value of the array is false
> if( empty( $array ) ) // If the array is empty
The second is more intuitive. The first is more readable, since it
Hey,
Why is this thread not titled "return of the bikeshed"? I've seen this one
so many times over the past few days. Wonder how many man-days have been
wasted on this :)
> It doesn't seem faster to me.
Those benchmarks are only testing some rather small arrays no?
I did some stuff a while back
On Wed, Feb 6, 2013 at 8:36 PM, Jeroen De Dauw wrote:
>
> > Currently our coding conventions have major prohibitions on the use of
> isset() ...
>
> Oh, would not think so if you did a grep on core.
>
> There are valid uses for isset, and as far as I am aware, those are not
prohibited and are acti
So basically here's my goal (it's the same as if ( v. if( ). I don't care
about reaching consensus on either side, because such an attempt is futile.
The only thing I want to at least get some support on is that a given
patchset should not be blocked from merging just because it uses empty() in
a p
Le 06/02/13 22:22, Tyler Romeo a écrit :
> So basically here's my goal (it's the same as if ( v. if( ). I don't care
> about reaching consensus on either side, because such an attempt is futile.
I prefer unless( !$foo ) but that is just me.
> The only thing I want to at least get some support on
>
> I discourage the use of empty(), it can leads to so many potential
> mistakes that is better to simply never use it.
The only mistake it can lead to is if there's a typo in a variable name,
but in cases like this:
function myfunc( array $var ) {
if( empty( $var ) )
I highly doubt there'
On 07/02/13 06:36, Jeroen De Dauw wrote:
> Those benchmarks are only testing some rather small arrays no?
>
> I did some stuff a while back as well:
> https://github.com/JeroenDeDauw/php/blob/master/profile/array-empty.php
That is an interesting way to do benchmarks. XHProf has a bug in it
which
Le 06/02/13 23:48, Tyler Romeo wrote:
> The only mistake it can lead to is if there's a typo in a variable name,
> but in cases like this:
There are a few more possible such as 0 or "0" being considered empty.
And as you said, that hide the fact a variable is not defined, that is
sometime useful,