Fix bin/publish: copy docs.dist from project root

Fix bin/publish: use correct .env path for rspade_system
Fix bin/publish script: prevent grep exit code 1 from terminating script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-10-21 02:08:33 +00:00
commit f6fac6c4bc
79758 changed files with 10547827 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Linter;
use PhpCsFixer\Hasher;
/**
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* @internal
*/
final class CachingLinter implements LinterInterface
{
private LinterInterface $sublinter;
/**
* @var array<string, LintingResultInterface>
*/
private array $cache = [];
public function __construct(LinterInterface $linter)
{
$this->sublinter = $linter;
}
public function isAsync(): bool
{
return $this->sublinter->isAsync();
}
public function lintFile(string $path): LintingResultInterface
{
$checksum = Hasher::calculate(file_get_contents($path));
return $this->cache[$checksum] ??= $this->sublinter->lintFile($path);
}
public function lintSource(string $source): LintingResultInterface
{
$checksum = Hasher::calculate($source);
return $this->cache[$checksum] ??= $this->sublinter->lintSource($source);
}
}

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Linter;
/**
* Handle PHP code linting process.
*
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* @readonly
*
* @internal
*/
final class Linter implements LinterInterface
{
private LinterInterface $subLinter;
public function __construct()
{
$this->subLinter = new TokenizerLinter();
}
public function isAsync(): bool
{
return $this->subLinter->isAsync();
}
public function lintFile(string $path): LintingResultInterface
{
return $this->subLinter->lintFile($path);
}
public function lintSource(string $source): LintingResultInterface
{
return $this->subLinter->lintSource($source);
}
}

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Linter;
/**
* Interface for PHP code linting process manager.
*
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*/
interface LinterInterface
{
public function isAsync(): bool;
/**
* Lint PHP file.
*/
public function lintFile(string $path): LintingResultInterface;
/**
* Lint PHP code.
*/
public function lintSource(string $source): LintingResultInterface;
}

View File

@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Linter;
/**
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* @final
*
* @TODO 4.0 make class "final"
*/
class LintingException extends \RuntimeException {}

View File

@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Linter;
/**
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*/
interface LintingResultInterface
{
/**
* Check if linting process was successful and raise LintingException if not.
*/
public function check(): void;
}

View File

@@ -0,0 +1,149 @@
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Linter;
use PhpCsFixer\FileReader;
use PhpCsFixer\FileRemoval;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
/**
* Handle PHP code linting using separated process of `php -l _file_`.
*
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* @internal
*/
final class ProcessLinter implements LinterInterface
{
private FileRemoval $fileRemoval;
private ProcessLinterProcessBuilder $processBuilder;
/**
* Temporary file for code linting.
*/
private ?string $temporaryFile = null;
/**
* @param null|string $executable PHP executable, null for autodetection
*/
public function __construct(?string $executable = null)
{
if (null === $executable) {
$executableFinder = new PhpExecutableFinder();
$executable = $executableFinder->find(false);
if (false === $executable) {
throw new UnavailableLinterException('Cannot find PHP executable.');
}
if ('phpdbg' === \PHP_SAPI) {
if (!str_contains($executable, 'phpdbg')) {
throw new UnavailableLinterException('Automatically found PHP executable is non-standard phpdbg. Could not find proper PHP executable.');
}
// automatically found executable is `phpdbg`, let us try to fallback to regular `php`
$executable = str_replace('phpdbg', 'php', $executable);
if (!is_executable($executable)) {
throw new UnavailableLinterException('Automatically found PHP executable is phpdbg. Could not find proper PHP executable.');
}
}
}
$this->processBuilder = new ProcessLinterProcessBuilder($executable);
$this->fileRemoval = new FileRemoval();
}
public function __destruct()
{
if (null !== $this->temporaryFile) {
$this->fileRemoval->delete($this->temporaryFile);
}
}
/**
* This class is not intended to be serialized,
* and cannot be deserialized (see __wakeup method).
*/
public function __sleep(): array
{
throw new \BadMethodCallException('Cannot serialize '.self::class);
}
/**
* Disable the deserialization of the class to prevent attacker executing
* code by leveraging the __destruct method.
*
* @see https://owasp.org/www-community/vulnerabilities/PHP_Object_Injection
*/
public function __wakeup(): void
{
throw new \BadMethodCallException('Cannot unserialize '.self::class);
}
public function isAsync(): bool
{
return true;
}
public function lintFile(string $path): LintingResultInterface
{
return new ProcessLintingResult($this->createProcessForFile($path), $path);
}
public function lintSource(string $source): LintingResultInterface
{
return new ProcessLintingResult($this->createProcessForSource($source), $this->temporaryFile);
}
/**
* @param string $path path to file
*/
private function createProcessForFile(string $path): Process
{
// in case php://stdin
if (!is_file($path)) {
return $this->createProcessForSource(FileReader::createSingleton()->read($path));
}
$process = $this->processBuilder->build($path);
$process->setTimeout(10);
$process->start();
return $process;
}
/**
* Create process that lint PHP code.
*
* @param string $source code
*/
private function createProcessForSource(string $source): Process
{
if (null === $this->temporaryFile) {
$this->temporaryFile = tempnam(sys_get_temp_dir(), 'cs_fixer_tmp_');
$this->fileRemoval->observe($this->temporaryFile);
}
if (false === @file_put_contents($this->temporaryFile, $source)) {
throw new IOException(\sprintf('Failed to write file "%s".', $this->temporaryFile), 0, null, $this->temporaryFile);
}
return $this->createProcessForFile($this->temporaryFile);
}
}

