104 protected function addItem( $type, $marker, $value ) {
105 if ( !preg_match( $this->regex, $marker, $m ) ) {
106 throw new InvalidArgumentException(
"Invalid marker: $marker" );
109 $this->data[$type][$m[1]] = $value;
135 if ( !count( $this->data[
'nowiki'] ) ) {
139 $callback =
function ( $m ) use ( $callback ) {
141 if ( isset( $this->data[
'nowiki'][$marker] ) ) {
142 $value = $this->data[
'nowiki'][$marker];
143 if ( $value instanceof Closure ) {
147 $this->expandSize += strlen( $value );
148 if ( $this->expandSize > $this->sizeLimit ) {
149 return $this->getLimitationWarning(
'unstrip-size', $this->sizeLimit );
152 return call_user_func( $callback, $value );
158 return preg_replace_callback( $this->regex, $callback, $text );
178 if ( !count( $this->data[$type] ) ) {
182 $callback =
function ( $m ) use ( $type ) {
184 if ( isset( $this->data[$type][$marker] ) ) {
185 if ( isset( $this->circularRefGuard[$marker] ) ) {
186 return $this->getWarning(
'parser-unstrip-loop-warning' );
189 if ( $this->depth > $this->highestDepth ) {
190 $this->highestDepth = $this->depth;
192 if ( $this->depth >= $this->depthLimit ) {
193 return $this->getLimitationWarning(
'unstrip-depth', $this->depthLimit );
196 $value = $this->data[$type][$marker];
197 if ( $value instanceof Closure ) {
201 $this->expandSize += strlen( $value );
202 if ( $this->expandSize > $this->sizeLimit ) {
203 return $this->getLimitationWarning(
'unstrip-size', $this->sizeLimit );
206 $this->circularRefGuard[$marker] =
true;
208 $ret = $this->unstripType( $type, $value );
210 unset( $this->circularRefGuard[$marker] );
218 $text = preg_replace_callback( $this->regex, $callback, $text );