Problem
Modern IDEs (Netbeans, Phpstorm) can provide intelligent autocomplete functions based on the PhpDoc.
The problem is that if a type hint in the @return defined with the fully qualified name of an interface and that method return with the called object (return $this;) then one can't use all the method from the original object just those methods which are come from the interface.
For example:
The ->condition()
method is unknown because the ->->addTag()
-
according to the Phpdoc - returns an \Drupal\Core\Database\Query\AlterableInterface
instance, and it has no condition()
method.
/** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */
$storage
->getQuery()
->addTag('xxx')
->condition();
Other example:
/** @var \Drupal\Core\Database\Query\SelectInterface $select */
$select
->condition()
->groupBy();
These are the methods where the @return type hint could be replaced with $this.
- interface Drupal\Component\Plugin\ContextAwarePluginInterface::setContextValue
- class Drupal\Core\Access\AccessResultAllowed::allowed
- class Drupal\Core\Access\AccessResultForbidden::forbidden
- class Drupal\Core\Access\AccessResultNeutral::neutral
- interface Drupal\Core\Asset\AttachedAssetsInterface::createFromRenderArray
- interface Drupal\Core\Config\StorageComparerInterface::reset
- interface Drupal\Core\Config\StorageInterface::createCollection
- class Drupal\Core\Config\Config::setSettingsOverride
- class Drupal\Core\Config\Config::setModuleOverride
- class Drupal\Core\Config\Config::setOverriddenData
- class Drupal\Core\Config\Config::resetOverriddenData
- class Drupal\Core\Config\Config::delete
- class Drupal\Core\Config\ConfigImporter::reset
- class Drupal\Core\Config\ConfigImporter::import
- class Drupal\Core\Config\PreExistingConfigException::create
- interface Drupal\Core\Database\Query\ExtendableInterface::extend
- interface Drupal\Core\Database\Query\ConditionInterface::condition
- interface Drupal\Core\Database\Query\ConditionInterface::where
- interface Drupal\Core\Database\Query\ConditionInterface::isNull
- interface Drupal\Core\Database\Query\ConditionInterface::isNotNull
- interface Drupal\Core\Database\Query\ConditionInterface::exists
- interface Drupal\Core\Database\Query\ConditionInterface::notExists
- interface Drupal\Core\Database\Query\ConditionInterface::conditionGroupFactory
- interface Drupal\Core\Database\Query\ConditionInterface::andConditionGroup
- interface Drupal\Core\Database\Query\ConditionInterface::orConditionGroup
- class Drupal\Core\Database\Query\Insert::from
- class Drupal\Core\Database\Query\Merge::conditionTable
- class Drupal\Core\Database\Query\Merge::updateFields
- class Drupal\Core\Database\Query\Merge::expression
- class Drupal\Core\Database\Query\Merge::insertFields
- class Drupal\Core\Database\Query\Merge::useDefaults
- class Drupal\Core\Database\Query\Merge::fields
- class Drupal\Core\Database\Query\Update::fields
- class Drupal\Core\Database\Query\Update::expression
- class Drupal\Core\Database\Query\Select::prepareCountQuery
- interface Drupal\Core\Database\Query\SelectInterface::distinct
- interface Drupal\Core\Database\Query\SelectInterface::fields
- interface Drupal\Core\Database\Query\SelectInterface::orderBy
- interface Drupal\Core\Database\Query\SelectInterface::orderRandom
- interface Drupal\Core\Database\Query\SelectInterface::range
- interface Drupal\Core\Database\Query\SelectInterface::union
- interface Drupal\Core\Database\Query\SelectInterface::groupBy
- interface Drupal\Core\Database\Query\SelectInterface::countQuery
- interface Drupal\Core\Database\Query\AlterableInterface::addMetaData
- class Drupal\Core\Entity\Query\Sql\QueryAggregate::addAggregate
- class Drupal\Core\Entity\Query\Sql\QueryAggregate::compileAggregate
- class Drupal\Core\Entity\Query\Sql\QueryAggregate::addGroupBy
- class Drupal\Core\Entity\Query\Sql\QueryAggregate::addSortAggregate
- class Drupal\Core\Entity\Query\Sql\Query::prepare
- class Drupal\Core\Entity\Query\Sql\Query::compile
- class Drupal\Core\Entity\Query\Sql\Query::addSort
- class Drupal\Core\Entity\Query\Sql\Query::finish
- interface Drupal\Core\Entity\Query\ConditionAggregateInterface::condition
- interface Drupal\Core\Entity\Query\QueryAggregateInterface::aggregate
- interface Drupal\Core\Entity\Query\QueryAggregateInterface::groupBy
- interface Drupal\Core\Entity\Query\QueryAggregateInterface::conditionAggregate
- interface Drupal\Core\Entity\Query\QueryAggregateInterface::existsAggregate
- interface Drupal\Core\Entity\Query\QueryAggregateInterface::notExistsAggregate
- interface Drupal\Core\Entity\Query\QueryAggregateInterface::sortAggregate
- interface Drupal\Core\Entity\Query\QueryInterface::condition
- interface Drupal\Core\Entity\Query\QueryInterface::exists
- interface Drupal\Core\Entity\Query\QueryInterface::notExists
- interface Drupal\Core\Entity\Query\QueryInterface::pager
- interface Drupal\Core\Entity\Query\QueryInterface::range
- interface Drupal\Core\Entity\Query\QueryInterface::sort
- interface Drupal\Core\Entity\Query\QueryInterface::count
- interface Drupal\Core\Entity\Query\QueryInterface::tableSort
- interface Drupal\Core\Entity\Query\QueryInterface::accessCheck
- interface Drupal\Core\Entity\EntityConstraintViolationListInterface::getEntityViolations
- interface Drupal\Core\Entity\EntityConstraintViolationListInterface::getByFields
- class Drupal\Core\Field\Entity\BaseFieldOverride::createFromBaseFieldDefinition
- interface Drupal\Core\Field\FieldConfigInterface::getConfig
- class Drupal\Core\Form\EnforcedResponse::createFromException
- interface Drupal\Core\Archiver\ArchiverInterface::add
- interface Drupal\Core\Archiver\ArchiverInterface::remove
- interface Drupal\Core\Archiver\ArchiverInterface::extract
- class Drupal\Core\Cache\BackendChain::appendBackend
- class Drupal\Core\Cache\BackendChain::prependBackend
- interface Drupal\Core\ImageToolkit\ImageToolkitInterface::setSource
- interface Drupal\Core\Language\LanguageManagerInterface::reset
- interface Drupal\Core\Menu\LocalTaskInterface::setActive
- interface Drupal\Core\Session\AccountSwitcherInterface::switchTo
- interface Drupal\Core\Session\AccountSwitcherInterface::switchBack
- class Drupal\Core\StringTranslation\PluralTranslatableMarkup::createFromTranslatedString
- interface Drupal\Core\TypedData\TraversableTypedDataInterface::getParent
- interface Drupal\Core\TypedData\TraversableTypedDataInterface::getRoot
- interface Drupal\Core\TypedData\TypedDataInterface::applyDefaultValue
- class Drupal\Core\TypedData\ListDataDefinition::create
- class Drupal\Core\Updater\Updater::factory
- class Drupal\Core\Url::fromRoute
- class Drupal\Core\Url::fromUri
- class Drupal\Core\Url::fromEntityUri
- class Drupal\Core\Url::fromInternalUri
- class Drupal\Core\Url::fromRouteUri
- interface Drupal\block_content\BlockContentInterface::setInfo
- interface Drupal\block_content\BlockContentInterface::setRevisionLog
- interface Drupal\block_content\BlockContentInterface::setTheme
- interface Drupal\comment\CommentInterface::getParentComment
- interface Drupal\image\ImageStyleInterface::setName
- interface Drupal\locale\StringStorageInterface::save
- interface Drupal\locale\StringStorageInterface::delete
- class Drupal\locale\TranslationString::setCustomized
- interface Drupal\node\NodeInterface::setTitle
- interface Drupal\node\NodeInterface::setCreatedTime
- interface Drupal\node\NodeInterface::setPromoted
- interface Drupal\node\NodeInterface::setSticky
- interface Drupal\node\NodeInterface::setRevisionCreationTime
- interface Drupal\node\NodeInterface::setRevisionAuthorId
- interface Drupal\search\Plugin\SearchInterface::setSearch
- interface Drupal\shortcut\ShortcutInterface::setTitle
- interface Drupal\shortcut\ShortcutInterface::setWeight
- interface Drupal\shortcut\ShortcutSetInterface::resetLinkWeights
- class Drupal\system\Plugin\ImageToolkit\GDToolkit::setResource
- interface Drupal\user\UserInterface::setUsername
- interface Drupal\user\UserInterface::setPassword
- interface Drupal\user\UserInterface::setEmail
- interface Drupal\user\UserInterface::setLastAccessTime
- interface Drupal\user\UserInterface::setLastLoginTime
- interface Drupal\user\UserInterface::activate
- interface Drupal\user\UserInterface::block
- interface Drupal\views\Plugin\views\display\DisplayRouterInterface::getRoutedDisplay