Sebastian Mendel wrote:
> Hi,
> 
> how can i check if a method is called statically when called from inside
> another object? (without debug_bactrace())
> 
> 
> class foo
> {
>     function bar()
>     {
>         if ( isset( $this ) )
>         {
>             return 'not static';
>         }
>         return 'static';
>     }
> 
>     function bar2() { foo::bar(); }
> }
> 

sorry, my mistake

// returns 'static'
echo foo::bar();

// returns 'not static' but should be 'static'
$foo = new foo;
echo $foo->bar2();

> so, how can i prevent a method from called static or not called static?
> 
> and btw. does anynone know why it is not good to let one function handle
> both mehtods of calling (static and not static) as in PHP 5 you will get
> notices if called wrong - but PHP doesnt support multiple
> function-definitions like:
> 
> class foo
> {
>     static function bar()
>     {
>         return ANY_DEFAULT_VALUE;
>     }
> 
>     function bar()
>     {
>         return $this->value;
>     }
> }
> 
> or even
> 
> 
> class foo
> {
>     static function bar( $param )
>     {
>         return $param;
>     }
> 
>     function bar()
>     {
>         return $this->param;
>     }
> }
> 
> or is this at least an issue for the internals-list?
> 


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to