I’m sure I read a while back about a new feature of PHP that was either a new magic method or a new interface so that you could implement Arrayable methods.
eg
interface Arrayable
{
public function toArray();
}
Was I imagining it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes.
There is no interface (PHP 5.4 or otherwise) within PHP for handling casting to an array.
PHP 5.4.0 introduced the
JsonSerializableinterface, perhaps you’re thinking of that?There’s also a draft RFC (one of several related) that suggests a
__toArray()method; see Request for Comments: Scalar Type Casting Magic Methods