Skip to content

Commit 6278c60

Browse files
xepozzrector-botStyleCIBotvjik
authored
Raise PHP to 8.0 + Add rector (#115)
* Add rector files yiisoft/yii-dev-tool#232 * Add rector/rector dependecy * [rector] Apply fixes * Apply fixes from StyleCI * Use predefined rector action * raise php version * fixes * phpdoc * fixed * changelog * improve * improve Co-authored-by: rector-bot <rector@yiiframework.com> Co-authored-by: StyleCI Bot <bot@styleci.io> Co-authored-by: Sergei Predvoditelev <sergei@predvoditelev.ru>
1 parent eb3fad2 commit 6278c60

23 files changed

+161
-195
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ jobs:
2828
os: >-
2929
['ubuntu-latest', 'windows-latest']
3030
php: >-
31-
['7.4', '8.0', '8.1']
31+
['8.0', '8.1', '8.2']

.github/workflows/rector.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
on:
2+
pull_request:
3+
paths-ignore:
4+
- 'docs/**'
5+
- 'README.md'
6+
- 'CHANGELOG.md'
7+
- '.gitignore'
8+
- '.gitattributes'
9+
- 'infection.json.dist'
10+
- 'psalm.xml'
11+
12+
name: rector
13+
14+
jobs:
15+
rector:
16+
uses: yiisoft/actions/.github/workflows/rector.yml@master
17+
with:
18+
os: >-
19+
['ubuntu-latest']
20+
php: >-
21+
['8.0']

.github/workflows/static.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ jobs:
2828
os: >-
2929
['ubuntu-latest']
3030
php: >-
31-
['7.4', '8.0', '8.1']
31+
['8.0', '8.1', '8.2']

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Yii Arrays Change Log
22

3-
## 2.1.1 under development
3+
## 3.0.0 under development
44

5-
- no changes in this release.
5+
- Enh #115: Raise required PHP version to `^8.0`, move union type hints from annotations
6+
to methods' signatures (@xepozz, @vjik)
67

78
## 2.1.0 August 20, 2022
89

@@ -19,7 +20,7 @@
1920

2021
## 1.0.1 February 10, 2021
2122

22-
- Chg: Update yiisoft/strings dependency (@samdark)
23+
- Chg: Update `yiisoft/strings` dependency (@samdark)
2324

2425
## 1.0.0 February 02, 2021
2526

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The package provides:
2727

2828
## Requirements
2929

30-
- PHP 7.4 or higher.
30+
- PHP 8.0 or higher.
3131

3232
## Installation
3333

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
}
2929
],
3030
"require": {
31-
"php": "^7.4|^8.0",
31+
"php": "^8.0",
3232
"yiisoft/strings": "^2.1"
3333
},
3434
"require-dev": {
3535
"phpunit/phpunit": "^9.5",
36+
"rector/rector": "^0.15.4",
3637
"roave/infection-static-analysis-plugin": "^1.16",
3738
"spatie/phpunit-watcher": "^1.23",
3839
"vimeo/psalm": "^4.18"

rector.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Set\ValueObject\LevelSetList;
8+
9+
return static function (RectorConfig $rectorConfig): void {
10+
$rectorConfig->paths([
11+
__DIR__ . '/src',
12+
__DIR__ . '/tests',
13+
]);
14+
15+
// register a single rule
16+
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
17+
18+
// define sets of rules
19+
$rectorConfig->sets([
20+
LevelSetList::UP_TO_PHP_80,
21+
]);
22+
};

src/ArrayAccessTrait.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
use ArrayIterator;
88

99
/**
10-
* ArrayAccessTrait provides the implementation for {@see \IteratorAggregate}, {@see \ArrayAccess}
10+
* `ArrayAccessTrait` provides the implementation for {@see \IteratorAggregate}, {@see \ArrayAccess}
1111
* and {@see \Countable}.
1212
*
13-
* Note that ArrayAccessTrait requires the class using it contain a property named `data` which should be an array.
14-
* The data will be exposed by ArrayAccessTrait to support accessing the class object like an array.
13+
* Note that `ArrayAccessTrait` requires the class using it contain a property named `data` which should be an array.
14+
* The data will be exposed by `ArrayAccessTrait` to support accessing the class object like an array.
1515
*
1616
* @property array $data
1717
*/
@@ -44,10 +44,8 @@ public function count(): int
4444
* This method is required by the interface {@see \ArrayAccess}.
4545
*
4646
* @param mixed $offset The offset to check on.
47-
*
48-
* @return bool
4947
*/
50-
public function offsetExists($offset): bool
48+
public function offsetExists(mixed $offset): bool
5149
{
5250
return isset($this->data[$offset]);
5351
}
@@ -59,8 +57,7 @@ public function offsetExists($offset): bool
5957
*
6058
* @return mixed The element at the offset, null if no element is found at the offset.
6159
*/
62-
#[\ReturnTypeWillChange]
63-
public function offsetGet($offset)
60+
public function offsetGet(mixed $offset): mixed
6461
{
6562
return $this->data[$offset] ?? null;
6663
}
@@ -71,7 +68,7 @@ public function offsetGet($offset)
7168
* @param mixed $offset The offset to set element.
7269
* @param mixed $value The element value.
7370
*/
74-
public function offsetSet($offset, $value): void
71+
public function offsetSet(mixed $offset, mixed $value): void
7572
{
7673
if ($offset === null) {
7774
$this->data[] = $value;
@@ -85,7 +82,7 @@ public function offsetSet($offset, $value): void
8582
*
8683
* @param mixed $offset The offset to unset element.
8784
*/
88-
public function offsetUnset($offset): void
85+
public function offsetUnset(mixed $offset): void
8986
{
9087
unset($this->data[$offset]);
9188
}

0 commit comments

Comments
 (0)