Auto complete adding backslash with native php functions

General discussion on Zend Studio
lansoweb
Posts: 14
Joined: Tue Jun 01, 2010 1:47 pm

Auto complete adding backslash with native php functions

Post by lansoweb » Wed Jan 21, 2015 11:28 am

Hello!

Before 12.0.1, auto completed functions like is_int was completed to:
is_int($value);

After the update, it (and all php functions) completes to:
\is_int($value);

This is happening with all my projects (Zend Framework 2). Is that a new feature or a bug? Is there a way to disable it? Couldn't find anything in the Settings...

Regards,
Leandro Silva

mich6938
Zend Product Manager
Posts: 352
Joined: Wed Jul 16, 2014 12:32 pm

Re: Auto complete adding backslash with native php functions

Post by mich6938 » Wed Jan 21, 2015 11:53 am

Hi,

This is a feature. Content assist is now adding "\" prefix for global functions in namspaced context. This is similar situation like adding "\" for global types e.g.:

Code: Select all

<?php

namesce Test;

new \Exception();
Actually there is no preference to change this behavior (for functions and also for types).

lansoweb
Posts: 14
Joined: Tue Jun 01, 2010 1:47 pm

Re: Auto complete adding backslash with native php functions

Post by lansoweb » Wed Jan 21, 2015 12:20 pm

Thanks for the feedback!

andr4817
Posts: 222
Joined: Mon Aug 25, 2014 8:04 am

Re: Auto complete adding backslash with native php functions

Post by andr4817 » Wed Jan 21, 2015 3:13 pm

What?? Who requested such 'feature' ? And why??

PHP native functions are global by default. They are accessible from everywhere without the need of any backslashes.

What is the point of adding them and making code more ugly?

I don't understand the purpose of such 'feature'... is this coming from eclipse platform or from ZS development?

At least please make option to turn this nonsence off...

mich6938
Zend Product Manager
Posts: 352
Joined: Wed Jul 16, 2014 12:32 pm

Re: Auto complete adding backslash with native php functions

Post by mich6938 » Wed Jan 21, 2015 7:13 pm

We will add option to disable it to our list. We are gathering feedback right now.

andr4817
Posts: 222
Joined: Mon Aug 25, 2014 8:04 am

Re: Auto complete adding backslash with native php functions

Post by andr4817 » Wed Jan 21, 2015 8:01 pm

Option to disable it is 100% necessary.

Now, instead of helping, CA makes you do more work. Because every time you insert native (or custom made, which is also global) function, you need to manually remove backslash.

Or you have useless backslashes at the front to which users are not used to as nobody writes them.

However it's completely opposite for using other classes from other namespaces. Without backslash the code will not work at all. But for php functions this is not needed and code will work and have worked perfectly for the last 10 years.

Two different things.

mich6938
Zend Product Manager
Posts: 352
Joined: Wed Jul 16, 2014 12:32 pm

Re: Auto complete adding backslash with native php functions

Post by mich6938 » Fri Jan 23, 2015 4:14 pm

Hi,
In official release this option will be disabled by default. New option will be available in content assist preferences.

andr4817
Posts: 222
Joined: Mon Aug 25, 2014 8:04 am

Re: Auto complete adding backslash with native php functions

Post by andr4817 » Fri Jan 23, 2015 4:40 pm

Thank you! This is correct solution.

gaborm
Posts: 22
Joined: Fri Jun 26, 2009 10:33 am

Re: Auto complete adding backslash with native php functions

Post by gaborm » Fri Jan 30, 2015 1:30 pm

It's not only native functions. In 12.0.2 (x64/x86 both) I am getting those backslashes on class methods calls too.

To reproduce:

1. create new workspace
2. create a local PHP project, add Composer support
3. add a lib via Composer (I added google/apiclient)
4. create a blank php file and add a namespace to it (Note: if you don't add namespace to the file the issue is not an issue.)
5. include the Composer autoload
6. try to access a class method from the lib from step #3 and let autoassist complete your line:
zstudio12x64_namespace_assist.png
zstudio12x64_namespace_assist.png (68.01 KiB) Viewed 5423 times

mich6938
Zend Product Manager
Posts: 352
Joined: Wed Jul 16, 2014 12:32 pm

Re: Auto complete adding backslash with native php functions

Post by mich6938 » Fri Jan 30, 2015 1:37 pm

Thanks for info! This issue was already detected and fixed. Fix will be in next release that will be available soon.

Post Reply