Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replacing explicit class calls with __CLASS__ in callables

Create new instance with new static instead of new 'name of class'
  • Loading branch information...
commit 047be0135bc2c545ba7193e41c99347862e46776 1 parent 9999e9c
@dongilbert authored
View
4 libraries/joomla/application/cli.php
@@ -126,13 +126,13 @@ public static function getInstance($name = null)
// Only create the object if it doesn't exist.
if (empty(self::$instance))
{
- if (class_exists($name) && (is_subclass_of($name, 'JApplicationCli')))
+ if (class_exists($name) && (is_subclass_of($name, __CLASS__)))
{
self::$instance = new $name;
}
else
{
- self::$instance = new JApplicationCli;
+ self::$instance = new static;
}
}
View
4 libraries/joomla/application/daemon.php
@@ -157,7 +157,7 @@ public static function signal($signal)
JLog::add('Received signal: ' . $signal, JLog::DEBUG);
// Let's make sure we have an application instance.
- if (!is_subclass_of(static::$instance, 'JApplicationDaemon'))
+ if (!is_subclass_of(static::$instance, __CLASS__))
{
JLog::add('Cannot find the application instance.', JLog::EMERGENCY);
throw new \RuntimeException('Cannot find the application instance.');
@@ -706,7 +706,7 @@ protected function setupSignalHandlers()
}
// Attach the signal handler for the signal.
- if (!$this->pcntlSignal(constant($signal), array('JApplicationDaemon', 'signal')))
+ if (!$this->pcntlSignal(constant($signal), array(__CLASS__, 'signal')))
{
JLog::add(sprintf('Unable to reroute signal handler: %s', $signal), JLog::EMERGENCY);
View
6 libraries/joomla/application/web.php
@@ -136,7 +136,7 @@ public function __construct(JInput $input = null, JRegistry $config = null, JApp
$this->set('execution.timestamp', time());
// Setup the response object.
- $this->response = new stdClass;
+ $this->response = new \stdClass;
$this->response->cachable = false;
$this->response->headers = array();
$this->response->body = array();
@@ -161,13 +161,13 @@ public static function getInstance($name = null)
// Only create the object if it doesn't exist.
if (empty(self::$instance))
{
- if (class_exists($name) && (is_subclass_of($name, 'JApplicationWeb')))
+ if (class_exists($name) && (is_subclass_of($name, __CLASS__)))
{
self::$instance = new $name;
}
else
{
- self::$instance = new JApplicationWeb;
+ self::$instance = new static;
}
}
View
6 libraries/joomla/date/date.php
@@ -30,7 +30,7 @@
* @subpackage Date
* @since 11.1
*/
-class JDate extends DateTime
+class JDate extends \DateTime
{
const DAY_ABBR = "\x021\x03";
const DAY_NAME = "\x022\x03";
@@ -88,7 +88,7 @@ public function __construct($date = 'now', $tz = null)
}
// If the time zone object is not set, attempt to build it.
- if (!($tz instanceof DateTimeZone))
+ if (!($tz instanceof \DateTimeZone))
{
if ($tz === null)
{
@@ -213,7 +213,7 @@ public function __toString()
*/
public static function getInstance($date = 'now', $tz = null)
{
- return new JDate($date, $tz);
+ return new static($date, $tz);
}
/**
View
4 libraries/joomla/environment/browser.php
@@ -170,13 +170,13 @@ public function __construct($userAgent = null, $accept = null)
*
* @since 11.1
*/
- static public function getInstance($userAgent = null, $accept = null)
+ public static function getInstance($userAgent = null, $accept = null)
{
$signature = serialize(array($userAgent, $accept));
if (empty(self::$instances[$signature]))
{
- self::$instances[$signature] = new JBrowser($userAgent, $accept);
+ self::$instances[$signature] = new static($userAgent, $accept);
}
return self::$instances[$signature];
View
12 libraries/loader.php
@@ -505,7 +505,7 @@ public static function setup($caseStrategy = self::LOWER_CASE, $enableNamespaces
if ($enableClasses)
{
// Register the class map based autoloader.
- spl_autoload_register(array('JLoader', 'load'));
+ spl_autoload_register(array(__CLASS__, 'load'));
}
if ($enablePrefixes)
@@ -514,7 +514,7 @@ public static function setup($caseStrategy = self::LOWER_CASE, $enableNamespaces
self::registerPrefix('J', JPATH_PLATFORM . '/joomla');
// Register the prefix autoloader.
- spl_autoload_register(array('JLoader', '_autoload'));
+ spl_autoload_register(array(__CLASS__, '_autoload'));
}
if ($enableNamespaces)
@@ -523,22 +523,22 @@ public static function setup($caseStrategy = self::LOWER_CASE, $enableNamespaces
{
// Register the lower case namespace loader.
case self::LOWER_CASE:
- spl_autoload_register(array('JLoader', 'loadByNamespaceLowerCase'));
+ spl_autoload_register(array(__CLASS__, 'loadByNamespaceLowerCase'));
break;
// Register the natural case namespace loader.
case self::NATURAL_CASE:
- spl_autoload_register(array('JLoader', 'loadByNamespaceNaturalCase'));
+ spl_autoload_register(array(__CLASS__, 'loadByNamespaceNaturalCase'));
break;
// Register the mixed case namespace loader.
case self::MIXED_CASE:
- spl_autoload_register(array('JLoader', 'loadByNamespaceMixedCase'));
+ spl_autoload_register(array(__CLASS__, 'loadByNamespaceMixedCase'));
break;
// Default to the lower case namespace loader.
default:
- spl_autoload_register(array('JLoader', 'loadByNamespaceLowerCase'));
+ spl_autoload_register(array(__CLASS__, 'loadByNamespaceLowerCase'));
break;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.