[ Index ]

PHP Cross Reference of phpBB-3.3.9-deutsch

title

Body

[close]

/vendor/s9e/text-formatter/src/Configurator/TemplateNormalizations/ -> SortAttributesByName.php (source)

   1  <?php
   2  
   3  /**
   4  * @package   s9e\TextFormatter
   5  * @copyright Copyright (c) 2010-2022 The s9e authors
   6  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
   7  */
   8  namespace s9e\TextFormatter\Configurator\TemplateNormalizations;
   9  
  10  use DOMElement;
  11  
  12  /**
  13  * Sort attributes by name in lexical order
  14  *
  15  * Only applies to inline attributes, not attributes created with xsl:attribute
  16  */
  17  class SortAttributesByName extends AbstractNormalization
  18  {
  19      /**
  20      * {@inheritdoc}
  21      */
  22      protected $queries = ['//*[@*]'];
  23  
  24      /**
  25      * {@inheritdoc}
  26      */
  27  	protected function normalizeElement(DOMElement $element)
  28      {
  29          $attributes = [];
  30          foreach ($element->attributes as $name => $attribute)
  31          {
  32              $attributes[$name] = $element->removeAttributeNode($attribute);
  33          }
  34  
  35          ksort($attributes);
  36          foreach ($attributes as $attribute)
  37          {
  38              $element->setAttributeNode($attribute);
  39          }
  40      }
  41  }


Generated: Wed Dec 7 15:09:22 2022 Cross-referenced by PHPXref 0.7.1