late-static-binding

Is there a way to have PHP subclasses inherit properties (both static and instance)?

If I declare a base class as follows: abstract class Parent { protected static $message = "UNTOUCHED"; public static function yeah() { static::$message = "YEAH"; } public static function nope() { static::$message = "NOPE"; } public static function lateStaticDebug() { return(static...

Is it possible to overuse late static binding in PHP?

Starting with version 5.3, PHP supports late binding for static methods. While it's an undoubtedly useful feature, there are only several cases where its use is really necessary (e.g. the Active Record pattern). Consider these examples: 1. Convenience constructors (::create()) class SimpleObject { public function __construct() {...

What exactly is late-static binding in PHP?

Hello, What exactly is late-static binding in PHP? ...

Forget late static binding, I need late static __FILE__ ...

I'm looking for the get_called_class() equivalent for __FILE__ ... Maybe something like get_included_file()? I have a set of classes which would like to know what directory they exist in. Something like this: <?php class A { protected $baseDir; public function __construct() { $this->baseDir = dirname(__FILE__); }...

Inherit static properties in subclass without redeclaration?

Hi, I'm having the same problem as this guy with the application I'm writing right now. The problem is that static properties are not being inherited in subclasses, and so if I use the static:: keyword in my main class, it sets the variable in my main class as well. It works if I redeclare the static variables in my subclass, but I expe...

get_called_class hack not working with eval-code.

Hi there. I am using a ge_called_class hack for allowing late static binding in php version 5.2 (found here). I have the following in my code: # db_record.php $ac = "ForumThread"; $objects = $ac::find("all"); This will not work in php 5.2 for some reason, so I have done this: # db_record.php $ac = "ForumThread"; eval("\$objects =...

Abstract Factories not possible in php < 5.3?

I was working on an abstract class to save on some code for a couple of classes. These classes are all factories that instantiate themselves through different static calls. I could save some code by putting all those methods in an abstract class. However, I ran into a late static binding problem... since our web host isn't using 5.3 or...

Objective-C Late Static Binding

I'm teaching myself Objective-C as a guilty pleasure, if you would. I have a self-proclaimed strong grasp of the Java language, so it's not a terribly difficult transition – it sure is fun though. But alas, my question! I'm attempting to reproduce something that exists in PHP: Late Static Binding. In PHP, I can decorate a method call w...