public function asConfig()
 {
     $this->plugins->finalize();
     $properties = \get_object_vars($this);
     unset($properties['attributeFilters']);
     unset($properties['bundleGenerator']);
     unset($properties['javascript']);
     unset($properties['rendering']);
     unset($properties['rulesGenerator']);
     unset($properties['registeredVars']);
     unset($properties['templateChecker']);
     unset($properties['templateNormalizer']);
     unset($properties['stylesheet']);
     $config = ConfigHelper::toArray($properties);
     $bitfields = RulesHelper::getBitfields($this->tags, $this->rootRules);
     $config['rootContext'] = $bitfields['root'];
     $config['rootContext']['flags'] = $config['rootRules']['flags'];
     $config['registeredVars'] = ConfigHelper::toArray($this->registeredVars, \true);
     $config += array('plugins' => array(), 'tags' => array());
     $config['tags'] = \array_intersect_key($config['tags'], $bitfields['tags']);
     foreach ($bitfields['tags'] as $tagName => $tagBitfields) {
         $config['tags'][$tagName] += $tagBitfields;
     }
     unset($config['rootRules']);
     return $config;
 }
 /**
  * @testdox Bitfields are compressed by making tags that are targeted by the same permissions share the same bit number
  */
 public function testTwoIdenticalTags()
 {
     $tags = new TagCollection();
     $tags->add('A');
     $tags->add('B');
     $this->assertEquals(['root' => ['allowed' => [0b100000001]], 'tags' => ['A' => ['bitNumber' => 0, 'allowed' => [0b100000001]], 'B' => ['bitNumber' => 0, 'allowed' => [0b100000001]]]], RulesHelper::getBitfields($tags, new Ruleset()));
 }
 /**
  * Generate and return the complete config array
  *
  * @return array
  */
 public function asConfig()
 {
     // Finalize the plugins' config
     $this->plugins->finalize();
     // Remove properties that shouldn't be turned into config arrays
     $properties = get_object_vars($this);
     unset($properties['attributeFilters']);
     unset($properties['bundleGenerator']);
     unset($properties['javascript']);
     unset($properties['rendering']);
     unset($properties['rulesGenerator']);
     unset($properties['registeredVars']);
     unset($properties['templateChecker']);
     unset($properties['templateNormalizer']);
     unset($properties['stylesheet']);
     // Create the config array
     $config = ConfigHelper::toArray($properties);
     $bitfields = RulesHelper::getBitfields($this->tags, $this->rootRules);
     // Save the root context
     $config['rootContext'] = $bitfields['root'];
     $config['rootContext']['flags'] = $config['rootRules']['flags'];
     // Save the registered vars (including the empty ones)
     $config['registeredVars'] = ConfigHelper::toArray($this->registeredVars, true);
     // Make sure those keys exist even if they're empty
     $config += ['plugins' => [], 'tags' => []];
     // Remove unused tags
     $config['tags'] = array_intersect_key($config['tags'], $bitfields['tags']);
     // Add the bitfield information to each tag
     foreach ($bitfields['tags'] as $tagName => $tagBitfields) {
         $config['tags'][$tagName] += $tagBitfields;
     }
     // Remove unused entries
     unset($config['rootRules']);
     return $config;
 }