Skip to content

Commit

Permalink
Add PHP 8.4, remove PHP 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
stephank committed Dec 13, 2024
1 parent 68cd668 commit 8e4be52
Show file tree
Hide file tree
Showing 26 changed files with 69 additions and 33 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/php-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.2', '8.3', '8.4']
name: PHP ${{ matrix.php-versions }} tests
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -19,10 +19,10 @@ jobs:

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
Expand Down
13 changes: 13 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

$config = new PhpCsFixer\Config();

return $config
->setRules([
'@PSR12' => true,
'@PHP82Migration' => true,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
);
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 4.0.0

- Dropped support for PHP `8.1` and lower.
- Added support for PHP `8.4`.
- Compatible with Symfony 6 and 7.

## 3.0.0

### PHP support
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@
},
"minimum-stability": "stable",
"require": {
"php": "8.1.* || 8.2.* || 8.3.*",
"php": "8.2 - 8.4",
"ext-json": "*",
"symfony/finder": "^6.0.0"
"symfony/finder": "6 - 7"
},
"require-dev": {
"phpstan/phpstan": "1.10.46",
"phpunit/phpunit": "10.4.2",
"squizlabs/php_codesniffer": "3.7.2"
"phpstan/phpstan": "2.0.3",
"phpunit/phpunit": "11.5.1",
"squizlabs/php_codesniffer": "3.11.2",
"friendsofphp/php-cs-fixer": "^3.65"
}
}
1 change: 1 addition & 0 deletions src/Naneau/ProjectVersioner/Reader/Composer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Naneau\ProjectVersioner\Reader;

use Naneau\ProjectVersioner\ReaderInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Naneau/ProjectVersioner/Reader/ComposerJson.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Naneau\ProjectVersioner\Reader;

use JsonException;
use Naneau\ProjectVersioner\ReaderInterface;

use stdClass;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Naneau/ProjectVersioner/Reader/ComposerPackage.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Naneau\ProjectVersioner\Reader;

use JsonException;
use Naneau\ProjectVersioner\ReaderInterface;

use stdClass;
use RuntimeException;

Expand Down
1 change: 1 addition & 0 deletions src/Naneau/ProjectVersioner/Reader/File.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Naneau\ProjectVersioner\Reader;

use Naneau\ProjectVersioner\ReaderInterface;
Expand Down
1 change: 1 addition & 0 deletions src/Naneau/ProjectVersioner/Reader/Finder/Contents.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Naneau\ProjectVersioner\Reader\Finder;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Naneau/ProjectVersioner/Reader/Finder/Finder.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Naneau\ProjectVersioner\Reader\Finder;

use Naneau\ProjectVersioner\ReaderInterface;

use Symfony\Component\Finder\Finder as SfFinder;

