Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nomadicjosh committed Aug 27, 2023
2 parents 034ffc0 + 34319be commit e4ceda7
Show file tree
Hide file tree
Showing 39 changed files with 154 additions and 340 deletions.
15 changes: 0 additions & 15 deletions CHANGELOG.md

This file was deleted.

19 changes: 11 additions & 8 deletions Cache/ApcReflectionCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* Qubus\Injector
*
* @link https://github.com/QubusPHP/injector
* @copyright 2020 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2020 Joshua Parker <joshua@joshuaparker.dev>
* @copyright 2013-2014 Daniel Lowrey, Levi Morrison, Dan Ackroyd
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 1.0.0
*/

declare(strict_types=1);
Expand Down Expand Up @@ -49,7 +47,7 @@ public function setTimeToLive(int $seconds): ApcReflectionCache
* @param string $key The key to fetch.
* @return mixed|false Value of the key in the cache, or false if not found.
*/
public function fetch(string $key)
public function fetch(string $key): mixed
{
$localData = $this->cache->fetch($key);

Expand All @@ -65,12 +63,17 @@ public function fetch(string $key)
/**
* Store the value for a specified key in the cache.
*
* @param string $key The key for which to store the value.
* @param mixed $data The value to store under the specified key.
* @param string $key The key for which to store the value.
* @param mixed $data The value to store under the specified key.
* @throws ApcStoreException
*/
public function store(string $key, $data)
public function store(string $key, $data): void
{
$ret = apc_store($key, $data, $this->timeToLive);
if ($ret === false) {
throw new ApcStoreException('apc_store failed to cache a variable in the data store.');
}

$this->cache->store($key, $data);
apc_store($key, $data, $this->timeToLive);
}
}
20 changes: 20 additions & 0 deletions Cache/ApcStoreException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/**
* Qubus\Injector
*
* @link https://github.com/QubusPHP/injector
* @copyright 2020 Joshua Parker <[email protected]>
* @copyright 2013-2014 Daniel Lowrey, Levi Morrison, Dan Ackroyd
* @license https://opensource.org/licenses/mit-license.php MIT License
*/

declare(strict_types=1);

namespace Qubus\Injector\Cache;

use Qubus\Exception\Exception;

class ApcStoreException extends Exception
{
}
19 changes: 11 additions & 8 deletions Cache/ApcuReflectionCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* Qubus\Injector
*
* @link https://github.com/QubusPHP/injector
* @copyright 2020 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2020 Joshua Parker <joshua@joshuaparker.dev>
* @copyright 2013-2014 Daniel Lowrey, Levi Morrison, Dan Ackroyd
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 1.0.0
*/

declare(strict_types=1);
Expand Down Expand Up @@ -49,7 +47,7 @@ public function setTimeToLive(int $seconds): ApcuReflectionCache
* @param string $key The key to fetch.
* @return mixed|false Value of the key in the cache, or false if not found.
*/
public function fetch(string $key)
public function fetch(string $key): mixed
{
$localData = $this->cache->fetch($key);

Expand All @@ -65,12 +63,17 @@ public function fetch(string $key)
/**
* Store the value for a specified key in the cache.
*
* @param string $key The key for which to store the value.
* @param mixed $data The value to store under the specified key.
* @param string $key The key for which to store the value.
* @param mixed $data The value to store under the specified key.
* @throws ApcuStoreException
*/
public function store(string $key, $data)
public function store(string $key, $data): void
{
$ret = apcu_store($key, $data, $this->timeToLive);
if ($ret === false) {
throw new ApcuStoreException('apcu_store failed to cache a variable in the data store.');
}

$this->cache->store($key, $data);
apcu_store($key, $data, $this->timeToLive);
}
}
20 changes: 20 additions & 0 deletions Cache/ApcuStoreException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/**
* Qubus\Injector
*
* @link https://github.com/QubusPHP/injector
* @copyright 2020 Joshua Parker <[email protected]>
* @copyright 2013-2014 Daniel Lowrey, Levi Morrison, Dan Ackroyd
* @license https://opensource.org/licenses/mit-license.php MIT License
*/

