class Foo in Coder 8.2
Same name in this branch
Same name and namespace in other branches
All classes need to have a docblock.
Hierarchy
- class \Foo implements \FooInterface
Expanded class hierarchy of Foo
File
- coder_sniffer/
Drupal/ Test/ good/ good.php, line 981 - This file contains all the valid notations for the drupal coding standard.
View source
class Foo implements FooInterface {
/**
* {@inheritdoc}
*/
public function test() {
/** @var \Drupal\node\NodeInterface $node */
$node = $this->entity;
/** @var \Drupal\node\NodeInterface[] $nodes */
$nodes = foo();
/** @var \Drupal\node\NodeInterface|\PHPUnit_Framework_MockObject_MockObject $node_mock */
$node_mock = mock_node();
/** @var \Drupal\SomeInterface4You $thing */
$thing = thing();
/** @var \Drupal\SomeInterface4You $test2 */
$test2 = test2();
return $node;
}
/**
* {@inheritdoc}
*
* Some additional documentation here.
*/
public function test2() {
}
/**
* Return docs are allowed to use $this.
*
* @return $this
* This object for chaining method calls.
*/
public function test3() {
return $this;
}
/**
* Returns the string representatuion of this object.
*/
public function __toString() {
return 'foo';
}
/**
* Omitting the comment when returning $this is allowed.
*
* @return $this
*/
public function test4() {
return $this;
}
/**
* Omitting the comment when returning static is allowed.
*
* @return static
*/
public function test41() {
return new static();
}
/**
* Loads multiple string objects.
*
* @param array $conditions
* Any of the conditions used by dbStringSelect().
* @param array $options
* Any of the options used by dbStringSelect().
* @param string $class
* Class name to use for fetching returned objects.
*
* @return \Drupal\locale\StringInterface[]
* Array of objects of the class requested.
*/
protected function dbStringLoad(array $conditions, array $options, $class) {
$strings = array();
$result = $this
->dbStringSelect($conditions, $options)
->execute();
foreach ($result as $item) {
/** @var \Drupal\locale\StringInterface $string */
$string = new $class($item);
$string
->setStorage($this);
$strings[] = $string;
}
return $strings;
}
/**
* Short array syntax is allowed.
*/
public function getConfiguration() {
return [
'id' => $this
->getPluginId(),
] + $this->configuration;
}
/**
* Not documenting a "throws" tag is allowed.
*
* This should not fail for errors with underscores in names as well.
* The second version of this test with error name with underscores
* is added below.
*
* @throws Exception
*/
public function test6() {
throw new Exception();
}
/**
* Repeat of above test with error name with underscores.
*
* @throws \Twig_Error_Syntax
*/
public function test7() {
throw new Exception();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Foo:: |
protected | function | Loads multiple string objects. | |
Foo:: |
public | function | Short array syntax is allowed. | |
Foo:: |
public | function | ||
Foo:: |
public | function | Some additional documentation here. | |
Foo:: |
public | function | Return docs are allowed to use $this. | |
Foo:: |
public | function | Omitting the comment when returning $this is allowed. | |
Foo:: |
public | function | Omitting the comment when returning static is allowed. | |
Foo:: |
public | function | Not documenting a "throws" tag is allowed. | |
Foo:: |
public | function | Repeat of above test with error name with underscores. | |
Foo:: |
public | function | Returns the string representatuion of this object. |