jeudi 8 octobre 2020

Can not get private property from reflection object php

So the project I am working on has multiple sub projects and in some cases, while not ideal there is communication across them with serialized objects.

Now I need to access some private properties from a serialized object, I wanted to use Reflection class, but I could not access the property, my code is as follows.

$test = new ReflectionObject($object);
$test2 = $test->getProperty('something');
$test2->setAccessible(true);

Now I get back message 'Property something does not exist'

Ok, so I check what variables are in class with get_object_vars() and I get back this

'__PHP_Incomplete_Class_Name'
'�modules\xx\yy�something'
'�modules\xx\yy�somethingElse'

yet I can not access either something or somethingElse if I copy paste it into reflection.

Is there an easier way to access private properties? Or should I how could I access them?

Using PHP 7.1





Aucun commentaire:

Enregistrer un commentaire