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

Add a null safety check for instances when calling functions (instances null problems) #60

Open
Danil42Russia opened this issue Apr 2, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Danil42Russia
Copy link
Collaborator

Danil42Russia commented Apr 2, 2024

KPHPStorm already has a check for primitives. We need to expand it and add a check for instances of the class.
Sample code:

<?php

declare(strict_types = 1);

function primitive_types() {
  /** @var int|null $type */
  $type = null;

  primitive_fun($type); // error: Can't pass '?int' to 'int' $var

  function primitive_fun(int $var) {
  }
}

function instances_types() {
  class Cls {
  }

  /** @var Cls|null $type */
  $type = null;

  instances_fun($type); // no error or warning

  function instances_fun(Cls $var) {
  }
}

Current check for primitives in KphpParameterTypeMismatchInspection

@Danil42Russia Danil42Russia added the enhancement New feature or request label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants