Tools

Festi CLI

Detail Documentation

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, 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

Now let's add autocompletion descriptions for our setType method in the .phpstorm.meta.php file:

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

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

Response setType

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:

namespace PHPSTORM_META {

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

PHPStorm Autocomplete

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

PHPStorm Autocomplete

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).

    /**
     * @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):

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

    PHPStorm Autocomplete

Autocompletion for calling $this->object in a plugin

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

class ContentsPlugin extends DisplayPlugin
{
    /**
     * @var ContentsObject
     */
    protected $object;

    ...
}