note 114009 added to reflectionmethod.setaccessible

From: Date: Sun, 29 Dec 2013 19:30:32 +0000
Subject: note 114009 added to reflectionmethod.setaccessible
Groups: php.notes 
Request: Send a blank email to php-notes+get-198051@lists.php.net to get a copy of this message
It seems this doesn't work while making a public method to be inaccessible. Tried with 5.4: <?php namespace Test; class RefTest { public function copy() { echo 'x'; } } $reflection = new \ReflectionClass('Test\\RefTest'); $method = $reflection->getMethod('copy'); $method->setAccessible(false); /** @var $test RefTest */ $test = $reflection->newInstance(); $test->copy(); // still writes x to screen, whereas you may wait a fatal error ?> ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/reflectionmethod.setaccessible.php Edit -- https://master.php.net/note/edit/114009 Del: integrated -- https://master.php.net/note/delete/114009/integrated Del: useless -- https://master.php.net/note/delete/114009/useless Del: bad code -- https://master.php.net/note/delete/114009/bad+code Del: spam -- https://master.php.net/note/delete/114009/spam Del: non-english -- https://master.php.net/note/delete/114009/non-english Del: in docs -- https://master.php.net/note/delete/114009/in+docs Del: other reasons-- https://master.php.net/note/delete/114009 Reject -- https://master.php.net/note/reject/114009 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198051) next »