View File

@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Linter;
use Symfony\Component\Process\Process;
/**
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* @readonly
*
* @internal
*/
final class ProcessLinterProcessBuilder
{
private string $executable;
/**
* @param string $executable PHP executable
*/
public function __construct(string $executable)
{
$this->executable = $executable;
}
public function build(string $path): Process
{
return new Process([
$this->executable,
'-l',
$path,
]);
}
}

View File

@@ -0,0 +1,86 @@
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Linter;
use Symfony\Component\Process\Process;
/**
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* @internal
*/
final class ProcessLintingResult implements LintingResultInterface
{
private Process $process;
private ?string $path;
private ?bool $isSuccessful = null;
public function __construct(Process $process, ?string $path = null)
{
$this->process = $process;
$this->path = $path;
}
public function check(): void
{
if (!$this->isSuccessful()) {
// on some systems stderr is used, but on others, it's not
throw new LintingException($this->getProcessErrorMessage(), $this->process->getExitCode());
}
}
private function getProcessErrorMessage(): string
{
$errorOutput = $this->process->getErrorOutput();
$output = strtok(ltrim('' !== $errorOutput ? $errorOutput : $this->process->getOutput()), "\n");
if (false === $output) {
return 'Fatal error: Unable to lint file.';
}
if (null !== $this->path) {
$needle = \sprintf('in %s ', $this->path);
$pos = strrpos($output, $needle);
if (false !== $pos) {
$output = \sprintf('%s%s', substr($output, 0, $pos), substr($output, $pos + \strlen($needle)));
}
}
$prefix = substr($output, 0, 18);
if ('PHP Parse error: ' === $prefix) {
return \sprintf('Parse error: %s.', substr($output, 18));
}
if ('PHP Fatal error: ' === $prefix) {
return \sprintf('Fatal error: %s.', substr($output, 18));
}
return \sprintf('%s.', $output);
}
private function isSuccessful(): bool
{
if (null === $this->isSuccessful) {
$this->process->wait();
$this->isSuccessful = $this->process->isSuccessful();
}
return $this->isSuccessful;
}
}

View File

@@ -0,0 +1,58 @@
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Linter;
use PhpCsFixer\FileReader;
use PhpCsFixer\Hasher;
use PhpCsFixer\Tokenizer\Tokens;
/**
* Handle PHP code linting.
*
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* @readonly
*
* @internal
*/
final class TokenizerLinter implements LinterInterface
{
public function isAsync(): bool
{
return false;
}
public function lintFile(string $path): LintingResultInterface
{
return $this->lintSource(FileReader::createSingleton()->read($path));
}
public function lintSource(string $source): LintingResultInterface
{
try {
// To lint, we will parse the source into Tokens.
// During that process, it might throw a ParseError or CompileError.
// If it won't, cache of tokenized version of source will be kept, which is great for Runner.
// Yet, first we need to clear already existing cache to not hit it and lint the code indeed.
$codeHash = Hasher::calculate($source);
Tokens::clearCache($codeHash);
Tokens::fromCode($source);
return new TokenizerLintingResult();
} catch (\CompileError|\ParseError $e) {
return new TokenizerLintingResult($e);
}
}
}

View File

@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Linter;
/**
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* @readonly
*
* @internal
*/
final class TokenizerLintingResult implements LintingResultInterface
{
private ?\Error $error;
public function __construct(?\Error $error = null)
{
$this->error = $error;
}
public function check(): void
{
if (null !== $this->error) {
throw new LintingException(
\sprintf('%s: %s on line %d.', $this->getMessagePrefix(), $this->error->getMessage(), $this->error->getLine()),
$this->error->getCode(),
$this->error
);
}
}
private function getMessagePrefix(): string
{
return $this->error instanceof \ParseError ? 'Parse error' : 'Fatal error';
}
}

View File

@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace PhpCsFixer\Linter;
/**
* Exception that is thrown when the chosen linter is not available on the environment.
*
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* @final
*
* @TODO 4.0 make class "final"
*/
class UnavailableLinterException extends \RuntimeException {}