Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Handle empty namespace prefixes #30

Merged
merged 2 commits into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ the LICENSE file that was distributed with this source code.
@see https://github.com/localheinz/composer-normalize
EOF;

$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php70($header));
$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php71($header));

$config->getFinder()->in(__DIR__);

Expand Down
22 changes: 2 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
include:
- stage: Style

php: 7.0
php: 7.1

before_install:
- source .travis/xdebug.sh
Expand All @@ -40,7 +40,7 @@ jobs:

stage: Test

php: 7.0
php: 7.1

env: WITH_LOWEST=true

Expand All @@ -63,24 +63,6 @@ jobs:
after_success:
- if [[ "$WITH_COVERAGE" == "true" ]]; then bash <(curl -s https://codecov.io/bash); fi

- <<: *TEST

php: 7.0

env: WITH_LOCKED=true

- <<: *TEST

php: 7.0

env: WITH_HIGHEST=true

- <<: *TEST

php: 7.1

env: WITH_LOWEST=true

- <<: *TEST

php: 7.1
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"require": {
"php": "^7.0",
"php": "^7.1",
"composer-plugin-api": "^1.1.0",
"localheinz/json-normalizer": "0.2.0"
},
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

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

2 changes: 1 addition & 1 deletion src/Command/NormalizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(Normalizer\NormalizerInterface $normalizer)
$this->normalizer = $normalizer;
}

