Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ParserAbstract.php

function ParserAbstract::checkClassMethod

File

vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php, line 1113

Class

ParserAbstract

Namespace

PhpParser

Code

protected function checkClassMethod(ClassMethod $node, int $modifierPos) : void {
    if ($node->flags & Modifiers::STATIC) {
        switch ($node->name
            ->toLowerString()) {
            case '__construct':
                $this->emitError(new Error(sprintf('Constructor %s() cannot be static', $node->name), $this->getAttributesAt($modifierPos)));
                break;
            case '__destruct':
                $this->emitError(new Error(sprintf('Destructor %s() cannot be static', $node->name), $this->getAttributesAt($modifierPos)));
                break;
            case '__clone':
                $this->emitError(new Error(sprintf('Clone method %s() cannot be static', $node->name), $this->getAttributesAt($modifierPos)));
                break;
        }
    }
    if ($node->flags & Modifiers::READONLY) {
        $this->emitError(new Error(sprintf('Method %s() cannot be readonly', $node->name), $this->getAttributesAt($modifierPos)));
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal