google-code-backups / xinc

Automatically exported from code.google.com/p/xinc
0 stars 0 forks source link

Prefer instanceof over in_array(class_parents, class_implements) [minor] #77

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Already in quite a few places there is code like:

if (!in_array('Class_Parent', class_parents($object) {
  // ...
}

This can be reliably replaced with the instanceof operator, as so:

if (!$object instanceof Class_Parent) {
  //..
}

instanceof has a higher precendence than boolean operators, so it's safe,
and is quicker and cleaner than using 2 function calls.  I'd recommend
using it for similar tasks going forward.  Quick patch for current trunk
attached - I hope the code coverage extends to the sections I've modified :)

Original issue reported on code.google.com by majelbst...@gmail.com on 12 Dec 2007 at 10:21

Attachments:

GoogleCodeExporter commented 8 years ago
Also, first time using Google Code - any way I can set the issue type and 
priority
that you know of?

Cheers,

Jamie.

Original comment by majelbst...@gmail.com on 12 Dec 2007 at 10:22

GoogleCodeExporter commented 8 years ago
Thanks jamie :-) Will integrate it.

For the priority stuff and type def I have to check the administration section.

Will see what I can do.

Arno

Original comment by arnos...@gmail.com on 12 Dec 2007 at 10:39

GoogleCodeExporter commented 8 years ago

Original comment by arnos...@gmail.com on 12 Dec 2007 at 10:49

GoogleCodeExporter commented 8 years ago
Fixed in Build.22 pls verify.

Thanks

Original comment by arnos...@gmail.com on 13 Dec 2007 at 12:50

GoogleCodeExporter commented 8 years ago
Verified here - looks good.

Cheers,

Jamie.

Original comment by majelbst...@gmail.com on 13 Dec 2007 at 11:06

GoogleCodeExporter commented 8 years ago
thx

Original comment by arnos...@gmail.com on 14 Dec 2007 at 6:41