Skip to content

Commit c431d34

Browse files
authored
Merge pull request #21 from kagg-design/php-8.4
PHP 8.1 - 8.4 compatibility
2 parents 0bf4a35 + 09bbea6 commit c431d34

14 files changed

+35
-22
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
os: [ubuntu-latest, windows-latest]
11-
php-version: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
11+
php-version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
1212
name: PHP ${{ matrix.php-version }} on ${{ matrix.os }}
1313

1414
steps:

bin/update-tests

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This file updates tests according to the phpunit library used for current php version, or php version in 1st argument.
33
# Usage:
44
# update-tests - to update tests according to the phpunit library used for current php version.
5-
# 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.
5+
# 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.
66

77
# Directory with phpunit tests.
88
TEST_DIR="tests"
@@ -14,7 +14,7 @@ else
1414
fi
1515

1616
if [[ $1 == '' && $DEV_MODE != '1' ]]; then
17-
echo "Script works with composer in dev mode only."
17+
# Script works with composer in dev mode only.
1818
exit 0
1919
fi
2020

@@ -52,7 +52,7 @@ elif [[ $PHP_VERSION == '7.1' ]]; then
5252
PHP_UNIT='7.5'
5353
elif [[ $PHP_VERSION == '7.2' ]]; then
5454
PHP_UNIT='8.5'
55-
elif [[ $PHP_VERSION == '7.3' || $PHP_VERSION == '7.4' || $PHP_VERSION == '8.0' ]]; then
55+
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
5656
PHP_UNIT='9.5'
5757
fi
5858

changelog.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. This projec
33

44
## [Unreleased][unreleased]
55

6+
## [1.5.0]
7+
### Added
8+
- Support for PHP 8.4.
9+
10+
### Changed
11+
- The minimum required PHP version is now 7.2.
12+
613
## [1.4.0]
714
### Added
815
- 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
2128

2229
## [1.3.7]
2330
### Fixed
24-
- issue that would generate en excpetion when providing an empty configuration to the `FunctionMocker::init` method
31+
- issue that would generate en exception when providing an empty configuration to the `FunctionMocker::init` method
2532

2633
## [1.3.6]
2734
### Fixed

