Skip to content

Commit d0bef39

Browse files
committed
ci(config): Update github config files
1 parent c4af07e commit d0bef39

File tree

6 files changed

+69
-47
lines changed

6 files changed

+69
-47
lines changed

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ body:
2929
attributes:
3030
label: Package Version
3131
description: What version of our Package are you running? Please be as specific as possible
32-
placeholder: 2.0.0
32+
placeholder: 8.0.0
3333
validations:
3434
required: true
3535
- type: input
@@ -45,7 +45,7 @@ body:
4545
# attributes:
4646
# label: Laravel Version
4747
# description: What version of Laravel are you running? Please be as specific as possible
48-
# placeholder: 9.0.0
48+
# placeholder: 11.0.0
4949
# validations:
5050
# required: true
5151
- type: dropdown

.github/ISSUE_TEMPLATE/feature-request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ body:
3737
label: Validations
3838
description: Before submitting the issue, please make sure you do the following
3939
options:
40-
- label: Follow our [Code of Conduct](../blob/main/.github/CODE_OF_CONDUCT.md)
40+
- label: Follow our [Code of Conduct](../blob/master/.github/CODE_OF_CONDUCT.md)
4141
required: true
42-
- label: Read the [Contributing Guide](../blob/main/.github/CONTRIBUTING.md).
42+
- label: Read the [Contributing Guide](../blob/master/.github/CONTRIBUTING.md).
4343
required: true
4444
- label: Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
4545
required: true

