Skip to content

Commit

Permalink
More test (#7)
Browse files Browse the repository at this point in the history
* WIP: More test

* [ci skip] Fix styling

* WIP: Skip test fix later

* WIP: Fix deprecated: Return type

* WIP: fix deprecated: Return type

* WIP: Fix deprecated: Return type

* WIP: Fix deprecated: Return type

* WIP: Fix getDictionaryKey attribute

* WIP: Fix deprecated: Return type

Co-authored-by: agungsugiarto <[email protected]>
  • Loading branch information
agungsugiarto and agungsugiarto authored Mar 6, 2022
1 parent 0e98af6 commit a7e1b61
Show file tree
Hide file tree
Showing 19 changed files with 1,689 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Casts/ArrayObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function toArray()
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->getArrayCopy();
Expand Down
4 changes: 4 additions & 0 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ public function load($path)
* @param string $offset
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return isset($this->definitions[$offset]);
Expand All @@ -245,6 +246,7 @@ public function offsetExists($offset)
* @param string $offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->make($offset);
Expand All @@ -257,6 +259,7 @@ public function offsetGet($offset)
* @param callable $value
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
$this->define($offset, $value);
Expand All @@ -268,6 +271,7 @@ public function offsetSet($offset, $value)
* @param string $offset
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->definitions[$offset]);
Expand Down
5 changes: 5 additions & 0 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,7 @@ public function toJson($options = 0)
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->toArray();
Expand Down Expand Up @@ -1851,6 +1852,7 @@ public function __set($key, $value)
* @param mixed $offset
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return ! is_null($this->getAttribute($offset));
Expand All @@ -1862,6 +1864,7 @@ public function offsetExists($offset)
* @param mixed $offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->getAttribute($offset);
Expand All @@ -1874,6 +1877,7 @@ public function offsetGet($offset)
* @param mixed $value
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
$this->setAttribute($offset, $value);
Expand All @@ -1885,6 +1889,7 @@ public function offsetSet($offset, $value)
* @param mixed $offset
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->attributes[$offset], $this->relations[$offset]);
Expand Down
6 changes: 6 additions & 0 deletions src/Pagination/AbstractCursorPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ public static function viewFactory()
*
* @return \ArrayIterator
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return $this->items->getIterator();
Expand Down Expand Up @@ -495,6 +496,7 @@ public function isNotEmpty()
*
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
{
return $this->items->count();
Expand Down Expand Up @@ -539,6 +541,7 @@ public function getOptions()
* @param mixed $key
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($key)
{
return $this->items->has($key);
Expand All @@ -550,6 +553,7 @@ public function offsetExists($key)
* @param mixed $key
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($key)
{
return $this->items->get($key);
Expand All @@ -562,6 +566,7 @@ public function offsetGet($key)
* @param mixed $value
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetSet($key, $value)
{
$this->items->put($key, $value);
Expand All @@ -573,6 +578,7 @@ public function offsetSet($key, $value)
* @param mixed $key
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($key)
{
$this->items->forget($key);
Expand Down
6 changes: 6 additions & 0 deletions src/Pagination/AbstractPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ public static function useBootstrapThree()
*
* @return \ArrayIterator
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return $this->items->getIterator();
Expand Down Expand Up @@ -647,6 +648,7 @@ public function isNotEmpty()
*
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
{
return $this->items->count();
Expand Down Expand Up @@ -691,6 +693,7 @@ public function getOptions()
* @param mixed $key
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($key)
{
return $this->items->has($key);
Expand All @@ -702,6 +705,7 @@ public function offsetExists($key)
* @param mixed $key
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($key)
{
return $this->items->get($key);
Expand All @@ -714,6 +718,7 @@ public function offsetGet($key)
* @param mixed $value
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetSet($key, $value)
{
$this->items->put($key, $value);
Expand All @@ -725,6 +730,7 @@ public function offsetSet($key, $value)
* @param mixed $key
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($key)
{
$this->items->forget($key);
Expand Down
1 change: 1 addition & 0 deletions src/Pagination/CursorPaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public function toArray()
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->toArray();
Expand Down
1 change: 1 addition & 0 deletions src/Pagination/LengthAwarePaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public function toArray()
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->toArray();
Expand Down
1 change: 1 addition & 0 deletions src/Pagination/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public function toArray()
*
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->toArray();
Expand Down
6 changes: 6 additions & 0 deletions src/Relations/Concerns/InteractsWithDictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Fluent\Orm\Relations\Concerns;

use BackedEnum;
use Doctrine\Instantiator\Exception\InvalidArgumentException;

trait InteractsWithDictionary
Expand All @@ -21,6 +22,11 @@ protected function getDictionaryKey($attribute)
return $attribute->__toString();
}

if (function_exists('enum_exists') &&
$attribute instanceof BackedEnum) {
return $attribute->value;
}

throw new InvalidArgumentException('Model attribute value is an object but does not have a __toString method.');
}

Expand Down
3 changes: 2 additions & 1 deletion src/Relations/MorphTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Fluent\Orm\Relations;

use BadMethodCallException;
use CodeIgniter\Database\Config;
use Fluent\Orm\Builder;
use Fluent\Orm\Collection;
use Fluent\Orm\Model;
Expand Down Expand Up @@ -186,7 +187,7 @@ public function createModelByType($type)

return tap(new $class(), function ($instance) {
if (! $instance->getConnectionName()) {
$instance->setConnection($this->getConnection()->getName());
$instance->setConnection(array_keys(Config::getConnections())[0]);
}
});
}
Expand Down
1 change: 1 addition & 0 deletions src/Support/Stringable.php
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ public function dd()
*
* @return string
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->__toString();
Expand Down
Loading

0 comments on commit a7e1b61

Please sign in to comment.