|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-09-19 04:59 UTC] requinix@php.net
-Status: Open
+Status: Wont fix
[2013-09-19 04:59 UTC] requinix@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 14:00:01 2025 UTC |
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.