Private Properties Exposed
For our Components project we are ofcourse writing unit tests (with PHPUnit ). Sometimes you would want to test whether a private property contains the correct data, and of course with the normal visibility rules you can't access those from your unit test. There is an interesting trick for this, which I'll share here:
<?php
class foo {
private $bar = 42;
}
$obj = new foo;
$propname="\0foo\0bar";
$a = (array) $obj;
echo $a[$propname];
?>
Comments
$f->{"0Foo0id"} (for private members) and $f->{"0*0name"} (for protected ones) used to work. Too bad someone added a "Cannot access property started with '0'" fatal error to the Zend Engine in the meantime, making necessary the array-cast hack presented here...
I'd rather have ReflectionProperty->setAccessible(TRUE) like (insert other programming language here):)
Life Line
Specify whether pitches are lit
Survey whether benches have backrests
Specify what can be recycled in recycling containers
Specify type of recycling amenities
Survey postbox collection times
Determine whether any glass or just glass bottles can be recycled here
Specify whether bicycles can be charged at charging stations
Specify whether pedestrian crossings have islands
Specify whether pedestrian crossings have traffic signals
Specify parking types
Specify bicycle parking types
Add whether public transport stops are lit
Specify whether public transport stops have tactile paving
Determine the heights of kerbs at crossings
Specify whether roads have lane markings
Specify whether there are cycleways
Specify bollard types
Determine the heights of kerbs
Specify whether kerbs have tactile paving
Specify bicycle parkings covers
Survey if places still exist
Specify road surfaces
Specify whether crosswalks have tactile paving
Specify street/place names to addresses
Specify whether steps have a ramp

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