oop - What fundamental objects are missing in Object Oriented PHP? -


i've been coding php while, , i've been relatively irritated @ inconsistencies in procedural functions (especially strings , arrays).

with support objects, i've been wishing php had native implementation of arrays , strings objects write code like:

$arr = new array('foo', 'bar'); $item = $arr->pop(); 

making array-like object isn't overly difficult, however, there's significant performance hit. end being wrapper array constructs anyway.

are there other core objects php should have object oriented php?

edit add:

this not how can use arrays objects; in fact, not want discussion of arrays in answer, that's not question about. used arrays example, , seems no 1 read question. interested in other classes/objects should exist natively in core php.

edit: possible in php 6 aoutoboxing automatic conversion compiler makes between primitive (basic) types , corresponding object wrapper classes (eg, array , arrayobject, double , double, etc). there special function named __autobox()

    <?php function __autobox($value) {     return ... /* object */ } ?> 

for example :

function __autobox($value)      {         switch(gettype($value))         {             case 'integer':                 return new myintegerobject($value);                 break;              case 'array':                 return new arrayobject($value);                 break;              default:                 $stdobj =  new stdclass();                 $stdobj->value = $value;                 return $stdobj;                 break;          }     } 

example using:

var_dump(5 == new myinteger(5)); bool(true) 

Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -