Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ parameters:
paths:
- src
ignoreErrors:
# A PHPStan release that knows no PHP 8.6 (phpVersion.max capped at 80599) folds the runtime
# check guarding the 8.6-specific boolean rendering to "always false"; newer releases know 8.6
# and report nothing, hence reportUnmatched is disabled for these two entries. The code path is
# exercised by the experimental PHP 8.6 CI job.
- identifier: greaterOrEqual.alwaysFalse
path: src/ReflectionClassConstant.php
reportUnmatched: false
- identifier: booleanAnd.alwaysFalse
path: src/ReflectionClassConstant.php
reportUnmatched: false
# Both classes are final, so "might have hooks in a subclass" is a false positive
- identifier: unset.possiblyHookedProperty
path: src/ReflectionFunction.php
Expand Down
12 changes: 11 additions & 1 deletion src/ReflectionClassConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,22 @@ public function __toString(): string
$docComment = $this->getDocComment();
$prefix = $docComment !== false ? $docComment . "\n" : '';

// Since PHP 8.6 the native reflection prints boolean values as "true"/"false" instead of
// the string cast "1"/"" used before
if (is_bool($value) && PHP_VERSION_ID >= 80600) {
$displayValue = $value ? 'true' : 'false';
} elseif (is_object($value)) {
$displayValue = 'Object';
} else {
$displayValue = is_scalar($value) || $value === null ? (string) $value : '';
}

return $prefix . sprintf(
"Constant [ %s %s %s ] { %s }\n",
implode(' ', Reflection::getModifierNames($this->getModifiers())),
ReflectionType::convertToDisplayType($valueType),
$this->getName(),
is_object($value) ? 'Object' : (is_scalar($value) || $value === null ? $value : '')
$displayValue
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/ReflectionParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ final class ReflectionParameter extends BaseReflectionParameter implements NodeA
*
* @see $isDefaultValueConstant
*/
private ?string $defaultValueConstantName;
private ?string $defaultValueConstantName = null;

/**
* Index of parameter in the list
Expand All @@ -77,9 +77,9 @@ final class ReflectionParameter extends BaseReflectionParameter implements NodeA
*/
private Param $parameterNode;

private bool $isDefaultValueConstExpr;
private bool $isDefaultValueConstExpr = false;

private ?string $defaultValueConstExpr;
private ?string $defaultValueConstExpr = null;

private \ReflectionUnionType|\ReflectionNamedType|\ReflectionIntersectionType|null $type = null;

Expand Down
4 changes: 2 additions & 2 deletions src/ReflectionProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ final class ReflectionProperty extends BaseReflectionProperty implements NodeAwa

private bool $isDefaultValueConstant = false;

private ?string $defaultValueConstantName;
private ?string $defaultValueConstantName = null;

private bool $isDefaultValueConstExpr = false;

private ?string $defaultValueConstExpr;
private ?string $defaultValueConstExpr = null;

/**
* Initializes a reflection for the property
Expand Down
Loading
Loading