Re: New function proposal: spl_class_vars / params / contents
| From: | Etienne Kneuss | Date: | Tue, 20 Jan 2009 20:04:47 +0000 |
| Subject: | Re: New function proposal: spl_class_vars / params / contents | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-42734@lists.php.net to get a copy of this message | ||
Hello,
On Tue, Jan 20, 2009 at 8:30 PM, Kenan R Sulayman
<kureal@kkooporation.de> wrote:
> Hi,
> I'd like to propose a new function: spl_class_vars / params / contents.
>
> Notice: I haven't figured out a name yet Please help me find one.. :-)
>
> The function returns an array of the contents of the given class-object.
> The class-object parameter may be text or rather directly the object ( new
> foo() ).
>
> Example, while the function-name 'spl_class_contents' is being used :
> <?php
> class foo {
> public $data = array();
> public $lastbit = null;
> public $passive = null;
> public static $bar = null;
> public $foo = true;
>
> public function registerCall ( $key, $call, $passive =
> false ) {
> return $this ->foo;
> }
>
> private static function bregisterCall ( $key, $call,
> $passive = false ) {
> return $this ->foo;
> }
> }
> print_r ( spl_class_contents( 'foo' ) );
> print_r ( spl_class_contents( new foo() ) );
> ?>
>
> Expected
> Ex. 1:
> <?php
> print_r ( spl_class_contents( 'foo' ) );
> ?>
> should return the following array: ( print_r 'd, cause the returning value
> should be usable for other functions )
>
> Array
> (
> [data] => Array
> (
> [0] => public
> [1] => array
> )
> [lastbit] => Array
> (
> [0] => public
> [1] => null
> )
> [passive] => Array
> (
> [0] => static
> [1] => null
> )
> [foo] => Array
> (
> [0] => public
> [1] => true
> )
> [registerCall] => Array
> (
> [0] => public
> [function] => Array
> (
> [0] => key
> [1] => call
> [passive] => false
> )
> )
> )
>
> Ex.2.
> Example 2 should return the same as the above example.
Why can't you use Reflection in this case? It looks like you can quite
easily implement that in userland from Reflection.
Regards
>
> Cheers,
> --
> (c) Kenan Sulayman
> Freelance Designer and Programmer
>
> Life's Live Poetry
>
--
Etienne Kneuss
http://www.colder.ch
Men never do evil so completely and cheerfully as
when they do it from a religious conviction.
-- Pascal