declare(strict_types=1);

namespace Qubus\Injector\Cache;

use Qubus\Exception\Exception;

class ApcuStoreException extends Exception
{
}
8 changes: 3 additions & 5 deletions Cache/ArrayReflectionCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* Qubus\Injector
*
* @link https://github.com/QubusPHP/injector
* @copyright 2020 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2020 Joshua Parker <joshua@joshuaparker.dev>
* @copyright 2013-2014 Daniel Lowrey, Levi Morrison, Dan Ackroyd
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 1.0.0
*/

declare(strict_types=1);
Expand All @@ -28,7 +26,7 @@ class ArrayReflectionCache implements ReflectionCache
* @param string $key The key to fetch.
* @return mixed|false Value of the key in the cache, or false if not found.
*/
public function fetch(string $key)
public function fetch(string $key): mixed
{
// The additional isset() check here improves performance but we also
// need array_key_exists() because some cached values === NULL.
Expand All @@ -43,7 +41,7 @@ public function fetch(string $key)
* @param string $key The key for which to store the value.
* @param mixed $data The value to store under the specified key.
*/
public function store(string $key, $data)
public function store(string $key, $data): void
{
$this->cache[$key] = $data;
}
Expand Down
4 changes: 1 addition & 3 deletions Cache/CachingReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* Qubus\Injector
*
* @link https://github.com/QubusPHP/injector
* @copyright 2020 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2020 Joshua Parker <joshua@joshuaparker.dev>
* @copyright 2013-2014 Daniel Lowrey, Levi Morrison, Dan Ackroyd
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 1.0.0
*/

declare(strict_types=1);
Expand Down
4 changes: 1 addition & 3 deletions Cache/ReflectionCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* Qubus\Injector
*
* @link https://github.com/QubusPHP/injector
* @copyright 2020 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2020 Joshua Parker <joshua@joshuaparker.dev>
* @copyright 2013-2014 Daniel Lowrey, Levi Morrison, Dan Ackroyd
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 1.0.0
*/

declare(strict_types=1);
Expand Down
6 changes: 2 additions & 4 deletions Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* Qubus\Injector
*
* @link https://github.com/QubusPHP/injector
* @copyright 2020 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2020 Joshua Parker <joshua@joshuaparker.dev>
* @copyright 2013-2014 Daniel Lowrey, Levi Morrison, Dan Ackroyd
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 1.0.0
*/

declare(strict_types=1);
Expand All @@ -18,7 +16,7 @@
interface Config
{
/**
* Retuns configuration value. If doesn't exist, return the set default value.
* Returns configuration value. If doesn't exist, return the set default value.
*
* @param mixed $default
*/
Expand Down
27 changes: 4 additions & 23 deletions Config/InjectorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* Qubus\Injector
*
* @link https://github.com/QubusPHP/injector
* @copyright 2020 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2020 Joshua Parker <joshua@joshuaparker.dev>
* @copyright 2013-2014 Daniel Lowrey, Levi Morrison, Dan Ackroyd
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 1.0.0
*/

declare(strict_types=1);
Expand Down Expand Up @@ -55,9 +53,6 @@ public function __construct($config = [], $default = [])
parent::__construct($this->storage, ArrayObject::ARRAY_AS_PROPS);
}

/**
* {@inheritDoc}
*/
public function all(): array
{
return $this->getArrayCopy();
Expand All @@ -74,7 +69,7 @@ public function get(string $key, $default = null): string|array
return $default;
}

// The class::temp variable is always setted by the class::has() method
// The class::temp variable is always set by the class::has() method
return $this->temp;
}

Expand All @@ -88,19 +83,13 @@ public function has(string $key): bool
return isset($this->temp);
}

