Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feat/command-tester
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Dec 7, 2024
2 parents c6100b5 + 933ebb1 commit 39a097a
Show file tree
Hide file tree
Showing 49 changed files with 1,061 additions and 936 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ updates:
patterns:
- "*"

- package-ecosystem: "composer"
directory: "vendor-bin/*/"
schedule:
interval: "weekly"
groups:
dependencies:
patterns:
- "*"

- package-ecosystem: "github-actions"
directory: ".github/workflows"
schedule:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/auto-review.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ jobs:
coverage: none

- name: Install Composer dependencies
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3

- name: Install PHP-CS-Fixer Composer dependencies
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3
with:
working-directory: 'vendor-bin/php-cs-fixer'

- name: Ensure PHP-CS-Fixer is properly installed
run: make php_cs_fixer_install

- name: Install Psalm Composer dependencies
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3
with:
working-directory: 'vendor-bin/psalm'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: echo "SYMFONY_REQUIRE=${{ matrix.symfony }}" >> $GITHUB_ENV

- name: Install Composer dependencies
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3
with:
dependency-versions: ${{ matrix.dependency }}

Expand All @@ -60,7 +60,7 @@ jobs:
coverage: pcov

- name: Install Composer dependencies
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3

- run: make infection

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PSALM_BIN = vendor-bin/psalm/vendor/vimeo/psalm/psalm
PSALM = $(PSALM_BIN) --no-cache

PHP_CS_FIXER_BIN = vendor-bin/php-cs-fixer/vendor/friendsofphp/php-cs-fixer/php-cs-fixer
PHP_CS_FIXER = $(PHP_CS_FIXER_BIN) fix --ansi --verbose --config=.php-cs-fixer.php
PHP_CS_FIXER = PHP_CS_FIXER_IGNORE_ENV=1 $(PHP_CS_FIXER_BIN) fix --ansi --verbose --config=.php-cs-fixer.php


