bmewburn / vscode-intelephense

PHP intellisense for Visual Studio Code
https://intelephense.com
Other
1.57k stars 93 forks source link

Type checking not checking string, bool, etc. #2845

Closed bdombro closed 2 months ago

bdombro commented 2 months ago

Describe the bug

class Post
{
  public function __construct(
    public string $title,
    public array $categories,
  ) {
  }
}
function post2(bool $foo)
{
  return $foo;
}

// warns about the second parameter, but not the first or 3rd
$p = new Post(2, 2, 2);
// does not warn that am setting title as a number
$p->title = 1;
// does not warn that setting foo as a string
$p2 = post2('222');
image

Platform and version OS and Intelephense version. MacOS 14.4.1, VSCode 1.87.2, Intellephense 1.10.4

bmewburn commented 2 months ago

Are you using declare(strict_types=1) ?

bdombro commented 2 months ago

That was it! Thanks! Bummer I can't enable it globally -- or at least have the IDE warn me without having to add it. Maybe future feature.