Skip to content

Commit b3fc96a

Browse files
authored
Merge pull request #146 from Tofandel/master
Allow symfony/console 7 and add tests for php 8.2 and 8.3 with phpunit range
2 parents 3d197c4 + 2c4196f commit b3fc96a

13 files changed

+140
-179
lines changed

.github/workflows/php.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
php: ['8.0', '8.1']
17+
php: ['8.0', '8.1', '8.2', '8.3']
1818

1919
steps:
2020
- name: Checkout

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ cghooks-temp-*
55
.php_cs.cache
66
phpunit.xml
77
cghooks.lock
8+
composer.lock
9+
.phpunit.result.cache

composer.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^8.0|^8.1",
20-
"symfony/console": "^5.0|^6.0"
19+
"php": "^8.0",
20+
"symfony/console": "^5.0|^6.0|^7.0"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "^9.5",
23+
"phpunit/phpunit": "^9|^10|^11",
2424
"friendsofphp/php-cs-fixer": "^3.0",
2525
"ext-json": "*"
2626
},
@@ -57,11 +57,11 @@
5757
"pre-commit": "composer check-style",
5858
"pre-push": [
5959
"composer test",
60-
"appver=$(grep -o -E '\\d.\\d.\\d(-alpha.\\d)?' cghooks)",
60+
"appver=$(grep -o -E '[0-9]+\\.[0-9]+\\.[0-9]+(-alpha\\.[0-9]+)?' cghooks)",
6161
"tag=$(git tag | tail -n 1)",
62-
"if [ \"$tag\" != \"v$appver\" ]; then",
63-
"echo \"The most recent tag $tag does not match the application version $appver\\n\"",
6462
"tag=${tag#v}",
63+
"if [ \"$tag\" != \"$appver\" ]; then",
64+
"echo \"The most recent tag $tag does not match the application version $appver\\n\"",
6565
"sed -i -E \"s/$appver/$tag/\" cghooks",
6666
"exit 1",
6767
"fi"

phpunit.xml.dist

+6-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit backupGlobals="false"
3-
backupStaticAttributes="false"
4-
bootstrap="vendor/autoload.php"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false">
11-
<testsuites>
12-
<testsuite name="Application Test Suite">
13-
<directory>./tests/</directory>
14-
</testsuite>
15-
</testsuites>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3+
<testsuites>
4+
<testsuite name="Application Test Suite">
5+
<directory>./tests/</directory>
6+
</testsuite>
7+
</testsuites>
168
</phpunit>

src/Commands/Command.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ abstract protected function init(InputInterface $input);
2323

2424
abstract protected function command();
2525

26-
final protected function execute(InputInterface $input, OutputInterface $output)
26+
final protected function execute(InputInterface $input, OutputInterface $output): int
2727
{
2828
$this->output = $output;
2929
$this->gitDir = $input->getOption('git-dir') ?: git_dir();
@@ -41,7 +41,7 @@ final protected function execute(InputInterface $input, OutputInterface $output)
4141
}
4242
if ($this->gitDir === false) {
4343
$output->writeln('Git is not initialized. Skip setting hooks...');
44-
return 0;
44+
return SymfonyCommand::SUCCESS;
4545
}
4646
$this->lockFile = (null !== $this->lockDir ? ($this->lockDir . '/') : '') . Hook::LOCK_FILE;
4747

@@ -52,7 +52,7 @@ final protected function execute(InputInterface $input, OutputInterface $output)
5252
$this->init($input);
5353
$this->command();
5454

55-
return 0;
55+
return SymfonyCommand::SUCCESS;
5656
}
5757

5858
protected function global_dir_fallback()

src/Commands/HookCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ protected function configure()
3030
;
3131
}
3232

33-
protected function execute(InputInterface $input, OutputInterface $output)
33+
protected function execute(InputInterface $input, OutputInterface $output): int
3434
{
3535
$contents = Hook::getHookContents($this->composerDir, $this->contents, $this->hook);
3636
$outputMessage = [];
37-
$returnCode = 0;
37+
$returnCode = SymfonyCommand::SUCCESS;
3838
exec($contents, $outputMessage, $returnCode);
3939

4040
$output->writeln(implode(PHP_EOL, $outputMessage));

0 commit comments

Comments
 (0)