Skip to content

Commit

Permalink
Variable and property deferencing has been changed to left-to-right i…
Browse files Browse the repository at this point in the history
…n PHP 7.
  • Loading branch information
yunosh committed Jan 30, 2015
1 parent b4e3ed6 commit 72ce9aa
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 36 deletions.
45 changes: 24 additions & 21 deletions framework/ActiveSync/lib/Horde/ActiveSync/Message/Base.php
Expand Up @@ -292,9 +292,9 @@ public function decodeStream(Horde_ActiveSync_Wbxml_Decoder &$decoder)
if (!($entity[Horde_ActiveSync_Wbxml::EN_FLAGS] & Horde_ActiveSync_Wbxml::EN_FLAGS_CONTENT)) {
$map = $this->_mapping[$entity[Horde_ActiveSync_Wbxml::EN_TAG]];
if (!isset($map[self::KEY_TYPE])) {
$this->$map[self::KEY_ATTRIBUTE] = '';
$this->{$map[self::KEY_ATTRIBUTE]} = '';
} elseif ($map[self::KEY_TYPE] == self::TYPE_DATE || $map[self::KEY_TYPE] == self::TYPE_DATE_DASHES ) {
$this->$map[self::KEY_ATTRIBUTE] = '';
$this->{$map[self::KEY_ATTRIBUTE]} = '';
}
continue;
}
Expand Down Expand Up @@ -324,8 +324,8 @@ public function decodeStream(Horde_ActiveSync_Wbxml_Decoder &$decoder)
} else {
$decoded = $decoder->getElementContent();
}
if (!isset($this->$map[self::KEY_ATTRIBUTE])) {
$this->$map[self::KEY_ATTRIBUTE] = array($decoded);
if (!isset($this->{$map[self::KEY_ATTRIBUTE]})) {
$this->{$map[self::KEY_ATTRIBUTE]} = array($decoded);
} else {
$this->{$map[self::KEY_ATTRIBUTE]}[] = $decoded;
}
Expand Down Expand Up @@ -381,7 +381,7 @@ public function decodeStream(Horde_ActiveSync_Wbxml_Decoder &$decoder)
$this->_logger->err('Unable to get end tag for ' . $entity[Horde_ActiveSync_Wbxml::EN_TAG]);
throw new Horde_ActiveSync_Exception('Missing expected wbxml end tag');
}
$this->$map[self::KEY_ATTRIBUTE] = $decoded;
$this->{$map[self::KEY_ATTRIBUTE]} = $decoded;
}
}
} elseif ($entity[Horde_ActiveSync_Wbxml::EN_TYPE] == Horde_ActiveSync_Wbxml::EN_TYPE_ENDTAG) {
Expand All @@ -403,21 +403,24 @@ public function decodeStream(Horde_ActiveSync_Wbxml_Decoder &$decoder)
public function encodeStream(Horde_ActiveSync_Wbxml_Encoder &$encoder)
{
foreach ($this->_mapping as $tag => $map) {
if (isset($this->$map[self::KEY_ATTRIBUTE])) {
if (isset($this->{$map[self::KEY_ATTRIBUTE]})) {
// Variable is available
if (is_object($this->$map[self::KEY_ATTRIBUTE]) && !($this->$map[self::KEY_ATTRIBUTE] instanceof Horde_Date)) {
if (is_object($this->{$map[self::KEY_ATTRIBUTE]}) &&
!($this->{$map[self::KEY_ATTRIBUTE]} instanceof Horde_Date)) {
// Subobjects can do their own encoding
$encoder->startTag($tag);
$this->$map[self::KEY_ATTRIBUTE]->encodeStream($encoder);
$this->{$map[self::KEY_ATTRIBUTE]}->encodeStream($encoder);
$encoder->endTag();
} elseif (isset($map[self::KEY_VALUES]) && is_array($this->$map[self::KEY_ATTRIBUTE])) {
} elseif (isset($map[self::KEY_VALUES]) &&
is_array($this->{$map[self::KEY_ATTRIBUTE]})) {
// Array of objects. Note that some array values must be
// send as an empty tag if they contain no elements.
if (count($this->$map[self::KEY_ATTRIBUTE])) {
if (!isset($map[self::KEY_PROPERTY]) || $map[self::KEY_PROPERTY] != self::PROPERTY_NO_CONTAINER) {
if (count($this->{$map[self::KEY_ATTRIBUTE]})) {
if (!isset($map[self::KEY_PROPERTY]) ||
$map[self::KEY_PROPERTY] != self::PROPERTY_NO_CONTAINER) {
$encoder->startTag($tag);
}
foreach ($this->$map[self::KEY_ATTRIBUTE] as $element) {
foreach ($this->{$map[self::KEY_ATTRIBUTE]} as $element) {
if (is_object($element)) {
// Outputs object container (eg Attachment)
$encoder->startTag($map[self::KEY_VALUES]);
Expand All @@ -440,11 +443,11 @@ public function encodeStream(Horde_ActiveSync_Wbxml_Encoder &$encoder)
}
} else {
// Simple type
if (!is_resource($this->$map[self::KEY_ATTRIBUTE]) &&
strlen($this->$map[self::KEY_ATTRIBUTE]) == 0) {
if (!is_resource($this->{$map[self::KEY_ATTRIBUTE]}) &&
strlen($this->{$map[self::KEY_ATTRIBUTE]}) == 0) {
// Do not output empty items except for the following:
if ($this->_checkSendEmpty($tag)) {
$encoder->startTag($tag, $this->$map[self::KEY_ATTRIBUTE], true);
$encoder->startTag($tag, $this->{$map[self::KEY_ATTRIBUTE]}, true);
}
continue;
} elseif ($encoder->multipart &&
Expand All @@ -454,7 +457,7 @@ public function encodeStream(Horde_ActiveSync_Wbxml_Encoder &$encoder)
Horde_ActiveSync_Request_ItemOperations::ITEMOPERATIONS_DATA)
)) {
$this->_logger->info('HANDLING MULTIPART OUTPUT');
$encoder->addPart($this->$map[self::KEY_ATTRIBUTE]);
$encoder->addPart($this->{$map[self::KEY_ATTRIBUTE]});
$encoder->startTag(Horde_ActiveSync_Request_ItemOperations::ITEMOPERATIONS_PART);
$encoder->content((string)(count($encoder->getParts()) - 1));
$encoder->endTag();
Expand All @@ -463,16 +466,16 @@ public function encodeStream(Horde_ActiveSync_Wbxml_Encoder &$encoder)

$encoder->startTag($tag);
if (isset($map[self::KEY_TYPE]) && ($map[self::KEY_TYPE] == self::TYPE_DATE || $map[self::KEY_TYPE] == self::TYPE_DATE_DASHES)) {
if (!empty($this->$map[self::KEY_ATTRIBUTE])) { // don't output 1-1-1970
$encoder->content($this->_formatDate($this->$map[self::KEY_ATTRIBUTE], $map[self::KEY_TYPE]));
if (!empty($this->{$map[self::KEY_ATTRIBUTE]})) { // don't output 1-1-1970
$encoder->content($this->_formatDate($this->{$map[self::KEY_ATTRIBUTE]}, $map[self::KEY_TYPE]));
}
} elseif (isset($map[self::KEY_TYPE]) && $map[self::KEY_TYPE] == self::TYPE_HEX) {
$encoder->content(Horde_String::upper(bin2hex($this->$map[self::KEY_ATTRIBUTE])));
$encoder->content(Horde_String::upper(bin2hex($this->{$map[self::KEY_ATTRIBUTE]})));
} elseif (isset($map[self::KEY_TYPE]) && $map[self::KEY_TYPE] == self::TYPE_MAPI_STREAM) {
$encoder->content($this->$map[self::KEY_ATTRIBUTE]);
$encoder->content($this->{$map[self::KEY_ATTRIBUTE]});
} else {
$encoder->content(
$this->_checkEncoding($this->$map[self::KEY_ATTRIBUTE], $tag));
$this->_checkEncoding($this->{$map[self::KEY_ATTRIBUTE]}, $tag));
}
$encoder->endTag();
}
Expand Down
Expand Up @@ -59,7 +59,7 @@ protected function validateCompFilters(VObject\Component $parent, array $filters

foreach($filters as $filter) {

$isDefined = isset($parent->$filter['name']);
$isDefined = isset($parent->{$filter['name']});

if ($filter['is-not-defined']) {

Expand All @@ -75,7 +75,7 @@ protected function validateCompFilters(VObject\Component $parent, array $filters
}

if ($filter['time-range']) {
foreach($parent->$filter['name'] as $subComponent) {
foreach($parent->{$filter['name']} as $subComponent) {
if ($this->validateTimeRange($subComponent, $filter['time-range']['start'], $filter['time-range']['end'])) {
continue 2;
}
Expand All @@ -89,7 +89,7 @@ protected function validateCompFilters(VObject\Component $parent, array $filters

// If there are sub-filters, we need to find at least one component
// for which the subfilters hold true.
foreach($parent->$filter['name'] as $subComponent) {
foreach($parent->{$filter['name']} as $subComponent) {

if (
$this->validateCompFilters($subComponent, $filter['comp-filters']) &&
Expand Down Expand Up @@ -128,7 +128,7 @@ protected function validatePropFilters(VObject\Component $parent, array $filters

foreach($filters as $filter) {

$isDefined = isset($parent->$filter['name']);
$isDefined = isset($parent->{$filter['name']});

if ($filter['is-not-defined']) {

Expand All @@ -144,7 +144,7 @@ protected function validatePropFilters(VObject\Component $parent, array $filters
}

if ($filter['time-range']) {
foreach($parent->$filter['name'] as $subComponent) {
foreach($parent->{$filter['name']} as $subComponent) {
if ($this->validateTimeRange($subComponent, $filter['time-range']['start'], $filter['time-range']['end'])) {
continue 2;
}
Expand All @@ -158,7 +158,7 @@ protected function validatePropFilters(VObject\Component $parent, array $filters

// If there are sub-filters, we need to find at least one property
// for which the subfilters hold true.
foreach($parent->$filter['name'] as $subComponent) {
foreach($parent->{$filter['name']} as $subComponent) {

if(
$this->validateParamFilters($subComponent, $filter['param-filters']) &&
Expand Down
4 changes: 2 additions & 2 deletions framework/Imap_Client/lib/Horde/Imap/Client/Socket.php
Expand Up @@ -3397,7 +3397,7 @@ protected function _parseEnvelope(Horde_Imap_Client_Tokenize $data)

if (is_string($val)) {
// These entries are text fields.
$ret->$env_data[$key] = substr($val, 0, $env_str);
$ret->{$env_data[$key]} = substr($val, 0, $env_str);
} else {
// These entries are address structures.
$group = null;
Expand Down Expand Up @@ -3439,7 +3439,7 @@ protected function _parseEnvelope(Horde_Imap_Client_Tokenize $data)
}
}

$ret->$env_data[$key] = $tmp;
$ret->{$env_data[$key]} = $tmp;
}

++$key;
Expand Down
8 changes: 4 additions & 4 deletions framework/Rdo/lib/Horde/Rdo/Mapper.php
Expand Up @@ -549,12 +549,12 @@ public function addRelation($relationship, Horde_Rdo_Base $ours,
switch ($rel['type']) {
case Horde_Rdo::ONE_TO_ONE:
case Horde_Rdo::MANY_TO_ONE:
$ours->$rel['foreignKey'] = $theirs->$theirKey;
$ours->{$rel['foreignKey']} = $theirs->$theirKey;
$ours->save();
break;

case Horde_Rdo::ONE_TO_MANY:
$theirs->$rel['foreignKey'] = $ours->$ourKey;
$theirs->{$rel['foreignKey']} = $ours->$ourKey;
$theirs->save();
break;

Expand Down Expand Up @@ -610,13 +610,13 @@ public function removeRelation($relationship, Horde_Rdo_Base $ours,
switch ($rel['type']) {
case Horde_Rdo::ONE_TO_ONE:
case Horde_Rdo::MANY_TO_ONE:
$ours->$rel['foreignKey'] = null;
$ours->{$rel['foreignKey']} = null;
$ours->save();
return 1;
break;

case Horde_Rdo::ONE_TO_MANY:
$theirs->$rel['foreignKey'] = null;
$theirs->{$rel['foreignKey']} = null;
$theirs->save();
return 1;
break;
Expand Down
6 changes: 3 additions & 3 deletions framework/SyncMl/lib/Horde/SyncMl/Sync.php
Expand Up @@ -772,7 +772,7 @@ public function createUidMap($databaseURI, $cuid, $suid)
public function getServerChange($change, $id)
{
$property = '_server_' . $change . 's';
return isset($this->$property[$id]) ? $this->$property[$id] : null;
return isset($this->{$property[$id]}) ? $this->{$property[$id]} : null;
}

/**
Expand All @@ -786,7 +786,7 @@ public function getServerChange($change, $id)
public function setServerChange($change, $sid, $cid)
{
$property = '_server_' . $change . 's';
$this->$property[$sid] = $cid;
$this->{$property[$sid]} = $cid;
}

/**
Expand All @@ -799,7 +799,7 @@ public function setServerChange($change, $sid, $cid)
public function unsetServerChange($change, $id)
{
$property = '_server_' . $change . 's';
unset($this->$property[$id]);
unset($this->{$property[$id]});
}

/**
Expand Down

0 comments on commit 72ce9aa

Please sign in to comment.