public function __construct() { $this->keywords = new Set([T_ABSTRACT, T_CASE, T_CLASS, T_FUNCTION, T_CLONE, T_CONST, T_EXTENDS, T_FINAL, T_GLOBAL, T_IMPLEMENTS, T_INTERFACE, T_NAMESPACE, T_NEW, T_PRIVATE, T_PUBLIC, T_PROTECTED, T_THROW, T_TRAIT, T_USE]); $this->blocks = new Set([T_IF, T_ELSEIF, T_ELSE, T_FOR, T_FOREACH, T_WHILE, T_DO, T_SWITCH, T_TRY, T_CATCH, T_CLASS, T_INTERFACE, T_TRAIT, T_NAMESPACE, T_USE, T_FUNCTION]); $this->casts = new Set([T_ARRAY_CAST, T_BOOL_CAST, T_DOUBLE_CAST, T_INT_CAST, T_OBJECT_CAST, T_STRING_CAST, T_UNSET_CAST]); $this->assignments = new Set(['=', '&=', '.=', '/=', '-=', '%=', '*=', '|=', '+=', '**=', '<<=', '>>=', '^=']); $this->operators = new Set(['&', '&&', 'and', '|', '||', 'or', '^', 'xor', 'instanceof', '==', '>=', '>', '===', '!=', '<>', '!==', '<=', '<', '<<', '>>', '+', '-', '*', '/', '**', 'as']); $this->structural = new Set([T_CLASS, T_INTERFACE, T_TRAIT, T_NAMESPACE, T_USE, T_FUNCTION]); $this->structs = new Set([T_CLASS, T_INTERFACE, T_TRAIT]); $this->lineContext = new Set(['echo', 'global', 'static', 'yield', 'case']); $this->imports = new Set([T_REQUIRE, T_REQUIRE_ONCE, T_INCLUDE, T_INCLUDE_ONCE]); $this->unitIdentifier = new Set([T_CONST, T_NAMESPACE, T_USE]); $this->unitIdentifier->addAll($this->imports); $this->modifier = new Set([T_PRIVATE, T_PUBLIC, T_PROTECTED, T_STATIC, T_VAR, T_ABSTRACT]); }
public function testAddRemove() { $item1 = 'item 1'; $item2 = 'item 2'; $item3 = 'item 3'; $items = [$item1, $item2]; $set = new Set(); $set->add($item1); $this->assertEquals(1, $set->size()); $set->remove($item1); $this->assertEquals(0, $set->size()); $set->addAll($items); $this->assertEquals(2, $set->size()); $this->assertSame($items, $set->toArray()); $set->add($item3); $this->assertEquals(3, $set->size()); $set->removeAll($items); $this->assertEquals(1, $set->size()); }
public function setAcl(array $groups) { $this->acl->clear(); $this->acl->addAll($groups); return $this; }
/** * @param string $name * @return Startgroup */ private function getStartgroup($name) { $name = $this->translate($name); // some special cases $competition = null; if ($name == 'Junior Expert (male)' || $name == 'Expert (male)') { $competition = $this->competitions->get('Individual Freestyle (male)'); $startgroupName = str_replace(' (male)', '', $name); } else { if ($name == 'Junior Expert (female)' || $name == 'Expert (female)') { $competition = $this->competitions->get('Individual Freestyle (female)'); $startgroupName = str_replace(' (female)', '', $name); } } if ($competition === null) { $words = new Set(); foreach (array_values($this->translations) as $names) { $words->addAll(Text::create($names)->split(' ')); } $startgroupName = trim(str_replace($words->toArray(), '', $name)); $words = Text::create($startgroupName)->split(' '); $competitionName = preg_replace('/\\s\\s+/', ' ', trim(str_replace($words->toArray(), '', $name))); if (!$this->competitions->has($competitionName)) { throw new \Exception('Cannot find competition for ' . $competitionName); } $competition = $this->competitions->get($competitionName); } $startgroup = new Startgroup(); $startgroup->setName($startgroupName); $startgroup->setSlug(NameUtils::dasherize(strtolower($startgroupName))); $startgroup->setCompetition($competition); return $startgroup; }