Skip to content

Commit

Permalink
Merge pull request #13 from jkowalleck/php-cs-fixer3_risky
Browse files Browse the repository at this point in the history
applied php-cs-fixer "@symfony:risky"
  • Loading branch information
stevespringett authored May 13, 2021
2 parents 211c341 + 83a51d4 commit 3f35e3f
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 16 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
->setRules([
'@PHP73Migration' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'declare_strict_types' => true,
'phpdoc_order' => true,
'header_comment' => ['header' => $header],
Expand Down
15 changes: 15 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changes

## 1.0.2

Maintenance release:
* Misc
* Applied QA tool `php-cs-fixer` rule `@Symfony:risky`.

## 1.0.1

Maintenance release:
* Docs
* Upgraded install instructions in the `README.md`.
* Misc
* Upgraded the internally used QA tools in development processes,
Update `php-cs-fixer` to v3.

## 1.0.0

* First implementation
6 changes: 3 additions & 3 deletions src/BuildParseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private function isNotEmpty(string $data): bool
*/
private function isUsefulSubpathSegment(string $segment): bool
{
return false === in_array($segment, ['', '.', '..'], true);
return false === \in_array($segment, ['', '.', '..'], true);
}

/**
Expand All @@ -62,7 +62,7 @@ private function getNormalizerForNamespace(?string $type): Closure
if (null !== $type) {
$type = strtolower($type);
}
if (in_array($type, ['bitbucket', 'deb', 'github', 'golang', 'hex', 'rpm'], true)) {
if (\in_array($type, ['bitbucket', 'deb', 'github', 'golang', 'hex', 'rpm'], true)) {
return static function (string $data): string {
return strtolower($data);
};
Expand Down Expand Up @@ -92,7 +92,7 @@ private function normalizeNameForType(string $name, ?string $type): string
$name = str_replace('_', '-', $name);
}

if (in_array($type, ['bitbucket', 'deb', 'github', 'golang', 'hex', 'npm', 'pypi'], true)) {
if (\in_array($type, ['bitbucket', 'deb', 'github', 'golang', 'hex', 'npm', 'pypi'], true)) {
$name = strtolower($name);
}

Expand Down
2 changes: 1 addition & 1 deletion src/PackageUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function getQualifiers(): ?array
*/
public function setQualifiers(?array $qualifiers): self
{
if ($qualifiers && array_key_exists(self::CHECKSUM_QUALIFIER, $qualifiers)) {
if ($qualifiers && \array_key_exists(self::CHECKSUM_QUALIFIER, $qualifiers)) {
throw new DomainException('Checksums must not be part of the qualifiers. Use setChecksums().');
}
$this->qualifiers = $qualifiers;
Expand Down
10 changes: 5 additions & 5 deletions src/PackageUrlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function normalizeQualifiers(?array $data): ?string

$segments = [];

$data = array_change_key_case($data, CASE_LOWER);
$data = array_change_key_case($data, \CASE_LOWER);

$checksum = $this->normalizeChecksum($data[PackageUrl::CHECKSUM_QUALIFIER] ?? null);
unset($data[PackageUrl::CHECKSUM_QUALIFIER]);
Expand All @@ -190,7 +190,7 @@ public function normalizeQualifiers(?array $data): ?string
$segments[] = PackageUrl::CHECKSUM_QUALIFIER.'='.$checksum;
}

sort($segments, SORT_STRING);
sort($segments, \SORT_STRING);
$qualifiers = implode('&', $segments);

return '' === $qualifiers
Expand All @@ -207,9 +207,9 @@ private function normalizeChecksum($data): ?string
if (null === $data) {
return null;
}
if (is_string($data)) {
if (\is_string($data)) {
$data = explode(',', $data);
} elseif (!is_array($data)) {
} elseif (!\is_array($data)) {
return null;
}

Expand Down Expand Up @@ -276,7 +276,7 @@ private function encode(string $data): string
rawurlencode($data),
self::RAWURLENCODE_REVERT
);
assert('' !== $encoded);
\assert('' !== $encoded);

return $encoded;
}
Expand Down
2 changes: 1 addition & 1 deletion src/PackageUrlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public function normalizeQualifiers(?string $data): array
continue;
}
$key = strtolower(substr($dataKeyValue, 0, $eqPos));
assert('' !== $key);
\assert('' !== $key);
$qualifiers[$key] = $value;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/PackageUrlBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PackageUrlBuilderTest extends TestCase
/** @var PackageUrlBuilder */
private $sut;

public function setUp(): void
protected function setUp(): void
{
$this->sut = new PackageUrlBuilder();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/PackageUrlParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PackageUrlParserTest extends TestCase
/** @var PackageUrlParser */
private $sut;

public function setUp(): void
protected function setUp(): void
{
$this->sut = new PackageUrlParser();
}
Expand Down
6 changes: 3 additions & 3 deletions tests/PackageUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class PackageUrlTest extends TestCase
/** @var PackageUrl */
private $sut;

public function setUp(): void
protected function setUp(): void
{
$randomString = bin2hex(random_bytes(255));
$this->sut = (new PackageUrl($randomString, $randomString))
Expand Down Expand Up @@ -282,7 +282,7 @@ public function testFromString(): void
// act
$purl = $this->sut::fromString($purlString, $parser);
// assert
self::assertInstanceOf(get_class($this->sut), $purl);
self::assertInstanceOf(\get_class($this->sut), $purl);
self::assertEquals($purlNormalized['type'], $purl->getType());
self::assertEquals($purlNormalized['namespace'], $purl->getNamespace());
self::assertEquals($purlNormalized['name'], $purl->getName());
Expand Down Expand Up @@ -311,7 +311,7 @@ private static function parsedToNulls(): array
public function testAsString(): void
{
$expected = bin2hex(random_bytes(32));
$sut = $this->createPartialMock(get_class($this->sut), ['toString']);
$sut = $this->createPartialMock(\get_class($this->sut), ['toString']);
$sut->expects(self::once())->method('toString')->willReturn($expected);
$toString = (string) $sut;
self::assertEquals($expected, $toString);
Expand Down
2 changes: 1 addition & 1 deletion tests/_data/TestSuiteData.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ abstract class TestSuiteData
*/
public static function data(): Generator
{
$testSuite = json_decode(file_get_contents(__DIR__.'/../_examples/test-suite-data.json'), true, 521, JSON_THROW_ON_ERROR);
$testSuite = json_decode(file_get_contents(__DIR__.'/../_examples/test-suite-data.json'), true, 521, \JSON_THROW_ON_ERROR);
foreach ($testSuite as $data) {
yield $data['description'] => [$data];
}
Expand Down

0 comments on commit 3f35e3f

Please sign in to comment.