diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c312bc..1d1267d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] - php-version: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] + php-version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] name: PHP ${{ matrix.php-version }} on ${{ matrix.os }} steps: diff --git a/bin/update-tests b/bin/update-tests index d1f7145..f1e3f48 100644 --- a/bin/update-tests +++ b/bin/update-tests @@ -2,7 +2,7 @@ # This file updates tests according to the phpunit library used for current php version, or php version in 1st argument. # Usage: # update-tests - to update tests according to the phpunit library used for current php version. -# update-tests x.x - to update tests according to the phpunit library used for specific php version x.x, where x.x = 5.6|7.0|7.1|7.2|7.3|7.4|8.0. +# update-tests x.x - to update tests according to the phpunit library used for specific php version x.x, where x.x = 5.6|7.0|7.1|7.2|7.3|7.4|8.0|8.1|8.2|8.3|8.4. # Directory with phpunit tests. TEST_DIR="tests" @@ -14,7 +14,7 @@ else fi if [[ $1 == '' && $DEV_MODE != '1' ]]; then - echo "Script works with composer in dev mode only." +# Script works with composer in dev mode only. exit 0 fi @@ -52,7 +52,7 @@ elif [[ $PHP_VERSION == '7.1' ]]; then PHP_UNIT='7.5' elif [[ $PHP_VERSION == '7.2' ]]; then PHP_UNIT='8.5' -elif [[ $PHP_VERSION == '7.3' || $PHP_VERSION == '7.4' || $PHP_VERSION == '8.0' ]]; then +elif [[ $PHP_VERSION == '7.3' || $PHP_VERSION == '7.4' || $PHP_VERSION == '8.0' || $PHP_VERSION == '8.1' || $PHP_VERSION == '8.2' || $PHP_VERSION == '8.3' || $PHP_VERSION == '8.4' ]]; then PHP_UNIT='9.5' fi diff --git a/changelog.md b/changelog.md index 805344f..6805cd1 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. This projec ## [Unreleased][unreleased] +## [1.5.0] +### Added +- Support for PHP 8.4. + +### Changed +- The minimum required PHP version is now 7.2. + ## [1.4.0] ### Added - PHP 8 compatibility and test coverage (thanks @kagg-design) @@ -21,7 +28,7 @@ All notable changes to this project will be documented in this file. This projec ## [1.3.7] ### Fixed -- issue that would generate en excpetion when providing an empty configuration to the `FunctionMocker::init` method +- issue that would generate en exception when providing an empty configuration to the `FunctionMocker::init` method ## [1.3.6] ### Fixed diff --git a/composer.json b/composer.json index cf652f0..bf30b6c 100644 --- a/composer.json +++ b/composer.json @@ -10,9 +10,10 @@ ], "minimum-stability": "stable", "require": { - "phpunit/phpunit": "5.7 - 9.5", - "antecedent/patchwork": "^2.0", - "lucatume/args": "^1.0" + "php": ">=7.1", + "phpunit/phpunit": "7.5 - 9.6", + "antecedent/patchwork": "^2.2.0", + "lucatume/args": "^1.0.1" }, "autoload": { "psr-0": { diff --git a/src/functions.php b/src/functions.php index b6864d4..a0ca3f0 100644 --- a/src/functions.php +++ b/src/functions.php @@ -14,7 +14,7 @@ * @see \Patchwork\configure() * */ -function init(array $options = null) { +function init(?array $options = null) { FunctionMocker::init($options); } diff --git a/src/tad/FunctionMocker/Call/Logger/LoggerInterface.php b/src/tad/FunctionMocker/Call/Logger/LoggerInterface.php index f795afa..f59bed0 100644 --- a/src/tad/FunctionMocker/Call/Logger/LoggerInterface.php +++ b/src/tad/FunctionMocker/Call/Logger/LoggerInterface.php @@ -5,5 +5,5 @@ interface LoggerInterface { - public function called(array $args = null); + public function called(?array $args = null); } diff --git a/src/tad/FunctionMocker/Call/Logger/SpyCallLogger.php b/src/tad/FunctionMocker/Call/Logger/SpyCallLogger.php index b34bdbb..e4b1d62 100644 --- a/src/tad/FunctionMocker/Call/Logger/SpyCallLogger.php +++ b/src/tad/FunctionMocker/Call/Logger/SpyCallLogger.php @@ -22,12 +22,12 @@ public function __construct() : '\\PHPUnit\\Framework\\Constraint\\Constraint'; } - public function called(array $args = null) + public function called(?array $args = null) { $this->calls[] = CallTrace::fromArguments($args); } - public function getCallTimes(array $args = null) + public function getCallTimes(?array $args = null) { $calls = $this->calls; if ($args) { diff --git a/src/tad/FunctionMocker/Call/Verifier/InstanceMethodCallVerifier.php b/src/tad/FunctionMocker/Call/Verifier/InstanceMethodCallVerifier.php index 701ef42..7fc19ea 100644 --- a/src/tad/FunctionMocker/Call/Verifier/InstanceMethodCallVerifier.php +++ b/src/tad/FunctionMocker/Call/Verifier/InstanceMethodCallVerifier.php @@ -43,7 +43,7 @@ private function realWasCalledTimes( $times ) { * * @return array */ - protected function getCallTimesWithArgs( $methodName, array $args = null ) { + protected function getCallTimesWithArgs( $methodName, ?array $args = null ) { $invocations = $this->getInvocations(); $callTimes = 0; array_map( function ( $invocation ) use ( &$callTimes, $args, $methodName ) { diff --git a/src/tad/FunctionMocker/CallTrace.php b/src/tad/FunctionMocker/CallTrace.php index 2636eb8..91e09d1 100644 --- a/src/tad/FunctionMocker/CallTrace.php +++ b/src/tad/FunctionMocker/CallTrace.php @@ -7,7 +7,7 @@ class CallTrace protected $args; - public static function fromArguments(array $args = null) + public static function fromArguments(?array $args = null) { $instance = new self; $instance->args = $args ? $args : array(); diff --git a/src/tad/FunctionMocker/FunctionMocker.php b/src/tad/FunctionMocker/FunctionMocker.php index 387b21f..4b9a4a2 100644 --- a/src/tad/FunctionMocker/FunctionMocker.php +++ b/src/tad/FunctionMocker/FunctionMocker.php @@ -54,7 +54,7 @@ public static function setUp() { * * @see \Patchwork\configure() */ - public static function init(array $options = null, $forceReinit = false) { + public static function init(?array $options = null, $forceReinit = false) { if (!$forceReinit && self::$didInit) { return; } @@ -300,7 +300,7 @@ private static function getIndexedReplacements($return) { * * @return mixed */ - public static function callOriginal(array $args = null) { + public static function callOriginal(?array $args = null) { return \Patchwork\relay($args); } @@ -367,7 +367,7 @@ public static function forge($class) { * * @throws \RuntimeException If the Patchwork configuration file or the checksum file could not be written. */ - public static function writePatchworkConfig(array $options = null, $destinationFolder) { + public static function writePatchworkConfig(?array $options = null, $destinationFolder = '') { $options = self::getPatchworkConfiguration($options, $destinationFolder); $configFileContents = json_encode($options); diff --git a/src/tad/FunctionMocker/Method/Verifier.php b/src/tad/FunctionMocker/Method/Verifier.php index 3458a06..cc35c88 100644 --- a/src/tad/FunctionMocker/Method/Verifier.php +++ b/src/tad/FunctionMocker/Method/Verifier.php @@ -27,7 +27,7 @@ public function __construct() { } - public function __call($name, array $args = null) + public function __call($name, ?array $args = null) { return InstanceMethodCallVerifier::from($this->returnValue, $this->callLogger); } diff --git a/src/tad/FunctionMocker/MockWrapper.php b/src/tad/FunctionMocker/MockWrapper.php index 3bf1133..8376491 100644 --- a/src/tad/FunctionMocker/MockWrapper.php +++ b/src/tad/FunctionMocker/MockWrapper.php @@ -29,7 +29,12 @@ class MockWrapper */ protected $classTemplate; - public function __construct($originalClassName = '', ClassTemplateInterface $classTemplate = null, MethodCodeInterface $methodCode = null) + /** + * @var MethodCode|MethodCodeInterface + */ + private $methodCode; + + public function __construct($originalClassName = '', ?ClassTemplateInterface $classTemplate = null, ?MethodCodeInterface $methodCode = null) { $this->originalClassName = $originalClassName; $this->classTemplate = $classTemplate ?: new ClassTemplate(); @@ -66,7 +71,7 @@ public function wrap($mockObject, $invokedRecorder, ReplacementRequest $request) * @throws \Exception * */ - protected function getWrappedInstance($object, ExtenderInterface $extender, $invokedRecorder = null, ReplacementRequest $request = null) + protected function getWrappedInstance($object, ExtenderInterface $extender, $invokedRecorder = null, ?ReplacementRequest $request = null) { $mockClassName = get_class($object); $extendClassName = sprintf('%s_%s', uniqid('Extended_'), $mockClassName); diff --git a/src/tad/FunctionMocker/PHPUnitFrameworkAssertWrapper.php b/src/tad/FunctionMocker/PHPUnitFrameworkAssertWrapper.php index 764ee28..1e01340 100644 --- a/src/tad/FunctionMocker/PHPUnitFrameworkAssertWrapper.php +++ b/src/tad/FunctionMocker/PHPUnitFrameworkAssertWrapper.php @@ -32,7 +32,7 @@ public static function getTestCase() * @param array $args * @return mixed */ - public static function __callStatic($name, array $args = null) + public static function __callStatic($name, ?array $args = null) { return call_user_func_array([self::getTestCase(), $name], $args); } diff --git a/src/tad/FunctionMocker/Replacers/InstanceForger.php b/src/tad/FunctionMocker/Replacers/InstanceForger.php index 78a24d6..34ee417 100644 --- a/src/tad/FunctionMocker/Replacers/InstanceForger.php +++ b/src/tad/FunctionMocker/Replacers/InstanceForger.php @@ -90,7 +90,7 @@ public function getPHPUnitMockObjectFor($className, array $methods) * @param $methodName * @param ReturnValue|null $returnValue */ - public function setMockObjectExpectation(&$mockObject, $methodName, ReturnValue $returnValue = null) + public function setMockObjectExpectation(&$mockObject, $methodName, ?ReturnValue $returnValue = null) { if ($returnValue->isCallable()) { // callback