var_export and classes
Today I stumbled upon an old problem while using var_export() on an array with objects. var_exports()'s description is " Outputs or returns a parsable string representation of a variable ", but it didn't work to well in this case:
array (
0 =>
class ezcTranslationData {
public $original = 'Node ID:';
public $translation = 'Knoop ID:';
public $comment = false;
public $status = 0;
},
);
This snippet above can of course not be parsed as valid PHP code. After thinking about it for a bit, I came up with a solution. Instead of the code above, we now generate:
array (
0 =>
ezcTranslationData::__set_state(array(
'original' => 'Node ID:',
'translation' => 'Knoop ID:',
'comment' => false,
'status' => 0,
)),
);
The __set_state() method is then required to be implemented by the class for this to work, but that is better than generating code which can never be parsed. The name comes from the Memento pattern . As this fixes a bug this made it into PHP 5.1.0 and PHP 6.0.0.
Life Line
What new fresh hell is this?
"Please click here and tick the box if you DO NOT want to be opted in."
And when you click on the non-visible link:
"[ ] I DO NOT want to be opted in."
@jamesholden Have you ever seen the Expanse? One of the main characters shares your name!
I walked 4.4km in 51m58s
I walked 8.2km in 1h40m07s
I walked 2.4km in 38m25s
@Edent With your ActivityPub implementation, have you figured out how to allow quote posts for your bot posts yet?
📷 Brown Cap in the Grass
🚩 Herikhuizerweg, Rheden, Nederland
I walked 0.9km in 11m17s
I walked 2.8km in 25m32s
I walked 4.6km in 1h8m02s
📷 Stalkers Lane
🚩 Graywood Lane, Wealden, United Kingdom
I hiked 23.0km in 4h10m15s
I walked 3.9km in 39m07s
After my PHP 8.5 in Leeds last night, it's now time to head to Rotterdam to give the same talk there tonight!
It's cold out here, but atleast the snow is now gone.
I walked 1.7km in 13m18s
📷 Avenue Gardens
🚩 Princess Road, London Borough of Brent, United Kingdom
📷 Leafy Entrance
🚩 East Heath Road, London Borough of Camden, United Kingdom
📷 From Green to Yellow.
🚩 St John's Wood Road, City of Westminster, United Kingdom
I walked 9.1km in 1h56m24s







Shortlink
This article has a short URL available: https://drck.me/vac-46l