---
title: "Tools"
url: https://festi.dev/8.0/Utilities/Tools/
---

# Tools

## Festi CLI

[Detail Documentation](https://festi.dev/8.0/Packages/CLI/index.md)

## PHPStorm

You need to create or place the `.phpstorm.meta.php` file in the project root (an example is available in `core/tool/.phpstorm.meta.php`)

### Autocompletion through .phpstorm.meta.php
Most developers use PhpStorm as their development tool. 
To speed up coding, developers use code autocompletion (ctrl+space), which is a good IDE feature. But PhpStorm doesn't always provide the correct and necessary autocompletions. For such purposes, it's useful to use `.phpstorm.meta.php` files in your projects.
You can read more about this mechanism from the official [source](https://blog.jetbrains.com/phpstorm/2019/02/new-phpstorm-meta-php-features/), and examples of usage are presented below.

A typical example of usage. We need to set the `Response` type, here's how a project with standard autocompletion looks:

![Response setType](https://festi.dev/8.0/images/phpstorm_settype.jpg)

Now let's add autocompletion descriptions for our `setType` method in the `.phpstorm.meta.php` file:
```php
namespace PHPSTORM_META {
    expectedArguments(
        \Response::setType(),
        0,
        \Response::NORMAL,
        \Response::JSON,
        \Response::JSON_IFRAME,
        \Response::JSON_JS,
        \Response::JSON_P
    );
}
```
And here's what we get:

![Response setType](https://festi.dev/8.0/images/phpstorm_settype_meta.jpg)

Another example of usage is autocompletion for a method's return parameters.

![Response setType](https://festi.dev/8.0/images/phpstorm_return.jpg)

```php
registerArgumentsSet(
    'store_actions',
    \Store::ACTION_LIST,
    \Store::ACTION_INSERT,
    \Store::ACTION_EDIT,
    \Store::ACTION_REMOVE,
    \Store::ACTION_PARENT,
    \Store::ACTION_CHILD,
    \Store::ACTION_INFO,
    \Store::ACTION_DOWNLOAD,
    \Store::ACTION_CONFIRM,
    \Store::ACTION_CSV,
    \Store::ACTION_PLUGIN,
    \Store::ACTION_CSV_IMPORT,
    \Store::ACTION_BATCH_INSERT,
    \Store::ACTION_GRID_EDITOR,
);
expectedReturnValues(
    \Store::getAction(),
    argumentsSet('store_actions')
);
```

### Autocompletion for Core::getInstance()->getPluginInstance()

For the obtained plugin instance to work in the IDE, you need to define data mapping:

```php
namespace PHPSTORM_META {

    override(\Core::getInstance()->getPluginInstance(0), map([
        'Jimbo' => \JimboPlugin::class,
        'Contents' => \ContentsPlugin::class,
        'FestiIDE' => \FestiIDEPlugin::class
    ]));
}
```

![PHPStorm Autocomplete](https://festi.dev/8.0/images/Tools/PHPStorm_PluginAutocomplete3.png)

### Autocompletion for calling `$this->plugin` in a plugin

All system and common plugins are added with the annotation `@property-read \YourPlugin $your` in the `core\util\PluginWrapper` class,
for example:

`@property-read \JimboPlugin $jimbo` 

![PHPStorm Autocomplete](https://festi.dev/8.0/images/Tools/PHPStorm_PluginAutocomplete.png)

![PHPStorm Autocomplete](https://festi.dev/8.0/images/Tools/PHPStorm_PluginAutocomplete2.png)

To add your plugins to autocompletion, you can do the following:

1.  Create a class, for example, `PHPStormPluginWrapper` (you don't need to include it in your code, it's solely needed to trick PHPStorm).
    
    ```php
    /**
     * @property-read \FestiIDEPlugin $festiIDE
     * @property-read \MyPlugin $my
     */
    class PHPStormPluginWrapper extends \core\util\PluginWrapper
    {
    }
    ```

2. Add to your `.phpstorm.meta.php` (it's better to place it in the project root):

    ```php
    namespace PHPSTORM_META {
    
        override(\core\util\PluginWrapper::getInstance(0), map([
            '' => \PHPStormPluginWrapper::class
        ]));
    }
    ```

3. Use autocompletion:

    ![PHPStorm Autocomplete](https://festi.dev/8.0/images/Tools/PHPStorm_PluginAutocomplete4.png)

### Autocompletion for calling `$this->object` in a plugin

For autocompletion here, you need to override the global attribute `$object`:

```php
class ContentsPlugin extends DisplayPlugin
{
    /**
     * @var ContentsObject
     */
    protected $object;
    
    ...
}
```
