php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64136 Better things handling - basic variables should behave like object, etc
Submitted: 2013-02-02 19:52 UTC Modified: 2018-02-27 11:25 UTC
Votes:20
Avg. Score:4.8 ± 0.5
Reproduced:11 of 11 (100.0%)
Same Version:3 (27.3%)
Same OS:3 (27.3%)
From: staff at newsocialife dot com Assigned:
Status: Suspended Package: *General Issues
PHP Version: Irrelevant OS: Doesn't matter
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: staff at newsocialife dot com
New email:
PHP Version: OS:

 

 [2013-02-02 19:52 UTC] 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



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-10-24 06:22 UTC] yohgaki@php.net
-Summary: Better things handling +Summary: Better things handling - basic variables should behave like object, etc
 [2018-02-27 11:25 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2018-02-27 11:25 UTC] cmb@php.net
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>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 01:01:28 2024 UTC