Consider this sample code
<?php
class MyAwesomeClass {
public $myawesomeproperty = 'test';
public function __construct() {
$self = new stdClass();
$self->myawesomeproperty = "hello guys!";
}
}
$test_obj = new MyAwesomeClass();
echo '<pre>';
var_export( $test_obj );
echo '</pre>';
?>
It's supposed to set "myawesomeproperty" to a new string so var_export shows "hello guys!" in the output.
What I'm actually getting is
MyAwesomeClass::__set_state(array(
'myawesomeproperty' => 'test',
))
Apparently the construct function does not save anything to actual object.
Why is this happening? What am I missing?