Missing dependancies
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?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\FixerDefinition;
|
||||
|
||||
/**
|
||||
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
|
||||
*/
|
||||
final class CodeSample implements CodeSampleInterface
|
||||
{
|
||||
private string $code;
|
||||
|
||||
/**
|
||||
* @var null|array<string, mixed>
|
||||
*/
|
||||
private ?array $configuration;
|
||||
|
||||
/**
|
||||
* @param null|array<string, mixed> $configuration
|
||||
*/
|
||||
public function __construct(string $code, ?array $configuration = null)
|
||||
{
|
||||
$this->code = $code;
|
||||
$this->configuration = $configuration;
|
||||
}
|
||||
|
||||
public function getCode(): string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function getConfiguration(): ?array
|
||||
{
|
||||
return $this->configuration;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?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\FixerDefinition;
|
||||
|
||||
/**
|
||||
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
|
||||
*/
|
||||
interface CodeSampleInterface
|
||||
{
|
||||
public function getCode(): string;
|
||||
|
||||
/**
|
||||
* @return null|array<string, mixed>
|
||||
*/
|
||||
public function getConfiguration(): ?array;
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
<?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\FixerDefinition;
|
||||
|
||||
/**
|
||||
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class FileSpecificCodeSample implements FileSpecificCodeSampleInterface
|
||||
{
|
||||
private CodeSampleInterface $codeSample;
|
||||
|
||||
private \SplFileInfo $splFileInfo;
|
||||
|
||||
/**
|
||||
* @param null|array<string, mixed> $configuration
|
||||
*/
|
||||
public function __construct(
|
||||
string $code,
|
||||
\SplFileInfo $splFileInfo,
|
||||
?array $configuration = null
|
||||
) {
|
||||
$this->codeSample = new CodeSample($code, $configuration);
|
||||
$this->splFileInfo = $splFileInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCode(): string
|
||||
{
|
||||
return $this->codeSample->getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfiguration(): ?array
|
||||
{
|
||||
return $this->codeSample->getConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSplFileInfo(): \SplFileInfo
|
||||
{
|
||||
return $this->splFileInfo;
|
||||
}
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
<?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\FixerDefinition;
|
||||
|
||||
/**
|
||||
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
interface FileSpecificCodeSampleInterface extends CodeSampleInterface
|
||||
{
|
||||
public function getSplFileInfo(): \SplFileInfo;
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
<?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\FixerDefinition;
|
||||
|
||||
/**
|
||||
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
|
||||
*/
|
||||
final class FixerDefinition implements FixerDefinitionInterface
|
||||
{
|
||||
private string $summary;
|
||||
|
||||
/**
|
||||
* @var list<CodeSampleInterface>
|
||||
*/
|
||||
private array $codeSamples;
|
||||
|
||||
private ?string $description;
|
||||
|
||||
private ?string $riskyDescription;
|
||||
|
||||
/**
|
||||
* @param list<CodeSampleInterface> $codeSamples array of samples, where single sample is [code, configuration]
|
||||
* @param null|string $riskyDescription null for non-risky fixer
|
||||
*/
|
||||
public function __construct(
|
||||
string $summary,
|
||||
array $codeSamples,
|
||||
?string $description = null,
|
||||
?string $riskyDescription = null
|
||||
) {
|
||||
$this->summary = $summary;
|
||||
$this->codeSamples = $codeSamples;
|
||||
$this->description = $description;
|
||||
$this->riskyDescription = $riskyDescription;
|
||||
}
|
||||
|
||||
public function getSummary(): string
|
||||
{
|
||||
return $this->summary;
|
||||
}
|
||||
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function getRiskyDescription(): ?string
|
||||
{
|
||||
return $this->riskyDescription;
|
||||
}
|
||||
|
||||
public function getCodeSamples(): array
|
||||
{
|
||||
return $this->codeSamples;
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<?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\FixerDefinition;
|
||||
|
||||
/**
|
||||
* @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
|
||||
*/
|
||||
interface FixerDefinitionInterface
|
||||
{
|
||||
public function getSummary(): string;
|
||||
|
||||
public function getDescription(): ?string;
|
||||
|
||||
/**
|
||||
* @return null|string null for non-risky fixer
|
||||
*/
|
||||
public function getRiskyDescription(): ?string;
|
||||
|
||||
/**
|
||||
* Array of samples, where single sample is [code, configuration].
|
||||
*
|
||||
* @return list<CodeSampleInterface>
|
||||
*/
|
||||
public function getCodeSamples(): array;
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
<?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\FixerDefinition;
|
||||
|
||||
/**
|
||||
* @author Andreas Möller <am@localheinz.com>
|
||||
*/
|
||||
final class VersionSpecificCodeSample implements VersionSpecificCodeSampleInterface
|
||||
{
|
||||
private CodeSampleInterface $codeSample;
|
||||
|
||||
private VersionSpecificationInterface $versionSpecification;
|
||||
|
||||
/**
|
||||
* @param null|array<string, mixed> $configuration
|
||||
*/
|
||||
public function __construct(
|
||||
string $code,
|
||||
VersionSpecificationInterface $versionSpecification,
|
||||
?array $configuration = null
|
||||
) {
|
||||
$this->codeSample = new CodeSample($code, $configuration);
|
||||
$this->versionSpecification = $versionSpecification;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCode(): string
|
||||
{
|
||||
return $this->codeSample->getCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfiguration(): ?array
|
||||
{
|
||||
return $this->codeSample->getConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isSuitableFor(int $version): bool
|
||||
{
|
||||
return $this->versionSpecification->isSatisfiedBy($version);
|
||||
}
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
<?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\FixerDefinition;
|
||||
|
||||
/**
|
||||
* @author Andreas Moeller <am@localheinz.com>
|
||||
*/
|
||||
interface VersionSpecificCodeSampleInterface extends CodeSampleInterface
|
||||
{
|
||||
public function isSuitableFor(int $version): bool;
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
<?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\FixerDefinition;
|
||||
|
||||
/**
|
||||
* @author Andreas Möller <am@localheinz.com>
|
||||
*/
|
||||
final class VersionSpecification implements VersionSpecificationInterface
|
||||
{
|
||||
/**
|
||||
* @var null|int<1, max>
|
||||
*/
|
||||
private ?int $minimum;
|
||||
|
||||
/**
|
||||
* @var null|int<1, max>
|
||||
*/
|
||||
private ?int $maximum;
|
||||
|
||||
/**
|
||||
* @param null|int<1, max> $minimum
|
||||
* @param null|int<1, max> $maximum
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(?int $minimum = null, ?int $maximum = null)
|
||||
{
|
||||
if (null === $minimum && null === $maximum) {
|
||||
throw new \InvalidArgumentException('Minimum or maximum need to be specified.');
|
||||
}
|
||||
|
||||
// @phpstan-ignore-next-line
|
||||
if (null !== $minimum && 1 > $minimum) {
|
||||
throw new \InvalidArgumentException('Minimum needs to be either null or an integer greater than 0.');
|
||||
}
|
||||
|
||||
if (null !== $maximum) {
|
||||
// @phpstan-ignore-next-line
|
||||
if (1 > $maximum) {
|
||||
throw new \InvalidArgumentException('Maximum needs to be either null or an integer greater than 0.');
|
||||
}
|
||||
|
||||
if (null !== $minimum && $maximum < $minimum) {
|
||||
throw new \InvalidArgumentException('Maximum should not be lower than the minimum.');
|
||||
}
|
||||
}
|
||||
|
||||
$this->minimum = $minimum;
|
||||
$this->maximum = $maximum;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isSatisfiedBy(int $version): bool
|
||||
{
|
||||
if (null !== $this->minimum && $version < $this->minimum) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (null !== $this->maximum && $version > $this->maximum) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
<?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\FixerDefinition;
|
||||
|
||||
/**
|
||||
* @author Andreas Möller <am@localheinz.com>
|
||||
*/
|
||||
interface VersionSpecificationInterface
|
||||
{
|
||||
public function isSatisfiedBy(int $version): bool;
|
||||
}
|
||||
Reference in New Issue
Block a user