_name = $name; $this->_contentName = $contentName; $this->_match = $match; $this->_patterns = $patterns; $this->_captures = $captures; $this->_endPattern = $endPattern; $this->_ownerGrammar = ($ownerGrammar === null) ? null : \WeakReference::create($ownerGrammar); } // Used when adopting to change the $ownerGrammar property. public function withOwnerGrammar(Grammar $ownerGrammar): self { $new = parent::withOwnerGrammar($ownerGrammar); if ($new->_patterns !== null) { foreach ($new->_patterns as &$p) { $p = $p->withOwnerGrammar($ownerGrammar); } } return $new; } }