composer.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
],
1111
"minimum-stability": "stable",
1212
"require": {
13-
"phpunit/phpunit": "5.7 - 9.5",
14-
"antecedent/patchwork": "^2.0",
15-
"lucatume/args": "^1.0"
13+
"php": ">=7.1",
14+
"phpunit/phpunit": "7.5 - 9.6",
15+
"antecedent/patchwork": "^2.2.0",
16+
"lucatume/args": "^1.0.1"
1617
},
1718
"autoload": {
1819
"psr-0": {

src/functions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @see \Patchwork\configure()
1515
*
1616
*/
17-
function init(array $options = null) {
17+
function init(?array $options = null) {
1818
FunctionMocker::init($options);
1919
}
2020

src/tad/FunctionMocker/Call/Logger/LoggerInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
interface LoggerInterface
66
{
77

8-
public function called(array $args = null);
8+
public function called(?array $args = null);
99
}

src/tad/FunctionMocker/Call/Logger/SpyCallLogger.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ public function __construct()
2222
: '\\PHPUnit\\Framework\\Constraint\\Constraint';
2323
}
2424

25-
public function called(array $args = null)
25+
public function called(?array $args = null)
2626
{
2727
$this->calls[] = CallTrace::fromArguments($args);
2828
}
2929

30-
public function getCallTimes(array $args = null)
30+
public function getCallTimes(?array $args = null)
3131
{
3232
$calls = $this->calls;
3333
if ($args) {

src/tad/FunctionMocker/Call/Verifier/InstanceMethodCallVerifier.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private function realWasCalledTimes( $times ) {
4343
*
4444
* @return array
4545
*/
46-
protected function getCallTimesWithArgs( $methodName, array $args = null ) {
46+
protected function getCallTimesWithArgs( $methodName, ?array $args = null ) {
4747
$invocations = $this->getInvocations();
4848
$callTimes = 0;
4949
array_map( function ( $invocation ) use ( &$callTimes, $args, $methodName ) {

src/tad/FunctionMocker/CallTrace.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class CallTrace
77

88
protected $args;
99

10-
public static function fromArguments(array $args = null)
10+
public static function fromArguments(?array $args = null)
1111
{
1212
$instance = new self;
1313
$instance->args = $args ? $args : array();

src/tad/FunctionMocker/FunctionMocker.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static function setUp() {
5454
*
5555
* @see \Patchwork\configure()
5656
*/
57-
public static function init(array $options = null, $forceReinit = false) {
57+
public static function init(?array $options = null, $forceReinit = false) {
5858
if (!$forceReinit && self::$didInit) {
5959
return;
6060
}
@@ -300,7 +300,7 @@ private static function getIndexedReplacements($return) {
300300
*
301301
* @return mixed
302302
*/
303-
public static function callOriginal(array $args = null) {
303+
public static function callOriginal(?array $args = null) {
304304
return \Patchwork\relay($args);
305305
}
306306

@@ -367,7 +367,7 @@ public static function forge($class) {
367367
*
368368
* @throws \RuntimeException If the Patchwork configuration file or the checksum file could not be written.
369369
*/
370-
public static function writePatchworkConfig(array $options = null, $destinationFolder) {
370+
public static function writePatchworkConfig(?array $options = null, $destinationFolder = '') {
371371
$options = self::getPatchworkConfiguration($options, $destinationFolder);
372372

373373
$configFileContents = json_encode($options);

src/tad/FunctionMocker/Method/Verifier.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct()
2727
{
2828
}
2929

30-
public function __call($name, array $args = null)
30+
public function __call($name, ?array $args = null)
3131
{
3232
return InstanceMethodCallVerifier::from($this->returnValue, $this->callLogger);
3333
}

src/tad/FunctionMocker/MockWrapper.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ class MockWrapper
2929
*/
3030
protected $classTemplate;
3131

32-
public function __construct($originalClassName = '', ClassTemplateInterface $classTemplate = null, MethodCodeInterface $methodCode = null)
32+
/**
33+
* @var MethodCode|MethodCodeInterface
34+
*/
35+
private $methodCode;
36+
37+
public function __construct($originalClassName = '', ?ClassTemplateInterface $classTemplate = null, ?MethodCodeInterface $methodCode = null)
3338
{
3439
$this->originalClassName = $originalClassName;
3540
$this->classTemplate = $classTemplate ?: new ClassTemplate();
@@ -66,7 +71,7 @@ public function wrap($mockObject, $invokedRecorder, ReplacementRequest $request)
6671
* @throws \Exception
6772
*
6873
*/
69-
protected function getWrappedInstance($object, ExtenderInterface $extender, $invokedRecorder = null, ReplacementRequest $request = null)
74+
protected function getWrappedInstance($object, ExtenderInterface $extender, $invokedRecorder = null, ?ReplacementRequest $request = null)
7075
{
7176
$mockClassName = get_class($object);
7277
$extendClassName = sprintf('%s_%s', uniqid('Extended_'), $mockClassName);

src/tad/FunctionMocker/PHPUnitFrameworkAssertWrapper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static function getTestCase()
3232
* @param array $args
3333
* @return mixed
3434
*/
35-
public static function __callStatic($name, array $args = null)
35+
public static function __callStatic($name, ?array $args = null)
3636
{
3737
return call_user_func_array([self::getTestCase(), $name], $args);
3838
}

src/tad/FunctionMocker/Replacers/InstanceForger.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function getPHPUnitMockObjectFor($className, array $methods)
9090
* @param $methodName
9191
* @param ReturnValue|null $returnValue
9292
*/
93-
public function setMockObjectExpectation(&$mockObject, $methodName, ReturnValue $returnValue = null)
93+
public function setMockObjectExpectation(&$mockObject, $methodName, ?ReturnValue $returnValue = null)
9494
{
9595
if ($returnValue->isCallable()) {
9696
// callback

0 commit comments

Comments
 (0)