PHP for Visual Studio, AI, IntelliSense - July 2023#
Announcing availability of PHP Tools v1.74 - for Visual Studio 2019 and Visual Studio 2022. The update introduces exciting new features!
IntelliPHP#
Introducing AI-powered inline code predictions enhancing productivity and code development experience for PHP. Devsense's IntelliPHP leverages machine learning to provide intelligent code predictions. As you type, the extension suggests relevant code completions and shows them as grey text in your editor. This feature helps you write code faster and reduces the time spent on manual typing.
The code predictions work completely offline, and do not send or receive any data to Internet.
Confirm the suggestion with TAB
key, or just keep typing and it adapts. Cancel the suggestion with ESC
key.
Security: The AI suggestions work completely offline, they don't send or receive any data to Internet, and they don't store any data locally either.
To disable/enable the feature, go to
Tools
/Options
,Text Editor
/PHP
/IntelliPHP
.Note, the feature is available for Visual Studio 2022 and separately for Visual Studio Code at marketplace.visualstudio.com.
New IntelliSense Features#
IntelliSense & IteratorIterator
#
IteratorIterator
and RecursiveIteratorIterator
are extended with generic type argument TInner
, @mixin TInner
, and their __construct()
infers this TInner
. Therefore, IntelliSense knows the inner iterator type and so it can provide inner iterator's members. (#1613)
IntelliSense & @phpstan-type
, @psalm-type
, @phpstan-import-type
#
Since now, we have a basic support for local type aliasing.
IntelliSense & Traits with Generics#
Newly, trait
use can be annotated with @use
doc comment to specify the trait's generic arguments (#840), i.e.:
IntelliSense & static
Type#
We have reimplemented the internals and improved type analysis for various cases involving use of static
and $this
within traits, protected properties, and class inheritance in general. Moreover generic arguments and trait members are resolved better with more inherited type information (#931).
Other IntelliSense Features#
@phpstan-type
and@phpstan-import-type
are supported (#1543).phpstan.neon
(and.dist
alternatives) in containing directories processed; supporting their global type aliases (phpstan.neon
file's"typeAliases"
setting).- Handling
Collection<TValue>
,Iterator<TInner>
correctly. - Undefined properties accessed with magic
__get()
reported with lower severity. - Fixes trait adaptation and class inheritance analysis. Classes with complex inheritance with trait
use
with adaptation are analysed correctly giving unseful insights about missing method implementation. - Fixes control-flow analysis of certain
try
/finally
blocks. - Improves Laravel IntelliSense.
- Type inferring in the context of
is_a()
analyzed correctly. - Less falsy warnings for non-static methods called statically in case there is
__callStatic()
magic method. - New quick refactorings through code actions.
- Updated integrated PHP manual and localizations.
match
,fn
, andinterface
are not reported as syntax errors when within a qualified name (PHP 8.0+).- PHP 8.2 standalone
true
,false
, andnull
type names. (#338) - Fixed a few type inferring cases.
- Fixed reporting functions annotated with
@ignore
tag as unknown. - Type hinting through
` above
if` fixed. - Fixed check of
define()
. (#340) - Fixed issue causing removal of new lines when formatting after abstract method. #1525
- Arrow functions now respect php.format.rules.spaceWithinDeclParens to add spaces within parentheses. #1536
- Fixed unwanted space when function is named as keyword #335
- Do not increase indentation if previous sibling node ends on the same line #333
- Fix of array items aliging when keys are not simple literals #1602
Refactoring#
Trait function members are resolved in semantic highlighting, finding references, code lenses with method overrides, and rename refactoring.
Stability Fixes#
- Memory leak when having
.phar
files in the solution has been fixed.