????JFIF??x?x????'
Server IP : 79.136.114.73 / Your IP : 3.145.116.170 Web Server : Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.29 OpenSSL/1.0.1f System : Linux b8009 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 User : www-data ( 33) PHP Version : 5.5.9-1ubuntu4.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/home/b8009/php-5.6.22/ext/reflection/tests/ |
Upload File : |
--TEST-- Test ReflectionProperty::setAccessible(). --FILE-- <?php class A { protected $protected = 'a'; protected static $protectedStatic = 'b'; private $private = 'c'; private static $privateStatic = 'd'; } class B extends A {} $a = new A; $protected = new ReflectionProperty($a, 'protected'); $protectedStatic = new ReflectionProperty('A', 'protectedStatic'); $private = new ReflectionProperty($a, 'private'); $privateStatic = new ReflectionProperty('A', 'privateStatic'); try { var_dump($protected->getValue($a)); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($protectedStatic->getValue()); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($private->getValue($a)); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($privateStatic->getValue()); } catch (ReflectionException $e) { var_dump($e->getMessage()); } $protected->setAccessible(TRUE); $protectedStatic->setAccessible(TRUE); $private->setAccessible(TRUE); $privateStatic->setAccessible(TRUE); var_dump($protected->getValue($a)); var_dump($protectedStatic->getValue()); var_dump($private->getValue($a)); var_dump($privateStatic->getValue()); $protected->setValue($a, 'e'); $protectedStatic->setValue('f'); $private->setValue($a, 'g'); $privateStatic->setValue('h'); var_dump($protected->getValue($a)); var_dump($protectedStatic->getValue()); var_dump($private->getValue($a)); var_dump($privateStatic->getValue()); $a = new A; $b = new B; $protected = new ReflectionProperty($b, 'protected'); $protectedStatic = new ReflectionProperty('B', 'protectedStatic'); $private = new ReflectionProperty($a, 'private'); try { var_dump($protected->getValue($b)); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($protectedStatic->getValue()); } catch (ReflectionException $e) { var_dump($e->getMessage()); } try { var_dump($private->getValue($b)); } catch (ReflectionException $e) { var_dump($e->getMessage()); } $protected->setAccessible(TRUE); $protectedStatic->setAccessible(TRUE); $private->setAccessible(TRUE); var_dump($protected->getValue($b)); var_dump($protectedStatic->getValue()); var_dump($private->getValue($b)); $protected->setValue($b, 'e'); $protectedStatic->setValue('f'); $private->setValue($b, 'g'); var_dump($protected->getValue($b)); var_dump($protectedStatic->getValue()); var_dump($private->getValue($b)); ?> --EXPECT-- string(44) "Cannot access non-public member A::protected" string(50) "Cannot access non-public member A::protectedStatic" string(42) "Cannot access non-public member A::private" string(48) "Cannot access non-public member A::privateStatic" string(1) "a" string(1) "b" string(1) "c" string(1) "d" string(1) "e" string(1) "f" string(1) "g" string(1) "h" string(44) "Cannot access non-public member B::protected" string(50) "Cannot access non-public member B::protectedStatic" string(42) "Cannot access non-public member A::private" string(1) "a" string(1) "f" string(1) "c" string(1) "e" string(1) "f" string(1) "g"