ignace nyamagana butera on Nostr: #PHP I've notice that I barely use __toString nowadays. I came to realise that there ...
#PHP I've notice that I barely use __toString nowadays. I came to realise that there is no one true single string representation for anything. So __toString is a bad micro/early optimisation that should be avoided. It is conceptually a bad idea. I prefer toWhateverRepresentationString. it might be a bit longer to type but it won't bite you in six months.
PS: I have the same thoughts for toArray.
Published at
2026-07-11 11:46:32 UTCEvent JSON
{
"id": "bdd99b5525ea3aaf0bf405251c3e5dbbf2edeb4c899592ad06798ae71f3f04a8",
"pubkey": "e9d881022615c98346bc5e6f055d6275500e5eea7a406095b6e1ae400c89ea10",
"created_at": 1783770392,
"kind": 1,
"tags": [
[
"t",
"php"
],
[
"proxy",
"https://phpc.social/users/nyamsprod/statuses/116901176420524341",
"activitypub"
],
[
"client",
"Mostr",
"31990:6be38f8c63df7dbf84db7ec4a6e6fbbd8d19dca3b980efad18585c46f04b26f9:mostr",
"wss://relay.ditto.pub"
]
],
"content": "#PHP I've notice that I barely use __toString nowadays. I came to realise that there is no one true single string representation for anything. So __toString is a bad micro/early optimisation that should be avoided. It is conceptually a bad idea. I prefer toWhateverRepresentationString. it might be a bit longer to type but it won't bite you in six months. \nPS: I have the same thoughts for toArray.",
"sig": "d6ee3718ce749ae997c14c8375538c918fffe18222902c18e4b0e24f4f42b20df906c4855c1e2554c2490e6866e32dff65e203a433b1fd4c3889e43e3327ebb1"
}