/**
Expand All @@ -21,7 +21,7 @@ public function __construct(?string $name = null, ?SfFinder $finder = null)
{
// Create finder if not given
if ($finder === null) {
$finder = new SfFinder;
$finder = new SfFinder();
}

// Set name if given
Expand Down
1 change: 1 addition & 0 deletions src/Naneau/ProjectVersioner/Reader/Finder/MTime.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Naneau\ProjectVersioner\Reader\Finder;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Naneau/ProjectVersioner/Reader/Git/Commit/Exec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Naneau\ProjectVersioner\Reader\Git\Commit;

use Naneau\ProjectVersioner\Reader\Git\Exec as GitExec;
Expand Down
1 change: 1 addition & 0 deletions src/Naneau/ProjectVersioner/Reader/Git/Describe/Exec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Naneau\ProjectVersioner\Reader\Git\Describe;

use Naneau\ProjectVersioner\Reader\Git\Exec as GitExec;
Expand Down
2 changes: 1 addition & 1 deletion src/Naneau/ProjectVersioner/Reader/Git/Exec.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Naneau\ProjectVersioner\Reader\Git;

use Naneau\ProjectVersioner\ReaderInterface;

use RuntimeException;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Naneau/ProjectVersioner/Reader/Git/Tag/Exec.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Naneau\ProjectVersioner\Reader\Git\Tag;

use Naneau\ProjectVersioner\Reader\Git\Exec as GitExec;
Expand Down
1 change: 1 addition & 0 deletions src/Naneau/ProjectVersioner/ReaderInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Naneau\ProjectVersioner;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Naneau/ProjectVersioner/Versioner.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Naneau\ProjectVersioner;

use Naneau\ProjectVersioner\ReaderInterface as Reader;

use \RuntimeException;
use RuntimeException;

/**
* Versioner
Expand Down
5 changes: 3 additions & 2 deletions tests/Naneau/ProjectVersioner/Test/Reader/ComposerTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Naneau\ProjectVersioner\Test\Reader;

use Naneau\ProjectVersioner\Versioner;
Expand All @@ -12,7 +13,7 @@ public function testRead(): void
{
$directory = __DIR__ . '/../../../../projects/composer';

$readers = [new ComposerReader];
$readers = [new ComposerReader()];

$versioner = new Versioner($readers);

Expand All @@ -34,7 +35,7 @@ public function testComposerJsonRead(): void
{
$directory = __DIR__ . '/../../../../projects/composer';

$readers = [new ComposerJsonReader];
$readers = [new ComposerJsonReader()];

$versioner = new Versioner($readers);

Expand Down
1 change: 1 addition & 0 deletions tests/Naneau/ProjectVersioner/Test/Reader/FileTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Naneau\ProjectVersioner\Test\Reader;

use Naneau\ProjectVersioner\Versioner;
Expand Down
10 changes: 5 additions & 5 deletions tests/Naneau/ProjectVersioner/Test/Reader/FinderTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Naneau\ProjectVersioner\Test\Reader;

use Naneau\ProjectVersioner\Versioner;
use Naneau\ProjectVersioner\Reader\Finder\MTime as MTimeReader;
use Naneau\ProjectVersioner\Reader\Finder\Contents as ContentsReader;

use Symfony\Component\Finder\Finder;

class FinderTest extends \PHPUnit\Framework\TestCase
Expand All @@ -27,7 +27,7 @@ public function testContents(): void
$versioner = new Versioner([new ContentsReader('*.php')]);

self::assertEquals(
'db9d80',
'd35015',
$versioner->get(
__DIR__ . '/../../../../projects/finder'
)
Expand Down Expand Up @@ -56,11 +56,11 @@ public function testEmptyNamesWithFinder(): void

$directory = __DIR__ . '/../../../../projects/finder';

$finderTxt = new Finder;
$finderTxt = new Finder();
$finderTxt->name('*.txt');
$versionerTxt = new Versioner([new MTimeReader(null, $finderTxt)]);

$finderPhp = new Finder;
$finderPhp = new Finder();
$finderPhp->name('*.php');
$versionerPhp = new Versioner([new MTimeReader(null, $finderPhp)]);

Expand All @@ -78,7 +78,7 @@ public function testNamesAndFinder(): void
{
$directory = __DIR__ . '/../../../../projects/finder';

$finder = new Finder;
$finder = new Finder();
$finder->name('*.txt');
$versioner = new Versioner([new MTimeReader('*.php', $finder)]);

Expand Down
11 changes: 6 additions & 5 deletions tests/Naneau/ProjectVersioner/Test/Reader/GitExecTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Naneau\ProjectVersioner\Test\Reader;

use Naneau\ProjectVersioner\Versioner;
Expand All @@ -16,7 +17,7 @@ public function testShortCommitRead(): void
$versionOutput = self::execInDir(['git rev-parse --short HEAD']);
$version = $versionOutput[0];

$versioner = new Versioner([new GitCommitExecReader]);
$versioner = new Versioner([new GitCommitExecReader()]);

self::assertEquals($version, $versioner->get(self::getDirectory()));
}
Expand All @@ -42,14 +43,14 @@ public function testDescribeRead(): void
$versionOutput = self::execInDir(['git describe']);
$version = $versionOutput[0];

$versioner = new Versioner([new GitDescribeExecReader]);
$versioner = new Versioner([new GitDescribeExecReader()]);

self::assertEquals($version, $versioner->get(self::getDirectory()));
}

public function testTagRead(): void
{
$versioner = new Versioner([new GitTagExecReader]);
$versioner = new Versioner([new GitTagExecReader()]);
self::assertEquals('0.0.2', $versioner->get(self::getDirectory()));
}

Expand All @@ -63,7 +64,7 @@ public function setUp(): void
'touch testfile',
'git init',
'git config user.email "[email protected]"',
'git config user.name "PHPUnit"'
'git config user.name "PHPUnit"',
]);

// Add commits, with matching tags
Expand All @@ -79,7 +80,7 @@ public function setUp(): void
// Not in tag
sprintf('touch test.%d.notag', $x),
sprintf('git add test.%d.notag', $x),
sprintf('git commit -m "commit %d no tag"', $x)
sprintf('git commit -m "commit %d no tag"', $x),
]);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Naneau\ProjectVersioner\Test\Versioner;

use Naneau\ProjectVersioner\Versioner;
Expand All @@ -13,7 +14,7 @@ public function testComposerFirst(): void
$readers = [
new ComposerPackageReader('symfony/filesystem'),
new ComposerReader(),
new FileReader('VERSION')
new FileReader('VERSION'),
];

$versioner = new Versioner($readers);
Expand All @@ -31,7 +32,7 @@ public function testFileFirst(): void
$readers = [
new FileReader('VERSION'),
new ComposerPackageReader('symfony/filesystem'),
new ComposerReader()
new ComposerReader(),
];

$versioner = new Versioner($readers);
Expand All @@ -49,7 +50,7 @@ public function testComposerFirstWithCombine(): void
$readers = [
new ComposerPackageReader('symfony/filesystem'),
new ComposerReader(),
new FileReader('VERSION')
new FileReader('VERSION'),
];

$versioner = new Versioner($readers);
Expand All @@ -68,7 +69,7 @@ public function testFileFirstWithCombine(): void
$readers = [
new FileReader('VERSION'),
new ComposerPackageReader('symfony/filesystem'),
new ComposerReader()
new ComposerReader(),
];
$versioner = new Versioner($readers);

Expand All @@ -82,7 +83,7 @@ public function testFileFirstWithCombine(): void

public function testHasAVersion(): void
{
$versioner = new Versioner;
$versioner = new Versioner();

// This one should have a version
$versioner->setReaders(
Expand Down
1 change: 1 addition & 0 deletions tests/Naneau/ProjectVersioner/Test/VersionerTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Naneau\ProjectVersioner\Test;

use Naneau\ProjectVersioner\Versioner;
Expand Down
1 change: 1 addition & 0 deletions tests/projects/finder/DirectoryOne/FileThree.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<?php

echo 'FileThree';
1 change: 1 addition & 0 deletions tests/projects/finder/DirectoryTwo/FileSix.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<?php

echo 'FileSix';
1 change: 1 addition & 0 deletions tests/projects/finder/FileTwo.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<?php

echo 'FileTwo';

0 comments on commit 8e4be52

Please sign in to comment.