/**
* {@inheritDoc}
*/
public function add($key, $value): InjectorConfig
{
$this->storage[ $key ] = $value;
parent::exchangeArray($this->storage);
return $this;
}

/**
* {@inheritDoc}
*/
public function remove(...$withKeys): InjectorConfig
{
foreach ($withKeys as $keys) {
Expand All @@ -113,9 +102,6 @@ public function remove(...$withKeys): InjectorConfig
return $this;
}

/**
* {@inheritDoc}
*/
public function merge(...$arrayToMerge): InjectorConfig
{
foreach ($arrayToMerge as $key => $arr) {
Expand All @@ -132,17 +118,11 @@ public function merge(...$arrayToMerge): InjectorConfig
return $this;
}

/**
* {@inheritDoc}
*/
public function toArray(): array
{
return iterator_to_array($this);
}

/**
* {@inheritDoc}
*/
public function toJson(): string
{
return strval(json_encode($this->toArray()));
Expand All @@ -156,10 +136,11 @@ public function __clone()

/**
* @param array $array
* @param string|int $key
* @param mixed $default
* @return mixed
*/
private static function search(array $array, string|int $key, $default = null)
private static function search(array $array, string|int $key, $default = null): mixed
{
if (is_int($key) || strripos($key, self::$delimiter) === false) {
return array_key_exists($key, $array) ? $array[ $key ] : $default;
Expand Down
4 changes: 1 addition & 3 deletions Config/InjectorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* Qubus\Injector
*
* @link https://github.com/QubusPHP/injector
* @copyright 2020 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2020 Joshua Parker <joshua@joshuaparker.dev>
* @copyright 2013-2014 Daniel Lowrey, Levi Morrison, Dan Ackroyd
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 1.0.0
*/

declare(strict_types=1);
Expand Down
4 changes: 1 addition & 3 deletions ConfigException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* Qubus\Injector
*
* @link https://github.com/QubusPHP/injector
* @copyright 2020 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2020 Joshua Parker <joshua@joshuaparker.dev>
* @copyright 2013-2014 Daniel Lowrey, Levi Morrison, Dan Ackroyd
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 1.0.0
*/

declare(strict_types=1);
Expand Down
15 changes: 8 additions & 7 deletions Executable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* Qubus\Injector
*
* @link https://github.com/QubusPHP/injector
* @copyright 2020 Joshua Parker <josh@joshuaparker.blog>
* @copyright 2020 Joshua Parker <joshua@joshuaparker.dev>
* @copyright 2013-2014 Daniel Lowrey, Levi Morrison, Dan Ackroyd
* @license https://opensource.org/licenses/mit-license.php MIT License
*
* @since 1.0.0
*/

declare(strict_types=1);
Expand Down Expand Up @@ -37,6 +35,9 @@ class Executable

private bool $isInstanceMethod;

/**
* @throws TypeException
*/
public function __construct(ReflectionFunctionAbstract $reflFunc, ?object $invocationObject = null)
{
if ($reflFunc instanceof ReflectionMethod) {
Expand All @@ -48,7 +49,10 @@ public function __construct(ReflectionFunctionAbstract $reflFunc, ?object $invoc
}
}

private function setMethodCallable(ReflectionMethod $reflection, ?object $invocationObject)
/**
* @throws TypeException
*/
private function setMethodCallable(ReflectionMethod $reflection, ?object $invocationObject): void
{
if (is_object($invocationObject)) {
$this->callableReflection = $reflection;
Expand Down Expand Up @@ -99,9 +103,6 @@ public function getCallableReflection(): ReflectionFunctionAbstract
return $this->callableReflection;
}

/**
* @return ReflectionFunctionAbstract
*/
public function getInvocationObject()
{
return $this->invocationObject;
Expand Down
Loading

0 comments on commit e4ceda7

Please sign in to comment.