views:

128

answers:

1

Hello,

I'm getting the following strange looking error.

  • Unexpected PHP error [Use of undefined constant s - assumed 's'] severity [E_NOTICE] in [C:\Documents and Settings\yepthatsme\My Documents\Dev\nicnames\main\resources\includes\name.inc.php line 180]

The line it is referring to has:

     $types = nicnames_config::$resourcetypes;

nicnames_config::$resourcetypes is an array. I have no idea where this 's' it talks about is coming from, and I'm beginning to think it may be a PHP bug, though perhaps I have missed something. Where should I look?

I am using SimpleTest to do testing, and this error is occurring during a particular test.

In case you're interested, here is that line in context:

function getstrings()
 // returns array of strings suitable for human-readable rendering of this
 // piece of informtion.  Contains such fields as 'title', 'subtitle', 
 // 'pre-qualifier', 'post-qualifier', 'comment', etc
{
 $types = nicnames_config::$resourcetypes; // line 180

 $type = isset($types['name_type'][$this->type]) ?
  $types['name_type'][$this->type] : $this->type;
 $givens = $this->givennames == '' ? null : $this->givennames;
 return array(
  'title' => $this->surnamefirst ? ($this->surname . ',') : $givens,
  'subtitle' => $this->surnamefirst ? $givens : $this->surname,
  'pre-qualifier' => $type,
  'post-qualifier' => $this->title == '' ? null : ('(' . $this->title . ')'),
 ) + $this->getcommonstrings();
}

Edit: problem is now solved, see my own answer.

+1  A: 

The PHP error message was getting the location of the error wrong - I eventually found a stray letter 's' at the end of a line somewhere in a completely different source file - the one where the nicnames_config class, and this static member, had been defined.

It appears that when using static member variables, the variable value is assigned not when the class is declared but when the variable is first referred to (guess that's a decent optimisation), however if there is an error in assigning the value PHP gets the location of the error wrong.

thomasrutter