Skip to content

Commit

Permalink
chore: bump to PHP 8.1 as minimum and bump all deps
Browse files Browse the repository at this point in the history
  • Loading branch information
ramsey committed Mar 18, 2023
1 parent c53d557 commit ba9d08b
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 49 deletions.
41 changes: 20 additions & 21 deletions composer.json
Expand Up @@ -21,39 +21,38 @@
}
],
"require": {
"php": "^7.4 || ^8",
"php": "^8.1",
"ext-json": "*",
"composer-runtime-api": "^1.1 || ^2",
"composer/composer": "^1.10.23 || ^2.1.9",
"jawira/case-converter": "^3.3",
"opis/json-schema": "^2.2.0",
"symfony/console": "^4.4.30 || ^5.3.7 || ^6.0",
"symfony/filesystem": "^4.4 || ^5.1 || ^6.0",
"symfony/polyfill-php80": "^1.15"
"composer-runtime-api": "^2.0",
"composer/composer": "^2.4",
"jawira/case-converter": "^3.5",
"opis/json-schema": "^2.3",
"symfony/console": "^6.0",
"symfony/filesystem": "^6.0"
},
"require-dev": {
"captainhook/captainhook": "^5.10",
"captainhook/captainhook": "^5.15",
"captainhook/plugin-composer": "^5.3",
"ergebnis/composer-normalize": "^2.25",
"ergebnis/composer-normalize": "^2.30",
"hamcrest/hamcrest-php": "^2.0",
"mockery/mockery": "^1.5",
"php-parallel-lint/php-console-highlighter": "^1.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.5",
"phpstan/phpstan-mockery": "^1.0",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/extension-installer": "^1.2",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-mockery": "^1.1",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^9.5",
"psalm/plugin-mockery": "^1.1.0",
"psalm/plugin-phpunit": "^0.18.3",
"ramsey/coding-standard": "^2.0.3",
"psalm/plugin-mockery": "^1.1",
"psalm/plugin-phpunit": "^0.18.4",
"ramsey/coding-standard": "^2.2",
"ramsey/composer-repl": "^1.4",
"roave/security-advisories": "dev-latest",
"sebastianfeldmann/cli": "^3.3",
"sebastianfeldmann/git": "^3.3",
"sebastianfeldmann/cli": "^3.4",
"sebastianfeldmann/git": "^3.8",
"spatie/phpunit-snapshot-assertions": "^4.2",
"symfony/process": "^5.1 || ^6.0",
"vimeo/psalm": "^5.1"
"symfony/process": "^6.0",
"vimeo/psalm": "^5.8"
},
"suggest": {
"captainhook/captainhook": "Manage your project's Git hooks with CaptainHook, and use ramsey/conventional-commits in your commit-msg and prepare-commit-msg hooks."
Expand Down
2 changes: 0 additions & 2 deletions psalm-baseline.xml

This file was deleted.

5 changes: 3 additions & 2 deletions psalm.xml
Expand Up @@ -3,8 +3,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorLevel="1"
cacheDirectory="./build/cache/psalm"
errorBaseline="./psalm-baseline.xml">
findUnusedBaselineEntry="true"
findUnusedCode="false"
cacheDirectory="./build/cache/psalm">

<projectFiles>
<directory name="./src"/>
Expand Down
2 changes: 1 addition & 1 deletion src/CaptainHook/PrepareConventionalCommit.php
Expand Up @@ -63,7 +63,7 @@ public function execute(
Config $config,
IO $io,
Repository $repository,
ActionConfig $action
ActionConfig $action,
): void {
if (!$io->isInteractive()) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/CaptainHook/ValidateConventionalCommit.php
Expand Up @@ -63,7 +63,7 @@ public function execute(
Config $config,
IO $io,
Repository $repository,
ActionConfig $action
ActionConfig $action,
): void {
/** @var array{config?: ConfigurationOptionsType, configFile?: string} | null $options */
$options = $action->getOptions()->getAll();
Expand Down
4 changes: 2 additions & 2 deletions src/ConventionalCommits/Configuration/FinderTool.php
Expand Up @@ -65,7 +65,7 @@ trait FinderTool
public function findConfiguration(
InputInterface $input,
OutputInterface $output,
?array $options = null
?array $options = null,
): Configuration {
$config = $options['config'] ?? null;
$configFile = $options['configFile'] ?? null;
Expand All @@ -90,7 +90,7 @@ public function findConfiguration(
public function getComposer(
InputInterface $input,
OutputInterface $output,
Filesystem $filesystem
Filesystem $filesystem,
): Composer {
$composerJson = $this->findComposerJson($filesystem);

Expand Down
4 changes: 2 additions & 2 deletions src/ConventionalCommits/Console/Command/PrepareCommand.php
Expand Up @@ -212,7 +212,7 @@ private function askFooterQuestionSection(
Question $decisionPathQuestion,
Question $tokenQuestion,
Closure $valueQuestionCallback,
bool $isRequired = false
bool $isRequired = false,
): array {
/**
* @psalm-suppress ReservedWord
Expand Down Expand Up @@ -241,7 +241,7 @@ private function askFooterQuestionSection(
private function askFooterQuestion(
SymfonyStyle $console,
Question $tokenQuestion,
Closure $valueQuestionCallback
Closure $valueQuestionCallback,
): ?Footer {
/**
* @psalm-suppress ReservedWord
Expand Down
2 changes: 1 addition & 1 deletion src/ConventionalCommits/Message.php
Expand Up @@ -61,7 +61,7 @@ class Message implements Configurable, Stringable, Validatable
public function __construct(
Type $type,
Description $description,
bool $hasBreakingChanges = false
bool $hasBreakingChanges = false,
) {
$this->type = $type;
$this->description = $description;
Expand Down
2 changes: 1 addition & 1 deletion src/ConventionalCommits/Message/Footer.php
Expand Up @@ -88,7 +88,7 @@ class Footer implements Unit
public function __construct(
string $token,
string $value,
string $separator = self::SEPARATOR_COLON
string $separator = self::SEPARATOR_COLON,
) {
$this->token = $this->validateToken($token);
$this->value = $this->validateValue($value);
Expand Down
2 changes: 2 additions & 0 deletions tests/CaptainHook/PrepareConventionalCommitTest.php
Expand Up @@ -33,6 +33,7 @@ public function testExecuteDoesNothingIfNotInteractiveMode(): void
{
/** @var PrepareCommand & MockInterface $prepareCommand */
$prepareCommand = $this->mockery(PrepareCommand::class);
$prepareCommand->expects('run')->never();

/** @var Config & MockInterface $config */
$config = $this->mockery(Config::class);
Expand All @@ -57,6 +58,7 @@ public function testExecuteDoesNothingIfCommitMsgAlreadyExists(): void
{
/** @var PrepareCommand & MockInterface $prepareCommand */
$prepareCommand = $this->mockery(PrepareCommand::class);
$prepareCommand->expects('run')->never();

/** @var Config & MockInterface $config */
$config = $this->mockery(Config::class);
Expand Down
23 changes: 22 additions & 1 deletion tests/CaptainHook/ValidateConventionalCommitTest.php
Expand Up @@ -8,11 +8,16 @@
use CaptainHook\App\Config\Action as ConfigAction;
use CaptainHook\App\Console\IO;
use CaptainHook\App\Exception\ActionFailed;
use Hamcrest\Core\IsInstanceOf;
use Mockery\MockInterface;
use Ramsey\CaptainHook\Output;
use Ramsey\CaptainHook\ValidateConventionalCommit;
use Ramsey\ConventionalCommits\Console\SymfonyStyleFactory;
use Ramsey\Test\TestCase;
use SebastianFeldmann\Git\CommitMessage;
use SebastianFeldmann\Git\Repository;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Style\SymfonyStyle;

use function trim;

Expand Down Expand Up @@ -103,7 +108,23 @@ function (string $value) use (&$output): void {
->getCommitMsg()
->andReturn($commitMessage);

$action = new ValidateConventionalCommit();
$console = $this->mockery(SymfonyStyle::class);
$console
->expects('error')
->with([
'Invalid Commit Message',
'The commit message is not properly formatted according to the '
. 'Conventional Commits specification. For more details, see '
. 'https://www.conventionalcommits.org/en/v1.0.0/',
]);

$styleFactory = $this->mockery(SymfonyStyleFactory::class);
$styleFactory
->expects('factory')
->with(new IsInstanceOf(ArrayInput::class), new IsInstanceOf(Output::class))
->andReturns($console);

$action = new ValidateConventionalCommit($styleFactory);

$this->expectException(ActionFailed::class);
$this->expectExceptionMessage('Validation failed.');
Expand Down
18 changes: 6 additions & 12 deletions tests/ConventionalCommits/Configuration/FinderToolTest.php
Expand Up @@ -28,17 +28,11 @@ class FinderToolTest extends TestCase
{
use SnapshotsTool;

/**
* @var InputInterface & MockInterface
*/
private $input;
private InputInterface&MockInterface $input;

private object $finderTool;

/**
* @var OutputInterface & MockInterface
*/
private $output;
private OutputInterface&MockInterface $output;

protected function setUp(): void
{
Expand Down Expand Up @@ -240,7 +234,7 @@ public function testFindConfigurationThrowsExceptionWhenComposerHasInvalidValue(
public function getComposer(
InputInterface $input,
OutputInterface $output,
Filesystem $filesystem
Filesystem $filesystem,
): Composer {
return $this->composer;
}
Expand Down Expand Up @@ -279,7 +273,7 @@ public function testFindConfigurationReturnsConfigurationUsingComposerConfig():
public function getComposer(
InputInterface $input,
OutputInterface $output,
Filesystem $filesystem
Filesystem $filesystem,
): Composer {
return $this->composer;
}
Expand Down Expand Up @@ -312,7 +306,7 @@ public function testFindConfigurationReturnsConfigurationUsingComposerConfigFile
public function getComposer(
InputInterface $input,
OutputInterface $output,
Filesystem $filesystem
Filesystem $filesystem,
): Composer {
return $this->composer;
}
Expand Down Expand Up @@ -341,7 +335,7 @@ public function testFindConfigurationReturnsDefaultConfigurationWhenComposerHasN
public function getComposer(
InputInterface $input,
OutputInterface $output,
Filesystem $filesystem
Filesystem $filesystem,
): Composer {
return $this->composer;
}
Expand Down
Expand Up @@ -40,7 +40,7 @@ public function testIsValidOrException(
array $testValue,
bool $expectedResult,
array $options = [],
string $expectedError = ''
string $expectedError = '',
): void {
$validator = new RequiredFootersValidator();

Expand Down
2 changes: 1 addition & 1 deletion tests/ConventionalCommits/Validator/ScopeValidatorTest.php
Expand Up @@ -36,7 +36,7 @@ public function testIsValidOrException(
string $testValue,
bool $expectedResult,
array $options = [],
string $expectedError = ''
string $expectedError = '',
): void {
$validator = new ScopeValidator();

Expand Down
2 changes: 1 addition & 1 deletion tests/ConventionalCommits/Validator/TypeValidatorTest.php
Expand Up @@ -36,7 +36,7 @@ public function testIsValidOrException(
string $testValue,
bool $expectedResult,
array $options = [],
string $expectedError = ''
string $expectedError = '',
): void {
$validator = new TypeValidator();

Expand Down

0 comments on commit ba9d08b

Please sign in to comment.