Req #64136 [Opn->Sus]: Better things handling - basic variables should behave like object, etc

From: Date: Tue, 27 Feb 2018 11:25:52 +0000
Subject: Req #64136 [Opn->Sus]: Better things handling - basic variables should behave like object, etc
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214124@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64136&edit=1

 ID:                 64136
 Updated by:         cmb@php.net
 Reported by:        staff at newsocialife dot com
 Summary:            Better things handling - basic variables should
                     behave like object, etc
-Status:             Open
+Status:             Suspended
 Type:               Feature/Change Request
 Package:            *General Issues
 Operating System:   Doesn't matter
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Since this would be a substantial change, it would require the RFC
process[1].  Therefore I'm suspending this ticket for the time
being.

[1] <https://wiki.php.net/rfc>


Previous Comments:
------------------------------------------------------------------------
[2015-05-28 10:21:58] cmb@php.net

See also <https://nikic.github.io/2014/03/14/Methods-on-primitive-types-in-PHP.html>.

------------------------------------------------------------------------
[2013-02-02 19:52:40] staff at newsocialife dot com

Description:
------------
I would really like to have something like a better handling of array, strings, numbers and so on.
Look at my examples, you will understand better what i mean

Test script:
---------------
<?php
$a = [2, 3, 4, 5]; // I define an array as for php 5.4
$a = $a->map(function($el) { // $a = array_map(callback, $a);
   return $el +1;
});

$b = "Hello";
$b = $b->substr(0, -1); // $b = substr($b, 0, -1);

$c = [2, 3];
$c = $c->merge([4, 5]); // $c = array_merge($c, [4, 5]);

$d = 22 + [2, 3, 4, 5, 6]; // $d = 22 + 2 + 3 + 4 + 5 + 6

$a[] = $b;
$a[] = $c;
$a[] = $d;

// i also would like to have a built-in swap function like this:
$a->swap($b); // $a is $b and $b is $a 

Expected result:
----------------
$a should be [3, 4, 5, 6, "Hell", [2, 3, 4, 5], 42];
$b should be "Hell";
$c should be [2, 3, 4, 5];
$d should be The answer to universe, life and everything; // 42




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



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


Thread (3 messages)

« previous php.bugs (#214124) next »