.DEFAULT_GOAL := check
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ of the use case presented.
- [zenstruck/console-extra](https://github.com/zenstruck/console-extra)
- [zenstruck/console-test](https://github.com/zenstruck/console-test)
- [webignition/symfony-console-typed-input](https://github.com/webignition/symfony-console-typed-input)
- [webmozart-console](https://github.com/webmozart/console)


### Contributing
Expand Down
20 changes: 11 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
"require": {
"php": "^8.2",
"psr/log": "^3.0",
"symfony/console": "^6.4 || ^7.0",
"symfony/console": "^6.4 || ^7.2",
"symfony/deprecation-contracts": "^3.4",
"symfony/event-dispatcher-contracts": "^2.5 || ^3.0",
"symfony/polyfill-php84": "^1.31",
"symfony/service-contracts": "^2.5 || ^3.0",
"thecodingmachine/safe": "^2.0",
"webmozart/assert": "^1.11"
Expand All @@ -28,18 +30,18 @@
"composer/semver": "^3.3.2",
"ergebnis/composer-normalize": "^2.33",
"fidry/makefile": "^0.2.1 || ^1.0.0",
"infection/infection": "^0.27",
"infection/infection": "^0.28",
"phpunit/phpunit": "^10.2",
"symfony/dependency-injection": "^6.4",
"symfony/dependency-injection": "^6.4 || ^7.2",
"symfony/flex": "^2.4.0",
"symfony/framework-bundle": "^6.4",
"symfony/http-kernel": "^6.4",
"symfony/yaml": "^6.4 || ^7.0"
"symfony/framework-bundle": "^6.4 || ^7.2",
"symfony/http-kernel": "^6.4 || ^7.2",
"symfony/yaml": "^6.4 || ^7.2"
},
"conflict": {
"symfony/dependency-injection": "<6.4.0",
"symfony/framework-bundle": "<6.4.0",
"symfony/http-kernel": "<6.4.0"
"symfony/dependency-injection": "<6.4.0 || >=7.0.0 <7.2.0",
"symfony/framework-bundle": "<6.4.0 || >=7.0.0 <7.2.0",
"symfony/http-kernel": "<6.4.0 || >=7.0.0 <7.2.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
strictBinaryOperands="true"
ignoreInternalFunctionFalseReturn="false"
ignoreInternalFunctionNullReturn="false"
findUnusedBaselineEntry="true"
findUnusedVariablesAndParams="true"
findUnusedCode="true"
findUnusedPsalmSuppress="true"
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/FidryConsoleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use Fidry\Console\Command\Command;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use function file_exists;

final class FidryConsoleExtension extends Extension
Expand Down
2 changes: 1 addition & 1 deletion src/FidryConsoleBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use Fidry\Console\DependencyInjection\FidryConsoleExtension;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

final class FidryConsoleBundle extends Bundle
{
Expand Down
2 changes: 1 addition & 1 deletion src/Input/DecoratesInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function hasParameterOption(array|string $values, bool $onlyParams = fals

public function getParameterOption(
array|string $values,
null|array|bool|float|int|string $default = false,
array|bool|float|int|string|null $default = false,
bool $onlyParams = false
): mixed {
return $this->input->getParameterOption(...func_get_args());
Expand Down
2 changes: 1 addition & 1 deletion src/Input/IO.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use function class_alias;
use function sprintf;

$alias = \Fidry\Console\Input\IO::class;
$alias = IO::class;
$newClass = \Fidry\Console\IO::class;

Deprecation::trigger(
Expand Down
4 changes: 2 additions & 2 deletions src/Input/InvalidInputValueType.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function fromAssert(
$exception->getMessage(),
$inputLabel,
),
(int) $exception->getCode(),
$exception->getCode(),
$exception,
);
}
Expand All @@ -46,7 +46,7 @@ public static function withErrorMessage(
$errorMessage,
$exception->getMessage(),
),
(int) $exception->getCode(),
$exception->getCode(),
$exception,
);
}
Expand Down
30 changes: 10 additions & 20 deletions src/Input/TypedInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ final class TypedInput
/**
* @param ArgumentInput|OptionInput $value
* @param non-empty-string $label
*
* @psalm-suppress RedundantCondition
*/
private function __construct(
private readonly null|array|bool|string $value,
private readonly array|bool|string|null $value,
private readonly string $label,
) {
Assert::stringNotEmpty($label);
Expand All @@ -46,7 +44,6 @@ private function __construct(
* @param non-empty-string $name
*
* @psalm-assert ArgumentInput $argument
* @psalm-suppress ArgumentTypeCoercion
*/
public static function fromArgument(mixed $argument, string $name): self
{
Expand All @@ -65,7 +62,6 @@ public static function fromArgument(mixed $argument, string $name): self
* @param non-empty-string $name
*
* @psalm-assert OptionInput $option
* @psalm-suppress ArgumentTypeCoercion
*/
public static function fromOption(mixed $option, string $name): self
{
Expand Down Expand Up @@ -104,8 +100,6 @@ public function asStringChoice(
}

/**
* @psalm-suppress MoreSpecificReturnType
*
* @param positive-int|0 $min
* @param positive-int|0 $max
*
Expand All @@ -119,12 +113,10 @@ public function asNaturalWithinRange(
$type = new NaturalRangeType($min, $max);

if (null === $errorMessage) {
/** @psalm-suppress LessSpecificReturnStatement */
return $type->coerceValue($this->value, $this->label);
}

try {
/** @psalm-suppress LessSpecificReturnStatement */
return $type->coerceValue($this->value, $this->label);
} catch (InvalidInputValueType $coercingFailed) {
throw InvalidInputValueType::withErrorMessage(
Expand All @@ -135,6 +127,7 @@ public function asNaturalWithinRange(
}

/**
* @psalm-suppress InvalidReturnType, NoValue
* @template T of BackedEnum
*
* @param class-string<T> $backedEnumClassName
Expand Down Expand Up @@ -162,7 +155,6 @@ public function asBackedEnum(
}

/**
* @psalm-suppress InvalidReturnType
* @template T of BackedEnum
*
* @param class-string<T> $backedEnumClassName
Expand All @@ -178,12 +170,10 @@ public function asNullableBackedEnum(
);

if (null === $errorMessage) {
/** @psalm-suppress InvalidReturnStatement */
return $type->coerceValue($this->value, $this->label);
}

try {
/** @psalm-suppress InvalidReturnStatement */
return $type->coerceValue($this->value, $this->label);
} catch (InvalidInputValueType $coercingFailed) {
throw InvalidInputValueType::withErrorMessage(
Expand All @@ -198,7 +188,7 @@ public function asNullableBackedEnum(
/**
* @return null|bool|string|list<string>
*/
public function asRaw(?string $errorMessage = null): null|array|bool|string
public function asRaw(?string $errorMessage = null): array|bool|string|null
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\RawType::class,
Expand Down Expand Up @@ -241,7 +231,7 @@ public function asBoolean(?string $errorMessage = null): bool
public function asNullableBoolean(?string $errorMessage = null): ?bool
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\NullableType::class,
NullableType::class,
\Fidry\Console\Internal\Type\BooleanType::class,
]);

Expand Down Expand Up @@ -336,7 +326,7 @@ public function asNatural(?string $errorMessage = null): int
public function asNullableNatural(?string $errorMessage = null): ?int
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\NullableType::class,
NullableType::class,
\Fidry\Console\Internal\Type\NaturalType::class,
]);

Expand Down Expand Up @@ -431,7 +421,7 @@ public function asPositiveInteger(?string $errorMessage = null): int
public function asNullablePositiveInteger(?string $errorMessage = null): ?int
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\NullableType::class,
NullableType::class,
\Fidry\Console\Internal\Type\PositiveIntegerType::class,
]);

Expand Down Expand Up @@ -520,7 +510,7 @@ public function asFloat(?string $errorMessage = null): float
public function asNullableFloat(?string $errorMessage = null): ?float
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\NullableType::class,
NullableType::class,
\Fidry\Console\Internal\Type\FloatType::class,
]);

Expand Down Expand Up @@ -609,7 +599,7 @@ public function asString(?string $errorMessage = null): string
public function asNullableString(?string $errorMessage = null): ?string
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\NullableType::class,
NullableType::class,
\Fidry\Console\Internal\Type\StringType::class,
]);

Expand Down Expand Up @@ -704,7 +694,7 @@ public function asNonEmptyString(?string $errorMessage = null): string
public function asNullableNonEmptyString(?string $errorMessage = null): ?string
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\NullableType::class,
NullableType::class,
\Fidry\Console\Internal\Type\NonEmptyStringType::class,
]);

Expand Down Expand Up @@ -793,7 +783,7 @@ public function asUntrimmedString(?string $errorMessage = null): string
public function asNullableUntrimmedString(?string $errorMessage = null): ?string
{
$type = TypeFactory::createTypeFromClassNames([
\Fidry\Console\Internal\Type\NullableType::class,
NullableType::class,
\Fidry\Console\Internal\Type\UntrimmedStringType::class,
]);

Expand Down
5 changes: 5 additions & 0 deletions src/Internal/Generator/TypeMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ private function __construct()
{
}

/**
* @psalm-suppress LessSpecificReturnStatement,MoreSpecificReturnType
*
* @return non-empty-list<InputType>
*/
public static function provideTypes(): array
{
$baseTypes = [
Expand Down
Loading

0 comments on commit 39a097a

Please sign in to comment.