Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PEAR.php

function PEAR::getStaticProperty

If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. Eg. in your method(s) do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); You MUST use a reference, or they will not persist!

Parameters

string $class The calling classname, to prevent clashes:

string $var The variable to retrieve.:

Return value

mixed A reference to the variable. If not set it will be auto initialised to NULL.

2 calls to PEAR::getStaticProperty()
PEAR_Error::__construct in vendor/pear/pear-core-minimal/src/PEAR.php
PEAR_Error constructor
_PEAR_call_destructors in vendor/pear/pear-core-minimal/src/PEAR.php

File

vendor/pear/pear-core-minimal/src/PEAR.php, line 253

Class

PEAR
Base class for other PEAR classes. Provides rudimentary emulation of destructors.

Code

public static function &getStaticProperty($class, $var) {
    static $properties;
    if (!isset($properties[$class])) {
        $properties[$class] = array();
    }
    if (!array_key_exists($var, $properties[$class])) {
        $properties[$class][$var] = null;
    }
    return $properties[$class][$var];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal