Skip to content

Commit

Permalink
Adjusted handling of internal doc comment detection
Browse files Browse the repository at this point in the history
In BetterReflection v6, `#getDocComment()` returns `null` for missing docblocks.
  • Loading branch information
uzibhalepu authored and Ocramius committed Oct 10, 2022
1 parent 71361c3 commit 5082a4a
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 24 deletions.
5 changes: 3 additions & 2 deletions src/CompareClasses.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ private function examineSymbol(
yield from ($this->classBasedComparisons)($oldSymbol, $newClass);
}

private function isInternalDocComment(string $comment): bool
private function isInternalDocComment(string|null $comment): bool
{
return Regex\matches($comment, '/\s+@internal\s+/');
return $comment !== null
&& Regex\matches($comment, '/\s+@internal\s+/');
}
}
5 changes: 3 additions & 2 deletions src/DetectChanges/BCBreak/ClassBased/ClassBecameInternal.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ public function __invoke(ReflectionClass $fromClass, ReflectionClass $toClass):
return Changes::empty();
}

private function isInternalDocComment(string $comment): bool
private function isInternalDocComment(string|null $comment): bool
{
return Regex\matches($comment, '/\s+@internal\s+/');
return $comment !== null
&& Regex\matches($comment, '/\s+@internal\s+/');
}
}
5 changes: 3 additions & 2 deletions src/DetectChanges/BCBreak/ClassBased/ExcludeInternalClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public function __invoke(ReflectionClass $fromClass, ReflectionClass $toClass):
return ($this->check)($fromClass, $toClass);
}

private function isInternalDocComment(string $comment): bool
private function isInternalDocComment(string|null $comment): bool
{
return Regex\matches($comment, '/\s+@internal\s+/');
return $comment !== null
&& Regex\matches($comment, '/\s+@internal\s+/');
}
}
5 changes: 3 additions & 2 deletions src/DetectChanges/BCBreak/ClassBased/MethodRemoved.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ private function accessibleMethods(ReflectionClass $class): array
);
}

private function isInternalDocComment(string $comment): bool
private function isInternalDocComment(string|null $comment): bool
{
return Regex\matches($comment, '/\s+@internal\s+/');
return $comment !== null
&& Regex\matches($comment, '/\s+@internal\s+/');
}
}
5 changes: 3 additions & 2 deletions src/DetectChanges/BCBreak/ClassBased/PropertyRemoved.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ private function accessibleProperties(ReflectionClass $class): array
});
}

private function isInternalDocComment(string $comment): bool
private function isInternalDocComment(string|null $comment): bool
{
return Regex\matches($comment, '/\s+@internal\s+/');
return $comment !== null
&& Regex\matches($comment, '/\s+@internal\s+/');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public function __invoke(
return ($this->check)($fromFunction, $toFunction);
}

private function isInternalDocComment(string $comment): bool
private function isInternalDocComment(string|null $comment): bool
{
return Regex\matches($comment, '/\s+@internal\s+/');
return $comment !== null
&& Regex\matches($comment, '/\s+@internal\s+/');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public function __invoke(
return Changes::empty();
}

private function isInternalDocComment(string $comment): bool
private function isInternalDocComment(string|null $comment): bool
{
return Regex\matches($comment, '/\s+@internal\s+/');
return $comment !== null
&& Regex\matches($comment, '/\s+@internal\s+/');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public function __invoke(ReflectionClass $fromInterface, ReflectionClass $toInte
return ($this->check)($fromInterface, $toInterface);
}

private function isInternalDocComment(string $comment): bool
private function isInternalDocComment(string|null $comment): bool
{
return Regex\matches($comment, '/\s+@internal\s+/');
return $comment !== null
&& Regex\matches($comment, '/\s+@internal\s+/');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public function __invoke(ReflectionMethod $fromMethod, ReflectionMethod $toMetho
return ($this->check)($fromMethod, $toMethod);
}

private function isInternalDocComment(string $comment): bool
private function isInternalDocComment(string|null $comment): bool
{
return Regex\matches($comment, '/\s+@internal\s+/');
return $comment !== null
&& Regex\matches($comment, '/\s+@internal\s+/');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ public function __invoke(ReflectionProperty $fromProperty, ReflectionProperty $t
return ($this->propertyBased)($fromProperty, $toProperty);
}

private function isInternalDocComment(string $comment): bool
private function isInternalDocComment(string|null $comment): bool
{
return Regex\matches($comment, '/\s+@internal\s+/');
return $comment !== null
&& Regex\matches($comment, '/\s+@internal\s+/');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ public function __invoke(ReflectionProperty $fromProperty, ReflectionProperty $t
return Changes::empty();
}

private function isInternalDocComment(string $comment): bool
private function isInternalDocComment(string|null $comment): bool
{
return Regex\matches($comment, '/\s+@internal\s+/');
return $comment !== null
&& Regex\matches($comment, '/\s+@internal\s+/');
}
}
5 changes: 3 additions & 2 deletions src/DetectChanges/BCBreak/TraitBased/ExcludeInternalTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public function __invoke(ReflectionClass $fromTrait, ReflectionClass $toTrait):
return ($this->check)($fromTrait, $toTrait);
}

private function isInternalDocComment(string $comment): bool
private function isInternalDocComment(string|null $comment): bool
{
return Regex\matches($comment, '/\s+@internal\s+/');
return $comment !== null
&& Regex\matches($comment, '/\s+@internal\s+/');
}
}

0 comments on commit 5082a4a

Please sign in to comment.