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
Specify whether traffic signals have tactile indications that it's safe to cross
Determine roads lane count
Specify motorcycle parking capacities
Specify motorcycle parkings covers
Specify parking access
Specify road surfaces
Specify whether roads have lane markings
Survey postbox collection times
Specify street/place names to addresses
Survey opening hours
Survey hairdresser's customers
Survey if places still exist
Specify cycleways width
Specify width of opening
Specify whether there are cycleways
Created a main entrance and a home entrance
Okay, I think I fixed the PECL load situation.
Everything is now cached.
It means nobody can upload any new versions as you can't log in, but at least the server is not dying now.
It is deprecated, so this temporary measure is good enough for now.
I walked 2.8km in 18m39s
I've just finished reading The Things We Make by Bill Hammack.
A curious introduction into the world of the engineering method. How it's different from pure science and with the end product of serving mankind in mind.
Updated a restaurant
Updated 2 restaurants; Confirmed a bakery shop
I walked 4.1km in 48m53s
Updated a restaurant
Updated a bar
I walked 8.9km in 4h29m34s


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