late-static-binding Questions
2
Solved
Take a look at this example, and notice the outputs indicated.
<?php
class Mommy
{
protected static $_data = "Mommy Data";
public static function init( $data )
{
static::$_data = $data;
...
Biller asked 2/1, 2011 at 4:51
3
Solved
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 no...
Filter asked 30/7, 2009 at 0:24
3
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...
Strew asked 1/5, 2010 at 22:11
4
Solved
Trying to make an abstract class to partially implement functionality of its' child classes and force a contract upon them required for this implementation, I use the following construct:
abstract ...
Contrariety asked 28/6, 2017 at 13:4
8
Solved
What exactly are late static bindings in PHP?
Adrienadriena asked 16/12, 2009 at 7:17
3
Solved
I am converting a PHP 5.3 library to work on PHP 5.2. The main thing standing in my way is the use of late static binding like return new static($options); , if I convert this to return new self($o...
Futurism asked 4/3, 2011 at 17:41
1
I work on a proprietary project that uses quite a lot of factories of one form or another. Most of them don't instantiate the class by name, fortunately, but whether new self() or new static() is u...
Royston asked 20/10, 2017 at 13:10
2
Solved
Why some developers create one method that returns new static? What is the reason to have a method that returns new static? I am not asking what is the difference between static and self, or what s...
Michell asked 26/5, 2016 at 12:15
5
Solved
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. Somethin...
Pasteurization asked 27/4, 2010 at 4:53
3
Solved
Most PHP IDEs rely on phpdoc to get hints about the type of an expression. Yet, I use frequently this pattern, which doesn't seem to be covered:
class Control {
private $label = '';
/** @return...
Tetrad asked 2/5, 2011 at 13:56
1
In this StackOverflow question I learned that self:: was not inheritance-aware where static:: was (in PHP). When it comes to defining a bunch of constants within a class, if you want to override th...
Falsecard asked 5/11, 2014 at 15:2
3
Solved
Code in parent class:
foreach(static::$_aReadOnlyDatabaseTables AS $TableName => $aColumns){
// Do something
}
This works when $_aReadOnlyDatabaseTables is defined in the child class, but th...
Td asked 18/3, 2013 at 17:32
1
I am trying to make a script that is built for php 5.3 work on a php 5.2 server. The script uses a lot of late static binding like:
return new static($options);
What is the equivalent to this in...
Ecclesiastic asked 4/3, 2011 at 16:24
1
Solved
I'm trying to accomplish this without requiring a function on the child class... is this possible? I have a feeling it's not, but I really want to be sure...
<?php
class A {
public static func...
Littleton asked 6/3, 2012 at 4:40
3
Solved
How do I call child function from parent static function ?
In php5.3 there is a built in method called get_called_class() to call child method from parent class. But my server is running with php ...
Rhinitis asked 13/7, 2011 at 11:57
1
Solved
Let's start off with some code:
class Super {
protected static $color;
public static function setColor($color){
self::$color = $color;
}
public static function getColor() {
return self::$...
Wershba asked 14/5, 2011 at 7:18
3
Solved
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 Re...
Viceregent asked 29/11, 2009 at 19:52
1
© 2022 - 2024 — McMap. All rights reserved.