Skip to content

Commit

Permalink
Merge pull request #92 from php-tuf/dependabot/composer/all-d2d9338e52
Browse files Browse the repository at this point in the history
Bump the all group with 3 updates
  • Loading branch information
TravisCarden authored Apr 24, 2024
2 parents fd07a10 + aed3297 commit daf4129
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 55 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
!/.idea/dictionaries/project.xml
!/var/*/.gitkeep
/.idea/composer-stager-console.iml
/.idea/dictionaries/*
!/.idea/dictionaries/project.xml
/.idea/php-test-framework.xml
/.idea/php.xml
/.idea/workspace.xml
/grumphp.yml
Expand All @@ -10,3 +10,4 @@
/psalm.xml
/var/*/*
/vendor/
!/**/.gitkeep
38 changes: 17 additions & 21 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 43 additions & 27 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<!-- https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset -->
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="ComposerStager"
name="ComposerStagerConsole"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"
>

<description>Composer Stager</description>
<description>Composer Stager Console</description>

<arg name="colors"/>
<arg name="cache" value="var/phpcs/cache.json"/>
Expand All @@ -19,12 +19,12 @@
<config name="testVersion" value="8.1-"/>

<rule ref="PSR2">
<exclude name="Generic.Files.LineLength"/>
<exclude name="PSR2.Classes.ClassDeclaration.CloseBraceAfterBody"/>
</rule>

