Skip to content

Commit 0a99d7f

Browse files
authored
Fix implicit nullable to prevent deprecation on PHP 8.4 (#62)
2 parents e7289b8 + 03461a9 commit 0a99d7f

14 files changed

+55
-45
lines changed

.github/workflows/ci-mssql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ jobs:
1414
phpunit:
1515
uses: cycle/gh-actions/.github/workflows/db-mssql.yml@master
1616
with:
17-
php: '["8.1","8.2","8.3"]'
17+
php: '["8.1","8.2","8.3","8.4"]'
1818

1919
...

.github/workflows/ci-mysql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ jobs:
1414
phpunit:
1515
uses: cycle/gh-actions/.github/workflows/db-mysql.yml@master
1616
with:
17-
php: '["8.1","8.2","8.3"]'
17+
php: '["8.1","8.2","8.3","8.4"]'
1818

1919
...

.github/workflows/ci-pgsql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ jobs:
1414
phpunit:
1515
uses: cycle/gh-actions/.github/workflows/db-pgsql.yml@master
1616
with:
17-
php: '["8.1","8.2","8.3"]'
17+
php: '["8.1","8.2","8.3","8.4"]'
1818

1919
...

.github/workflows/main.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,45 @@ jobs:
1414
matrix:
1515
php-versions: ['8.1']
1616
steps:
17+
- name: Install ODBC driver.
18+
run: |
19+
sudo curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
20+
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
21+
1722
- name: Checkout
1823
uses: actions/checkout@v2
24+
1925
- name: Setup DB services
2026
run: |
2127
cd tests
2228
docker compose up -d
2329
cd ..
30+
2431
- name: Setup PHP ${{ matrix.php-versions }}
2532
uses: shivammathur/setup-php@v2
2633
with:
2734
php-version: ${{ matrix.php-versions }}
2835
coverage: pcov
2936
tools: pecl
3037
extensions: mbstring, pdo, pdo_sqlite, pdo_pgsql, pdo_sqlsrv, pdo_mysql
38+
3139
- name: Get Composer Cache Directory
3240
id: composer-cache
3341
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
42+
3443
- name: Restore Composer Cache
35-
uses: actions/cache@v2
44+
uses: actions/cache@v4
3645
with:
3746
path: ${{ steps.composer-cache.outputs.dir }}
3847
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
3948
restore-keys: ${{ runner.os }}-composer-
4049

4150
- name: Install dependencies with composer
42-
if: matrix.php-versions != '8.2'
51+
if: matrix.php-versions != '8.5'
4352
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
4453

45-
- name: Install dependencies with composer php 8.2
46-
if: matrix.php-versions == '8.2'
54+
- name: Install dependencies with composer php 8.5
55+
if: matrix.php-versions == '8.5'
4756
run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
4857

4958
- name: Execute Tests
@@ -67,7 +76,7 @@ jobs:
6776
runs-on: ubuntu-latest
6877
strategy:
6978
matrix:
70-
php-versions: ['8.1']
79+
php-versions: ['8.1', '8.4']
7180
steps:
7281
- name: Checkout
7382
uses: actions/checkout@v2
@@ -82,18 +91,18 @@ jobs:
8291
id: composer-cache
8392
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
8493
- name: Restore Composer Cache
85-
uses: actions/cache@v2
94+
uses: actions/cache@v4
8695
with:
8796
path: ${{ steps.composer-cache.outputs.dir }}
8897
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
8998
restore-keys: ${{ runner.os }}-composer-
9099

91100
- name: Install dependencies with composer
92-
if: matrix.php-versions != '8.1'
101+
if: matrix.php-versions != '8.5'
93102
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
94103

95-
- name: Install dependencies with composer php 8.1
96-
if: matrix.php-versions == '8.1'
104+
- name: Install dependencies with composer php 8.5
105+
if: matrix.php-versions == '8.5'
97106
run: composer update --ignore-platform-reqs --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
98107

99108
- name: Execute Tests

.github/workflows/static-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
uses: wayofdev/gh-actions/actions/composer/[email protected]
5757

5858
- name: ♻️ Restore cached dependencies installed with composer
59-
uses: actions/cache@v4.0.2
59+
uses: actions/cache@v4
6060
with:
6161
path: ${{ env.COMPOSER_CACHE_DIR }}
6262
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}

.idea/icon.svg

