tags:

views:

660

answers:

5

T_PAAMAYIM_NEKUDOTAYIM sounds really exotic, but most certainly absolutely nonsense to me. I traced it all down to this lines of code:

<?php
Class Context {
    protected $config;

    public function getConfig($key) { // Here's the problem somewhere...
    $cnf = $this->config;
    return $cnf::getConfig($key);
    }

    function __construct() {
    $this->config = new Config();
    }
}
?>

In the constructor I create a Config object. Here's the class:

final class Config {
    private static $instance = NULL;
    private static $config;

    public static function getConfig($key) {
    return self::$config[$key];
    }

    public static function getInstance() {
    if (!self::$instance) {
        self::$instance = new Config();
    }
    return self::$instance;
    }

    private function __construct() {
    // include configuration file
    include __ROOT_INCLUDE_PATH . '/sys/config/config.php'; // defines a $config array
    $this->config = $config;
    }
}

No idea why this doesnt work / what the error means...

+1  A: 

According to wikipedia, it means a "double colon" scope resolution operator.

http://en.wikipedia.org/wiki/Scope%5Fresolution%5Foperator

Paul Tomblin
+7  A: 

T_PAAMAYIM_NEKUDOTAYIM is the double colon scope resolution thingy PHP uses - ::

Quick glance at your code, I think this line:

return $cnf::getConfig($key);

should be

return $cnf->getConfig($key);

The first is the way to call a method statically - this code would be valid if $cnf contained a string that was also a valid class. The -> syntax is for calling a method on an instance of a class/object.

benlumley
This sounds like a near-perfect reason to *never* contemplate using PHP. Surely it wouldn't have been so hard to produce a decent error message?
paxdiablo
It's Hebrew -- because Zend Engine has initially been developped by Andi Gutmans and Zeev Suraski, who are from Israel (see http://en.wikipedia.org/wiki/Zend_Engine )
Pascal MARTIN
From Wikipedia: "In PHP, the scope resolution operator is also called Paamayim Nekudotayim (Hebrew: פעמיים נקודתיים‎, pronounced [paʔaˈmajim nəkudoˈtajim]), which means "twice colon" or "double colon" in Hebrew" -> Facing the fact that 99,9% of all dev's won't speak Hebrew very well, I must commit: I love Objective-C. And now I know why.
openfrog
Pascal MARTIN
@Pascal, if the entire set of error messages was in Hebrew, I'd be happy (though the use of PHP would be curtailed somewhat). But given it's a Hebrew phrase in what is otherwise an English message, it's out of place - how much effort would it take to replace that with the phrase "double-colon" or something else that doesn't require a lookup of an obscure phrase. Just think how much accumulated time is wasted by code-cutters around the world having to look up that phrase. There are enough obstacles in the way when learning a new environment without tossing in artificial ones.
paxdiablo
In addition, the stuff I've had to learn re algorithms, language features and so on, has actually been useful outside its immediate area of application. Since I'm unlikely to ever need the Hebrew phrase for double colon outside of PHP, that's a fairly limited piece of education. The fact that this question even had to be asked is testament to the fact that the Hebrew snippet is a bad idea.
paxdiablo
Well, at least, once you've gotten this error once, you remember what it means ;-) ;; and I don't thinks it's much harder to understand the meaning of this than to understand how the ?: operator works (for instance -- remember, it's behaviour has been altered with PHP 5.3 ;-) ) ;; but I see your point.
Pascal MARTIN
@paxdiablo the fact that this question had to be asked is a testament to openfrog again not trying to find out things on his own but heading straight to SO instead of at least trying to find an answer in the PHP manual: http://de3.php.net/manual/en/tokens.php
Gordon
+2  A: 

The error is down to an "inappropriate use" of the double colon operator:

return $cnf::getConfig($key);

as you're trying to call a static method of the class, but using an instantiation of it instead (someone else will no doubt phrase this better, I'm tired ;-))

I think what you want is:

return $cnf->getConfig($key);
richsage
@benlumley's answer above phrased it lots better :)
richsage
+1  A: 

It's the name for the :: operator

Wikipedia

schnaader
+1  A: 

In your example

return $cnf::getConfig($key)

Probably should be:

return $cnf->getConfig($key)

And make getConfig not static

Question Mark