forked from doctrine/doctrine1
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,050 changed files
with
34,881 additions
and
30,871 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,23 +20,25 @@ | |
*/ | ||
|
||
/** | ||
* Provides array access and property overload interface for Doctrine subclasses | ||
* Provides array access and property overload interface for Doctrine subclasses. | ||
* | ||
* @package Doctrine | ||
* @subpackage Access | ||
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL | ||
* @link www.doctrine-project.org | ||
* | ||
* @see www.doctrine-project.org | ||
* @since 1.0 | ||
* | ||
* @version $Revision: 7490 $ | ||
* | ||
* @author Konsta Vesterinen <[email protected]> | ||
*/ | ||
abstract class Doctrine_Access extends Doctrine_Locator_Injectable implements ArrayAccess | ||
{ | ||
/** | ||
* Set an entire aray to the data | ||
* Set an entire aray to the data. | ||
* | ||
* @param array $array An array of key => value pairs | ||
* | ||
* @param array $array An array of key => value pairs | ||
* @return Doctrine_Access | ||
* @return Doctrine_Access | ||
*/ | ||
public function setArray(array $array) | ||
{ | ||
|
@@ -48,48 +50,43 @@ public function setArray(array $array) | |
} | ||
|
||
/** | ||
* Set key and value to data | ||
* Set key and value to data. | ||
* | ||
* @see set, offsetSet | ||
* @param $name | ||
* @param $value | ||
* @return void | ||
*/ | ||
public function __set($name, $value) | ||
{ | ||
$this->set($name, $value); | ||
} | ||
|
||
/** | ||
* Get key from data | ||
* Get key from data. | ||
* | ||
* @see get, offsetGet | ||
* @param mixed $name | ||
* @return mixed | ||
*/ | ||
public function __get($name) | ||
{ | ||
return $this->get($name); | ||
} | ||
|
||
/** | ||
* Check if key exists in data | ||
* Check if key exists in data. | ||
* | ||
* @param string $name | ||
* @return boolean whether or not this object contains $name | ||
* @param string $name | ||
* | ||
* @return bool whether or not this object contains $name | ||
*/ | ||
public function __isset($name) | ||
{ | ||
return $this->contains($name); | ||
} | ||
|
||
/** | ||
* Remove key from data | ||
* Remove key from data. | ||
* | ||
* @param string $name | ||
* @return void | ||
* @param string $name | ||
*/ | ||
#[\ReturnTypeWillChange] | ||
#[ReturnTypeWillChange] | ||
public function __unset($name) | ||
{ | ||
return $this->remove($name); | ||
|
@@ -98,16 +95,13 @@ public function __unset($name) | |
/** | ||
* @return bool | ||
*/ | ||
#[\ReturnTypeWillChange] | ||
#[ReturnTypeWillChange] | ||
public function offsetExists($offset) | ||
{ | ||
return $this->contains($offset); | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
#[\ReturnTypeWillChange] | ||
#[ReturnTypeWillChange] | ||
public function offsetGet($offset) | ||
{ | ||
// array notation with no index was causing 'undefined variable: $offset' notices in php7, | ||
|
@@ -116,84 +110,78 @@ public function offsetGet($offset) | |
if (!isset($offset)) { | ||
return $this->get(null); | ||
} | ||
|
||
return $this->get($offset); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
#[\ReturnTypeWillChange] | ||
#[ReturnTypeWillChange] | ||
public function offsetSet($offset, $value) | ||
{ | ||
if ( ! isset($offset)) { | ||
if (!isset($offset)) { | ||
$this->add($value); | ||
} else { | ||
$this->set($offset, $value); | ||
} | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
#[\ReturnTypeWillChange] | ||
#[ReturnTypeWillChange] | ||
public function offsetUnset($offset) | ||
{ | ||
$this->remove($offset); | ||
} | ||
|
||
/** | ||
* Remove the element with the specified offset | ||
* Remove the element with the specified offset. | ||
* | ||
* @param mixed $offset The offset to remove | ||
* | ||
* @return bool True if removed otherwise false | ||
*/ | ||
public function remove($offset) | ||
{ | ||
throw new Doctrine_Exception('Remove is not supported for ' . get_class($this)); | ||
throw new Doctrine_Exception('Remove is not supported for '.get_class($this)); | ||
} | ||
|
||
/** | ||
* Return the element with the specified offset | ||
* Return the element with the specified offset. | ||
* | ||
* @param mixed $offset The offset to return | ||
* @return mixed | ||
* @param mixed $offset The offset to return | ||
*/ | ||
public function get($offset) | ||
{ | ||
throw new Doctrine_Exception('Get is not supported for ' . get_class($this)); | ||
throw new Doctrine_Exception('Get is not supported for '.get_class($this)); | ||
} | ||
|
||
/** | ||
* Set the offset to the value | ||
* Set the offset to the value. | ||
* | ||
* @param mixed $offset The offset to set | ||
* @param mixed $value The value to set the offset to | ||
* | ||
* @param mixed $value The value to set the offset to | ||
*/ | ||
public function set($offset, $value) | ||
{ | ||
throw new Doctrine_Exception('Set is not supported for ' . get_class($this)); | ||
throw new Doctrine_Exception('Set is not supported for '.get_class($this)); | ||
} | ||
|
||
/** | ||
* Check if the specified offset exists | ||
* Check if the specified offset exists. | ||
* | ||
* @param mixed $offset The offset to check | ||
* @return boolean True if exists otherwise false | ||
* | ||
* @return bool True if exists otherwise false | ||
*/ | ||
public function contains($offset) | ||
{ | ||
throw new Doctrine_Exception('Contains is not supported for ' . get_class($this)); | ||
throw new Doctrine_Exception('Contains is not supported for '.get_class($this)); | ||
} | ||
|
||
/** | ||
* Add the value | ||
* Add the value. | ||
* | ||
* @param mixed $value The value to add | ||
* @return void | ||
*/ | ||
public function add($value) | ||
{ | ||
throw new Doctrine_Exception('Add is not supported for ' . get_class($this)); | ||
throw new Doctrine_Exception('Add is not supported for '.get_class($this)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.