1
0
mirror of synced 2025-03-26 09:53:54 +03:00

Update coding standards

Removing underscores from property/method names and change use statements to PSR-2
This commit is contained in:
Calum Brodie 2013-04-21 20:43:48 +02:00
parent 92b41e017a
commit c2967b35ff

View File

@ -22,21 +22,21 @@ implement the ``NotifyPropertyChanged`` interface from the
.. code-block:: php .. code-block:: php
<?php <?php
use Doctrine\Common\NotifyPropertyChanged, use Doctrine\Common\NotifyPropertyChanged;
Doctrine\Common\PropertyChangedListener; use Doctrine\Common\PropertyChangedListener;
abstract class DomainObject implements NotifyPropertyChanged abstract class DomainObject implements NotifyPropertyChanged
{ {
private $_listeners = array(); private $listeners = array();
public function addPropertyChangedListener(PropertyChangedListener $listener) { public function addPropertyChangedListener(PropertyChangedListener $listener) {
$this->_listeners[] = $listener; $this->listeners[] = $listener;
} }
/** Notifies listeners of a change. */ /** Notifies listeners of a change. */
protected function _onPropertyChanged($propName, $oldValue, $newValue) { protected function onPropertyChanged($propName, $oldValue, $newValue) {
if ($this->_listeners) { if ($this->listeners) {
foreach ($this->_listeners as $listener) { foreach ($this->listeners as $listener) {
$listener->propertyChanged($this, $propName, $oldValue, $newValue); $listener->propertyChanged($this, $propName, $oldValue, $newValue);
} }
} }
@ -44,7 +44,7 @@ implement the ``NotifyPropertyChanged`` interface from the
} }
Then, in each property setter of concrete, derived domain classes, Then, in each property setter of concrete, derived domain classes,
you need to invoke \_onPropertyChanged as follows to notify you need to invoke \onPropertyChanged as follows to notify
listeners: listeners:
.. code-block:: php .. code-block:: php
@ -58,7 +58,7 @@ listeners:
public function setData($data) { public function setData($data) {
if ($data != $this->data) { // check: is it actually modified? if ($data != $this->data) { // check: is it actually modified?
$this->_onPropertyChanged('data', $this->data, $data); $this->onPropertyChanged('data', $this->data, $data);
$this->data = $data; $this->data = $data;
} }
} }