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

Breadcrumb

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

function ClassLike::getProperty

Gets property with the given name defined directly in this class/interface/trait.

Parameters

string $name Name of the property:

Return value

Property|null Property node or null if the property does not exist

File

vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassLike.php, line 65

Class

ClassLike

Namespace

PhpParser\Node\Stmt

Code

public function getProperty(string $name) : ?Property {
    foreach ($this->stmts as $stmt) {
        if ($stmt instanceof Property) {
            foreach ($stmt->props as $prop) {
                if ($prop instanceof PropertyItem && $name === $prop->name
                    ->toString()) {
                    return $stmt;
                }
            }
        }
    }
    return null;
}

API Navigation

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