Posted by Sebastian Mendel on 07/21/05 12:16
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(); }
}
// returns 'not static'
echo foo::bar();
// returns 'static' but should be 'not 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
Navigation:
[Reply to this message]
|