Reputation: 320
On a PHP 5.2 server this code was working, but it doesn't work any more under 5.6 :
$value = $record->{self::TABLE_METHOD}();
Under 5.6 I had to do that :
$abc=self::TABLE_METHOD;
$value = $record->{$abc}();
Otherwise said, it works using "self::TABLE_METHOD" via a variable, but not in curly braces.
Any help on why this is happening would be highly appreciated !
As requested, this is the "real" code :
class TActiveRecordGateway extends TComponent
{
private $_manager;
private $_tables=array(); //table cache
private $_meta=array(); //meta data cache.
private $_commandBuilders=array();
private $_currentRecord;
/**
* Constant name for specifying optional table name in TActiveRecord.
*/
const TABLE_CONST='TABLE';
/**
* Method name for returning optional table name in in TActiveRecord
*/
const TABLE_METHOD='table';
/**
* Record gateway constructor.
* @param TActiveRecordManager $manager
*/
public function __construct(TActiveRecordManager $manager)
{
$this->_manager=$manager;
}
/**
* @return TActiveRecordManager record manager.
*/
protected function getManager()
{
return $this->_manager;
}
/**
* Gets the table name from the 'TABLE' constant of the active record
* class if defined, otherwise use the class name as table name.
* @param TActiveRecord active record instance
* @return string table name for the given record class.
*/
protected function getRecordTableName(TActiveRecord $record)
{
$class = new ReflectionClass($record);
if($class->hasConstant(self::TABLE_CONST))
{
$value = $class->getConstant(self::TABLE_CONST);
if(empty($value))
throw new TActiveRecordException('ar_invalid_tablename_property',
get_class($record),self::TABLE_CONST);
return $value;
}
elseif ($class->hasMethod(self::TABLE_METHOD))
{
$value = $record->{self::TABLE_METHOD}();
# THE PROBLEM HAPPENS HERE : $value is empty
Upvotes: 0
Views: 411