Skip to content

Commit

Permalink
Merge pull request #3 from maintaina-com/FRAMEWORK_6_0
Browse files Browse the repository at this point in the history
Backport type fixes to horde/rdo
  • Loading branch information
ralflang committed Mar 28, 2024
2 parents 4655482 + 4d13d96 commit 0c3f8b4
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 33 deletions.
15 changes: 10 additions & 5 deletions lib/Horde/Rdo/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ public function __get($field)
} elseif (!empty($this->{$rel['foreignKey']})) {
$this->_fields[$field] = $m->findOne($this->{$rel['foreignKey']});
if (empty($this->_fields[$field])) {
throw new Horde_Rdo_Exception('The referenced object with key ' . $this->{$rel['foreignKey']} . ' does not exist. Your data is inconsistent');
throw new Horde_Rdo_Exception(sprintf(
'The referenced object of %s instance with key %s = %s does not exist. Your data is inconsistent',
get_class($this),
$rel['foreignKey'],
$this->{$rel['foreignKey']},
));
}
} else {
$this->_fields[$field] = null;
Expand Down Expand Up @@ -189,7 +194,7 @@ public function __set($field, $value)
*
* @see __set()
*/
public function offsetSet($field, $value)
public function offsetSet($field, $value): void
{
$this->__set($field, $value);
}
Expand All @@ -215,7 +220,7 @@ public function __isset($field)
*
* @see __isset()
*/
public function offsetExists($field)
public function offsetExists($field): bool
{
return $this->__isset($field);
}
Expand All @@ -238,7 +243,7 @@ public function __unset($field)
*
* @see __unset()
*/
public function offsetUnset($field)
public function offsetUnset($field): void
{
$this->__unset($field);
}
Expand All @@ -261,7 +266,7 @@ public function setFields($fields = array())
*
* @return Horde_Rdo_Iterator The Iterator instance.
*/
public function getIterator()
public function getIterator(): Traversable
{
return new Horde_Rdo_Iterator($this);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Horde/Rdo/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct($rdo)
/**
* Reset to the first key.
*/
public function rewind()
public function rewind(): void
{
$this->_valid = (false !== reset($this->_keys));
}
Expand Down Expand Up @@ -87,7 +87,7 @@ public function key()
/**
* Move to the next key in the iterator.
*/
public function next()
public function next(): void
{
$this->_valid = (false !== next($this->_keys));
}
Expand All @@ -97,7 +97,7 @@ public function next()
*
* @return boolean Inside array bounds?
*/
public function valid()
public function valid(): bool
{
return $this->_valid;
}
Expand Down
16 changes: 8 additions & 8 deletions lib/Horde/Rdo/List.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function __destruct()
/**
* Implementation of the rewind() method for iterator.
*/
public function rewind()
public function rewind(): void
{
if ($this->_result) {
unset($this->_result);
Expand Down Expand Up @@ -167,7 +167,7 @@ public function key()
* @return Horde_Rdo_Base|null The next Rdo object in the set or
* null if no more results.
*/
public function next()
public function next(): void
{
if (is_null($this->_result)) {
$this->rewind();
Expand All @@ -190,7 +190,7 @@ public function next()
}
}

return $this->_current;
// return $this->_current;
}

/**
Expand All @@ -200,7 +200,7 @@ public function next()
*
* @return boolean Whether or not an offset exists.
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
$query = Horde_Rdo_Query::create($this->_query);
$query->limit(1, $offset);
Expand Down Expand Up @@ -232,7 +232,7 @@ public function offsetGet($offset)
*
* @return Horde_Rdo_Base An entity object at the offset position or null
*/
public function offsetSet($offset, $item)
public function offsetSet($offset, $item): void
{
throw new Horde_Rdo_Exception('You cannot add objects to a result set');
}
Expand All @@ -247,7 +247,7 @@ public function offsetSet($offset, $item)
*
* @return Horde_Rdo_Base An entity object at the offset position or null
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
throw new Horde_Rdo_Exception('You cannot remove objects from a result set');
}
Expand All @@ -257,7 +257,7 @@ public function offsetUnset($offset)
*
* @return boolean Whether the iteration is valid
*/
public function valid()
public function valid(): bool
{
if (is_null($this->_result)) {
$this->rewind();
Expand All @@ -270,7 +270,7 @@ public function valid()
*
* @return integer Number of elements in the list
*/
public function count()
public function count(): int
{
if (is_null($this->_count)) {
$this->_count = $this->_mapper->count($this->_query);
Expand Down
5 changes: 1 addition & 4 deletions lib/Horde/Rdo/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,7 @@ public function find($arg = null)
// Numerically indexed arrays are assumed to be an array of
// primary keys.
$query = new Horde_Rdo_Query();
$query->combineWith('OR');
foreach ($argv[0] as $id) {
$query->addTest($this->primaryKey, '=', $id);
}
$query->addTest($this->primaryKey, 'IN', $arg);
} else {
$query = $arg;
}
Expand Down
6 changes: 3 additions & 3 deletions src/DefaultIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct($rdo)
/**
* Reset to the first key.
*/
public function rewind()
public function rewind(): void
{
$this->_valid = (false !== reset($this->_keys));
}
Expand Down Expand Up @@ -89,7 +89,7 @@ public function key()
/**
* Move to the next key in the iterator.
*/
public function next()
public function next(): void
{
$this->_valid = (false !== next($this->_keys));
}
Expand All @@ -99,7 +99,7 @@ public function next()
*
* @return boolean Inside array bounds?
*/
public function valid()
public function valid(): bool
{
return $this->_valid;
}
Expand Down
16 changes: 8 additions & 8 deletions src/DefaultList.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function __destruct()
/**
* Implementation of the rewind() method for iterator.
*/
public function rewind()
public function rewind(): void
{
if ($this->_result) {
unset($this->_result);
Expand Down Expand Up @@ -168,7 +168,7 @@ public function key()
* @return Base|null The next Rdo object in the set or
* null if no more results.
*/
public function next()
public function next(): void
{
if (is_null($this->_result)) {
$this->rewind();
Expand All @@ -191,7 +191,7 @@ public function next()
}
}

return $this->_current;
// return $this->_current;
}

/**
Expand All @@ -201,7 +201,7 @@ public function next()
*
* @return boolean Whether or not an offset exists.
*/
public function offsetExists($offset)
public function offsetExists($offset): bool
{
$query = BaseQuery::create($this->_query);
$query->limit(1, $offset);
Expand Down Expand Up @@ -233,7 +233,7 @@ public function offsetGet($offset)
*
* @return Base An entity object at the offset position or null
*/
public function offsetSet($offset, $item)
public function offsetSet($offset, $item): void
{
throw new RdoException('You cannot add objects to a result set');
}
Expand All @@ -248,7 +248,7 @@ public function offsetSet($offset, $item)
*
* @return Base An entity object at the offset position or null
*/
public function offsetUnset($offset)
public function offsetUnset($offset): void
{
throw new RdoException('You cannot remove objects from a result set');
}
Expand All @@ -258,7 +258,7 @@ public function offsetUnset($offset)
*
* @return boolean Whether the iteration is valid
*/
public function valid()
public function valid(): bool
{
if (is_null($this->_result)) {
$this->rewind();
Expand All @@ -271,7 +271,7 @@ public function valid()
*
* @return integer Number of elements in the list
*/
public function count()
public function count(): int
{
if (is_null($this->_count)) {
$this->_count = $this->_mapper->count($this->_query);
Expand Down
4 changes: 2 additions & 2 deletions src/RampageObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,10 @@ public function hasRelation($relationship, Rampage $peer = null)
*
* @param string $relationship The relationship key in the mapper
* @param Rampage $peer The object to remove from the relation
* @return integer The number of relations affected
* @return int The number of relations affected
* @throws RdoException
*/
public function removeRelation(string $relationship, Rampage $peer = null): integer
public function removeRelation(string $relationship, Rampage $peer = null): int
{
return $this->mapper->removeRelation($relationship, $this, $peer);
}
Expand Down

0 comments on commit 0c3f8b4

Please sign in to comment.