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
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/ppe-46g