From 7c39c4ca7d35f5e502a3de62d0dea04b0c996f08 Mon Sep 17 00:00:00 2001 From: vrana Date: Wed, 3 Oct 2012 11:14:29 -0700 Subject: [PATCH] Declare common Lisk properties Summary: Calling `->setPHID()` or other common Lisk setters creates an implicit public property `$phid`. I don't like implicit properties and I see them as errors. Its public visibility also makes me nervous and is vulnerable to bypassing any setters we may create. Test Plan: Loaded homepage, checked log. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3600 --- src/infrastructure/storage/lisk/LiskDAO.php | 27 ++++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/infrastructure/storage/lisk/LiskDAO.php b/src/infrastructure/storage/lisk/LiskDAO.php index 55d7dec5e9..80f7ef051f 100644 --- a/src/infrastructure/storage/lisk/LiskDAO.php +++ b/src/infrastructure/storage/lisk/LiskDAO.php @@ -209,6 +209,12 @@ abstract class LiskDAO { private $inSet = null; + protected $id; + protected $phid; + protected $version; + protected $dateCreated; + protected $dateModified; + /** * Build an empty object. * @@ -920,24 +926,21 @@ abstract class LiskDAO { } $id_key = $this->getIDKey(); - if ($id_key) { - if (!isset($properties[strtolower($id_key)])) { - $properties[strtolower($id_key)] = $id_key; - } + if ($id_key != 'id') { + unset($properties['id']); } - if ($this->getConfigOption(self::CONFIG_OPTIMISTIC_LOCKS)) { - $properties['version'] = 'version'; + if (!$this->getConfigOption(self::CONFIG_OPTIMISTIC_LOCKS)) { + unset($properties['version']); } - if ($this->getConfigOption(self::CONFIG_TIMESTAMPS)) { - $properties['datecreated'] = 'dateCreated'; - $properties['datemodified'] = 'dateModified'; + if (!$this->getConfigOption(self::CONFIG_TIMESTAMPS)) { + unset($properties['datecreated']); + unset($properties['datemodified']); } - if (!$this->isPHIDPrimaryID() && - $this->getConfigOption(self::CONFIG_AUX_PHID)) { - $properties['phid'] = 'phid'; + if ($id_key != 'phid' && !$this->getConfigOption(self::CONFIG_AUX_PHID)) { + unset($properties['phid']); } } return $properties;