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
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
Created a crossing and a gate
Specify road surfaces
Specify whether pedestrian crossings have markings


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