diff --git a/src/Signature/TraitUseIdentity.php b/src/Signature/TraitUseIdentity.php index 667dbfe..ba84abc 100644 --- a/src/Signature/TraitUseIdentity.php +++ b/src/Signature/TraitUseIdentity.php @@ -82,6 +82,15 @@ public function equals(IdentityKey $other): bool { * @return IdentityKey[] */ private function getNormalisedTraits(): array { + if ($this->kind === 'use') { + $traits = $this->traits; + usort($traits, function (IdentityKey $left, IdentityKey $right): int { + return strcmp($left->toIdentityKey(), $right->toIdentityKey()); + }); + + return $traits; + } + if ($this->kind !== 'precedence' || count($this->traits) <= 2) { return $this->traits; } diff --git a/tests/run.php b/tests/run.php index 8c19cf7..1ae1a0d 100644 --- a/tests/run.php +++ b/tests/run.php @@ -959,6 +959,100 @@ class Worker implements RenamedContract {} assertSameValue('Renaming an implemented contract alias without changing its target should remain PATCH.', 'PATCH', $diff->diff('HEAD', 'WC')->getIncrement()); } +function testExtendedParentAliasRenamingDoesNotBumpVersion(): void { + $root = createRepository('extends-alias-rename-equivalence', [ + 'src/Child.php' => <<<'PHP' +diff('HEAD', 'WC')->getIncrement()); +} + +function testGroupedAndUngroupedContractImportsRemainEquivalent(): void { + $root = createRepository('grouped-contract-import-equivalence', [ + 'src/Worker.php' => <<<'PHP' +diff('HEAD', 'WC')->getIncrement()); +} + +function testTraitUseOrderingDoesNotBumpVersion(): void { + $root = createRepository('trait-use-ordering', [ + 'src/Worker.php' => <<<'PHP' +diff('HEAD', 'WC')->getIncrement()); +} + +function testSplitAndGroupedNamespaceConstantDeclarationsRemainEquivalent(): void { + $root = createRepository('namespace-constant-declaration-shape', [ + 'src/Constants.php' => <<<'PHP' +diff('HEAD', 'WC')->getIncrement()); +} + function testIncludePathsRestrictTheSurface(): void { $root = createRepository('include-paths', [ 'src/Foo.php' => "