Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP deprecations on ArrayAccess and additional classes #106

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 9 additions & 24 deletions lib/Doctrine/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ public function __unset($name)
}

/**
* Check if an offset axists
*
* @param mixed $offset
* @return boolean Whether or not this object contains $offset
* @return bool
thePanz marked this conversation as resolved.
Show resolved Hide resolved
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
Expand All @@ -108,10 +105,6 @@ public function offsetExists($offset)
}

/**
* An alias of get()
*
* @see get, __get
* @param mixed $offset
* @return mixed
*/
#[\ReturnTypeWillChange]
Expand All @@ -127,11 +120,6 @@ public function offsetGet($offset)
}

/**
* Sets $offset to $value
*
* @see set, __set
* @param mixed $offset
* @param mixed $value
* @return void
*/
#[\ReturnTypeWillChange]
Expand All @@ -145,22 +133,19 @@ public function offsetSet($offset, $value)
}

/**
* Unset a given offset
*
* @see set, offsetSet, __set
* @param mixed $offset
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
return $this->remove($offset);
$this->remove($offset);
thePanz marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Remove the element with the specified offset
*
* @param mixed $offset The offset to remove
* @return boolean True if removed otherwise false
* @return bool True if removed otherwise false
*/
public function remove($offset)
{
Expand Down Expand Up @@ -191,8 +176,8 @@ public function set($offset, $value)
}

/**
* 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
*/
Expand All @@ -202,9 +187,9 @@ public function contains($offset)
}

/**
* Add the value
*
* @param mixed $value The value to add
* Add the value
*
* @param mixed $value The value to add
* @return void
*/
public function add($value)
Expand Down
5 changes: 3 additions & 2 deletions lib/Doctrine/Connection/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ class Doctrine_Connection_Common extends Doctrine_Connection
* @param string $query
* @param mixed $limit
* @param mixed $offset
* @return string
*/
public function modifyLimitQuery($query, $limit = false,$offset = false,$isManip=false)
{
$limit = (int) $limit;
$offset = (int) $offset;

if ($limit && $offset) {
$query .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} elseif ($limit && ! $offset) {
Expand All @@ -54,4 +55,4 @@ public function modifyLimitQuery($query, $limit = false,$offset = false,$isManip

return $query;
}
}
}
14 changes: 7 additions & 7 deletions lib/Doctrine/Hydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct()
/**
* Set the hydration mode
*
* @param mixed $hydrationMode One of the Doctrine_Core::HYDRATE_* constants or
* @param mixed $hydrationMode One of the Doctrine_Core::HYDRATE_* constants or
* a string representing the name of the hydration mode or
* or an instance of the hydration class
*/
Expand Down Expand Up @@ -112,9 +112,9 @@ public function getHydratorDriverClassName($mode = null)
/**
* Get an instance of the hydration driver for the passed hydration mode
*
* @param string $mode
* @param array $tableAliases
* @return object Doctrine_Hydrator_Abstract
* @param string $mode
* @param array $tableAliases
* @return Doctrine_Hydrator_Abstract
*/
public function getHydratorDriver($mode, $tableAliases)
{
Expand All @@ -138,8 +138,8 @@ public function getHydratorDriver($mode, $tableAliases)
* Hydrate the query statement in to its final data structure by one of the
* hydration drivers.
*
* @param object $stmt
* @param array $tableAliases
* @param object $stmt
* @param array $tableAliases
* @return mixed $result
*/
public function hydrateResultSet($stmt, $tableAliases)
Expand All @@ -149,4 +149,4 @@ public function hydrateResultSet($stmt, $tableAliases)

return $result;
}
}
}
7 changes: 3 additions & 4 deletions lib/Doctrine/Hydrator/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ public function onDemandReset()
* (I.e. ORACLE limit/offset emulation adds doctrine_rownum to the result set).
*
* @param string $name
* @return boolean
* @return bool
*/
protected function _isIgnoredName($name)
{
return $name == 'DOCTRINE_ROWNUM';
return $name === 'DOCTRINE_ROWNUM';
}

