Is it possible to simply make methods work with both static calls and instantiated object calls.
For example:
class MyClass {
private static $instance = null;
private $my_value = 'Foo';
public function __construct() {
self::$instance = new self;
}
public static function my_function() {
if( isset( $this ) ) {
$target = $this->; // I know its an invalid declaration
} else {
$target = self::$instance->; // I know its an invalid declaration
}
return $target $my_value; // Invalid statement
}
}
$my_object = new My_Class();
echo $my_object->my_function(); // Should output Foo
echo My_Class::my_function(); // Should output Foo
Hope this is clear