Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP 8.4] Fixes for implicit nullability deprecation #10832

Merged
merged 1 commit into from
Mar 19, 2024
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
6 changes: 3 additions & 3 deletions src/Psalm/Codebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ public function getMethodReturnsByRef($method_id): bool
*/
public function getMethodReturnTypeLocation(
$method_id,
CodeLocation &$defined_location = null
?CodeLocation &$defined_location = null
): ?CodeLocation {
return $this->methods->getMethodReturnTypeLocation(
MethodIdentifier::wrap($method_id),
Expand Down Expand Up @@ -1651,7 +1651,7 @@ public function getFunctionArgumentAtPosition(string $file_path, Position $posit
*/
public function getSignatureInformation(
string $function_symbol,
string $file_path = null
?string $file_path = null
): ?SignatureInformation {
$signature_label = '';
$signature_documentation = null;
Expand Down Expand Up @@ -1876,7 +1876,7 @@ public function getCompletionItemsForClassishThing(
string $type_string,
string $gap,
bool $snippets_supported = false,
array $allow_visibilities = null,
?array $allow_visibilities = null,
array $ignore_fq_class_names = []
): array {
if ($allow_visibilities === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ public function examineParamTypes(
StatementsAnalyzer $statements_analyzer,
Context $context,
Codebase $codebase,
PhpParser\Node $stmt = null
?PhpParser\Node $stmt = null
): void {
$storage = $this->getFunctionLikeStorage($statements_analyzer);

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Analyzer/IssueData.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function __construct(
int $shortcode = 0,
int $error_level = -1,
?array $taint_trace = null,
array $other_references = null,
?array $other_references = null,
?string $dupe_key = null
) {
$this->severity = $severity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function analyze(
array $pre_conditions,
array $post_expressions,
LoopScope $loop_scope,
Context &$continue_context = null,
?Context &$continue_context = null,
bool $is_do = false,
bool $always_enters_loop = false
): ?bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ private static function analyzeOperands(
bool &$has_valid_left_operand,
bool &$has_valid_right_operand,
bool &$has_string_increment,
Union &$result_type = null
?Union &$result_type = null
): ?Union {
if (($left_type_part instanceof TLiteralInt || $left_type_part instanceof TLiteralFloat)
&& ($right_type_part instanceof TLiteralInt || $right_type_part instanceof TLiteralFloat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function analyze(
PhpParser\Node\Expr $left,
PhpParser\Node\Expr $right,
Context $context,
Union &$result_type = null
?Union &$result_type = null
): void {
$codebase = $statements_analyzer->getCodebase();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class HighOrderFunctionArgInfo
public function __construct(
string $type,
FunctionLikeStorage $function_storage,
ClassLikeStorage $class_storage = null
?ClassLikeStorage $class_storage = null
) {
$this->type = $type;
$this->function_storage = $function_storage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static function analyze(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr\New_ $stmt,
Context $context,
TemplateResult $template_result = null
?TemplateResult $template_result = null
): bool {
$fq_class_name = null;

Expand Down Expand Up @@ -310,7 +310,7 @@ private static function analyzeNamedConstructor(
string $fq_class_name,
bool $from_static,
bool $can_extend,
TemplateResult $template_result = null
?TemplateResult $template_result = null
): void {
$storage = $codebase->classlike_storage_provider->get($fq_class_name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,8 @@ public static function getArrayAccessTypeGivenOffset(
bool $in_assignment,
?string $extended_var_id,
Context $context,
PhpParser\Node\Expr $assign_value = null,
Union $replacement_type = null
?PhpParser\Node\Expr $assign_value = null,
?Union $replacement_type = null
): Union {
$offset_type = $offset_type_original->getBuilder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static function infer(
NodeDataProvider $nodes,
PhpParser\Node\Expr $stmt,
Aliases $aliases,
FileSource $file_source = null,
?FileSource $file_source = null,
?array $existing_class_constants = null,
?string $fq_classlike_name = null
): ?Union {
Expand Down Expand Up @@ -544,7 +544,7 @@ private static function inferArrayType(
NodeDataProvider $nodes,
PhpParser\Node\Expr\Array_ $stmt,
Aliases $aliases,
FileSource $file_source = null,
?FileSource $file_source = null,
?array $existing_class_constants = null,
?string $fq_classlike_name = null
): ?Union {
Expand Down Expand Up @@ -628,7 +628,7 @@ private static function handleArrayItem(
ArrayCreationInfo $array_creation_info,
PhpParser\Node\Expr\ArrayItem $item,
Aliases $aliases,
FileSource $file_source = null,
?FileSource $file_source = null,
?array $existing_class_constants = null,
?string $fq_classlike_name = null
): bool {
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Codebase/Analyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ public function addNodeType(
string $file_path,
PhpParser\Node $node,
string $node_type,
PhpParser\Node $parent_node = null
?PhpParser\Node $parent_node = null
): void {
if ($node_type === '') {
throw new UnexpectedValueException('non-empty node_type expected');
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Codebase/ConstantTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class ConstantTypeResolver
public static function resolve(
ClassLikes $classlikes,
UnresolvedConstantComponent $c,
StatementsAnalyzer $statements_analyzer = null,
?StatementsAnalyzer $statements_analyzer = null,
array $visited_constant_ids = []
): Atomic {
$c_id = spl_object_id($c);
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Codebase/Methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ public function getMethodReturnsByRef(MethodIdentifier $method_id): bool

public function getMethodReturnTypeLocation(
MethodIdentifier $method_id,
CodeLocation &$defined_location = null
?CodeLocation &$defined_location = null
): ?CodeLocation {
$method_id = $this->getDeclaringMethodId($method_id);

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Provider/FakeFileProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function deleteFile(string $file_path): void
* @param null|callable(string):bool $filter
* @return list<string>
*/
public function getFilesInDir(string $dir_path, array $file_extensions, callable $filter = null): array
public function getFilesInDir(string $dir_path, array $file_extensions, ?callable $filter = null): array
{
$file_paths = parent::getFilesInDir($dir_path, $file_extensions, $filter);

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Provider/FileProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function isDirectory(string $file_path): bool
* @param null|callable(string):bool $filter
* @return list<string>
*/
public function getFilesInDir(string $dir_path, array $file_extensions, callable $filter = null): array
public function getFilesInDir(string $dir_path, array $file_extensions, ?callable $filter = null): array
{
$file_paths = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Type/ParseTree/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
int $offset_start,
int $offset_end,
?string $text,
ParseTree $parent = null
?ParseTree $parent = null
) {
$this->offset_start = $offset_start;
$this->offset_end = $offset_end;
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Plugin/DynamicTemplateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(string $defining_class)
/**
* If {@see DynamicFunctionStorage} requires template params this method can create it.
*/
public function createTemplate(string $param_name, Union $as = null): TTemplateParam
public function createTemplate(string $param_name, ?Union $as = null): TTemplateParam
{
return new TTemplateParam($param_name, $as ?? Type::getMixed(), $this->defining_class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
StatementsSource $statements_source,
Codebase $codebase,
array $file_replacements = [],
Union $return_type_candidate = null
?Union $return_type_candidate = null
) {
$this->expr = $expr;
$this->method_id = $method_id;
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Storage/FunctionLikeStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public function setParams(array $params): void
/**
* @internal
*/
public function addParam(FunctionLikeParameter $param, bool $lookup_value = null): void
public function addParam(FunctionLikeParameter $param, ?bool $lookup_value = null): void
{
$this->params[] = $param;
$this->param_lookup[$param->name] = $lookup_value ?? true;
Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Type/Atomic.php
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ public function replaceTemplateTypesWithStandins(
TemplateResult $template_result,
Codebase $codebase,
?StatementsAnalyzer $statements_analyzer = null,
Atomic $input_type = null,
?Atomic $input_type = null,
?int $input_arg_offset = null,
?string $calling_class = null,
?string $calling_function = null,
Expand Down
Loading