Lines changed: 15 additions & 0 deletions
Loading

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"buggregator/trap": "^1.11",
1616
"mockery/mockery": "^1.5",
1717
"phpunit/phpunit": "^9.5",
18-
"spiral/code-style": "~2.2.0",
19-
"vimeo/psalm": "^5.25"
18+
"spiral/code-style": "^2.2.0",
19+
"vimeo/psalm": "^6.4"
2020
},
2121
"autoload": {
2222
"psr-4": {

psalm-baseline.xml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
2+
<files psalm-version="6.4.0@04f312ac6ea48ba1c3e5db4d815bf6d74641c0ee">
33
<file src="src/Atomizer/Renderer.php">
44
<ArgumentTypeCoercion>
55
<code><![CDATA[$comparator]]></code>
@@ -65,9 +65,6 @@
6565
<ArgumentTypeCoercion>
6666
<code><![CDATA[$table]]></code>
6767
</ArgumentTypeCoercion>
68-
<MixedInferredReturnType>
69-
<code><![CDATA[AbstractTable]]></code>
70-
</MixedInferredReturnType>
7168
<MixedPropertyTypeCoercion>
7269
<code><![CDATA[$this->schemas]]></code>
7370
</MixedPropertyTypeCoercion>
@@ -80,12 +77,6 @@
8077
</UndefinedInterfaceMethod>
8178
</file>
8279
<file src="src/Config/MigrationConfig.php">
83-
<MixedInferredReturnType>
84-
<code><![CDATA[bool]]></code>
85-
<code><![CDATA[string]]></code>
86-
<code><![CDATA[string]]></code>
87-
<code><![CDATA[string]]></code>
88-
</MixedInferredReturnType>
8980
<MixedReturnStatement>
9081
<code><![CDATA[$this->config['directory'] ?? '']]></code>
9182
<code><![CDATA[$this->config['directory'] ?? '']]></code>
@@ -98,13 +89,14 @@
9889
</MixedReturnStatement>
9990
</file>
10091
<file src="src/FileRepository.php">
92+
<ArgumentTypeCoercion>
93+
<code><![CDATA[$directory]]></code>
94+
</ArgumentTypeCoercion>
10195
<MixedArgument>
10296
<code><![CDATA[$directory]]></code>
103-
<code><![CDATA[$filename]]></code>
10497
</MixedArgument>
10598
<MixedAssignment>
10699
<code><![CDATA[$directory]]></code>
107-
<code><![CDATA[$filename]]></code>
108100
</MixedAssignment>
109101
<MoreSpecificReturnType>
110102
<code><![CDATA[\Generator<int, TFileArray>]]></code>
@@ -124,9 +116,6 @@
124116
<LessSpecificReturnStatement>
125117
<code><![CDATA[$this->capsule->getDatabase()]]></code>
126118
</LessSpecificReturnStatement>
127-
<MixedInferredReturnType>
128-
<code><![CDATA[?string]]></code>
129-
</MixedInferredReturnType>
130119
<MixedReturnStatement>
131120
<code><![CDATA[static::DATABASE]]></code>
132121
</MixedReturnStatement>

psalm.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,4 @@
2020
<directory name="vendor" />
2121
</ignoreFiles>
2222
</projectFiles>
23-
<issueHandlers>
24-
<UndefinedAttributeClass>
25-
<errorLevel type="suppress">
26-
<referencedClass name="JetBrains\PhpStorm\ExpectedValues" />
27-
</errorLevel>
28-
</UndefinedAttributeClass>
29-
</issueHandlers>
3023
</psalm>

src/FileRepository.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ final class FileRepository implements RepositoryInterface
3939
private FilesInterface $files;
4040
private Inflector $inflector;
4141

42-
public function __construct(private MigrationConfig $config, FactoryInterface $factory = null)
42+
public function __construct(private MigrationConfig $config, ?FactoryInterface $factory = null)
4343
{
4444
$this->files = new Files();
4545
$this->factory = $factory ?? new Container();
@@ -71,7 +71,7 @@ public function getMigrations(): array
7171
return $migrations;
7272
}
7373

74-
public function registerMigration(string $name, string $class, string $body = null): string
74+
public function registerMigration(string $name, string $class, ?string $body = null): string
7575
{
7676
if (empty($body) && !\class_exists($class)) {
7777
throw new RepositoryException(
@@ -123,13 +123,16 @@ private function getFilesIterator(): \Generator
123123
$this->config->getVendorDirectories(),
124124
) as $directory
125125
) {
126+
$directory === '' and $directory = '.';
126127
yield from $this->getFiles($directory);
127128
}
128129
}
129130

130131
/**
131132
* Internal method to fetch all migration filenames.
132133
*
134+
* @param non-empty-string $directory
135+
*
133136
* @return \Generator<int, TFileArray>
134137
*/
135138
private function getFiles(string $directory): \Generator

0 commit comments

Comments
 (0)