/**
Expand All @@ -114,8 +114,7 @@ protected function _isIgnoredName($name)
* The key idea is the loop over the rowset only once doing all the needed operations
* within this massive loop.
*
* @param mixed $stmt
* @return mixed
*/
abstract public function hydrateResultSet($stmt);
}
}
5 changes: 4 additions & 1 deletion lib/Doctrine/Hydrator/ArrayHierarchyDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
*/
class Doctrine_Hydrator_ArrayHierarchyDriver extends Doctrine_Hydrator_ArrayDriver
{
/**
* @return array
*/
public function hydrateResultSet($stmt)
{
$collection = parent::hydrateResultSet($stmt);
Expand Down Expand Up @@ -80,4 +83,4 @@ public function hydrateResultSet($stmt)
}
return $trees;
}
}
}
5 changes: 4 additions & 1 deletion lib/Doctrine/Hydrator/ArrayShallowDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
*/
class Doctrine_Hydrator_ArrayShallowDriver extends Doctrine_Hydrator_ScalarDriver
{
/**
* @return array
*/
public function hydrateResultSet($stmt)
{
$cache = array();
Expand All @@ -41,4 +44,4 @@ public function hydrateResultSet($stmt)
}
return $result;
}
}
}
3 changes: 3 additions & 0 deletions lib/Doctrine/Hydrator/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ protected function _getCustomIndexField($alias)
return isset($this->_queryComponents[$alias]['map']) ? $this->_queryComponents[$alias]['map'] : null;
}

/**
* @return Doctrine_Collection|mixed
*/
public function hydrateResultSet($stmt)
{
// Used variables during hydration
Expand Down
5 changes: 4 additions & 1 deletion lib/Doctrine/Hydrator/NoneDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
*/
class Doctrine_Hydrator_NoneDriver extends Doctrine_Hydrator_Abstract
{
/**
* @return mixed
*/
public function hydrateResultSet($stmt)
{
return $stmt->fetchAll(PDO::FETCH_NUM);
}
}
}
5 changes: 4 additions & 1 deletion lib/Doctrine/Hydrator/RecordHierarchyDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
*/
class Doctrine_Hydrator_RecordHierarchyDriver extends Doctrine_Hydrator_RecordDriver
{
/**
* @return Doctrine_Collection
*/
public function hydrateResultSet($stmt)
{
return parent::hydrateResultSet($stmt)->toHierarchy();
}
}
}
9 changes: 6 additions & 3 deletions lib/Doctrine/Hydrator/ScalarDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
*/
class Doctrine_Hydrator_ScalarDriver extends Doctrine_Hydrator_Abstract
{
/**
* @return array
*/
public function hydrateResultSet($stmt)
{
$cache = array();
Expand All @@ -55,7 +58,7 @@ protected function _gatherRowData($data, &$cache, $aliasPrefix = true)
}
// cache general information like the column name <-> field name mapping
$e = explode('__', $key);
$columnName = strtolower(array_pop($e));
$columnName = strtolower(array_pop($e));
$cache[$key]['dqlAlias'] = $this->_tableAliases[strtolower(implode('__', $e))];
$table = $this->_queryComponents[$cache[$key]['dqlAlias']]['table'];
// check whether it's an aggregate value or a regular field
Expand Down Expand Up @@ -84,7 +87,7 @@ protected function _gatherRowData($data, &$cache, $aliasPrefix = true)
$fieldName = $cache[$key]['fieldName'];

$rowDataKey = $aliasPrefix ? $dqlAlias . '_' . $fieldName:$fieldName;

if ($cache[$key]['isSimpleType'] || $cache[$key]['isAgg']) {
$rowData[$rowDataKey] = $value;
} else {
Expand All @@ -94,4 +97,4 @@ protected function _gatherRowData($data, &$cache, $aliasPrefix = true)
}
return $rowData;
}
}
}
6 changes: 5 additions & 1 deletion lib/Doctrine/Hydrator/SingleScalarDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
*/
class Doctrine_Hydrator_SingleScalarDriver extends Doctrine_Hydrator_Abstract
{
/**
* @param mixed $stmt
* @return array|mixed
*/
public function hydrateResultSet($stmt)
{
$result = array();
Expand All @@ -44,4 +48,4 @@ public function hydrateResultSet($stmt)
return $result;
}
}
}
}
16 changes: 8 additions & 8 deletions lib/Doctrine/Locator/Injectable.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function setLocator(Doctrine_Locator $locator)
/**
* getLocator
* returns the locator associated with this object
*
*
* if there are no locator locally associated then
* this method tries to fetch the current global locator
*
Expand Down Expand Up @@ -101,7 +101,7 @@ public function locate($name)
} else {
// get the name of the concrete implementation
$concreteImpl = $this->_resources[$name];

return $this->getLocator()->locate($concreteImpl);
}
} else {
Expand All @@ -115,13 +115,13 @@ public function locate($name)
*
* @param string $name the name of the resource to bind
* @param mixed $value the value of the resource
* @return Doctrine_Locator this object
* @return static this object
*/
public function bind($name, $resource)
public function bind($name, $value)
{
$this->_resources[$name] = $resource;
return $this;
$this->_resources[$name] = $value;
thePanz marked this conversation as resolved.
Show resolved Hide resolved

return $this;
}

/**
Expand All @@ -146,4 +146,4 @@ public static function getNullObject()
{
return self::$_null;
}
}
}
Loading