Git viewing holonet/common / 52ad7f2968e15b0ee5b13dacab0d17f612e7bce3


Filter

52ad7f2968e15b0ee5b13dacab0d17f612e7bce3

Matthias Lantsch(3 years, 3 months ago)

Update di system to populate di variables before calling service constructor

Browse Files
  • Changed file composer.json
    diff --git a/da441c1d195b8d63eb52d8235c0403205246d401 b/19376ee751cf6b53a045e5f6acbe026bf4e91813
    index da441c1..19376ee 100644
    --- a/da441c1d195b8d63eb52d8235c0403205246d401
    +++ b/19376ee751cf6b53a045e5f6acbe026bf4e91813
    @@ -18,16 +18,13 @@
     		"psr/container-implementation": "1.0.0"
     	},
     	"require-dev": {
    -		"ergebnis/composer-normalize": "^2.5",
    -		"friendsofphp/php-cs-fixer": "^2.11@stable",
     		"holonet/hdev": "~1.0.0",
    -		"phpunit/phpunit": "^8.4.1",
    -		"vimeo/psalm": "^3.5"
    +		"phpunit/phpunit": "^8.4.1"
     	},
     	"extra": {
     		"branch-alias": {
    -			"dev-master": "1.3.x-dev",
    -			"dev-develop": "1.4.x-dev"
    +			"dev-develop": "1.4.x-dev",
    +			"dev-master": "1.3.x-dev"
     		}
     	},
     	"autoload": {
  • Changed file Enum.php
    diff --git a/8d3cde291ce1a6cda43ae32486d10e1d7e3b2b16 b/305060ef23500ebc512de8a0608e1c1a9f5b681f
    index 8d3cde2..305060e 100644
    --- a/8d3cde291ce1a6cda43ae32486d10e1d7e3b2b16
    +++ b/305060ef23500ebc512de8a0608e1c1a9f5b681f
    @@ -11,7 +11,6 @@ namespace holonet\common;
    
     use BadMethodCallException;
     use UnexpectedValueException;
    -use function array_key_exists;
    
     /**
      * Wrapper class around the standard enum to make all value classes singleton instances
    @@ -22,14 +21,16 @@ abstract class Enum extends \MyCLabs\Enum\Enum {
     	protected static $instances = array();
    
     	/**
    -	 * {@inheritdoc}
    +	 * @psalm-suppress OverriddenMethodAccess
    +	 * We must override the constructor so we can ensure the existence of only our instances
    +	 * {@inheritDoc}
     	 */
     	protected function __construct($value) {
     		$this->value = $value;
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 * @return static
     	 * @psalm-suppress MissingImmutableAnnotation
     	 */
    @@ -39,7 +40,7 @@ abstract class Enum extends \MyCLabs\Enum\Enum {
    
     	public static function fromValue($value): self {
     		$name = static::search($value);
    -		if ($name === null) {
    +		if ($name === false) {
     			/** @psalm-suppress InvalidCast */
     			throw new UnexpectedValueException("Value '{$value}' is not part of the enum ".static::class);
     		}
    @@ -48,18 +49,18 @@ abstract class Enum extends \MyCLabs\Enum\Enum {
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 * @psalm-suppress MissingImmutableAnnotation
     	 */
     	public static function isValid($value): bool {
    -		return static::search($value) !== null;
    +		return static::search($value) !== false;
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 * @psalm-suppress MissingImmutableAnnotation
     	 */
    -	public static function search($value): ?string {
    +	public static function search($value) {
     		$toArray = parent::toArray();
     		foreach ($toArray as $name => $constValue) {
     			if (is_array($constValue)) {
    @@ -70,11 +71,11 @@ abstract class Enum extends \MyCLabs\Enum\Enum {
     			}
     		}
    
    -		return null;
    +		return false;
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 * In order to not break any code outside relying on this method, we will reorganise to only return the
     	 * base values not the basic constant array.
     	 * @psalm-suppress MissingImmutableAnnotation
    @@ -98,7 +99,7 @@ abstract class Enum extends \MyCLabs\Enum\Enum {
     	public static function valueOf(string $name): self {
     		$array = parent::toArray();
     		$class = get_called_class();
    -		if (isset($array[$name]) || array_key_exists($name, $array)) {
    +		if (isset($array[$name]) || \array_key_exists($name, $array)) {
     			if (!isset(static::$instances[$class][$name])) {
     				if (is_array($array[$name])) {
     					$params = $array[$name];
    @@ -116,7 +117,7 @@ abstract class Enum extends \MyCLabs\Enum\Enum {
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 * @psalm-suppress MissingImmutableAnnotation
     	 */
     	public static function values(): array {
  • Changed file FilesystemUtils.php
    diff --git a/efda857ac1c25e8aa18afdbfb9f09a68913f6de9 b/1d85909b1141244f74a81db7f2eeb16d9a7cee23
    index efda857..1d85909 100644
    --- a/efda857ac1c25e8aa18afdbfb9f09a68913f6de9
    +++ b/1d85909b1141244f74a81db7f2eeb16d9a7cee23
    @@ -21,7 +21,7 @@ class FilesystemUtils {
     	 * @return string system independent absolute directory path with a trailing separator
     	 */
     	public static function dirpath(...$parts): string {
    -		return static::filepath(...$parts).DIRECTORY_SEPARATOR;
    +		return static::filepath(...$parts).\DIRECTORY_SEPARATOR;
     	}
    
     	/**
    @@ -38,15 +38,15 @@ class FilesystemUtils {
     	 * @return string system independent absolute path using the given path parts
     	 */
     	public static function filepath(...$parts): string {
    -		$ret = implode(DIRECTORY_SEPARATOR, $parts);
    +		$ret = implode(\DIRECTORY_SEPARATOR, $parts);
     		//prepend a / on linux
    -		if ($ret[0] !== DIRECTORY_SEPARATOR && DIRECTORY_SEPARATOR === '/') {
    -			$ret = DIRECTORY_SEPARATOR.$ret;
    +		if ($ret[0] !== \DIRECTORY_SEPARATOR && \DIRECTORY_SEPARATOR === '/') {
    +			$ret = \DIRECTORY_SEPARATOR.$ret;
     		}
     		//make sure there's no double separators
    -		$double = DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR;
    +		$double = \DIRECTORY_SEPARATOR.\DIRECTORY_SEPARATOR;
     		if (mb_strpos($ret, $double) !== false) {
    -			$ret = str_replace($double, DIRECTORY_SEPARATOR, $ret);
    +			$ret = str_replace($double, \DIRECTORY_SEPARATOR, $ret);
     		}
    
     		return $ret;
    @@ -57,7 +57,7 @@ class FilesystemUtils {
     	 * @return string system independent directory path relative to the calling file with a trailing separator
     	 */
     	public static function reldirpath(...$parts): string {
    -		$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
    +		$bt = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1);
     		array_unshift($parts, dirname($bt[0]['file']));
    
     		return static::dirpath(...$parts);
    @@ -68,7 +68,7 @@ class FilesystemUtils {
     	 * @return string system independent file path relative to the calling file
     	 */
     	public static function relfilepath(...$parts): string {
    -		$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
    +		$bt = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1);
     		array_unshift($parts, dirname($bt[0]['file']));
    
     		return static::filepath(...$parts);
    @@ -114,20 +114,22 @@ class FilesystemUtils {
     			$objects = scandir($directory);
     			foreach ($objects as $object) {
     				if ($object !== '.' && $object !== '..') {
    -					if (is_dir($directory.DIRECTORY_SEPARATOR.$object)) {
    -						static::rrmdir($directory.DIRECTORY_SEPARATOR.$object);
    +					if (is_dir($directory.\DIRECTORY_SEPARATOR.$object)) {
    +						static::rrmdir($directory.\DIRECTORY_SEPARATOR.$object);
     					} else {
    -						static::rrmdir($directory.DIRECTORY_SEPARATOR.$object);
    +						static::rrmdir($directory.\DIRECTORY_SEPARATOR.$object);
     					}
     				}
     			}
     			if (!@rmdir($directory) && $throw) {
     				$msg = error_get_last()['message'];
    +
     				throw new Exception("Could not rmdir '{$directory}': {$msg}", 100);
     			}
     		} else {
     			if ((!@unlink($directory) && $throw) || file_exists($directory)) {
     				$msg = error_get_last()['message'];
    +
     				throw new Exception("Could not unlink '{$directory}': {$msg}", 100);
     			}
     		}
  • Changed file ChangeAwareCollection.php
    diff --git a/84907abe1394f230ce571a5178f34f6418de3590 b/96a56fc0abe00b3d6f4a3b22df8a1887922d76be
    index 84907ab..96a56fc 100644
    --- a/84907abe1394f230ce571a5178f34f6418de3590
    +++ b/96a56fc0abe00b3d6f4a3b22df8a1887922d76be
    @@ -56,8 +56,6 @@ class ChangeAwareCollection implements ArrayAccess, ComparableInterface, Countab
    
     			return $this->all[$key];
     		}
    -
    -		return null;
     	}
    
     	/**
    @@ -126,7 +124,7 @@ class ChangeAwareCollection implements ArrayAccess, ComparableInterface, Countab
    
     	/**
     	 * Only counts the "current" entries
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	public function count(): int {
     		return count($this->getAll('current'));
    @@ -145,8 +143,6 @@ class ChangeAwareCollection implements ArrayAccess, ComparableInterface, Countab
     		if (isset($this->all[$key]) && !in_array($key, $this->removed)) {
     			return $this->all[$key];
     		}
    -
    -		return null;
     	}
    
     	/**
    @@ -193,7 +189,7 @@ class ChangeAwareCollection implements ArrayAccess, ComparableInterface, Countab
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	public function getIterator(): ArrayIterator {
     		return new ArrayIterator($this->getAll());
    @@ -216,7 +212,7 @@ class ChangeAwareCollection implements ArrayAccess, ComparableInterface, Countab
    
     	/**
     	 * Does not return true for "removed" entries.
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	public function offsetExists($offset): bool {
     		return isset($this->all[$offset]) && !in_array($offset, $this->removed);
    @@ -224,7 +220,7 @@ class ChangeAwareCollection implements ArrayAccess, ComparableInterface, Countab
    
     	/**
     	 * Does only return values that aren't "removed".
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 * @see self::get()
     	 */
     	public function offsetGet($offset) {
    @@ -232,7 +228,7 @@ class ChangeAwareCollection implements ArrayAccess, ComparableInterface, Countab
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 * @see self::set()
     	 */
     	public function offsetSet($offset, $value): void {
    @@ -241,7 +237,7 @@ class ChangeAwareCollection implements ArrayAccess, ComparableInterface, Countab
    
     	/**
     	 * Does only add the entry to "removed".
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 * @see self::remove()
     	 */
     	public function offsetUnset($offset): void {
    @@ -328,7 +324,5 @@ class ChangeAwareCollection implements ArrayAccess, ComparableInterface, Countab
     		} elseif (($key = array_search($entry, $this->all)) !== false) {
     			return $key;
     		}
    -
    -		return null;
     	}
     }
  • Changed file Collection.php
    diff --git a/652af8e0df409caa4a530534d099ea87306acc99 b/a032ecc3cd200babc8e821b4c22b6afbc67a0651
    index 652af8e..a032ecc 100644
    --- a/652af8e0df409caa4a530534d099ea87306acc99
    +++ b/a032ecc3cd200babc8e821b4c22b6afbc67a0651
    @@ -51,7 +51,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate {
     	 *  => cannot use our own get() method.
     	 */
     	public function &__get(string $key) {
    -		if (is_object($this->data[$key]) || null === $this->data[$key]) {
    +		if (is_object($this->data[$key]) || $this->data[$key] === null) {
     			//only actual variables should be returned by reference
     			return $this->data[$key];
     		}
    @@ -64,7 +64,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate {
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	public function count(): int {
     		return count($this->data);
    @@ -81,7 +81,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate {
     	/**
     	 * @param string[] $which Array with keys that are requested
     	 */
    -	public function getAll(array $which = null): array {
    +	public function getAll(?array $which = null): array {
     		if ($which !== null) {
     			return array_intersect_key($this->data, array_flip($which));
     		}
    @@ -90,7 +90,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate {
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	public function getIterator(): ArrayIterator {
     		return new ArrayIterator($this->data);
    @@ -109,7 +109,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate {
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 * @see self::__isset()
     	 */
     	public function offsetExists($offset): bool {
    @@ -118,7 +118,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate {
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 * @see self::get()
     	 */
     	public function offsetGet($offset) {
    @@ -126,7 +126,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate {
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 * @see self::set()
     	 */
     	public function offsetSet($offset, $value): void {
    @@ -134,7 +134,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate {
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 * @see self::remove()
     	 */
     	public function offsetUnset($offset): void {
  • Changed file ConfigRegistry.php
    diff --git a/cd1f9a0129c95dfadd60b1a1d66fb29c5e8b2c2e b/e105c818e448b3f863781c68aed42b1b4e6c7ff8
    index cd1f9a0..e105c81 100644
    --- a/cd1f9a0129c95dfadd60b1a1d66fb29c5e8b2c2e
    +++ b/e105c818e448b3f863781c68aed42b1b4e6c7ff8
    @@ -15,12 +15,12 @@ namespace holonet\common\collection;
     class ConfigRegistry extends Registry {
     	/**
     	 * Extend base placeholder logic to replace env variables in config values
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	protected function replacePlaceholder($position) {
     		if (is_string($position) && mb_strpos($position, '%') !== false) {
     			$matches = array();
    -			preg_match_all('/%(?:env\(|)([^%]+?)(?:\)|)%/', $position, $matches, PREG_SET_ORDER);
    +			preg_match_all('/%(?:env\(|)([^%]+?)(?:\)|)%/', $position, $matches, \PREG_SET_ORDER);
     			foreach ($matches as $placeholderPair) {
     				//check if it is a $_ENV placeholder
     				if (mb_strpos($placeholderPair[0], '%env(') === 0) {
    @@ -28,7 +28,7 @@ class ConfigRegistry extends Registry {
     					if (($envval = $_ENV[$placeholderPair[1]] ?? getenv($placeholderPair[1])) !== false) {
     						$position = str_replace($placeholderPair[0], $envval, $position);
     					} else {
    -						return null;
    +						return;
     					}
     				} else {
     					//if the placeholder is a value in the registry, replace it, otherwise leave it with the % signs
  • Changed file Registry.php
    diff --git a/e35ef868dca276b4f35ea5570fc70f076cb1f73c b/abc3883d5f4978a748bc727e2a5fad1208598d48
    index e35ef86..abc3883 100644
    --- a/e35ef868dca276b4f35ea5570fc70f076cb1f73c
    +++ b/abc3883d5f4978a748bc727e2a5fad1208598d48
    @@ -56,7 +56,7 @@ class Registry implements ArrayAccess {
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	public function offsetExists($offset): bool {
     		$parts = explode($this->separator, $offset);
    @@ -72,7 +72,7 @@ class Registry implements ArrayAccess {
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	public function offsetGet($offset) {
     		$parts = explode($this->separator, $offset);
    @@ -80,7 +80,7 @@ class Registry implements ArrayAccess {
    
     		foreach ($parts as $sublevel) {
     			if (!isset($position[$sublevel])) {
    -				return null;
    +				return;
     			}
     			$position = $position[$sublevel];
     		}
    @@ -89,7 +89,7 @@ class Registry implements ArrayAccess {
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	public function offsetSet($offset, $value): void {
     		$parts = explode($this->separator, $offset);
    @@ -107,7 +107,7 @@ class Registry implements ArrayAccess {
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	public function offsetUnset($offset): void {
     		$parts = explode($this->separator, $offset);
    @@ -156,7 +156,7 @@ class Registry implements ArrayAccess {
     	protected function replacePlaceholder($position) {
     		if (is_string($position) && mb_strpos($position, '%') !== false) {
     			$matches = array();
    -			preg_match_all('/%([^%]+)%/', $position, $matches, PREG_SET_ORDER);
    +			preg_match_all('/%([^%]+)%/', $position, $matches, \PREG_SET_ORDER);
     			foreach ($matches as $placeholderPair) {
     				//if the placeholder is a value in the registry, replace it, otherwise leave it with the % signs
     				$position = str_replace($placeholderPair[0], $this->get($placeholderPair[1], $placeholderPair[0]), $position);
  • Changed file ConfigReader.php
    diff --git a/b74acc025a80e9447c3fdb70091a70a98833050c b/f83419dce941fd75727e9f668321763f73bf4285
    index b74acc0..f83419d 100644
    --- a/b74acc025a80e9447c3fdb70091a70a98833050c
    +++ b/f83419dce941fd75727e9f668321763f73bf4285
    @@ -29,7 +29,7 @@ class ConfigReader {
    
     	public Registry $registry;
    
    -	public function __construct(Registry $registry = null) {
    +	public function __construct(?Registry $registry = null) {
     		if ($registry !== null) {
     			$this->registry = $registry;
     		} else {
    @@ -43,7 +43,7 @@ class ConfigReader {
     	 * @param string|null $type Allows the user to specify the type of file
     	 * @throws ConfigReaderException
     	 */
    -	public function read($input, string $type = null): void {
    +	public function read($input, ?string $type = null): void {
     		if (!is_array($input) && !is_string($input)) {
     			throw new ConfigReaderException('Given parameter to ConfigReader::read() must be filename or array of filenames');
     		}
    @@ -69,7 +69,7 @@ class ConfigReader {
     	 * @param string|null $type Allows the user to specify the type of file in the dir
     	 * @throws FileAccessException
     	 */
    -	private function readDir(string $filename, string $type = null): void {
    +	private function readDir(string $filename, ?string $type = null): void {
     		if ($dh = opendir($filename)) {
     			while (($file = readdir($dh)) !== false) {
     				if ($file !== '.' && $file !== '..') {
    @@ -86,9 +86,9 @@ class ConfigReader {
     	 * @param string|null $type Allows the user to specify the type of file
     	 * @throws FileAccessException
     	 */
    -	private function readFile(string $filename, string $type = null): void {
    +	private function readFile(string $filename, ?string $type = null): void {
     		if ($type === null) {
    -			$type = pathinfo($filename, PATHINFO_EXTENSION);
    +			$type = pathinfo($filename, \PATHINFO_EXTENSION);
     		}
    
     		if (!isset($this->parsers[$type])) {
  • Changed file IniConfigParser.php
    diff --git a/cf25f748fd31c887c19f7ae64b101f29d546ec7c b/dee5ba0378903d2b9aa85f1e565aa17773a8e72e
    index cf25f74..dee5ba0 100644
    --- a/cf25f748fd31c887c19f7ae64b101f29d546ec7c
    +++ b/dee5ba0378903d2b9aa85f1e565aa17773a8e72e
    @@ -16,10 +16,10 @@ use holonet\common\config\exception\FileAccessException;
      */
     class IniConfigParser extends AbstractParser {
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	protected function readFile(string $filename): array {
    -		$contents = @parse_ini_file($filename, true, INI_SCANNER_TYPED);
    +		$contents = @parse_ini_file($filename, true, \INI_SCANNER_TYPED);
     		if ($contents === false) {
     			throw new FileAccessException("Could not parse_ini_file() '{$filename}'");
     		}
  • Changed file JsonConfigParser.php
    diff --git a/6952468a0b65fa31d47ed580a7fed94b449c26b3 b/dd8ddf33ad20ccd1c1d4a8510dcd46c8973fc7c7
    index 6952468..dd8ddf3 100644
    --- a/6952468a0b65fa31d47ed580a7fed94b449c26b3
    +++ b/dd8ddf33ad20ccd1c1d4a8510dcd46c8973fc7c7
    @@ -17,7 +17,7 @@ use holonet\common\config\exception\ParseErrorException;
      */
     class JsonConfigParser extends AbstractParser {
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	protected function readFile(string $filename): array {
     		$contents = @file_get_contents($filename);
  • Changed file PhpConfigParser.php
    diff --git a/a17dee1be31525ffcd15c324c54f7040fcb894c3 b/12c8b270f22e436b35c5abeddcd64407d7f84e32
    index a17dee1..12c8b27 100644
    --- a/a17dee1be31525ffcd15c324c54f7040fcb894c3
    +++ b/12c8b270f22e436b35c5abeddcd64407d7f84e32
    @@ -16,7 +16,7 @@ use holonet\common\config\exception\FileAccessException;
      */
     class PhpConfigParser extends AbstractParser {
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	protected function readFile(string $filename): array {
     		/**
    @@ -25,14 +25,10 @@ class PhpConfigParser extends AbstractParser {
     		$ret = require $filename;
     		//either the user sets a variable called "config" or returns an array
     		if (!isset($config) && ($config = $ret) !== 1) {
    -			throw new FileAccessException(
    -				"Could not parse php config file '{$filename}'; File must either return an array or define the variable \$config"
    -			);
    +			throw new FileAccessException("Could not parse php config file '{$filename}'; File must either return an array or define the variable \$config");
     		}
     		if (!is_array($config)) {
    -			throw new FileAccessException(
    -				"Could not parse php config file '{$filename}'; Value defined by the config file must be an array"
    -			);
    +			throw new FileAccessException("Could not parse php config file '{$filename}'; Value defined by the config file must be an array");
     		}
    
     		return $config;
  • Changed file Container.php
    diff --git a/c1bc139d0571b8d54714b1a69b350ba49a3b9b2c b/72fa9456440f9ab849554b8370a8c2f1fba63060
    index c1bc139..72fa945 100644
    --- a/c1bc139d0571b8d54714b1a69b350ba49a3b9b2c
    +++ b/72fa9456440f9ab849554b8370a8c2f1fba63060
    @@ -10,6 +10,8 @@
     namespace holonet\common\di;
    
     use TypeError;
    +use ReflectionClass;
    +use ReflectionException;
     use Psr\Container\ContainerInterface;
    
     /**
    @@ -27,12 +29,12 @@ class Container implements ContainerInterface {
     	private array $dependencies = array();
    
     	/**
    -	 * @var array<string, array{class: class-string, args: array}> $lazyLoadedDeps Lazily loaded dependency objects
    +	 * @var array<string, array> $lazyLoadedDeps Lazily loaded dependency objects
     	 */
     	private array $lazyLoadedDeps = array();
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 * @param string[] $getFor Array used keep track of injections (to prevent recursive dependencies)
     	 */
     	public function get($id, array $getFor = array()) {
    @@ -46,21 +48,21 @@ class Container implements ContainerInterface {
     		if (isset($this->lazyLoadedDeps[$id])) {
     			try {
     				list('class' => $class, 'args' => $args) = $this->lazyLoadedDeps[$id];
    -				/** @psalm-suppress MixedMethodCall */
    -				$value = new $class(...$args);
    +				$rfc = new ReflectionClass($class);
    +				$value = $rfc->newInstanceWithoutConstructor();
     				$getFor[] = $id;
     				$this->inject($value, true, $getFor);
    +				if (method_exists($value, '__construct')) {
    +					$value->__construct(...$args);
    +				}
     				if (method_exists($value, 'init')) {
    -					$value->init();
    +					trigger_error('Relying on init() to initialise dependency objects after injecting is no longer required and deprecated', \E_USER_DEPRECATED);
     				}
     				$this->dependencies[$id] = $value;
    
     				return $value;
    -			} catch (TypeError $e) {
    -				throw new DependencyInjectionException(
    -					"Cannot initialise dependency '{$id}' on Dependency Container: '{$e->getMessage()}'",
    -					(int)($e->getCode()), $e
    -				);
    +			} catch (TypeError | ReflectionException $e) {
    +				throw new DependencyInjectionException("Cannot initialise dependency '{$id}' on Dependency Container: '{$e->getMessage()}'", (int)($e->getCode()), $e);
     			}
     		} else {
     			throw new DependencyNotFoundException("Dependency '{$id}' does not exist on Dependency Container");
    @@ -68,7 +70,7 @@ class Container implements ContainerInterface {
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	public function has($id) {
     		return isset($this->dependencies[$id]) || isset($this->lazyLoadedDeps[$id]);
    @@ -106,9 +108,7 @@ class Container implements ContainerInterface {
     			$this->lazyLoadedDeps[$id] = array('class' => $value, 'args' => $constructorArgs);
     		} else {
     			if (!is_object($value)) {
    -				throw new DependencyInjectionException(
    -					"Cannot create dependency '{$id}' on Dependency Container"
    -				);
    +				throw new DependencyInjectionException("Cannot create dependency '{$id}' on Dependency Container");
     			}
    
     			$this->inject($value);
  • Changed file Psr4ClassDiscovery.php
    diff --git a/29b69942407271f3404fee4b4f282ad0343eab36 b/cbffd55a3e99ce011068a2f8a10ca9519cc28e7c
    index 29b6994..cbffd55 100644
    --- a/29b69942407271f3404fee4b4f282ad0343eab36
    +++ b/cbffd55a3e99ce011068a2f8a10ca9519cc28e7c
    @@ -36,7 +36,7 @@ class Psr4ClassDiscovery extends ClassDiscovery {
     	}
    
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 */
     	public function fromFile(string $filename): string {
     		if (mb_strpos($filename, $this->srcDirectory) !== 0) {
  • Changed file TokeniserClassDiscovery.php
    diff --git a/d10f2dc34ff845d2491643d6e4ba4a3179711e3f b/d929afca3de936129378825e2bbb2262f6c1ea00
    index d10f2dc..d929afc 100644
    --- a/d10f2dc34ff845d2491643d6e4ba4a3179711e3f
    +++ b/d929afca3de936129378825e2bbb2262f6c1ea00
    @@ -16,7 +16,7 @@ use RuntimeException;
      */
     class TokeniserClassDiscovery extends ClassDiscovery {
     	/**
    -	 * {@inheritdoc}
    +	 * {@inheritDoc}
     	 * @see https://stackoverflow.com/a/7153391 Courtesy of stackoverflow
     	 */
     	public function fromFile(string $filename): string {
    @@ -36,9 +36,9 @@ class TokeniserClassDiscovery extends ClassDiscovery {
     			}
    
     			for (; $i < count($tokens); $i++) {
    -				if ($tokens[$i][0] === T_NAMESPACE) {
    +				if ($tokens[$i][0] === \T_NAMESPACE) {
     					for ($j = $i + 1; $j < count($tokens); $j++) {
    -						if ($tokens[$j][0] === T_STRING) {
    +						if ($tokens[$j][0] === \T_STRING) {
     							$namespace .= '\\'.$tokens[$j][1];
     						} elseif ($tokens[$j] === '{' || $tokens[$j] === ';') {
     							break;
    @@ -46,7 +46,7 @@ class TokeniserClassDiscovery extends ClassDiscovery {
     					}
     				}
    
    -				if ($tokens[$i][0] === T_CLASS) {
    +				if ($tokens[$i][0] === \T_CLASS) {
     					for ($j = $i + 1; $j < count($tokens); $j++) {
     						if ($tokens[$j] === '{') {
     							$class = $tokens[$i + 2][1];
  • Changed file Error.php
    diff --git a/e68b529d8de5deaf82eb84f0346420f40cf2ce56 b/c97b73b3d7a6e7a6db9de7aa0b23d8c78b933c7c
    index e68b529..c97b73b 100644
    --- a/e68b529d8de5deaf82eb84f0346420f40cf2ce56
    +++ b/c97b73b3d7a6e7a6db9de7aa0b23d8c78b933c7c
    @@ -33,7 +33,7 @@ class Error {
     	 * @param string $errfile The error file path
     	 * @param int|null $errline Error line number
     	 */
    -	public function __construct(string $level, int $errno, string $errstr = '', string $errfile = '', int $errline = null) {
    +	public function __construct(string $level, int $errno, string $errstr = '', string $errfile = '', ?int $errline = null) {
     		$this->errorlevel = $level;
     		$this->errorno = $errno;
     		$this->errormsg = $errstr;
  • Changed file ErrorHandler.php
    diff --git a/80aa08a707f5af0ee822cb31f3f1a20b1c59f249 b/63f09dabbe2c79b34b800a12ce7f9c89b55282d6
    index 80aa08a..63f09da 100644
    --- a/80aa08a707f5af0ee822cb31f3f1a20b1c59f249
    +++ b/63f09dabbe2c79b34b800a12ce7f9c89b55282d6
    @@ -22,26 +22,26 @@ class ErrorHandler {
     	 * @psalm-var array<int, array{level: string, name: string}>
     	 */
     	public const ERROR_LEVEL_LOOKUP = array(
    -		E_ERROR => array('level' => LogLevel::CRITICAL, 'name' => 'E_ERROR'),
    -		E_WARNING => array('level' => LogLevel::WARNING, 'name' => 'E_WARNING'),
    -		E_PARSE => array('level' => LogLevel::ALERT, 'name' => 'E_PARSE'),
    -		E_NOTICE => array('level' => LogLevel::NOTICE, 'name' => 'E_NOTICE'),
    -		E_CORE_ERROR => array('level' => LogLevel::CRITICAL, 'name' => 'E_CORE_ERROR'),
    -		E_CORE_WARNING => array('level' => LogLevel::WARNING, 'name' => 'E_CORE_WARNING'),
    -		E_COMPILE_ERROR => array('level' => LogLevel::ALERT, 'name' => 'E_COMPILE_ERROR'),
    -		E_COMPILE_WARNING => array('level' => LogLevel::WARNING, 'name' => 'E_COMPILE_WARNING'),
    -		E_USER_ERROR => array('level' => LogLevel::ERROR, 'name' => 'E_USER_ERROR'),
    -		E_USER_WARNING => array('level' => LogLevel::WARNING, 'name' => 'E_USER_WARNING'),
    -		E_USER_NOTICE => array('level' => LogLevel::NOTICE, 'name' => 'E_USER_NOTICE'),
    -		E_STRICT => array('level' => LogLevel::NOTICE, 'name' => 'E_STRICT'),
    -		E_RECOVERABLE_ERROR => array('level' => LogLevel::ERROR, 'name' => 'E_RECOVERABLE_ERROR'),
    -		E_DEPRECATED => array('level' => LogLevel::WARNING, 'name' => 'E_DEPRECATED'),
    -		E_USER_DEPRECATED => array('level' => LogLevel::WARNING, 'name' => 'E_USER_DEPRECATED'),
    +		\E_ERROR => array('level' => LogLevel::CRITICAL, 'name' => 'E_ERROR'),
    +		\E_WARNING => array('level' => LogLevel::WARNING, 'name' => 'E_WARNING'),
    +		\E_PARSE => array('level' => LogLevel::ALERT, 'name' => 'E_PARSE'),
    +		\E_NOTICE => array('level' => LogLevel::NOTICE, 'name' => 'E_NOTICE'),
    +		\E_CORE_ERROR => array('level' => LogLevel::CRITICAL, 'name' => 'E_CORE_ERROR'),
    +		\E_CORE_WARNING => array('level' => LogLevel::WARNING, 'name' => 'E_CORE_WARNING'),
    +		\E_COMPILE_ERROR => array('level' => LogLevel::ALERT, 'name' => 'E_COMPILE_ERROR'),
    +		\E_COMPILE_WARNING => array('level' => LogLevel::WARNING, 'name' => 'E_COMPILE_WARNING'),
    +		\E_USER_ERROR => array('level' => LogLevel::ERROR, 'name' => 'E_USER_ERROR'),
    +		\E_USER_WARNING => array('level' => LogLevel::WARNING, 'name' => 'E_USER_WARNING'),
    +		\E_USER_NOTICE => array('level' => LogLevel::NOTICE, 'name' => 'E_USER_NOTICE'),
    +		\E_STRICT => array('level' => LogLevel::NOTICE, 'name' => 'E_STRICT'),
    +		\E_RECOVERABLE_ERROR => array('level' => LogLevel::ERROR, 'name' => 'E_RECOVERABLE_ERROR'),
    +		\E_DEPRECATED => array('level' => LogLevel::WARNING, 'name' => 'E_DEPRECATED'),
    +		\E_USER_DEPRECATED => array('level' => LogLevel::WARNING, 'name' => 'E_USER_DEPRECATED'),
     	);
    
     	private ?LoggerInterface $logger;
    
    -	public function __construct(LoggerInterface $logger = null) {
    +	public function __construct(?LoggerInterface $logger = null) {
     		$this->logger = $logger;
     	}
    
    @@ -54,13 +54,13 @@ class ErrorHandler {
     	 * @param int $line The line the error was caused on
     	 * @return bool|null To advise the spl to continue error handling or not
     	 */
    -	public function handleError(int $errno, string $msg = '', string $file = '', int $line = null): ?bool {
    +	public function handleError(int $errno, string $msg = '', string $file = '', ?int $line = null): ?bool {
     		if (!(error_reporting() & $errno)) {
     			// This error code is not included in error_reporting
     			return null;
     		}
    
    -		list('type' => $type, 'name' => $name) = (self::ERROR_LEVEL_LOOKUP[$errno] ?? self::ERROR_LEVEL_LOOKUP[E_ERROR]);
    +		list('type' => $type, 'name' => $name) = (self::ERROR_LEVEL_LOOKUP[$errno] ?? self::ERROR_LEVEL_LOOKUP[\E_ERROR]);
    
     		if ($this->logger !== null) {
     			$this->logger->log(
  • Changed file functions.php
    diff --git a/77bf010df5f41779f3073581eba137e07f3e6c05 b/b92019ac2aa68e57a3968c60e671cdd2fc8f7183
    index 77bf010..b92019a 100644
    --- a/77bf010df5f41779f3073581eba137e07f3e6c05
    +++ b/b92019ac2aa68e57a3968c60e671cdd2fc8f7183
    @@ -15,8 +15,8 @@ if (!function_exists(__NAMESPACE__.'\\trigger_error_context')) {
     	 * @param string $message The message to throw in the error
     	 * @param int $level Error level integer, defaults to E_USER_ERROR
     	 */
    -	function trigger_error_context(string $message, int $level = E_USER_ERROR): void {
    -		$caller = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
    +	function trigger_error_context(string $message, int $level = \E_USER_ERROR): void {
    +		$caller = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0];
     		trigger_error("{$message} in file {$caller['file']} on line {$caller['line']}", $level);
     	}
     }
    @@ -41,7 +41,7 @@ if (!function_exists(__NAMESPACE__.'\\isAssoc')) {
     	 * @return bool true or false on is associative or not
     	 */
     	function isAssoc(array $arr): bool {
    -		if (array() === $arr) {
    +		if ($arr === array()) {
     			return false;
     		}
     		ksort($arr);
  • Changed file ConfigReaderTest.php
    diff --git a/150c59aafe4a807660b3bd768d40ed8a5dc82fae b/9227c8d6a3e577528146eb6be18818d1c8cc6d12
    index 150c59a..9227c8d 100644
    --- a/150c59aafe4a807660b3bd768d40ed8a5dc82fae
    +++ b/9227c8d6a3e577528146eb6be18818d1c8cc6d12
    @@ -9,6 +9,7 @@
    
     namespace holonet\common\tests;
    
    +use Exception;
     use PHPUnit\Framework\TestCase;
     use holonet\common\config\ConfigReader;
    
    @@ -28,7 +29,7 @@ class ConfigReaderTest extends TestCase {
     	public function configTestProvider() {
     		$ret = array();
     		foreach (glob(__DIR__.'/data/config.*') as $file) {
    -			$ext = pathinfo($file, PATHINFO_EXTENSION);
    +			$ext = pathinfo($file, \PATHINFO_EXTENSION);
     			$ret[$ext] = array($file);
     		}
    
    @@ -41,10 +42,10 @@ class ConfigReaderTest extends TestCase {
    
     		try {
     			$configreader->read($filename);
    -		} catch (\Exception $e) {
    +		} catch (Exception $e) {
     			$msg = $e->getMessage();
     		}
    -		static::assertSame("File path 'iSurelyDon'tExist.ini' does not exist", $msg);
    +		$this->assertSame("File path 'iSurelyDon'tExist.ini' does not exist", $msg);
     	}
    
     	/**
    @@ -59,7 +60,7 @@ class ConfigReaderTest extends TestCase {
     		$configreader = new ConfigReader();
     		$configreader->read($file);
    
    -		static::assertSame($expectedData, $configreader->registry->getAll());
    +		$this->assertSame($expectedData, $configreader->registry->getAll());
     	}
    
     	public function testUnknownType(): void {
    @@ -68,9 +69,9 @@ class ConfigReaderTest extends TestCase {
    
     		try {
     			$configreader->read($filename);
    -		} catch (\Exception $e) {
    +		} catch (Exception $e) {
     			$msg = $e->getMessage();
     		}
    -		static::assertSame("Could not parse config file '{$filename}'; Unknown config file type 'blablabla'", $msg);
    +		$this->assertSame("Could not parse config file '{$filename}'; Unknown config file type 'blablabla'", $msg);
     	}
     }
  • Created new file DiContainerTest.php
    <?php
    /**
     * This file is part of the hdev common library package
     * (c) Matthias Lantsch.
     *
     * @license http://www.wtfpl.net/ Do what the fuck you want Public License
     * @author  Matthias Lantsch <[email protected]>
     */
    
    namespace holonet\common\tests;
    
    use PHPUnit\Framework\TestCase;
    use holonet\common\di\Container;
    
    /**
     * Tests the functionality of utility functions in functions.php.
     *
     * @internal
     *
     * @covers \holonet\common\di\Container
     *
     * @small
     */
    class DiContainerTest extends TestCase {
    	public function testInjectionBeforeConstructor(): void {
    		$container = new Container();
    		$container->set('anonDep', DiAnonDep::class);
    		$container->set('anonClassTwo', DiAnonClassTwo::class);
    
    		$this->assertSame('test', $container->get('anonClassTwo')->test);
    	}
    }
    
    class DiAnonClassOne {
    	public DiAnonClassTwo $di_anonClassTwo;
    }
    
    class DiAnonClassTwo {
    	public DiAnonDep $di_anonDep;
    
    	public string $test;
    
    	public function __construct() {
    		$this->test = $this->di_anonDep->test();
    	}
    }
    
    class DiAnonDep {
    	public function test(): string {
    		return 'test';
    	}
    }
  • Changed file EnumTest.php
    diff --git a/14ff4b7519b836b0d82539aaf169c23ff6ba3623 b/d2f99de147798ada88bd855fa6e36a738aafde48
    index 14ff4b7..d2f99de 100644
    --- a/14ff4b7519b836b0d82539aaf169c23ff6ba3623
    +++ b/d2f99de147798ada88bd855fa6e36a738aafde48
    @@ -22,15 +22,15 @@ use PHPUnit\Framework\TestCase;
     class EnumTest extends TestCase {
     	public function testEnumExtraFeatures(): void {
     		// we should be able to instantiate all 4 enum values even though they are defined differently in the constant
    -		static::assertNotNull(TestEnum::VALUE1());
    -		static::assertNotNull(TestEnum::VALUE2());
    -		static::assertNotNull(TestEnum::VALUE3());
    -		static::assertNotNull(TestEnum::VALUE4());
    +		$this->assertNotNull(TestEnum::VALUE1());
    +		$this->assertNotNull(TestEnum::VALUE2());
    +		$this->assertNotNull(TestEnum::VALUE3());
    +		$this->assertNotNull(TestEnum::VALUE4());
    
     		$value1 = TestEnum::VALUE1();
     		// no matter how it's accessed (static method or from dynamic value) it should always be the same instance
    -		static::assertSame($value1, TestEnum::fromValue('value1'));
    -		static::assertSame($value1, TestEnum::valueOf('VALUE1'));
    +		$this->assertSame($value1, TestEnum::fromValue('value1'));
    +		$this->assertSame($value1, TestEnum::valueOf('VALUE1'));
     	}
    
     	/**
    @@ -38,7 +38,7 @@ class EnumTest extends TestCase {
     	 */
     	public function testToArrayMethod(): void {
     		$array = TestEnum::toArray();
    -		static::assertSame(array(
    +		$this->assertSame(array(
     			'VALUE1' => 'value1',
     			'VALUE2' => 'value2',
     			'VALUE3' => 'value3',
    @@ -57,6 +57,6 @@ class EnumTest extends TestCase {
     			'VALUE4' => TestEnum::VALUE4(),
     		);
    
    -		static::assertSame($values, TestEnum::values());
    +		$this->assertSame($values, TestEnum::values());
     	}
     }
  • Changed file FunctionsTest.php
    diff --git a/2c43e14d782ebcd45a9f194742b551c0e63eb472 b/18d36d2ac014052d135f1152e448bc2c46c61a7a
    index 2c43e14..18d36d2 100644
    --- a/2c43e14d782ebcd45a9f194742b551c0e63eb472
    +++ b/18d36d2ac014052d135f1152e448bc2c46c61a7a
    @@ -26,11 +26,11 @@ class FunctionsTest extends TestCase {
     	 * @covers \holonet\common\FilesystemUtils::filepath()
     	 */
     	public function testAbsolutePaths(): void {
    -		$expected = implode(DIRECTORY_SEPARATOR, array(__DIR__, 'subfolder', 'subsubfolder')).DIRECTORY_SEPARATOR;
    -		static::assertSame($expected, co\FilesystemUtils::dirpath(__DIR__, 'subfolder', 'subsubfolder'));
    +		$expected = implode(\DIRECTORY_SEPARATOR, array(__DIR__, 'subfolder', 'subsubfolder')).\DIRECTORY_SEPARATOR;
    +		$this->assertSame($expected, co\FilesystemUtils::dirpath(__DIR__, 'subfolder', 'subsubfolder'));
    
     		$expected .= 'test.txt';
    -		static::assertSame($expected, co\FilesystemUtils::filepath(__DIR__, 'subfolder', 'subsubfolder', 'test.txt'));
    +		$this->assertSame($expected, co\FilesystemUtils::filepath(__DIR__, 'subfolder', 'subsubfolder', 'test.txt'));
     	}
    
     	/**
    @@ -40,11 +40,11 @@ class FunctionsTest extends TestCase {
     	 * @covers \holonet\common\FilesystemUtils::relfilepath()
     	 */
     	public function testRelativePaths(): void {
    -		$expected = implode(DIRECTORY_SEPARATOR, array(__DIR__, 'subfolder', 'subsubfolder')).DIRECTORY_SEPARATOR;
    -		static::assertSame($expected, co\FilesystemUtils::reldirpath('subfolder', 'subsubfolder'));
    +		$expected = implode(\DIRECTORY_SEPARATOR, array(__DIR__, 'subfolder', 'subsubfolder')).\DIRECTORY_SEPARATOR;
    +		$this->assertSame($expected, co\FilesystemUtils::reldirpath('subfolder', 'subsubfolder'));
    
     		$expected .= 'test.txt';
    -		static::assertSame($expected, co\FilesystemUtils::relfilepath('subfolder', 'subsubfolder', 'test.txt'));
    +		$this->assertSame($expected, co\FilesystemUtils::relfilepath('subfolder', 'subsubfolder', 'test.txt'));
     	}
    
     	/**
    @@ -60,6 +60,6 @@ class FunctionsTest extends TestCase {
     		}
    
     		$expected = 'oh nos in file '.__FILE__.' on line 57';
    -		static::assertSame($expected, $msg);
    +		$this->assertSame($expected, $msg);
     	}
     }
  • Changed file RegistryTest.php
    diff --git a/4e5ac9928c696c62bb1cd740ee7de474175961c6 b/7b0c7d2ec72fe4f1993e71db497569228c89215d
    index 4e5ac99..7b0c7d2 100644
    --- a/4e5ac9928c696c62bb1cd740ee7de474175961c6
    +++ b/7b0c7d2ec72fe4f1993e71db497569228c89215d
    @@ -35,10 +35,10 @@ class RegistryTest extends TestCase {
     		);
     		$registry->setAll($data);
    
    -		static::assertSame('lower', $registry->get('array.lowerval'));
    -		static::assertNull($registry->get('array.notexisting'));
    -		static::assertSame('lowest', $registry->get('array.arrayarray.lowestval'));
    -		static::assertNull($registry->get('array.lowerval.stillnotexisting'));
    +		$this->assertSame('lower', $registry->get('array.lowerval'));
    +		$this->assertNull($registry->get('array.notexisting'));
    +		$this->assertSame('lowest', $registry->get('array.arrayarray.lowestval'));
    +		$this->assertNull($registry->get('array.lowerval.stillnotexisting'));
     	}
    
     	public function testPlaceholders(): void {
    @@ -48,9 +48,9 @@ class RegistryTest extends TestCase {
     		$registry->set('app.environment', '%app.name%-test');
     		$registry->set('app.testing', 'inside-%not-existing-placeholder%-testing');
    
    -		static::assertSame('coolapp-test', $registry->get('app.environment'));
    -		static::assertSame('inside-%not-existing-placeholder%-testing', $registry->get('app.testing'));
    -		static::assertSame(array('app' => array('name' => 'coolapp', 'environment' => 'coolapp-test', 'testing' => 'inside-%not-existing-placeholder%-testing')), $registry->getAll());
    +		$this->assertSame('coolapp-test', $registry->get('app.environment'));
    +		$this->assertSame('inside-%not-existing-placeholder%-testing', $registry->get('app.testing'));
    +		$this->assertSame(array('app' => array('name' => 'coolapp', 'environment' => 'coolapp-test', 'testing' => 'inside-%not-existing-placeholder%-testing')), $registry->getAll());
     	}
    
     	public function testSetMultilevel(): void {
    @@ -59,17 +59,17 @@ class RegistryTest extends TestCase {
     		//test multi level set
     		$registry->set('test.subone.sub2', 'subvalue');
     		$expected['test']['subone']['sub2'] = 'subvalue';
    -		static::assertSame($expected, $registry->getAll());
    +		$this->assertSame($expected, $registry->getAll());
    
     		//test multi level set with overwrite
     		$registry->set('test.subone', 'overwrite');
     		$expected['test']['subone'] = 'overwrite';
    -		static::assertSame($expected, $registry->getAll());
    +		$this->assertSame($expected, $registry->getAll());
    
     		//test same level 2 values set
     		$registry->set('test.subonebrother', 'nexttoit');
     		$expected['test'] = array('subone' => 'overwrite', 'subonebrother' => 'nexttoit');
    -		static::assertSame($expected, $registry->getAll());
    +		$this->assertSame($expected, $registry->getAll());
     	}
    
     	public function testSetSublevelKeyWithoutOverwrite(): void {
    @@ -84,15 +84,15 @@ class RegistryTest extends TestCase {
     		);
     		$registry->setAll($newConfigfile);
    
    -		static::assertSame(array('host' => 'localhost', 'port' => '224'), $registry->get('app.db'));
    +		$this->assertSame(array('host' => 'localhost', 'port' => '224'), $registry->get('app.db'));
     	}
    
     	public function testSimplePair(): void {
     		$registry = new Registry();
     		$registry->set('test', 'value');
    
    -		static::assertSame('value', $registry->get('test'));
    -		static::assertNull($registry->get('notexisting'));
    -		static::assertSame(array('test' => 'value'), $registry->getAll());
    +		$this->assertSame('value', $registry->get('test'));
    +		$this->assertNull($registry->get('notexisting'));
    +		$this->assertSame(array('test' => 'value'), $registry->getAll());
     	}
     }
  • Changed file TestEnum.php
    diff --git a/5339d7206dbc7d3b94f787fd796bf963cbe763f4 b/55b027ed63b455128fe1ee0c9e9a75baba9ffcfb
    index 5339d72..55b027e 100644
    --- a/5339d7206dbc7d3b94f787fd796bf963cbe763f4
    +++ b/55b027ed63b455128fe1ee0c9e9a75baba9ffcfb
    @@ -31,7 +31,7 @@ class TestEnum extends Enum {
    
     	protected ?string $thirdAttr = null;
    
    -	protected function __construct($value, string $secondAttr = null, string $thirdAttr = null) {
    +	protected function __construct($value, ?string $secondAttr = null, ?string $thirdAttr = null) {
     		parent::__construct($value);
     		if ($secondAttr !== null) {
     			$this->secondAttr = $secondAttr;