Skip to content

Commit

Permalink
Added PHP 8.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrankruijter committed Feb 23, 2021
1 parent c3b0bee commit 3481c3e
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 82 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
language: php
php:
- '7.2'
- '7.3'
- '7.4'
- '8.0'

before_script:
- yes '' | pecl install yaml
- composer install

script:
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.2.0 - 2021-02-23
### Added
- Compatibility for PHP 8.0

## 1.1.0 - 2020-06-08
### Added
- Separate method reflector.
Expand All @@ -15,5 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Initial implementation of the object factory package.

- [1.1.0 > Unreleased](https://github.com/grizz-it/object-factory/compare/1.1.0...HEAD)
# Versions
- [1.2.0 > Unreleased](https://github.com/grizz-it/object-factory/compare/1.2.0...HEAD)
- [1.1.0 > 1.2.0](https://github.com/grizz-it/object-factory/compare/1.1.0...1.2.0)
- [1.0.0 > 1.1.0](https://github.com/grizz-it/object-factory/compare/1.0.0...1.1.0)
101 changes: 48 additions & 53 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,56 +1,51 @@
{
"name": "grizz-it/object-factory",
"description": "An object factory for PHP applications.",
"keywords": ["object-factory"],
"type": "library",
"license": "MIT",
"prefer-stable": true,
"minimum-stability": "stable",
"require":
"name": "grizz-it/object-factory",
"description": "An object factory for PHP applications.",
"keywords": [
"object-factory"
],
"type": "library",
"license": "MIT",
"prefer-stable": true,
"minimum-stability": "stable",
"require": {
"php": "^8.0",
"grizz-it/storage": "^1.1"
},
"authors": [
{
"php": "^7.2",
"grizz-it/storage": "^1.0"
},
"authors": [
{
"name": "GrizzIT",
"homepage": "https://www.grizzit.com/",
"role": "Developer"
}],
"config":
{
"sort-packages": true
},
"autoload":
{
"psr-4":
{
"GrizzIt\\ObjectFactory\\": "src/"
}
},
"autoload-dev":
{
"psr-4":
{
"GrizzIt\\ObjectFactory\\Tests\\": "tests/"
}
},
"archive":
{
"exclude": [
"/tests",
"/.gitignore",
"/.travis.yml",
"/phpunit.xml",
"/phpcs.xml",
"/PULL_REQUEST_TEMPLATE.md",
"/CODE_OF_CONDUCT.md",
"/CONTRIBUTING.md"
]
},
"require-dev":
{
"phpunit/phpunit": "^8.0",
"squizlabs/php_codesniffer": "^3.4"
"name": "GrizzIT",
"homepage": "https://www.grizzit.com/",
"role": "Developer"
}
],
"config": {
"sort-packages": true
},
"autoload": {
"psr-4": {
"GrizzIt\\ObjectFactory\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"GrizzIt\\ObjectFactory\\Tests\\": "tests/"
}
}
},
"archive": {
"exclude": [
"/tests",
"/.gitignore",
"/.travis.yml",
"/phpunit.xml",
"/phpcs.xml",
"/PULL_REQUEST_TEMPLATE.md",
"/CODE_OF_CONDUCT.md",
"/CONTRIBUTING.md"
]
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.5"
}
}
4 changes: 3 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<arg name="colors" />
<arg value="s" />

<rule ref="PSR12" />
<rule ref="PSR12">
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols"/>
</rule>
</ruleset>
23 changes: 12 additions & 11 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResult="false">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 2 additions & 0 deletions src/Common/ClassAnalyserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ interface ClassAnalyserInterface
/**
* Analyses the constructor of a class and returns a configuration array.
*
* @param string $class
*
* @return array
*/
public function analyse(string $class): array;
Expand Down
3 changes: 3 additions & 0 deletions src/Common/MethodReflectorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ interface MethodReflectorInterface
/**
* Analyses a method of a class and returns a configuration array.
*
* @param string $class
* @param string $method
*
* @return array
*/
public function reflect(string $class, string $method): array;
Expand Down
3 changes: 3 additions & 0 deletions src/Common/ObjectFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ interface ObjectFactoryInterface
/**
* Creates an instance of an object.
*
* @param string $class
* @param array $parameters
*
* @return object
*/
public function create(string $class, array $parameters): object;
Expand Down
6 changes: 4 additions & 2 deletions src/Component/Analyser/ClassAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class ClassAnalyser implements ClassAnalyserInterface
*
* @var StorageInterface
*/
private $analysisStorage;
private StorageInterface $analysisStorage;

/**
* Contains the method reflector.
*
* @var MethodReflectorInterface
*/
private $methodReflector;
private MethodReflectorInterface $methodReflector;

/**
* Constructor
Expand All @@ -49,6 +49,8 @@ public function __construct(
/**
* Analyses the constructor of a class and returns a configuration array.
*
* @param string $class
*
* @return array
*
* @throws NonInstantiableClassException When the analysed class is not instantiable.
Expand Down
7 changes: 5 additions & 2 deletions src/Component/Reflector/MethodReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MethodReflector implements MethodReflectorInterface
*
* @var array
*/
private $translations = [
private array $translations = [
'bool' => 'boolean',
'int' => 'integer',
'float' => 'double',
Expand All @@ -30,7 +30,7 @@ class MethodReflector implements MethodReflectorInterface
*
* @var StorageInterface
*/
private $analysisStorage;
private StorageInterface $analysisStorage;

/**
* Constructor
Expand All @@ -45,6 +45,9 @@ public function __construct(StorageInterface $analysisStorage)
/**
* Analyses a method of a class and returns a configuration array.
*
* @param string $class
* @param string $method
*
* @return array
*/
public function reflect(string $class, string $method): array
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidParameterTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class InvalidParameterTypeException extends Exception
*/
public function __construct(
array $parameterConfig,
$parameter,
mixed $parameter,
Throwable $previous = null
) {
parent::__construct(
Expand Down
1 change: 0 additions & 1 deletion src/Exception/MissingParameterException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class MissingParameterException extends Exception
* Constructor.
*
* @param array $parameterConfig
* @param mixed $parameter
* @param Throwable $previous
*/
public function __construct(
Expand Down
2 changes: 0 additions & 2 deletions src/Exception/NonInstantiableClassException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class NonInstantiableClassException extends Exception
* Constructor.
*
* @param array $parameterConfig
* @param mixed $parameter
* @param Throwable $previous
*/
public function __construct(
string $class
Expand Down
13 changes: 9 additions & 4 deletions src/Factory/ObjectFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ObjectFactory implements ObjectFactoryInterface
*
* @var ClassAnalyserInterface
*/
private $classAnalyser;
private ClassAnalyserInterface $classAnalyser;

/**
* Constructor.
Expand Down Expand Up @@ -78,6 +78,9 @@ public function create(string $class, array $parameters): object
* Converts the parameter order based on the configuration and returns a
* array which can be passed variadically.
*
* @param array $config
* @param array $parameters
*
* @return array
*/
private function translate(array $config, array $parameters): array
Expand Down Expand Up @@ -117,7 +120,7 @@ private function translate(array $config, array $parameters): array
return $invokeParameters;
}

/**
/**
* Checks the parameter type.
*
* @param array $parameterConfig
Expand All @@ -127,8 +130,10 @@ private function translate(array $config, array $parameters): array
*
* @throws InvalidParameterTypeException When the type can not be resolved.
*/
private function parameterByType(array $parameterConfig, $parameter)
{
private function parameterByType(
array $parameterConfig,
mixed $parameter
): mixed {
if ($parameterConfig['builtin']) {
if (
gettype(
Expand Down

0 comments on commit 3481c3e

Please sign in to comment.