$class = new \ReflectionClass('MyNamespace\MyClass');
$myProtectedMethod = $class->getMethod('myProtectedMethod');
$myProtectedMethod->setAccessible(true);
$myInstance = new MyClass();
$result = $myProtectedMethod->invokeArgs($myInstance, [$argument1, $argument2]);
$class = new \ReflectionClass('MyNamespace\MyClass');
$myProtectedProperty = $class->getProperty(myProtectedProperty);
$myProtectedProperty->setAccessible(true);
$myInstance = new MyClass();
$myProtectedProperty->setValue($myInstance, 'value');
Sign up for our newsletter to stay up to date.
We care about the protection of your data. Read our Privacy Policy.
Schopenhauerstr. 71
80807 München
max@42coders.com
+49 (0)176 / 724 306 82
© 2024 42coders All rights reserved.