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

Breadcrumb

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

function ParserAbstract::parseNumString

Parse a T_NUM_STRING token into either an integer or string node.

Parameters

string $str Number string:

array<string, mixed> $attributes Attributes:

Return value

Int_|String_ Integer or string node.

File

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

Class

ParserAbstract

Namespace

PhpParser

Code

protected function parseNumString(string $str, array $attributes) {
    if (!preg_match('/^(?:0|-?[1-9][0-9]*)$/', $str)) {
        return new String_($str, $attributes);
    }
    $num = +$str;
    if (!is_int($num)) {
        return new String_($str, $attributes);
    }
    return new Int_($num, $attributes);
}

API Navigation

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