Apply more strict type checking

This commit is contained in:
Jaapio
2024-11-03 21:54:10 +01:00
parent db271d6f57
commit f985773245
11 changed files with 18 additions and 18 deletions
+3 -3
View File
@@ -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;
}
+1 -1
View File
@@ -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,
+2 -2
View File
@@ -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'
);
+1 -1
View File
@@ -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();
}
+1 -1
View File
@@ -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;
}
+2 -2
View File
@@ -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 = '';
+2 -2
View File
@@ -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 = '';
+2 -2
View File
@@ -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 = '';
+2 -2
View File
@@ -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 = '';
+1 -1
View File
@@ -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();
}