Skip to content

Commit 295d0c8

Browse files
authored
Merge pull request #392 from kenjis/php81
Update for PHP 8.1
2 parents 7478cb6 + 4cb22c2 commit 295d0c8

File tree

17 files changed

+130
-35
lines changed

17 files changed

+130
-35
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
language: php
22

3+
dist: bionic
4+
35
php:
46
- 7.3
57
- 7.4.22
68
- 8.0
9+
- 8.1.0
710

811
env:
912
global:

application/tests/_ci_phpunit_test/CIPHPUnitTestDouble.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public function getDouble($classname, $params, $constructor_params = false)
8888
} elseif (is_object($return) && $return instanceof Closure) {
8989
$mock->expects($this->testCase->any())->method($method)
9090
->willReturnCallback($return);
91+
} elseif ($return === ':void') {
92+
$mock->expects($this->testCase->any())->method($method);
9193
} else {
9294
$mock->expects($this->testCase->any())->method($method)
9395
->willReturn($return);

application/tests/_ci_phpunit_test/CIPHPUnitTestFileCache.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public function __construct($file)
2121
if (file_exists($this->file))
2222
{
2323
$this->map = unserialize(file_get_contents($this->file));
24+
25+
if (! is_array($this->map)) {
26+
$this->map = [];
27+
}
28+
2429
return;
2530
}
2631

@@ -50,7 +55,7 @@ public function __destruct()
5055

5156
/**
5257
* Dump cache data (sorted by key)
53-
*
58+
*
5459
* @return array
5560
*/
5661
public function dump()
@@ -60,12 +65,14 @@ public function dump()
6065
return $map;
6166
}
6267

68+
#[\ReturnTypeWillChange]
6369
public function offsetSet($key, $value)
6470
{
6571
$this->map[$key] = $value;
6672
$this->updated = true;
6773
}
6874

75+
#[\ReturnTypeWillChange]
6976
public function offsetGet($key)
7077
{
7178
if ($this->offsetExists($key))
@@ -78,11 +85,13 @@ public function offsetGet($key)
7885
}
7986
}
8087

88+
#[\ReturnTypeWillChange]
8189
public function offsetExists($key)
8290
{
8391
return isset($this->map[$key]);
8492
}
8593

94+
#[\ReturnTypeWillChange]
8695
public function offsetUnset($key)
8796
{
8897
unset($this->map[$key]);

application/tests/_ci_phpunit_test/ChangeLog.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Change Log for ci-phpunit-test
22

3+
## v3.0.4 (Not Released)
4+
5+
### Added
6+
7+
* You can set return value type `void` as `':void'` when you use `$this->getDouble()`.
8+
9+
```php
10+
$mock = $this->getDouble(
11+
'SplFileObject',
12+
['next' => ':void'],
13+
['php://memory']
14+
);
15+
```
16+
17+
### Others
18+
19+
* Compatible with PHP 8.1
20+
321
## v3.0.3 (2022/03/17)
422

523
### Others

application/tests/_ci_phpunit_test/exceptions/CIPHPUnitTestExitException.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,17 @@
1010

1111
class CIPHPUnitTestExitException extends RuntimeException
1212
{
13-
public $file;
14-
public $line;
1513
public $class;
1614
public $method;
1715
public $exit_status;
16+
17+
public function setFile($file)
18+
{
19+
$this->file = $file;
20+
}
21+
22+
public function setLine($line)
23+
{
24+
$this->line = $line;
25+
}
1826
}

application/tests/_ci_phpunit_test/patcher/2.x/Exception/ExitException.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@
1414

1515
class ExitException extends RuntimeException
1616
{
17-
public $file;
18-
public $line;
1917
public $class;
2018
public $method;
2119
public $exit_status;
20+
21+
public function setFile($file)
22+
{
23+
$this->file = $file;
24+
}
25+
26+
public function setLine($line)
27+
{
28+
$this->line = $line;
29+
}
2230
}

application/tests/_ci_phpunit_test/patcher/2.x/Patcher/ConstantPatcher/Proxy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ protected static function checkCalledMethod($constant)
7373
$trace = debug_backtrace();
7474
$info = Backtrace::getInfo('ConstantPatcher', $trace);
7575

76-
$class = strtolower($info['class']);
77-
$class_method = strtolower($info['class_method']);
76+
$class = strtolower((string) $info['class']);
77+
$class_method = strtolower((string) $info['class_method']);
7878

7979
// Patches the constants only in the class
8080
if (strpos(self::$patches_to_apply[$constant], '::') === false)

application/tests/_ci_phpunit_test/patcher/3.x/Exception/ExitException.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@
1414

1515
class ExitException extends RuntimeException
1616
{
17-
public $file;
18-
public $line;
1917
public $class;
2018
public $method;
2119
public $exit_status;
20+
21+
public function setFile($file)
22+
{
23+
$this->file = $file;
24+
}
25+
26+
public function setLine($line)
27+
{
28+
$this->line = $line;
29+
}
2230
}

application/tests/_ci_phpunit_test/patcher/3.x/Patcher/ConstantPatcher/Proxy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ protected static function checkCalledMethod($constant)
7373
$trace = debug_backtrace();
7474
$info = Backtrace::getInfo('ConstantPatcher', $trace);
7575

76-
$class = strtolower($info['class']);
77-
$class_method = strtolower($info['class_method']);
76+
$class = strtolower((string) $info['class']);
77+
$class_method = strtolower((string) $info['class_method']);
7878

7979
// Patches the constants only in the class
8080
if (strpos(self::$patches_to_apply[$constant], '::') === false)

application/tests/_ci_phpunit_test/patcher/4.5/Exception/ExitException.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@
1414

1515
class ExitException extends RuntimeException
1616
{
17-
public $file;
18-
public $line;
1917
public $class;
2018
public $method;
2119
public $exit_status;
20+
21+
public function setFile($file)
22+
{
23+
$this->file = $file;
24+
}
25+
26+
public function setLine($line)
27+
{
28+
$this->line = $line;
29+
}
2230
}

0 commit comments

Comments
 (0)