You are here

class Foo in Coder 8.2

Same name in this branch
  1. 8.2 coder_sniffer/Drupal/Test/Commenting/FileCommentUnitTest.11.inc \Foo
  2. 8.2 coder_sniffer/Drupal/Test/good/good.php \Foo
Same name and namespace in other branches
  1. 8.3 tests/Drupal/Commenting/FileCommentUnitTest.11.inc \Foo
  2. 7.2 coder_sniffer/Test/good/good.php \Foo
  3. 8.3.x tests/Drupal/Commenting/FileCommentUnitTest.11.inc \Foo

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

Namesort descending Modifiers Type Description Overrides
Foo::dbStringLoad protected function Loads multiple string objects.
Foo::getConfiguration public function Short array syntax is allowed.
Foo::test public function
Foo::test2 public function Some additional documentation here.
Foo::test3 public function Return docs are allowed to use $this.
Foo::test4 public function Omitting the comment when returning $this is allowed.
Foo::test41 public function Omitting the comment when returning static is allowed.
Foo::test6 public function Not documenting a "throws" tag is allowed.
Foo::test7 public function Repeat of above test with error name with underscores.
Foo::__toString public function Returns the string representatuion of this object.