Edit report at https://bugs.php.net/bug.php?id=65703&edit=1

 ID:                 65703
 Updated by:         requi...@php.net
 Reported by:        worldoffame at hotmail dot com
 Summary:            Primitives, Strings and Arrays as Objects
-Status:             Open
+Status:             Wont fix
 Type:               Feature/Change Request
 Package:            Class/Object related
 Operating System:   Irrelevant
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

This has been brought up numerous times before with the answer of "not going to 
happen anytime soon".

You can bring this subject up on the internals mailing list but know that 
requesting such a huge (I don't know if I can stress that enough) change simply 
because other languages do it that way won't get much of a positive response.

http://www.php.net/mailing-lists.php#internals

You may also be interested in the autoboxing RFC.

https://wiki.php.net/rfc/autoboxing


Previous Comments:
------------------------------------------------------------------------
[2013-09-19 04:02:57] worldoffame at hotmail dot com

Description:
------------
Well currently in PHP not everything is an object, if you use the object 
operator -> on an integer variable(like 2->toFloat()) you will get an error. 
Strings and Arrays are not object either, and these are bigger problems than 
primitives like integers, floats and booleans. 

So I propose that in PHP 5.6 everything is an object. The PHP core will provide 
special classes such as Boolean, Integer, Float, String and Array, all of them 
have methods for client users to manipulate. 

For Booleans and Integers, the methods will be quite limited. But for Strings 
and Arrays, each currently available orphan string/array functions can be made 
into methods. Below is how you'd play with strings and arrays in PHP 5.5 and 
5.6:

PHP 5.5:
echo strtoupper("this is a string");
$array = sort([2, 5, 1, 4, 6, 3]);

PHP 5.6:
echo "this is a string"->toUpper();
$array = [2, 5, 1, 4, 6, 3]->sort();

Id say the proposed methods are much more elegant, and thats how Python and 
Ruby deal with strings and arrays. Also the keyword array will be removed as 
Array will be used as a class name.

In PHP 5.7 and beyond it may be a good point to consider deprecating the 
traditiona/procedural way of creating primitive types, strings and arrays.  



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=65703&edit=1

Reply via email to