Php Framework-how to intelligently prompt php class array member variables (auto-completion )?

Source: Internet
Author: User
{Code ...} $ snewa (); echos: config-& amp; gt; id; die; how to make s: $ config-& amp; gt; you can automatically complete the IDs and status .....
class a{    static $config = [        'id' => 1,        'status' => ['status1'=>1,'status2'=>2]    ];  }

$ S = new ();
Echo s: config-> id;
Die;

How to enable s: $ config-> to automatically complete the id and status .....

Reply content:
class a{    static $config = [        'id' => 1,        'status' => ['status1'=>1,'status2'=>2]    ];  }

$ S = new ();
Echo s: config-> id;
Die;

How to enable s: $ config-> to automatically complete the id and status .....

Of course, you can do this by using phpdoc annotations and a helper class that implements the ArrayAccess interface and has the prompted attributes you need.

In fact, the principle is to let ide mistakenly think that this array is a class and then automatically prompts to complete the attribute name, and ArrayAccess has the "black" Magic to treat the class object as an array operation.

The code prompts of ide are to generate an index when loading the project, and then start to retrieve the complete prompt when entering the relevant characters. If arrays are to be prompted, the possibility is extremely small, this method consumes too many resources and is local and keeps searching. However, if sublime is used, it will prompt the recently used words, which may meet your needs.

Phpstorm automatically prompts the class member variables. elements that prompt the array type member variables have not been involved yet.

Generally, IDE development tools will prompt the class member variables and class member method names. However, I haven't found any prompts yet.

Basically, no. Simply put, these arrays are created at runtime, and syntax parsing is not at this level, and it is not necessary.

For example:
I want to delete a key in the array in the code. what should I do?

The supplemented comments and completions on the array structure layer are not as good as the phpdoc study.

ArrayAccess

Phpstorm of the new version has been supported. Today, my colleague said that his prompt was prompted. my const array declaration was reported to be red .... His phpstorm is supported ....!!

PHPDoc + 1 can refer to this http://www.07net01.com/progra...

Some IDEs can be implemented to install corresponding plug-ins. we recommend that you use sublime.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.