<rule ref="Generic.Arrays.ArrayIndent"/>
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.Files.LineLength"/>
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
Expand All @@ -39,6 +39,13 @@
<include-pattern>*Exception.php$</include-pattern>
<include-pattern>*Interface.php$</include-pattern>
</rule>
<rule ref="PEAR.Commenting.FunctionComment.Missing">
<properties>
<property name="minimumVisibility" value="public" />
</properties>
<include-pattern>src/*Exception.php$</include-pattern>
<include-pattern>src/*Interface.php$</include-pattern>
</rule>

<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
<rule ref="Squiz.Arrays.ArrayDeclaration">
Expand All @@ -61,13 +68,12 @@
<rule ref="SlevomatCodingStandard.Classes.ClassMemberSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.ClassStructure"/>
<rule ref="SlevomatCodingStandard.Classes.ConstantSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants"/>
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiConstantDefinition"/>
<rule ref="SlevomatCodingStandard.Classes.DisallowMultiPropertyDefinition"/>
<rule ref="SlevomatCodingStandard.Classes.EmptyLinesAroundClassBraces">
<properties>
<property name="linesCountAfterOpeningBrace">0</property>
<property name="linesCountBeforeClosingBrace">0</property>
<property name="linesCountAfterOpeningBrace" value="0"/>
<property name="linesCountBeforeClosingBrace" value="0"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.ForbiddenPublicProperty"/>
Expand All @@ -76,35 +82,45 @@
<rule ref="SlevomatCodingStandard.Classes.ParentCallSpacing"/>
<rule ref="SlevomatCodingStandard.Classes.PropertyDeclaration"/>
<rule ref="SlevomatCodingStandard.Classes.PropertySpacing"/>
<rule ref="SlevomatCodingStandard.Classes.RequireAbstractOrFinal">
<exclude-pattern>src/Domain/Exception</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.Classes.RequireAbstractOrFinal"/>
<rule ref="SlevomatCodingStandard.Classes.RequireConstructorPropertyPromotion"/>
<rule ref="SlevomatCodingStandard.Classes.RequireMultiLineMethodSignature"/>
<rule ref="SlevomatCodingStandard.Classes.RequireSingleLineMethodSignature"/>
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing"><properties>
<property name="linesCountBeforeFirstUseWhenFirstInClass" value="0"/>
</properties></rule>
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing">
<exclude name="SlevomatCodingStandard.Classes.TraitUseSpacing.IncorrectLinesCountAfterLastUse"/>
<properties>
<property name="linesCountBeforeFirstUseWhenFirstInClass" value="0"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.UselessLateStaticBinding"/>

<rule ref="SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration"/>
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing"><properties>
<property name="annotationsGroups" type="array">
<element value="@file"/>
<element value="@coversDefaultClass"/>
<element value="@covers,@coversNothing"/>
<element value="@uses"/>
<element value="@dataProvider"/>
<element value="@property"/>
<element value="@var"/>
<element value="@param"/>
<element value="@return"/>
<element value="@throws"/>
<element value="@see"/>
<element value="@package"/>
<element value="@api,@internal"/>
<element value="@todo"/>
<element value="@noinspection"/>
<element value="@noinspection,@SuppressWarnings"/>
</property>
<property name="linesCountBetweenDifferentAnnotationsTypes" value="1"/>
</properties></rule>

<!-- @see https://github.com/slevomat/coding-standard/issues/1632 -->
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectLinesCountAfterLastContent"/>
<rule ref="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectLinesCountBetweenDescriptionAndAnnotations"/>

<rule ref="SlevomatCodingStandard.Commenting.EmptyComment"/>
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenAnnotations"/>
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments"/>
Expand Down Expand Up @@ -133,31 +149,26 @@
<rule ref="SlevomatCodingStandard.ControlStructures.RequireShortTernaryOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireTernaryOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn"/>
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>

<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly"/>

<rule ref="SlevomatCodingStandard.Files.LineLength"/>
<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch"/>

<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration"/>
<rule ref="SlevomatCodingStandard.Functions.RequireArrowFunction"/>
<rule ref="SlevomatCodingStandard.Functions.DisallowEmptyFunction"/>
<rule ref="SlevomatCodingStandard.Functions.DisallowNamedArguments"/>
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInClosureUse"/>
<rule ref="SlevomatCodingStandard.Functions.DisallowTrailingCommaInDeclaration"/>
<rule ref="SlevomatCodingStandard.Functions.FunctionLength"><properties>
<!-- @todo It would be nice to reduce this. -->
<property name="maxLinesLength" value="40"/>
<property name="maxLinesLength" value="24"/>
</properties></rule>
<rule ref="SlevomatCodingStandard.Functions.RequireMultiLineCall"/>
<rule ref="SlevomatCodingStandard.Functions.RequireSingleLineCall"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse"/>
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration"/>
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<rule ref="SlevomatCodingStandard.Functions.StrictCall"/>
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>

<!-- Missing type hint sniffs don't support inherited docs. -->
Expand All @@ -180,11 +191,10 @@
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing"/>

<rule ref="SlevomatCodingStandard.Numbers.DisallowNumericLiteralSeparator"/>
<rule ref="SlevomatCodingStandard.Numbers.RequireNumericLiteralSeparator"/>

<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<rule ref="SlevomatCodingStandard.Operators.DisallowIncrementAndDecrementOperators"/>
<rule ref="SlevomatCodingStandard.Operators.DisallowIncrementAndDecrementOperators.DisallowedPreIncrementOperator"/>
<rule ref="SlevomatCodingStandard.Operators.NegationOperatorSpacing"/>
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<rule ref="SlevomatCodingStandard.Operators.RequireOnlyStandaloneIncrementAndDecrementOperators"/>
Expand Down Expand Up @@ -239,18 +249,24 @@

<rule ref="SlevomatCodingStandard.Whitespaces.DuplicateSpaces"/>

<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch"/>

<!-- Exclusions for test classes. -->
<!-- Exclusions for test and tool classes. -->
<rule ref="Generic.Files.LineLength"><exclude-pattern>tests</exclude-pattern><exclude-pattern>tools</exclude-pattern><exclude-pattern>rector.php</exclude-pattern></rule>
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses"><exclude-pattern>tests</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.Classes.ClassStructure.IncorrectGroupOrder"><exclude-pattern>tests</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.Classes.ForbiddenPublicProperty.ForbiddenPublicProperty"><exclude-pattern>tests</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.Files.LineLength.LineTooLong"><exclude-pattern>tests</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.Functions.FunctionLength.FunctionLength"><exclude-pattern>tests</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.Functions.FunctionLength.FunctionLength"><exclude-pattern>tests</exclude-pattern><exclude-pattern>tools/PHPCS</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.Functions.RequireMultiLineCall.RequiredMultiLineCall"><exclude-pattern>rector.php</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.Functions.RequireMultiLineCall.RequiredMultiLineCall"><exclude-pattern>tests</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.Namespaces.NamespaceDeclaration.DisallowedBracketedSyntax"><exclude-pattern>tests/TestUtils/builtin_function_mocks.inc</exclude-pattern><exclude-pattern>tools/PHPCS</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile.MoreNamespacesInFile"><exclude-pattern>tests/TestUtils/builtin_function_mocks.inc</exclude-pattern><exclude-pattern>tools/PHPCS</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.PHP.DisallowDirectMagicInvokeCall.DisallowDirectMagicInvokeCall"><exclude-pattern>tests</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.PHP.DisallowReference.DisallowedAssigningByReference"><exclude-pattern>tests</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.PHP.RequireExplicitAssertion.RequiredExplicitAssertion"><exclude-pattern>tests</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint"><exclude-pattern>tests</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint"><exclude-pattern>tools/PHPCS</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"><exclude-pattern>tools/PHPCS</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"><exclude-pattern>tests</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"><exclude-pattern>tools/PHPCS</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint"><exclude-pattern>tests</exclude-pattern></rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"><exclude-pattern>tests</exclude-pattern></rule>

Expand Down
60 changes: 55 additions & 5 deletions src/Console/Output/ProcessOutputCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,70 @@
use PhpTuf\ComposerStager\API\Process\Service\OutputCallbackInterface;
use PhpTuf\ComposerStager\API\Process\Value\OutputTypeEnum;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputInterface as SymfonyInputInterface;
use Symfony\Component\Console\Output\OutputInterface as SymfonyOutputInterface;

/** @internal */
final class ProcessOutputCallback implements OutputCallbackInterface
{
public function __construct(private readonly InputInterface $input, private readonly OutputInterface $output)
/** @var array<string> */
private array $errorOutput = [];

/** @var array<string> */
private array $output = [];

public function __construct(
private readonly SymfonyInputInterface $symfonyInput,
private readonly SymfonyOutputInterface $symfonyOutput,
) {
}

public function clearErrorOutput(): void
{
$this->errorOutput = [];
}

public function clearOutput(): void
{
$this->output = [];
}

public function getErrorOutput(): array
{
return $this->errorOutput;
}

public function getOutput(): array
{
return $this->output;
}

/** @return array<string> */
private function normalizeBuffer(string $buffer): array
{
// Convert Windows line endings.
$buffer = str_replace("\r\n", "\n", $buffer);

// Trim meaningless new lines at the beginning and end of buffers.
$buffer = preg_replace("/(^\r?\n|\r?\n$)/", '', $buffer, 1);
assert(is_string($buffer));

// Split multiline strings into an array.
return explode("\n", $buffer);
}

public function __invoke(OutputTypeEnum $type, string $buffer): void
{
$lines = $this->normalizeBuffer($buffer);

if ($type === OutputTypeEnum::OUT) {
$this->output = array_merge($this->output, $lines);
} else {
$this->errorOutput = array_merge($this->errorOutput, $lines);
}

try {
if ($this->input->getOption('quiet') === true) {
if ($this->symfonyInput->getOption('quiet') === true) {
return;
}
} catch (InvalidArgumentException) {
Expand All @@ -27,6 +77,6 @@ public function __invoke(OutputTypeEnum $type, string $buffer): void
}

// Write process output as it comes.
$this->output->write($buffer);
$this->symfonyOutput->write($buffer);
}
}

0 comments on commit daf4129

Please sign in to comment.