php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80068 Feature request magic methods
Submitted: 2020-09-07 04:38 UTC Modified: 2020-09-07 04:41 UTC
From: peter dot quinn at optushome dot com dot au Assigned:
Status: Duplicate Package: Class/Object 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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: peter dot quinn at optushome dot com dot au
New email:
PHP Version: OS:

 

 [2020-09-07 04:38 UTC] peter dot quinn at optushome dot com dot au
Description:
------------
A toNumeric(), toArray, toObject would be handy so can cast an object in different ways.

Eg, If I had a object which had the queried result set from a database query within a private member, then could use toString() to display the current row as say a HTML version of it, use toArray to return the current row as an array, and use toObject to return the current row as an object.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-07 04:41 UTC] requinix@php.net
-Status: Open +Status: Duplicate
 [2020-09-07 04:41 UTC] requinix@php.net
Duplicate of other requests, and the idea of casting objects to other types has been discussed multiple times on the mailing list.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 09:00:02 2026 UTC