Merge "A few tiny code cleanups in the ReferenceStack class"

This commit is contained in:
jenkins-bot 2024-06-07 03:06:56 +00:00 committed by Gerrit Code Review
commit 0dedffacd3

View file

@ -242,7 +242,7 @@ class ReferenceStack {
if ( $lookup === null ) {
// Find anonymous ref by key.
foreach ( $this->refs[$group] as $k => $v ) {
if ( $this->refs[$group][$k]->key === $key ) {
if ( $v->key === $key ) {
$lookup = $k;
break;
}
@ -310,13 +310,11 @@ class ReferenceStack {
* Returns true if the group exists and contains references.
*/
public function hasGroup( string $group ): bool {
return isset( $this->refs[$group] ) && $this->refs[$group];
return (bool)( $this->refs[$group] ?? false );
}
/**
* Returns a list of all groups with references.
*
* @return string[]
* @return string[] List of group names that contain at least one reference
*/
public function getGroups(): array {
$groups = [];
@ -357,7 +355,7 @@ class ReferenceStack {
}
}
private function nextRefSequence() {
private function nextRefSequence(): int {
return ++$this->refSequence;
}