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
Merge branch 'v2022'
Merge pull request #196 from jorgsowa/fix-tzparse-oob-counts
Validate TZif header counts to prevent OOB access
Long-Tailed Tit at Sunrise
Along the sea wall at RSPB Rainham Marshes this tiny birb was enjoying the berries in the bushes.
#photography #Birds #BirdPhotography #BirdsOfFediverse #NaturePhotography #wildlife #RSPB #RainhamMarshes
Survey housenumbers
Determine roads lane count
Specify whether roads have lane markings
Specify whether there are cycleways
Specify whether crosswalks have tactile paving
Specify whether roads have sidewalks
Survey opening hours
Specify path surfaces
Survey if places still exist
Specify parking access
Specify road surfaces
Specify parking types
Specify street/place names to addresses
Specify bicycle parking capacities
Specify bicycle parking types
Specify bicycle parkings covers
Specify path surfaces
Specify width of opening
Specify type of entrances
Specify street/place names to addresses
Survey housenumbers


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