[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/symfony/error-handler/Resources/bin/ -> extract-tentative-return-types.php (source)

   1  #!/usr/bin/env php
   2  <?php
   3  
   4  /*
   5   * This file is part of the Symfony package.
   6   *
   7   * (c) Fabien Potencier <[email protected]>
   8   *
   9   * For the full copyright and license information, please view the LICENSE
  10   * file that was distributed with this source code.
  11   */
  12  
  13  // Run from the root of the php-src repository, this script generates
  14  // a table with all the methods that have a tentative return type.
  15  //
  16  // Usage: find -name *.stub.php | sort | /path/to/extract-tentative-return-types.php > /path/to/TentativeTypes.php
  17  
  18  echo <<<EOPHP
  19  <?php
  20  
  21  /*
  22   * This file is part of the Symfony package.
  23   *
  24   * (c) Fabien Potencier <[email protected]>
  25   *
  26   * For the full copyright and license information, please view the LICENSE
  27   * file that was distributed with this source code.
  28   */
  29  
  30  namespace Symfony\Component\ErrorHandler\Internal;
  31  
  32  /**
  33   * This class has been generated by extract-tentative-return-types.php.
  34   *
  35   * @internal
  36   */
  37  class TentativeTypes
  38  {
  39      public const RETURN_TYPES = [
  40  
  41  EOPHP;
  42  
  43  while (false !== $file = fgets(\STDIN)) {
  44      $code = file_get_contents(substr($file, 0, -1));
  45  
  46      if (!str_contains($code, '@tentative-return-type')) {
  47          continue;
  48      }
  49  
  50      $code = preg_split('{^\s*(?:(?:abstract )?class|interface|trait) ([^\s]++)}m', $code, -1, \PREG_SPLIT_DELIM_CAPTURE);
  51  
  52      if (1 === count($code)) {
  53          continue;
  54      }
  55  
  56      for ($i = 1; null !== $class = $code[$i] ?? null; $i += 2) {
  57          $methods = $code[1 + $i];
  58  
  59          if (!str_contains($methods, '@tentative-return-type')) {
  60              continue;
  61          }
  62  
  63          echo "        '$class' => [\n";
  64  
  65          preg_replace_callback('{@tentative-return-type.*?[\s]function ([^(]++)[^)]++\)\s*+:\s*+([^\n;\{]++)}s', function ($m) {
  66              $m[2] = str_replace(' ', '', $m[2]);
  67              echo "            '$m[1]' => '$m[2]',\n";
  68  
  69              return '';
  70          }, $methods);
  71  
  72          echo "        ],\n";
  73      }
  74  }
  75  
  76  echo <<<EOPHP
  77      ];
  78  }
  79  
  80  EOPHP;


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer