php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51598 String Objects?
Submitted: 2010-04-19 11:05 UTC Modified: 2020-10-23 12:42 UTC
Votes:6
Avg. Score:5.0 ± 0.0
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:1 (25.0%)
From: tom at r dot je Assigned:
Status: Suspended Package: Strings related
PHP Version: Irrelevant OS:
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tom at r dot je
New email:
PHP Version: OS:

 

 [2010-04-19 11:05 UTC] tom at r dot je
Description:
------------
To make PHP more object-oriented it would be useful to give primitives (Strings 
especially, as they have a large number of related functions) a more OO 
interface.

In the same way PHP5 introduced ArrayObject, it would be useful to create a 
StringObject in PHP6.

E.g. example usage:

<?php
//Some example usage
$str = 'Foo';
echo $str->toLower();
echo $str->replace('Foo', 'Bar');
echo $str->replace('Foo', 'Bar')->toLower(); //ideally needs inbuilt support for 
chaining
echo $str; //could be done using __toString()
?>

This can be achieved at the moment by defining a StringObject class and using 
$str = new String('My String'); or similar.  However, the usefulness is limited 
because there's no way to automatically wrap all strings within the application.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-23 14:34 UTC] tyrael@php.net
-PHP Version: 6SVN-2010-04-19 (snap) +PHP Version: Irrelevant
 [2020-10-23 12:42 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2020-10-23 12:42 UTC] cmb@php.net
This feature request needed to be discussed, for what this bug
tracker is unsuitable.  So if you're still interested in this
feature, please forward the request to the internals mailing
list[1].  For the time being, I'm suspending this ticket.

[1] <https://www.php.net/mailing-lists.php#internals>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 21:01:28 2024 UTC