natanfelles / codeigniter-phpstorm

PhpStorm Code Completion for CodeIgniter 3

Home Page:https://natanfelles.github.io/blog/codeigniter-code-completion-phpstorm.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can it possible to prompt a variable in view?

weituotian opened this issue · comments

Yes. If you have the msg index in a data array:

<div class="container">
<?php
/**
 * $data array holds the $msg value
 * 
 * @see Controller_name::method_name()
 * @var Controller_name $msg The message
 */
echo $msg;
?>

Seems to be not working :(

image

I didn't get how to make it work! Can someone explain more thoroughly, in for dummies style☻
Why do i need to write so much code to get autocomplition in a view?

Btw - Thanks for plugin! It seems to work just fine!

I use my own Library, so i jsut added new lines to phpstorm.php file with names of my liblires. But i can't understand why do we need 3 different paragraphs in this file. What is the difference between them?

I mean -


	public function __construct()
	{
	}
}

```

```
class CI_Model {

	public function __construct()
	{
	}
}
```


```
class MX_Controller {

	public function __construct()
	{
	}
```

Why do i need to write so much code to get autocomplition in a view?

@glorsh66 You don't need. But you can. This will will make PhpStorm easier to develop, as well as helping you know what each variable in your view is receiving.

i can't understand why do we need 3 different paragraphs in this file. What is the difference between them?

PhpStorm will index this file and understand that the properties in PHP Doc is a property in these three classes: CI_Controller, CI_Model and MX_Controller.

When you create a controller that extends the CI_Controller, for example, through $this the PhpStorm, and also other editors/IDES, will show you the properties defined there in phpstorm.php.

So there is a need to make the IDE not index the native Controller because it does not provide the understanding that properties. In fact, you'll need to load whatever you want with $this->load or autoload so these properties really work.

I also created a post on how to make it work on Atom, the logic of the operation is the same.

The reason for the three paragraphs was to separate them, but although I have not tested it yet, I believe that if you do something like this will work the same:

/**
 * @property Foo $foo
 */
class CI_Controller {}
class CI_Model extends CI_Controller {}
class MX_Controller extends CI_Controller {}

The main reason for this need may be because CodeIgniter pattern, because the IDEs do not understand it very well.

The use of namespaces facilitates the development and understanding of IDES. Something present in the next version of this framework.