protected function configure()
protected function configure(): void
{
$this->setDescription('Normalizes composer.json according to its JSON schema (https://getcomposer.org/schema.json).');
$this->setDefinition([
Expand Down
2 changes: 1 addition & 1 deletion src/Normalizer/VersionConstraintNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private function normalizeVersionConstraint(string $versionConstraint): string
{
$normalized = $versionConstraint;

foreach (self::$map as list($pattern, $glue)) {
foreach (self::$map as [$pattern, $glue]) {
$split = \preg_split(
$pattern,
$normalized
Expand Down
32 changes: 16 additions & 16 deletions test/Unit/Command/NormalizeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ protected function tearDown()
$this->clearComposerFile();
}

public function testExtendsBaseCommand()
public function testExtendsBaseCommand(): void
{
$this->assertClassExtends(Command\BaseCommand::class, NormalizeCommand::class);
}

public function testHasNameAndDescription()
public function testHasNameAndDescription(): void
{
$command = new NormalizeCommand($this->prophesize(Normalizer\NormalizerInterface::class)->reveal());

$this->assertSame('normalize', $command->getName());
$this->assertSame('Normalizes composer.json according to its JSON schema (https://getcomposer.org/schema.json).', $command->getDescription());
}

public function testHasNoArguments()
public function testHasNoArguments(): void
{
$command = new NormalizeCommand($this->prophesize(Normalizer\NormalizerInterface::class)->reveal());

Expand All @@ -68,7 +68,7 @@ public function testHasNoArguments()
$this->assertCount(0, $definition->getArguments());
}

public function testHasNoUpdateLockOption()
public function testHasNoUpdateLockOption(): void
{
$command = new NormalizeCommand($this->prophesize(Normalizer\NormalizerInterface::class)->reveal());

Expand All @@ -84,7 +84,7 @@ public function testHasNoUpdateLockOption()
$this->assertSame('Do not update lock file if it exists', $option->getDescription());
}

public function testExecuteFailsIfComposerFileDoesNotExist()
public function testExecuteFailsIfComposerFileDoesNotExist(): void
{
$composerFile = $this->pathToNonExistentComposerFile();

Expand All @@ -109,7 +109,7 @@ public function testExecuteFailsIfComposerFileDoesNotExist()
$this->assertFileNotExists($composerFile);
}

public function testExecuteFailsIfComposerFileIsNotReadable()
public function testExecuteFailsIfComposerFileIsNotReadable(): void
{
$original = $this->composerFileContent();

Expand Down Expand Up @@ -141,7 +141,7 @@ public function testExecuteFailsIfComposerFileIsNotReadable()
$this->assertStringEqualsFile($composerFile, $original);
}

public function testExecuteFailsIfComposerFileIsNotWritable()
public function testExecuteFailsIfComposerFileIsNotWritable(): void
{
$original = $this->composerFileContent();

Expand Down Expand Up @@ -173,7 +173,7 @@ public function testExecuteFailsIfComposerFileIsNotWritable()
$this->assertStringEqualsFile($composerFile, $original);
}

public function testExecuteFailsIfLockerIsLockedButNotFresh()
public function testExecuteFailsIfLockerIsLockedButNotFresh(): void
{
$original = $this->composerFileContent();

Expand Down Expand Up @@ -218,7 +218,7 @@ public function testExecuteFailsIfLockerIsLockedButNotFresh()
$this->assertStringEqualsFile($composerFile, $original);
}

public function testExecuteFailsIfNormalizerThrowsInvalidArgumentException()
public function testExecuteFailsIfNormalizerThrowsInvalidArgumentException(): void
{
$faker = $this->faker();

Expand Down Expand Up @@ -305,7 +305,7 @@ public function testExecuteFailsIfNormalizerThrowsInvalidArgumentException()
$this->assertStringEqualsFile($composerFile, $original);
}

public function testExecuteFailsIfNormalizerThrowsRuntimeException()
public function testExecuteFailsIfNormalizerThrowsRuntimeException(): void
{
$exception = new \RuntimeException($this->faker()->sentence);

Expand Down Expand Up @@ -362,7 +362,7 @@ public function testExecuteFailsIfNormalizerThrowsRuntimeException()
$this->assertStringEqualsFile($composerFile, $original);
}

public function testExecuteSucceedsIfLockerIsNotLockedAndComposerFileIsAlreadyNormalized()
public function testExecuteSucceedsIfLockerIsNotLockedAndComposerFileIsAlreadyNormalized(): void
{
$original = $this->composerFileContent();

Expand Down Expand Up @@ -412,7 +412,7 @@ public function testExecuteSucceedsIfLockerIsNotLockedAndComposerFileIsAlreadyNo
$this->assertStringEqualsFile($composerFile, $original);
}

public function testExecuteSucceedsIfLockerIsLockedAndFreshButComposerFileIsAlreadyNormalized()
public function testExecuteSucceedsIfLockerIsLockedAndFreshButComposerFileIsAlreadyNormalized(): void
{
$original = $this->composerFileContent();

Expand Down Expand Up @@ -467,7 +467,7 @@ public function testExecuteSucceedsIfLockerIsLockedAndFreshButComposerFileIsAlre
$this->assertStringEqualsFile($composerFile, $original);
}

public function testExecuteSucceedsIfLockerIsNotLockedAndComposerFileWasNormalizedSuccessfully()
public function testExecuteSucceedsIfLockerIsNotLockedAndComposerFileWasNormalizedSuccessfully(): void
{
$original = $this->composerFileContent();

Expand Down Expand Up @@ -522,7 +522,7 @@ public function testExecuteSucceedsIfLockerIsNotLockedAndComposerFileWasNormaliz
$this->assertStringEqualsFile($composerFile, $normalized);
}

public function testExecuteSucceedsIfLockerIsLockedAndLockerCouldBeUpdatedAfterNormalization()
public function testExecuteSucceedsIfLockerIsLockedAndLockerCouldBeUpdatedAfterNormalization(): void
{
$original = $this->composerFileContent();

Expand Down Expand Up @@ -612,7 +612,7 @@ public function testExecuteSucceedsIfLockerIsLockedAndLockerCouldBeUpdatedAfterN
$this->assertStringEqualsFile($composerFile, $normalized);
}

public function testExecuteSucceedsIfLockerIsLockedButSkipsUpdatingLockerIfNoUpdateLockOptionIsUsed()
public function testExecuteSucceedsIfLockerIsLockedButSkipsUpdatingLockerIfNoUpdateLockOptionIsUsed(): void
{
$original = $this->composerFileContent();

Expand Down Expand Up @@ -760,7 +760,7 @@ private function useComposerFile(string $composerFile)
/**
* @see Factory::getComposerFile()
*/
private function clearComposerFile()
private function clearComposerFile(): void
{
\putenv('COMPOSER');
}
Expand Down
4 changes: 2 additions & 2 deletions test/Unit/NormalizePluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function providerInterfaceName(): \Generator
}
}

public function testGetCapabilitiesReturnsCapabilities()
public function testGetCapabilitiesReturnsCapabilities(): void
{
$plugin = new NormalizePlugin();

Expand All @@ -67,7 +67,7 @@ public function testGetCapabilitiesReturnsCapabilities()
$this->assertSame($expected, $plugin->getCapabilities());
}

public function testProvidesNormalizeCommand()
public function testProvidesNormalizeCommand(): void
{
$plugin = new NormalizePlugin();

Expand Down
4 changes: 2 additions & 2 deletions test/Unit/Normalizer/AbstractNormalizerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ abstract class AbstractNormalizerTestCase extends Framework\TestCase
{
use Helper;

final public function testImplementsNormalizerInterface()
final public function testImplementsNormalizerInterface(): void
{
$this->assertClassImplementsInterface(NormalizerInterface::class, $this->className());
}

final public function testNormalizeRejectsInvalidJson()
final public function testNormalizeRejectsInvalidJson(): void
{
$json = $this->faker()->realText();

Expand Down
6 changes: 3 additions & 3 deletions test/Unit/Normalizer/BinNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

final class BinNormalizerTest extends AbstractNormalizerTestCase
{
public function testNormalizeDoesNotModifyOtherProperty()
public function testNormalizeDoesNotModifyOtherProperty(): void
{
$json = <<<'JSON'
{
Expand All @@ -33,7 +33,7 @@ public function testNormalizeDoesNotModifyOtherProperty()
$this->assertSame($json, $normalizer->normalize($json));
}

public function testNormalizeDoesNotModifyBinIfPropertyExistsAsString()
public function testNormalizeDoesNotModifyBinIfPropertyExistsAsString(): void
{
$json = <<<'JSON'
{
Expand All @@ -50,7 +50,7 @@ public function testNormalizeDoesNotModifyBinIfPropertyExistsAsString()
$this->assertSame($json, $normalizer->normalize($json));
}

public function testNormalizeSortsBinIfPropertyExistsAsArray()
public function testNormalizeSortsBinIfPropertyExistsAsArray(): void
{
$json = <<<'JSON'
{
Expand Down
10 changes: 6 additions & 4 deletions test/Unit/Normalizer/ComposerJsonNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

final class ComposerJsonNormalizerTest extends AbstractNormalizerTestCase
{
public function testComposesNormalizers()
public function testComposesNormalizers(): void
{
$normalizer = new ComposerJsonNormalizer();

Expand Down Expand Up @@ -55,7 +55,7 @@ public function testComposesNormalizers()
$this->assertAttributeSame('https://getcomposer.org/schema.json', 'schemaUri', $schemaNormalizer);
}

public function testNormalizeNormalizes()
public function testNormalizeNormalizes(): void
{
$json = <<<'JSON'
{
Expand Down Expand Up @@ -90,6 +90,7 @@ public function testNormalizeNormalizes()
},
"autoload": {
"psr-4": {
"": "/foo",
"Helmut\\Foo\\Bar\\": "src/"
}
},
Expand Down Expand Up @@ -147,6 +148,7 @@ public function testNormalizeNormalizes()
},
"autoload": {
"psr-4": {
"": "/foo",
"Helmut\\Foo\\Bar\\": "src/"
}
},
Expand Down Expand Up @@ -179,7 +181,7 @@ public function testNormalizeNormalizes()
$this->assertSame($normalized, $normalizer->normalize($json));
}

private function assertComposesNormalizer(string $className, NormalizerInterface $normalizer)
private function assertComposesNormalizer(string $className, NormalizerInterface $normalizer): void
{
$this->assertClassExists($className);
$this->assertClassImplementsInterface(NormalizerInterface::class, $className);
Expand All @@ -199,7 +201,7 @@ private function assertComposesNormalizer(string $className, NormalizerInterface
));
}

private function assertComposesNormalizers(array $classNames, NormalizerInterface $normalizer)
private function assertComposesNormalizers(array $classNames, NormalizerInterface $normalizer): void
{
foreach ($classNames as $className) {
$this->assertClassExists($className);
Expand Down
6 changes: 3 additions & 3 deletions test/Unit/Normalizer/ConfigHashNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

final class ConfigHashNormalizerTest extends AbstractNormalizerTestCase
{
public function testNormalizeDoesNotModifyOtherProperty()
public function testNormalizeDoesNotModifyOtherProperty(): void
{
$json = <<<'JSON'
{
Expand All @@ -33,7 +33,7 @@ public function testNormalizeDoesNotModifyOtherProperty()
$this->assertSame($json, $normalizer->normalize($json));
}

public function testNormalizeIgnoresEmptyConfigHash()
public function testNormalizeIgnoresEmptyConfigHash(): void
{
$json = <<<'JSON'
{
Expand All @@ -46,7 +46,7 @@ public function testNormalizeIgnoresEmptyConfigHash()
$this->assertSame($json, $normalizer->normalize($json));
}

public function testNormalizeSortsConfigHashIfPropertyExists()
public function testNormalizeSortsConfigHashIfPropertyExists(): void
{
$json = <<<'JSON'
{
Expand Down
Loading