.github/workflows/issues-translate.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/Concerns/HasOptions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ protected function normalizeOption(string $name, mixed $value): string
584584
*
585585
* @noinspection PhpUnhandledExceptionInspection
586586
* @noinspection PhpDocMissingThrowsInspection
587+
* @noinspection MultipleReturnStatementsInspection
587588
*/
588589
protected function normalizeValue(string $name, mixed $value): ?string
589590
{

src/Support/ComposerScripts.php

Lines changed: 64 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
/** @noinspection EfferentObjectCouplingInspection */
4+
/** @noinspection PhpUnused */
45

56
declare(strict_types=1);
67

@@ -24,6 +25,7 @@
2425
use Rector\DependencyInjection\LazyContainerFactory;
2526
use Symfony\Component\Console\Application;
2627
use Symfony\Component\Console\Input\ArgvInput;
28+
use Symfony\Component\Console\Input\InputDefinition;
2729
use Symfony\Component\Console\Input\InputInterface;
2830
use Symfony\Component\Console\Output\ConsoleOutput;
2931
use Symfony\Component\Console\Output\OutputInterface;
@@ -39,6 +41,12 @@
3941
*/
4042
final class ComposerScripts
4143
{
44+
/**
45+
* @see \PhpCsFixer\Hasher
46+
* @see \PhpCsFixer\Utils
47+
*/
48+
private function __construct() {}
49+
4250
/**
4351
* @see \Composer\Util\Silencer
4452
*
@@ -126,7 +134,6 @@ public static function dumpSoarPHPConfig(Event $event): int
126134
/**
127135
* @throws \Guanguans\SoarPHP\Exceptions\InvalidOptionException
128136
*
129-
* @noinspection D
130137
* @noinspection PhpFunctionCyclomaticComplexityInspection
131138
*/
132139
public static function resolveSoarHelp(): Collection
@@ -249,41 +256,79 @@ public static function makeRectorConfig(): RectorConfig
249256
return $rectorConfig ??= (new LazyContainerFactory)->create();
250257
}
251258

259+
/**
260+
* @noinspection PhpPossiblePolymorphicInvocationInspection
261+
*/
262+
public static function requireAutoload(Event $event, ?bool $enableDebugging = null): void
263+
{
264+
$enableDebugging ??= (new ArgvInput)->hasParameterOption('-vvv', true);
265+
$enableDebugging and $event->getIO()->enableDebugging(microtime(true));
266+
(fn () => $this->output->setVerbosity(OutputInterface::VERBOSITY_DEBUG))->call($event->getIO());
267+
268+
require_once $event->getComposer()->getConfig()->get('vendor-dir').\DIRECTORY_SEPARATOR.'autoload.php';
269+
}
270+
271+
/**
272+
* @param null|list<string> $argv
273+
*/
274+
public static function makeArgvInput(?array $argv = null, ?InputDefinition $inputDefinition = null): ArgvInput
275+
{
276+
static $argvInput;
277+
278+
return $argvInput ??= new ArgvInput($argv, $inputDefinition);
279+
}
280+
252281
/**
253282
* @see \Rector\Console\Style\SymfonyStyleFactory
254283
*/
255-
public static function makeSymfonyStyle(): SymfonyStyle
284+
public static function makeSymfonyStyle(?InputInterface $input = null, ?OutputInterface $output = null): SymfonyStyle
256285
{
257286
static $symfonyStyle;
258287

259-
if ($symfonyStyle instanceof SymfonyStyle) {
288+
if (
289+
$symfonyStyle instanceof SymfonyStyle
290+
&& (
291+
!$input instanceof InputInterface
292+
|| (string) \Closure::bind(
293+
static fn (SymfonyStyle $symfonyStyle): InputInterface => $symfonyStyle->input,
294+
null,
295+
SymfonyStyle::class
296+
)($symfonyStyle) === (string) $input
297+
)
298+
&& (
299+
!$output instanceof OutputInterface
300+
|| \Closure::bind(
301+
static fn (SymfonyStyle $symfonyStyle): OutputInterface => $symfonyStyle->output,
302+
null,
303+
SymfonyStyle::class
304+
)($symfonyStyle) === $output
305+
)
306+
) {
260307
return $symfonyStyle;
261308
}
262309

263-
$argvInput = new ArgvInput;
264-
$consoleOutput = new ConsoleOutput;
310+
$input ??= new ArgvInput;
311+
$output ??= new ConsoleOutput;
265312

266313
// to configure all -v, -vv, -vvv options without memory-lock to Application run() arguments
267-
(fn () => $this->configureIO($argvInput, $consoleOutput))->call(new Application);
314+
(fn () => $this->configureIO($input, $output))->call(new Application);
315+
316+
// --debug or --xdebug is called
317+
if ($input->hasParameterOption(['--debug', '--xdebug'], true)) {
318+
$output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
319+
}
268320

269-
// --debug is called
270-
if ($argvInput->hasParameterOption(['--debug', '--xdebug'], true)) {
271-
$consoleOutput->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
321+
// disable output for testing
322+
if (self::isRunningInTesting()) {
323+
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
272324
}
273325

274-
return $symfonyStyle = new SymfonyStyle($argvInput, $consoleOutput);
326+
return $symfonyStyle = new SymfonyStyle($input, $output);
275327
}
276328

277-
/**
278-
* @noinspection PhpPossiblePolymorphicInvocationInspection
279-
*/
280-
private static function requireAutoload(Event $event, ?bool $enableDebugging = null): void
329+
public static function isRunningInTesting(): bool
281330
{
282-
$enableDebugging ??= (new ArgvInput)->hasParameterOption('-vvv', true);
283-
$enableDebugging and $event->getIO()->enableDebugging(microtime(true));
284-
(fn () => $this->output->setVerbosity(OutputInterface::VERBOSITY_DEBUG))->call($event->getIO());
285-
286-
require_once $event->getComposer()->getConfig()->get('vendor-dir').\DIRECTORY_SEPARATOR.'autoload.php';
331+
return 'testing' === getenv('ENV');
287332
}
288333

289334
/**

tests/ArchTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@
2222
use Guanguans\SoarPHP\Concerns\WithDumpable;
2323
use Guanguans\SoarPHP\Support\ComposerScripts;
2424

25-
/**
26-
* Copyright (c) 2019-2025 guanguans<[email protected]>.
27-
*
28-
* For the full copyright and license information, please view
29-
* the LICENSE file that was distributed with this source code.
30-
*
31-
* @see https://github.com/guanguans/soar-php
32-
*/
3325
arch('will not use debugging functions')
3426
// ->throwsNoExceptions()
3527
->group(__DIR__, __FILE__)

0 commit comments

Comments
 (0)