bmewburn / vscode-intelephense

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

Some PHPDoc types are not recognized #2951

Closed andrei-dascalu closed 1 month ago

andrei-dascalu commented 1 month ago

Describe the bug PHPDoc types (https://phpstan.org/writing-php-code/phpdoc-types) are not fully supported. For example, using @param non-negative-int $myVar results in Intelephense detecting the type as <current namespace>\non-negative-int and providing warnings that incorrect types are passed around (as other function parameters or returns using the type are detected as <other namespace>\non-negative-int

To Reproduce

<?php

namespace SomeNamespace\Domain;

class SomeClass
{
      /**
      * @param non-negative-int $param1
      * @param non-negative-int $param2
      */
      public function doSomething(int $param1, int $param2) {
      .... some code
      }
}
/** @var non-negative-int $param1 */
$param1 = 1;
/** @var non-negative-int $param2 */
$param2 = 2;

$newClass = new SomeClass();
$newClass->doSomething($param1, $param2);

Expected behavior Intelephense should not complain about these types

Platform and version MacOS Sonoma 14.5 (23F79) VSCode 1.91.1 Intelephense Extension 1.10.4 - 2024-03-26

bmewburn commented 1 month ago

Try the 1.11 pre-release. Not sure about this type but many are now handled and have a fallback to a standard type.

bmewburn commented 1 month ago

Closing, tested in 1.11 pre-release and this type does fallback to int.