Upgrades in Latte plugin for PHPStorm
- mesour
- Nette Blogger | 236
Introducing
I'm working on upgrade for Latte plugin for PHPStorm. Now is in the beta version only, you can download and test it by download link. It can be installed from disk (help for install). I will be happy if as many people as possible try it out before we release the official version. There were a lot of changes, so let’s test it out.
Before stable will be released, new beta versions will be pushed to Github and in this forum will be posted information about new update. Download link will be same.
Download and testing EAP version
Latte plugin for IntelliJ is downloadable from the JetBrains plugin
repository directly in the PHPStorm. Latte plugin for IntelliJ using channel
eap
which contains the latest release candidate.
- Here is, how to set up custom release channels in PHPStorm: Custom release channels
- You have to add this link: https://plugins.jetbrains.com/…ins/eap/list to your Custom plugin repositories
- After you add the link above, you can refresh your plugins Marketplace and you will see RC versions for Latte plugin
Links
- Custom
template class… – More informations about new
templateType
macro. MacrovarType
is equivalent for/** @var string|null $foo */
and have this syntax:{vatType string|null $foo}
. - I also created small update for Neon plugin
Issues
If you find some bug, please reply to this topic and I will add it to issues list.
Important notes
- Refactoring for class names is now supported only from PHP to Latte
Changelist
- Increased minimum compatibility with PhpStorm version to 2017.3 from PhpStorm 8 (pre-2016.2 IDE version)
- added support for PHP content
- added variable types
- added highlighting and go to source support for latte variables
- added support for define custom default variables per project
- added completions for latte variables, PHP functions, methods, constants and properties
- added varType macro
- added templateType macro
- added support for define type in {var Bar\FooClass $class = …}
- added support for mime types and completion it in contentType macro
- added reference search for usages from PHP to Latte (for classes, methods, properties and constants)
- added brace matcher for highlight braces
- added go to source for class names, methods, constants and properties
- added support for highlighting macro name and pair macro
- added support for refactoring rename (methods, properties, constants and class names)
- added code-completion for latte filters
- added support for adding custom latte filters
- added UI for setting custom variables, filters and macros
- added inspections for:
- class usages (Undefined class)
- checking not defined variables, more definitions with same variable name etc.
- checking constant, property and methods visibility (if is not public it make warning)
- checking not existing constants, properties and methods
- checking static methods and properties used non statically and vice versa
- checking valid content for
templateType
,varType
andvar
macro - checking existing latte filters
Donate
More of you wrote that they would like to contribute to development. I appreciate it, thanks. So I'm adding a link to PayPal and a bank account number. Donors will be posted here on the forum and in the future somewhere on the web with information about the Latte plugin (if you want, then write a payment note with your name for the recipient).
Donor list
- David Šolc – https://solc.dev/
Last edited by mesour (2020-05-29 14:59)
- mesour
- Nette Blogger | 236
Update 01
I added this to latest update (can be donwloaded by download link in main post):
- Support for refactoring rename
- Support for classes not starting with
\
and completion without\
- Added support for PHP functions (completions, reference…)
- Added completion type hints like
string
,int
… invarType
macro - Added better support for strings and support for variable used in double
quoted string like:
"foo-string $bar"
This is new compared to the version that has been on the Slack.
- mesour
- Nette Blogger | 236
Update 02
I added this to latest update (can be donwloaded by download link in main post):
- Fixed bug with refactoring rename
- Fixed bug in completion and reference class members if class name is without
\
and if is|null
in type - Added support for define type in
{var Bar\FooClass $class = ...}
- Added support for define variable in macro
{capture $definition}
- Added completion for content types to
{contentType application/json}
macro
I think this can be first release candidate. Because all important
features are implemented. Only minor changes are in need fix
section in issues list.
- Please if someone have PHPStorm with Java version 8, test it. I change settings for project and try it compile it for Java 8, but it is hard to test for me with Java 11.
Last edited by mesour (2020-01-07 22:06)
- mesour
- Nette Blogger | 236
Update 03
I added this to latest update (can be donwloaded by download link in main post):
- Added some performance improvements
- Added code-completion for latte filters
- Added support for adding custom latte filters
- Added UI for setting custom variables, filters and macros
- Added inspection for checking existing latte filters
Now Im waiting for review and some things to solve around the merge
to the main repository. After this it can be released. But I think it's good
to wait a week or two for finding bugs in this version. Only adding
templatePrint
macro is planed to this version. Next features really
in future versions.
If you want donate, I added a section to main post.
Last edited by mesour (2020-01-08 19:16)
- mesour
- Nette Blogger | 236
Update 04
I added this to the latest update (can be downloaded by a download link in the main post):
- Added support for
templatePrint
macro - Added tests for LattePhpLexer
- Added completion for macro end tag
- Improved
n:
attributes completion - Improved pages with settings for (macros, variables, and custom functions)
- Fixed bug in completion for the end tag macro
- Fixed annotator messages and annotating for some cases
- Nette macros moved to custom configurations and can be disabled for the project with Latte only
- Fixed bugs with unclosed block macro and translate macro
- Fixed macro completion at the end of the file
I have created a pull request. Now it is mergeable without conflicts. Now I'm working only on testing and bug fixing.
Last edited by mesour (2020-01-13 21:10)
- mesour
- Nette Blogger | 236
Update 05
I added this to the latest update (can be downloaded by a download link in the main post):
- Fixed bug in filters completion and settings
You have not reported any bugs for ~2 weeks and this update is minor. Now I will merge it to master and I will initiate for the plugin to be published.
Last edited by mesour (2020-01-25 08:49)
- mesour
- Nette Blogger | 236
Update 06
I added this to the latest update (can be downloaded by a download link in the main post):
- Changed functionality for reset buttons in settings (now working only with Nette macros, variables…)
- Renamed
macro
totag
- Fixed bugs in macro settings UI
- Fixed completion for magic methods prefixed with
__
(complete only if__
is typed) - Fixed bug in completion for custom-defined filters
This is the latest update before release.
- Tomáš Jacík
- Member | 147
@mesour Can you post your account number here? Are you able to make an invoice if my company donate too?
Thanks
- mesour
- Nette Blogger | 236
@TomášJacík I added the bank account to Donate information in the main post. I can make an invoice. If you want, email me by the contact form here: https://mesour.com/cs#… or message me on Slack
Last edited by mesour (2020-02-10 19:32)
- mesour
- Nette Blogger | 236
Version 1.0.0
I merged it to master and asked competent people to publish a new version of the plugin.
This is planed in the next version (v1.0.2)
- Fix and add more if completing code (for faster code writing in latte
templates)
- Complete variables without typing
$
- and more…
- Complete variables without typing
- Try to implement some performance improvements
- Fix resolving methods if a type is more classes
FooClass|BarClass
(sometimes bugging) - And more bug fixes if someone reports a new bug
Important planed features (v1.1.0)
- Add support for optional chaining
- {$order->item?->name}, {if $blogPost?->count(‘*’)}
- Add intention for add optional chaining
- Added resolving in foreach and ArrayAccess (
$arr['foo']
) for types defined with []. Example:FooClass[]
- Inspections
- For checking nullable types (eg. calling method on nullable variable)
- For checking
foreach
value, must be array or iterable - For used @deprecated and @internal PHP elements
Last edited by mesour (2020-02-18 02:23)
- mesour
- Nette Blogger | 236
A new version of the plugin has been submitted for moderation. Now we are
waiting for a security check from JetBrains. The request will be processed
within two business days. After this, the plugin will be visible and
downloadable for all, normally from IDEA
Preferences -> Plugins
.
Last edited by mesour (2020-02-10 19:18)
- Milo
- Nette Core | 1283
Hi. This is awesome and thanks for your work!
I'm excited about {varType}
macro and Latte autocompletion.
Unfortunatelly, I'm running Latte v2.6. So, I published small LatteBackportMacros
class as a workaround before upgrade to 2.7.
- mesour
- Nette Blogger | 236
Thank you all for your positive feedback and donating. In the future, I plan to update the plugin to make work with it even easier :)
Version 1.0.2
Version 1.0.1 was released and here is a new planed update.
If you want, you can test it by direct download from GitHub: DOWNLOAD and install it manually from a disc.
I added this to the latest update:
- added code style settings (settings for use tabs or spaces) (issue #46, #30)
- added support for define variable in tag {default $foo = 123}
- added class namespaces completion
- added support for define variables by {php [$foo, $bar] = $arr}
- implemented some performance improvements
- fixed resolving methods if a type is more classes FooClass|BarClass
- fixed completion for unpaired macro after if missing end }
- fixed filters on variables (issue #47)
- fixed wrong indent for elseifset (issue #42)
- fixed multiple variable definitions in for/foreach cycles
- fixed auto-complete (disabled in strings, more improvements)
- increased minimum compatibility to 2018.3
I'll wait a week for the bugs report and after this, I'll release this version.
Last edited by mesour (2020-02-18 18:31)
- MajklNajt
- Member | 494
hi @mesour, first I want to thank you for this plugin, nice work!
I have one surprising behavior, I have template:
{varType Student $student}
{$student->getCourse()->getName()}
Above is analysed fine getName
is known method, but if I assign
variable:
{varType Student $student}
{var $course = $student->getCourse()} <-- whithout type definition
{$course->getName()}
…method getName
is highlighted as unknown.
For completion – interfaces of PHP classes:
interface Student {
public function getCourse(): Course;
}
interface Course {
public function getName(): string;
}
Is this expected behavior?
- Milo
- Nette Core | 1283
Issue: Support stdClass type
If I typehint variable as {varType stdClass $data}
I get an
error First value in {varType} tag must be typehint
. When I use
typehint \stdClass
the error disappears but I still see higlighted
properties like Property 'xyz' not found
on
$data->xyz
.
Would be great to accept any property with stdClass
.
- dkorpar
- Member | 135
Milo wrote:
Issue: Support stdClass type
If I typehint variable as
{varType stdClass $data}
I get an errorFirst value in {varType} tag must be typehint
. When I use typehint\stdClass
the error disappears but I still see higlighted properties likeProperty 'xyz' not found
on$data->xyz
.Would be great to accept any property with
stdClass
.
what's the point of even using varType if you set it as stdClass?
- David Grudl
- Nette Core | 8218
dkorpar wrote:
what's the point of even using varType if you set it as stdClass?
The editor and static analysis will know that it is stdClass, not a string or a number, …
- mesour
- Nette Blogger | 236
MajklNajt wrote:
hi @mesour, first I want to thank you for this plugin, nice work!
I have one surprising behavior, I have template:
{varType Student $student} {$student->getCourse()->getName()}
Is this expected behavior?
@MajklNajt: Hi, I think, it is because there is not support to use classes without \ if class have not namespace. Try use:
{varType \Student $student}
Last edited by mesour (2020-03-05 10:27)
- mesour
- Nette Blogger | 236
Milo wrote:
Issue: Support stdClass type
If I typehint variable as
{varType stdClass $data}
I get an errorFirst value in {varType} tag must be typehint
. When I use typehint\stdClass
the error disappears but I still see higlighted properties likeProperty 'xyz' not found
on$data->xyz
.Would be great to accept any property with
stdClass
.
@Milo: Support for \stdClass will be added.
- MajklNajt
- Member | 494
Hi @messour, namespace is not problem, your cited code snippet work fine, problem is only with this:
{varType \Student $student}
{var $course = $student->getCourse()} <-- getCourse() is known, it returns \Course
{$course->getName()} <-- getName() is unknown for latte plugin
In runtime it work properly, only static analysis in PhpStorm screams
Last edited by MajklNajt (2020-03-05 13:33)
- mesour
- Nette Blogger | 236
Version 1.0.3
Hi, we finally managed to complete the implementation of Gradle into the Latte plugin with @Rixafy, thus freeing up space for further tweaks to the Latte plugin. Specifically, these are now the following:
- implemented Gradle
- added support for reformat code for spaces around assignment and equality operators
- added support for reformat code for spaces after tag name and before closing tag
- added support for reformat code for spaces before tag filters
- added support for change syntax highlight for operators
- added Latte context for live templates
- added live templates {fore, {forek, {ife and {frm
- switched to not deprecated api around Latte code formatter
- upgraded more deprecated usages
- improved LattePhpType to use less memory and work faster (about –75% processing time)
- added live templates {fore, {forek, {fori, {ife and {frm
- added new tags {do}, {sandbox}, {varPrint}
- added new macro |batch:(array, length [, item])
- added tag {inputError} – (reload for Nette tag settings needed)
- fixed issue #66 – methods, constants and properties are now recognized for static classes
- fixed issue #64 – ifcontent is now macro without parameters
- fixed issue #61 – improved working with methods (now it is prepared for future enhacements)
- fixed issue #69 – determine type for a variable, if call some on this now working
IMPORTANT is testing for reformat code. Try reformat your latte templates by reformat code in IDE and check if automatic reformat make some weird in code. If it will be OK, it can be published as stable version.
Last edited by mesour (2020-05-24 21:34)
- mesour
- Nette Blogger | 236
MajklNajt wrote:
Hi @messour, namespace is not problem, your cited code snippet work fine, problem is only with this:
{varType \Student $student} {var $course = $student->getCourse()} <-- getCourse() is known, it returns \Course {$course->getName()} <-- getName() is unknown for latte plugin
In runtime it work properly, only static analysis in PhpStorm screams
Moved to issue: https://github.com/…te/issues/69
Last edited by mesour (2020-05-16 23:12)
- mesour
- Nette Blogger | 236
Version 1.1.0 – XML config update
- Version 1.0.3 was renamed to 1.1.0
Documentation
More info about XML files: DOCUMENTATION
XML file for Nette < 3: latte-intellij.xml
Download
- Here is, how to set up custom release channels in PHPStorm: Custom release channels
- You have to add this link: https://plugins.jetbrains.com/…ins/eap/list to your Custom plugin repositories
- After you add the link above, you can refresh your plugins Marketplace and you will see RC versions for Latte plugin
Donate
Changelog
- added support for load configuration from XML files (issue #81)
- added support for multi line macro settings
- added support for reformat code for spaces around assignment and equality operators
- added support for reformat code for spaces after tag name and before closing tag
- added support for reformat code for spaces before tag filters
- added support for change syntax highlight for operators
- added Latte context for live templates
- added live templates {fore, {forek, {fori and {ife
- added new tags {do}, {sandbox}, {widget} and {varPrint}
- added new filter |batch:(array, length [, item])
- added tag {inputError} – (reload for Nette tag settings needed)
- switched to not deprecated api around Latte code formatter
- upgraded more deprecated usages
- improved LattePhpType to use less memory and work faster (about –75% processing time)
- implemented Gradle (for better plugin development)
- tag {? …} was tagged as deprecated since Nette 2.4
- increased minimum compatibility to PhpStorm 193.5233.102
- fixed issue #66 – methods, constants and properties are now recognized for static classes
- fixed issue #64 – ifcontent is now macro without parameters
- fixed issue #61 – improved working with methods (now it is prepared for future enhacements)
- fixed issue #69 – determine type for a variable, if call some on this now working
- fixed issue #62 – now is space after function name allowed and it is determined as function
- fixed issue #80 – better parsing for namespaces and classes and fixed refactoring for classes
- fixed issue #72 – added support for double colons in filters
- fixed issue #77 – added inspection for deprecated and internal usages
- fixed issue #55 – fixed macro {label foo} as unpaired (also fixed other AUTO_EMPTY tags)
Last edited by mesour (2020-05-29 14:56)
- mesour
- Nette Blogger | 236
Version 1.1.0 – RC3
Download
RC3 is out and from now is downloadable from JetBrains plugin repository
directly in the PHPStorm. Latte plugin for IntelliJ using channel
eap
which contains the latest release candidate.
- Here is, how to set up custom release channels in PHPStorm: Custom release channels
- You have to add this link: https://plugins.jetbrains.com/…ins/eap/list to your Custom plugin repositories
- After you add the link above, you can refresh your plugins Marketplace and you will see RC versions for Latte plugin
Changelog
- Improved tag completion information
- Added support to set tag arguments
- this replace
hasParameters
attribute from settings and xml config
- this replace
- Separated Nette tags to
nette/application
andnette/forms
tags - Fixed @deprecated and @internal in completion and inspections
for PHP functions and variables from
templateType
tag
- mesour
- Nette Blogger | 236
Version 1.1.0 – RC4 – Iterable types
Download
RC4 is out and from now is downloadable from JetBrains plugin repository
directly in the PHPStorm. Latte plugin for IntelliJ using channel
eap
which contains the latest release candidate.
- I added
Testing EAP version
section to README.md for more info about installing EAP versions
Changelog
- Added support for iterable types (issue #70)
- Added new inspections for iterable types (issue #78)
- Added support for array access (eg. $arr[][]) to parser (issue #82)
- Added support for define variables in tag {define} (issue #84)
- Added live template {va
- Fixed detecting variable type from code
- Fixed bug in autocomplete inside var macro
- Added support for using HTML elements in PSI tree (internal feature for future improvements)
Donate
You can now sponsor this open-source project through Patreon.
Do Nette plugins save you development time? Send a couple of 💸 a month my way too. Thank you!
More information about donating in README.md
- mesour
- Nette Blogger | 236
Version 1.1.0 – Iterable types and XML update
Download
Stable version is now out.
Important features
- Implemented live templates
- Added support for iterable types
- Added better support for reformat code
- Added support for load configuration from XML files
- Multi-line tag support
- Fixed more issues
Donate
I created Github sponsors profile. You can now sponsor this open-source project through Github.
Do Nette plugins save you development time? Send a couple of 💸 a month my way too. Thank you!
More information about donating in Repository and README.md
Last edited by mesour (2020-07-14 13:04)
- mesour
- Nette Blogger | 236
zoool wrote:
I have problem with macro {/block}. It write error message : T_MACRO_OPEN_TAG_OPEN expected, got ‘{/}’
I think it is the same problem as: https://github.com/…e/issues/109
Last edited by mesour (2020-07-29 12:51)
- dTTb
- Member | 30
Hi, I have a wierd problem, code like this:
<ul class="nav nav-pills flex-column mainmenu">
{if isset($admin) && $admin}
<li class="nav-item menutoggle" data-menutoggle="adminmenu">
<a class="menuhead" href="#"><h3>Admin</h3></a>
</li>
{/if}
<li class="nav-item menutoggle" data-menutoggle="employeemenu">
<a class="menuhead" href="#"><h3>Zaměstnanec</h3></a>
</li>
<li class="nav-item employeemenu">
<a n:class="$presenter->isLinkCurrent(':Todo:*') ? active, nav-link" n:href=":Todo:default">Činnosti</a>
</li>
{if $rent_acc}
<li class="nav-item menutoggle" data-menutoggle="rentmenu">
<a class="menuhead" href="#"><h3>Rent</h3></a>
</li>
{/if}
</ul>
after reformating becomes:
<ul class="nav nav-pills flex-column mainmenu">
{if isset($admin) && $admin}
<li class="nav-item menutoggle" data-menutoggle="adminmenu">
<a class="menuhead" href="#"><h3>Admin</h3></a>
</li>
{/if}
<li class="nav-item menutoggle" data-menutoggle="employeemenu">
<a class="menuhead" href="#"><h3>Zaměstnanec</h3></a>
</li>
<li class="nav-item employeemenu">
<a n:class="$presenter->isLinkCurrent(':Todo:*') ? active, nav-link" n:href=":Todo:default">Činnosti</a>
</li>
{if $rent_acc}
<li class="nav-item menutoggle" data-menutoggle="rentmenu">
<a class="menuhead" href="#"><h3>Rent</h3></a>
</li>
{/if}
</ul>
and each reformating after that adds empty lines:
<ul class="nav nav-pills flex-column mainmenu">
{if isset($admin) && $admin}
<li class="nav-item menutoggle" data-menutoggle="adminmenu">
<a class="menuhead" href="#"><h3>Admin</h3></a>
</li>
{/if}
<li class="nav-item menutoggle" data-menutoggle="employeemenu">
<a class="menuhead" href="#"><h3>Zaměstnanec</h3></a>
</li>
<li class="nav-item employeemenu">
<a n:class="$presenter->isLinkCurrent(':Todo:*') ? active, nav-link" n:href=":Todo:default">Činnosti</a>
</li>
{if $rent_acc}
<li class="nav-item menutoggle" data-menutoggle="rentmenu">
<a class="menuhead" href="#"><h3>Rent</h3></a>
</li>
{/if}
</ul>
Latte plugin 1.1.4, PhpStorm 2021.2.3, win 10 64b.
- mesour
- Nette Blogger | 236
dTTb wrote:
Hi, I have a wierd problem, code like this:
...
and each reformating after that adds empty lines:
<ul class="nav nav-pills flex-column mainmenu"> {if isset($admin) && $admin} <li class="nav-item menutoggle" data-menutoggle="adminmenu"> <a class="menuhead" href="#"><h3>Admin</h3></a> </li> ...
Latte plugin 1.1.4, PhpStorm 2021.2.3, win 10 64b.
Hello, it is known bug described here: https://github.com/…e/issues/175. I haven't been able to figure out what the problem is yet. But I'm trying to work it out sometimes.