mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 10:07:12 +00:00
Apply more strict type checking
This commit is contained in:
@@ -44,7 +44,7 @@ class ExampleFinder
|
||||
$filename = $example->getFilePath();
|
||||
|
||||
$file = $this->getExampleFileContents($filename);
|
||||
if (!$file) {
|
||||
if ($file === null) {
|
||||
return sprintf('** File not found : %s **', $filename);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ class ExampleFinder
|
||||
}
|
||||
}
|
||||
|
||||
if (!$normalizedPath) {
|
||||
if ($normalizedPath === null) {
|
||||
if (is_readable($this->getExamplePathFromSource($filename))) {
|
||||
$normalizedPath = $this->getExamplePathFromSource($filename);
|
||||
} elseif (is_readable($this->getExamplePathFromExampleDirectory($filename))) {
|
||||
@@ -122,7 +122,7 @@ class ExampleFinder
|
||||
}
|
||||
}
|
||||
|
||||
$lines = $normalizedPath && is_readable($normalizedPath) ? file($normalizedPath) : false;
|
||||
$lines = $normalizedPath !== null && is_readable($normalizedPath) ? file($normalizedPath) : false;
|
||||
|
||||
return $lines !== false ? $lines : null;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class Serializer
|
||||
$indent = str_repeat($this->indentString, $this->indent);
|
||||
$firstIndent = $this->isFirstLineIndented ? $indent : '';
|
||||
// 3 === strlen(' * ')
|
||||
$wrapLength = $this->lineLength ? $this->lineLength - strlen($indent) - 3 : null;
|
||||
$wrapLength = $this->lineLength !== null ? $this->lineLength - strlen($indent) - 3 : null;
|
||||
|
||||
$text = $this->removeTrailingSpaces(
|
||||
$indent,
|
||||
|
||||
@@ -166,14 +166,14 @@ final class StandardTagFactory implements TagFactory
|
||||
|
||||
public function addService(object $service, ?string $alias = null): void
|
||||
{
|
||||
$this->serviceLocator[$alias ?: get_class($service)] = $service;
|
||||
$this->serviceLocator[$alias ?? get_class($service)] = $service;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function registerTagHandler(string $tagName, $handler): void
|
||||
{
|
||||
Assert::stringNotEmpty($tagName);
|
||||
if (strpos($tagName, '\\') && $tagName[0] !== '\\') {
|
||||
if (strpos($tagName, '\\') !== false && $tagName[0] !== '\\') {
|
||||
throw new InvalidArgumentException(
|
||||
'A namespaced tag must have a leading backslash as it must be fully qualified'
|
||||
);
|
||||
|
||||
@@ -62,7 +62,7 @@ final class Deprecated extends BaseTag implements Factory\StaticMethod
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): self {
|
||||
if (empty($body)) {
|
||||
if ($body === null || $body === '') {
|
||||
return new static();
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ final class Param extends TagWithType implements Factory\StaticMethod
|
||||
}
|
||||
|
||||
$variableName = '';
|
||||
if ($this->variableName) {
|
||||
if ($this->variableName !== null && $this->variableName !== '') {
|
||||
$variableName .= ($this->isReference ? '&' : '') . ($this->isVariadic ? '...' : '');
|
||||
$variableName .= '$' . $this->variableName;
|
||||
}
|
||||
|
||||
@@ -111,13 +111,13 @@ final class Property extends TagWithType implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
if ($this->description !== null) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
if ($this->variableName) {
|
||||
if ($this->variableName !== null && $this->variableName !== '') {
|
||||
$variableName = '$' . $this->variableName;
|
||||
} else {
|
||||
$variableName = '';
|
||||
|
||||
@@ -111,13 +111,13 @@ final class PropertyRead extends TagWithType implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
if ($this->description !== null) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
if ($this->variableName) {
|
||||
if ($this->variableName !== null && $this->variableName !== '') {
|
||||
$variableName = '$' . $this->variableName;
|
||||
} else {
|
||||
$variableName = '';
|
||||
|
||||
@@ -59,7 +59,7 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): ?self {
|
||||
if (empty($body)) {
|
||||
if ($body === null || $body === '') {
|
||||
return new static();
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ final class Since extends BaseTag implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
if ($this->description !== null) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
|
||||
@@ -111,13 +111,13 @@ final class Var_ extends TagWithType implements Factory\StaticMethod
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
if ($this->description) {
|
||||
if ($this->description !== null) {
|
||||
$description = $this->description->render();
|
||||
} else {
|
||||
$description = '';
|
||||
}
|
||||
|
||||
if ($this->variableName) {
|
||||
if ($this->variableName !== null && $this->variableName !== '') {
|
||||
$variableName = '$' . $this->variableName;
|
||||
} else {
|
||||
$variableName = '';
|
||||
|
||||
@@ -59,7 +59,7 @@ final class Version extends BaseTag implements Factory\StaticMethod
|
||||
?DescriptionFactory $descriptionFactory = null,
|
||||
?TypeContext $context = null
|
||||
): ?self {
|
||||
if (empty($body)) {
|
||||
if ($body === null || $body === '') {
|
||||
return new static();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user