Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

BooleanFunctions.php

Zuletzt modifiziert: 02.04.2025, 15:04 - Dateigröße: 2.47 KiB


001  <?php
002   
003  /**
004  * @package   s9e\TextFormatter
005  * @copyright Copyright (c) 2010-2022 The s9e authors
006  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
007  */
008  namespace s9e\TextFormatter\Configurator\RendererGenerators\PHP\XPathConvertor\Convertors;
009   
010  class BooleanFunctions extends AbstractConvertor
011  {
012      /**
013      * {@inheritdoc}
014      */
015      public function getMatchers(): array
016      {
017          $groups = 'Boolean:BooleanFunction:';
018   
019          return [
020              $groups . 'BooleanParam'  => 'boolean \\( ((?&Parameter)) \\)',
021              $groups . 'False'         => 'false \\( \\)',
022              $groups . 'HasAttribute'  => 'boolean \\( ((?&Attribute)) \\)',
023              $groups . 'HasAttributes' => 'boolean \\( @\\* \\)',
024              $groups . 'Not'           => [
025                  // Only try matching generic not() invocations after special cases fail
026                  'order'  => 100,
027                  'regexp' => 'not \\( ((?&Boolean)|(?&BooleanExpression)) \\)'
028              ],
029              $groups . 'NotAttribute'  => 'not \\( ((?&Attribute)) \\)',
030              $groups . 'NotParam'      => 'not \\( ((?&Parameter)) \\)',
031              $groups . 'True'          => 'true \\( \\)'
032          ];
033      }
034   
035      /**
036      * Convert a call to boolean() with a param
037      *
038      * @param  string $expr
039      * @return string
040      */
041      public function parseBooleanParam($expr)
042      {
043          return $this->recurse($expr) . "!==''";
044      }
045   
046      /**
047      * Convert a call to false()
048      *
049      * @return string
050      */
051      public function parseFalse()
052      {
053          return 'false';
054      }
055   
056      /**
057      * Convert a call to boolean() with an attribute
058      *
059      * @param  string $expr
060      * @return string
061      */
062      public function parseHasAttribute($expr)
063      {
064          $attrName = $this->getAttributeName($expr);
065   
066          return '$node->hasAttribute(' . var_export($attrName, true) . ')';
067      }
068   
069      /**
070      * Convert a call to boolean(@*)
071      *
072      * @return string
073      */
074      public function parseHasAttributes()
075      {
076          return '$node->attributes->length';
077      }
078   
079      /**
080      * Convert a call to not() with a boolean expression
081      *
082      * @param  string $expr
083      * @return string
084      */
085      public function parseNot($expr)
086      {
087          return '!(' . $this->recurse($expr) . ')';
088      }
089   
090      /**
091      * Convert a call to not() with an attribute
092      *
093      * @param  string $expr
094      * @return string
095      */
096      public function parseNotAttribute($expr)
097      {
098          $attrName = $this->getAttributeName($expr);
099   
100          return '!$node->hasAttribute(' . var_export($attrName, true) . ')';
101      }
102   
103      /**
104      * Convert a call to not() with a param
105      *
106      * @param  string $expr
107      * @return string
108      */
109      public function parseNotParam($expr)
110      {
111          return $this->recurse($expr) . "===''";
112      }
113   
114      /**
115      * Convert a call to true()
116      *
117      * @return string
118      */
119      public function parseTrue()
120      {
121          return 'true';
122      }
123  }