Edwin
Edwin

Reputation: 2278

PhpStorm doesn't recognize return type after nesting calls

When I'm doing a nesting call of a function on an object the PhpStorm stop recognizing the function after some calls. Any idea how to solve this or why this occurs?

The function is highlighted and I get this following text message (see the code below to see the exact place where it comes):

Method addColumn not found in subject class. Referenced method is not found in subject class.

My case:

I use the Table class from here: github magento2 Table class

and my install function:

$installer = $setup;
$installer->startSetup();
/**
 * @var \Magento\Framework\DB\Ddl\Table $table
 */
$table = null;

    /**
     * Create table 'acc'
     */
    $table = $installer->getConnection()->newTable(
        $installer->getTable('acc')
    )->addColumn(
        'id',
        \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER,
        null,
        ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true],
        'Entity Id'
    )->addColumn(
        'user',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        32,
        ['identity' => true, 'unique' => true],
        'User'
    )->addColumn(
        'general',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        32,
        [],
        'General'
    )->addColumn(... //more columns (let's say that I add 20 columns) - Until here is no problem
    )->addColumn( //then I get here the text highlighted and text message written above the code. - in my case this is the 25th call to the function
        'individual',
        \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
        32,
        [],
        'Individual'
    )->addColumn(
        'created_at',
        \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP,
        null,
        ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT],
        'Created At'
    );

What I've tried:

to add @var \Magento\Framewrok\DB\Ddl\Table $table to the $table variable.

Upvotes: 0

Views: 57

Answers (1)

LazyOne
LazyOne

Reputation: 165088

For performance reasons PhpStorm stops analysing the chained calls at some point. Cannot say for sure when though -- but approximately at 25th-30th chain; may depends on the code complexity or something else.

There is no much you can do here -- you cannot increase such limit from user end (some hidden setting) AFAIK.

Breaking the chain at some point is the way to go here -- it seems to work fine. Not sure about you/others .. but it's acceptable solution as for me -- it may also work as visual separation between the related column groups or alike.

Upvotes: 3

Related Questions