From:             worldoffame at hotmail dot com
Operating system: Irrelevant
PHP version:      Irrelevant
Package:          Class/Object related
Bug Type:         Feature/Change Request
Bug description:Primitives, Strings and Arrays as Objects

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 bug report at https://bugs.php.net/bug.php?id=65703&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65703&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=65703&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=65703&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=65703&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=65703&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=65703&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=65703&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=65703&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=65703&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=65703&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=65703&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=65703&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=65703&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65703&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=65703&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=65703&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=65703&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65703&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=65703&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65703&r=mysqlcfg

Reply via email to