Skip to content

Commit 68cd668

Browse files
authored
Merge pull request #7 from AngryBytes/feat/php-8.3
Feat/php 8.3
2 parents b1de636 + 46b10aa commit 68cd668

File tree

20 files changed

+73
-60
lines changed

20 files changed

+73
-60
lines changed

.github/workflows/php-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
strategy:
77
matrix:
8-
php-versions: ['7.4', '8.0', '8.1', '8.2']
8+
php-versions: ['8.1', '8.2', '8.3']
99
name: PHP ${{ matrix.php-versions }} tests
1010
steps:
1111
- name: Checkout

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
/vendor/
2-
composer.lock
3-
.phpunit.result.cache
1+
/composer.lock
2+
/vendor
3+
4+
/.php-cs-fixer.cache
5+
/.phpunit.cache

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## 3.0.0
4+
5+
### PHP support
6+
7+
- Dropped support for PHP `8.0` and lower.
8+
- Added support for PHP `8.3`.
9+
10+
### 3rd party updates
11+
12+
- Updated `symfony/finder` to version `6`.
13+
314
## 2.0.1
415

516
### PHP support

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@
4040
},
4141
"minimum-stability": "stable",
4242
"require": {
43-
"php": "7.4.* || 8.0.* || 8.1.* || 8.2.*",
43+
"php": "8.1.* || 8.2.* || 8.3.*",
4444
"ext-json": "*",
45-
"symfony/finder": "^5.0.0"
45+
"symfony/finder": "^6.0.0"
4646
},
4747
"require-dev": {
48-
"phpstan/phpstan": "1.9.12",
49-
"phpunit/phpunit": "9.5.28",
50-
"squizlabs/php_codesniffer": "3.7.1"
48+
"phpstan/phpstan": "1.10.46",
49+
"phpunit/phpunit": "10.4.2",
50+
"squizlabs/php_codesniffer": "3.7.2"
5151
}
5252
}

phpunit.xml.dist

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
<?xml version="1.0"?>
12
<phpunit
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.5/phpunit.xsd"
4-
backupGlobals="false"
5-
backupStaticAttributes="false"
6-
bootstrap="vendor/autoload.php"
7-
colors="true"
8-
>
9-
10-
<testsuites>
11-
<testsuite name="ProjectVersioner Test Suite">
12-
<directory>./tests/</directory>
13-
</testsuite>
14-
</testsuites>
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
5+
backupGlobals="false"
6+
bootstrap="vendor/autoload.php"
7+
colors="true"
8+
cacheDirectory=".phpunit.cache"
9+
backupStaticProperties="false"
10+
>
11+
<testsuites>
12+
<testsuite name="ProjectVersioner Test Suite">
13+
<directory>./tests/</directory>
14+
</testsuite>
15+
</testsuites>
1516
</phpunit>

src/Naneau/ProjectVersioner/Reader/Composer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/**
77
* Composer
88
*
9-
* Finds version from composer lock file
9+
* Finds the version from composer lock file
1010
*/
1111
class Composer implements ReaderInterface
1212
{
@@ -21,7 +21,7 @@ public function canRead(string $directory): bool
2121
/**
2222
* {@inheritdoc}
2323
*/
24-
public function read(string $directory)
24+
public function read(string $directory): int|string|null
2525
{
2626
$contents = file_get_contents($directory . '/composer.lock');
2727
if (!$contents) {

src/Naneau/ProjectVersioner/Reader/ComposerJson.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Naneau\ProjectVersioner\Reader;
33

4+
use JsonException;
45
use Naneau\ProjectVersioner\ReaderInterface;
56

67
use stdClass;
@@ -21,14 +22,19 @@ public function canRead(string $directory): bool
2122
/**
2223
* {@inheritdoc}
2324
*/
24-
public function read(string $directory)
25+
public function read(string $directory): int|string|null
2526
{
2627
$json = @file_get_contents($directory . '/composer.json');
2728
if (!$json) {
2829
return null;
2930
}
3031

31-
$json = json_decode($json, false);
32+
try {
33+
$json = json_decode($json, false, 512, JSON_THROW_ON_ERROR);
34+
} catch (JsonException) {
35+
return null;
36+
}
37+
3238
if (!($json instanceof stdClass) || empty($json->version)) {
3339
return null;
3440
}

src/Naneau/ProjectVersioner/Reader/ComposerPackage.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Naneau\ProjectVersioner\Reader;
33

4+
use JsonException;
45
use Naneau\ProjectVersioner\ReaderInterface;
56

67
use stdClass;
@@ -15,10 +16,8 @@ class ComposerPackage implements ReaderInterface
1516
{
1617
/**
1718
* The page name to look for
18-
*
19-
* @var string
2019
*/
21-
private $package;
20+
private string $package;
2221

2322
public function __construct(string $package)
2423
{
@@ -46,7 +45,7 @@ public function canRead(string $directory): bool
4645
/**
4746
* {@inheritdoc}
4847
*/
49-
public function read(string $directory)
48+
public function read(string $directory): int|string|null
5049
{
5150
$package = $this->getPackageFromLockFile($directory);
5251

@@ -88,7 +87,12 @@ private function getPackageFromLockFile(string $directory): ?stdClass
8887
return null;
8988
}
9089

91-
$parsed = json_decode($contents, false);
90+
try {
91+
$parsed = json_decode($contents, false, 512, JSON_THROW_ON_ERROR);
92+
} catch (JsonException) {
93+
return null;
94+
}
95+
9296
if (!isset($parsed->packages)) {
9397
return null;
9498
}

src/Naneau/ProjectVersioner/Reader/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function canRead(string $directory): bool
3333
/**
3434
* {@inheritdoc}
3535
*/
36-
public function read(string $directory)
36+
public function read(string $directory): int|string|null
3737
{
3838
$contents = file_get_contents($directory . DIRECTORY_SEPARATOR . $this->getFile());
3939
if (!$contents) {

src/Naneau/ProjectVersioner/Reader/Finder/Contents.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Contents extends Finder
1111
/**
1212
* {@inheritdoc}
1313
*/
14-
public function read(string $directory)
14+
public function read(string $directory): string
1515
{
1616
$hash = '';
1717
foreach ($this->getFinder() as $file) {

0 commit comments

Comments
 (0)