vscode-intelephense
vscode-intelephense copied to clipboard
Support type annotations syntax `/* @var SomeType $variable */`
Feature description or problem with existing feature In our code there are many type declarations using single astreiks syntax for variable type annotations, phpStorm can parse them while Intelphense can't
Describe the solution you'd like
Consider /* @var */
the same as /** @var */
Additional context
Symfony cs fix rules auto convert /** @var */
to /* @var */
in some cases
Additional context Symfony cs fix rules auto convert
/** @var */
to/* @var */
Just to mention that I failed to confirm this.
[Clover@Clover-NB php2]$ ls
test.php
[Clover@Clover-NB php2]$ php-cs-fixer --version
PHP CS Fixer 2.16.3 Yellow Bird by Fabien Potencier and Dariusz Ruminski
[Clover@Clover-NB php2]$ cat test.php
<?php
/** @var SomeType $variable */
$variable = 1;
[Clover@Clover-NB php2]$ php-cs-fixer fix test.php --rules=@Symfony --verbose
Loaded config default.
.
Legend: ?-unknown, I-invalid file syntax (file ignored), S-skipped (cached or empty file), .-no changes, F-fixed, E-error
Fixed all files in 0.010 seconds, 12.000 MB memory used
[Clover@Clover-NB php2]$ cat test.php
<?php
/** @var SomeType $variable */
$variable = 1;
[Clover@Clover-NB php2]$
And obviously Symfony itself uses /** @var ...
far more than /* @var ...
[Clover@Clover-NB symfony](master)$ pwd
/e/WWW/XXXXXX/vendor/symfony
[Clover@Clover-NB symfony](master)$ ls
asset error-handler mime property-info translation-contracts
browser-kit event-dispatcher monolog-bridge routing twig-bridge
cache event-dispatcher-contracts monolog-bundle security-bundle twig-bundle
cache-contracts filesystem options-resolver security-core twig-pack
config finder orm-pack security-csrf validator
console flex phpunit-bridge security-guard var-dumper
css-selector framework-bundle polyfill-intl-grapheme security-http var-exporter
debug-bundle http-client polyfill-intl-idn serializer webpack-encore-bundle
debug-pack http-client-contracts polyfill-intl-normalizer serializer-pack web-profiler-bundle
dependency-injection http-foundation polyfill-mbstring service-contracts yaml
deprecation-contracts http-kernel polyfill-php80 stopwatch
doctrine-bridge inflector process string
dom-crawler mailer profiler-pack test-pack
dotenv maker-bundle property-access translation
[Clover@Clover-NB symfony](master)$ rg '/\*\* @var '
webpack-encore-bundle\tests\IntegrationTest.php:157: /** @var TagRenderer $tagRenderer */
webpack-encore-bundle\src\DependencyInjection\Configuration.php:22: /** @var ArrayNodeDefinition $rootNode */
webpack-encore-bundle\tests\EventListener\ExceptionListenerTest.php:24: /** @var EntrypointLookupInterface[]|Prophecy\Prophecy\ObjectProphecy[] $entrypointLookups */
webpack-encore-bundle\src\EventListener\PreLoadAssetsEventListener.php:51: /** @var GenericLinkProvider|FigGenericLinkProvider $linkProvider */
webpack-encore-bundle\tests\EventListener\PreLoadAssetsEventListenerTest.php:40: /** @var GenericLinkProvider|FigGenericLinkProvider $linkProvider */
webpack-encore-bundle\tests\EventListener\PreLoadAssetsEventListenerTest.php:45: /** @var Link[]|FigLink[] $links */
webpack-encore-bundle\tests\EventListener\PreLoadAssetsEventListenerTest.php:74: /** @var GenericLinkProvider|FigGenericLinkProvider $linkProvider */
security-http\RememberMe\PersistentTokenBasedRememberMeServices.php:35: /** @var TokenProviderInterface */
security-http\EventListener\CheckCredentialsListener.php:46: /** @var PasswordCredentials $badge */
security-http\EventListener\CheckCredentialsListener.php:72: /** @var CustomCredentials $badge */
security-http\EventListener\PasswordMigratingListener.php:42: /** @var PasswordUpgradeBadge $badge */
web-profiler-bundle\Controller\RouterController.php:68: /** @var RequestDataCollector $request */
security-http\EventListener\CsrfProtectionListener.php:43: /** @var CsrfTokenBadge $badge */
var-dumper\Command\ServerDumpCommand.php:41: /** @var DumpDescriptorInterface[] */
validator\Mapping\Loader\StaticMethodLoader.php:41: /** @var \ReflectionClass $reflClass */
validator\Constraints\Composite.php:126: /** @var Constraint[] $nestedConstraints */
mailer\Transport\Transports.php:49: /** @var Message $message */
validator\Constraints\Compound.php:24: /** @var Constraint[] */
translation\Util\XliffUtils.php:34: /** @var \DOMNode $xliff */
mailer\Transport\Smtp\EsmtpTransport.php:45: /** @var SocketStream $stream */
mailer\Transport\Smtp\EsmtpTransport.php:107: /** @var SocketStream $stream */
translation\Loader\XliffFileLoader.php:197: /** @var \SimpleXMLElement $xmlNote */
mailer\Transport\Smtp\EsmtpTransportFactory.php:33: /** @var SocketStream $stream */
service-contracts\ServiceSubscriberTrait.php:24: /** @var ContainerInterface */
routing\RouteCollectionBuilder.php:64: /** @var RouteCollection[] $collections */
routing\Matcher\UrlMatcher.php:35: /** @var RequestContext */
routing\Loader\YamlFileLoader.php:195: /** @var RouteCollection[] $imported */
routing\Loader\XmlFileLoader.php:188: /** @var RouteCollection[] $imported */
routing\Loader\XmlFileLoader.php:253: /** @var \DOMElement $n */
process\Process.php:76: /** @var PipesInterface */
property-info\Extractor\PhpDocExtractor.php:78: /** @var $docBlock DocBlock */
property-info\Extractor\PhpDocExtractor.php:106: /** @var $docBlock DocBlock */
property-info\Extractor\PhpDocExtractor.php:122: /** @var $docBlock DocBlock */
property-info\Extractor\PhpDocExtractor.php:143: /** @var DocBlock\Tags\Var_|DocBlock\Tags\Return_|DocBlock\Tags\Param $tag */
process\InputStream.php:23: /** @var callable|null */
monolog-bundle\SwiftMailer\MessageFactory.php:49: /** @var \Swift_Message $message */
options-resolver\Debug\OptionsResolverIntrospector.php:30: /** @var OptionsResolver $this */
maker-bundle\src\Command\MakerCommand.php:38: /** @var ConsoleStyle */
maker-bundle\src\FileManager.php:32: /** @var SymfonyStyle */
maker-bundle\src\Str.php:25: /** @var Inflector|null */
maker-bundle\src\Doctrine\EntityRegenerator.php:58: /** @var ClassSourceManipulator[] $operations */
maker-bundle\src\Doctrine\DoctrineHelper.php:91: /** @var EntityManagerInterface $em */
maker-bundle\src\Doctrine\DoctrineHelper.php:137: /** @var EntityManagerInterface $em */
maker-bundle\src\Doctrine\DoctrineHelper.php:233: /** @var NamingStrategy $namingStrategy */
maker-bundle\src\Doctrine\DoctrineHelper.php:241: /** @var Connection $connection */
maker-bundle\src\Security\SecurityConfigUpdater.php:22: /** @var YamlSourceManipulator */
maker-bundle\src\Util\ClassSourceManipulator.php:48: /** @var ConsoleStyle|null */
http-kernel\DependencyInjection\RegisterControllerArgumentLocatorsPass.php:128: /** @var \ReflectionMethod $r */
http-kernel\DependencyInjection\RegisterControllerArgumentLocatorsPass.php:133: /** @var \ReflectionParameter $p */
phpunit-bridge\DeprecationErrorHandler\Deprecation.php:37: /** @var string[] Absolute paths to vendor directories */
http-client\NativeHttpClient.php:40: /** @var NativeClientState */
http-client\Internal\NativeClientState.php:23: /** @var int */
http-client\Internal\NativeClientState.php:25: /** @var int */
http-client\Internal\NativeClientState.php:27: /** @var int */
http-client\Internal\NativeClientState.php:29: /** @var string[] */
http-client\Internal\NativeClientState.php:31: /** @var resource[] */
http-client\Internal\NativeClientState.php:33: /** @var bool */
framework-bundle\Command\AboutCommand.php:61: /** @var KernelInterface $kernel */
http-client\Response\ResponseTrait.php:53: /** @var resource */
http-client\Response\ResponseTrait.php:326: /** @var ClientState $multi */
http-client\Internal\CurlClientState.php:23: /** @var resource */
http-client\Internal\CurlClientState.php:25: /** @var PushedResponse[] */
http-client\Internal\CurlClientState.php:27: /** @var DnsCache */
http-client\AmpHttpClient.php:47: /** @var AmpClientState */
http-client\Internal\PushedResponse.php:27: /** @var string[] */
http-client\Response\StreamWrapper.php:25: /** @var resource|string|null */
http-client\Response\StreamWrapper.php:28: /** @var HttpClientInterface */
http-client\Response\StreamWrapper.php:31: /** @var ResponseInterface */
http-client\Response\StreamWrapper.php:34: /** @var resource|null */
http-client\Response\StreamWrapper.php:37: /** @var resource|null */
framework-bundle\Command\AssetsInstallCommand.php:96: /** @var KernelInterface $kernel */
framework-bundle\Command\AssetsInstallCommand.php:134: /** @var BundleInterface $bundle */
framework-bundle\Command\TranslationUpdateCommand.php:138: /** @var KernelInterface $kernel */
flex\src\Command\RecipesCommand.php:29: /** @var \Symfony\Flex\Flex */
flex\src\Command\RecipesCommand.php:108: /** @var Recipe $recipe */
framework-bundle\Command\TranslationDebugCommand.php:133: /** @var KernelInterface $kernel */
doctrine-bridge\PropertyInfo\DoctrineExtractor.php:99: /** @var ClassMetadataInfo $subMetadata */
doctrine-bridge\PropertyInfo\DoctrineExtractor.php:106: /** @var ClassMetadataInfo $subMetadata */
doctrine-bridge\Form\DoctrineOrmTypeGuesser.php:112: /** @var ClassMetadataInfo $classMetadata */
dependency-injection\Compiler\ResolveInstanceofConditionalsPass.php:75: /** @var ChildDefinition $instanceofDef */
dependency-injection\Compiler\ResolveInstanceofConditionalsPass.php:108: /** @var ChildDefinition $definition */
dependency-injection\Config\ContainerParametersResourceChecker.php:23: /** @var ContainerInterface */
console\Tester\TesterTrait.php:24: /** @var StreamOutput */
console\Helper\Table.php:539: /** @var WrappableOutputFormatterInterface $formatter */
css-selector\XPath\Translator.php:97: /** @var SelectorNode $selector */
console\Descriptor\ApplicationDescription.php:95: /** @var Command $command */
console\Command\LockableTrait.php:27: /** @var Lock */
config\Definition\Dumper\YamlReferenceDumper.php:45: /** @var NodeInterface[] $children */
cache\DataCollector\CacheDataCollector.php:118: /** @var TraceableAdapterEvent $call */
[Clover@Clover-NB symfony](master)$ rg '/\* @var '
validator\Constraints\Composite.php:62: /* @var Constraint[] $nestedConstraints */
validator\Validator\RecursiveContextualValidator.php:455: /* @var \Symfony\Component\Validator\GroupSequenceProviderInterface $object */
twig-bridge\Form\TwigRendererEngine.php:151: /* @var Template $theme */
framework-bundle\Kernel\MicroKernelTrait.php:125: /* @var ContainerPhpFileLoader $kernelLoader */
framework-bundle\Kernel\MicroKernelTrait.php:155: /* @var RoutingPhpFileLoader $kernelLoader */
routing\RouteCollectionBuilder.php:296: /* @var self $route */
property-access\PropertyPath.php:71: /* @var PropertyPath $propertyPath */
maker-bundle\src\Doctrine\DoctrineHelper.php:120: /* @var ClassMetadata $metadata */
maker-bundle\src\Doctrine\EntityRegenerator.php:239: /* @var $classReflection \ReflectionClass */
maker-bundle\src\Resources\skeleton\validator\Validator.tpl.php:12: /* @var $constraint \<?= $constraint_class_name ?> */
http-client\Response\AmpResponse.php:204: /* @var Response $response */
doctrine-bridge\Test\TestRepositoryFactory.php:54: /* @var $metadata ClassMetadata */
config\ResourceCheckerConfigCache.php:94: /* @var ResourceInterface $resource */
config\Resource\SelfCheckingResourceChecker.php:33: /* @var SelfCheckingResourceInterface $resource */
[Clover@Clover-NB symfony](master)$
@jfcherng Thanks for confirming, just got to know this auto conversion by php cs fixer only happens in cases where there is no assignment like this:
/* @var Contract $subject */
$subject->methodCall($argument);
Anyways would be nice if this is supported
where there is no assignment like this:
/* @var Contract $subject */ $subject->methodCall($argument);
Not on my side.
But I am not against supporting /* @var ...
since it's not a BC breaking feature.
@jfcherng Thanks, I made up an exact example to reproduce it:
<?php
if (true) {
/** @var Contract $subject */
$subject->methodCall($argument);
}
Using symfony rules this is converted to /* @var Contract $subject */
@jfcherng Thanks, I made up an exact example to reproduce it:
<?php if (true) { /** @var Contract $subject */ $subject->methodCall($argument); }
Using symfony rules this is converted to
/* @var Contract $subject */
Feel weird but confirmed.
any update on this?
also need support for
/* @var $obj Class */
support please
any update?
v1.8.2 any update?
também preciso de apoio para /* @var $obj Class */
Fix your "converters", /*
is not a docblock.
Please, support
/** @var $obj Class */
It is supported. Except it is senseless. But supported.
Use the following rule to prevent conversion /** @var */
: phpdoc_to_comment.ignored_tags
// .php-cs-fixer.php
<?php
return (new PhpCsFixer\Config())
->setRules([
// ... more rules
'phpdoc_to_comment' => ['ignored_tags' => ['var']],
])
;
Please, support
/** @var $obj Class */
-1 for this feature.
Both /* @var */
and /** @var $obj Class */
are wrong, should not be supported. You should fix your linter.
when I use something like this in my tests
/** @var CEClient $ceClient */
$ceClient = $this->mock(CEClient::class);
everything works
but if I use
/** @var CEClient $ceClient */
$ceClient = $this->mock(CEClient::class, function (MockInterface $mock) {
$mock->shouldReceive('createFulfillment')
->andThrow(new Exception('Exception occurred'));
});
It doesn't recognize the type correctly,