Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Drupal\Core\Template; use Drupal\Component\Utility\Html; /** * A class..
Decoded Output download
<?php
namespace Drupal\Core\Template;
use Drupal\Component\Utility\Html;
/**
* A class that defines a type of Attribute that can be added to as an array.
*
* To use with Attribute, the array must be specified.
* Correct:
* @code
* $attributes = new Attribute();
* $attributes['class'] = [];
* $attributes['class'][] = 'cat';
* @endcode
* Incorrect:
* @code
* $attributes = new Attribute();
* $attributes['class'][] = 'cat';
* @endcode
*
* @see \Drupal\Core\Template\Attribute
*/
class AttributeArray extends AttributeValueBase implements \ArrayAccess, \IteratorAggregate {
/**
* Ensures empty array as a result of array_filter will not print '$name=""'.
*
* @see \Drupal\Core\Template\AttributeArray::__toString()
* @see \Drupal\Core\Template\AttributeValueBase::render()
*/
const RENDER_EMPTY_ATTRIBUTE = FALSE;
/**
* {@inheritdoc}
*/
public function offsetGet($offset): mixed {
return $this->value[$offset];
}
/**
* {@inheritdoc}
*/
public function offsetSet($offset, $value): void {
if (isset($offset)) {
$this->value[$offset] = $value;
}
else {
$this->value[] = $value;
}
}
/**
* {@inheritdoc}
*/
public function offsetUnset($offset): void {
unset($this->value[$offset]);
}
/**
* {@inheritdoc}
*/
public function offsetExists($offset): bool {
return isset($this->value[$offset]);
}
/**
* Implements the magic __toString() method.
*/
public function __toString() {
// Filter out any empty values before printing.
$this->value = array_unique(array_filter($this->value));
return Html::escape(implode(' ', $this->value));
}
/**
* {@inheritdoc}
*/
public function getIterator(): \ArrayIterator {
return new \ArrayIterator($this->value);
}
/**
* Exchange the array for another one.
*
* @see ArrayObject::exchangeArray
*
* @param array $input
* The array input to replace the internal value.
*
* @return array
* The old array value.
*/
public function exchangeArray($input) {
$old = $this->value;
$this->value = $input;
return $old;
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Drupal\Core\Template;
use Drupal\Component\Utility\Html;
/**
* A class that defines a type of Attribute that can be added to as an array.
*
* To use with Attribute, the array must be specified.
* Correct:
* @code
* $attributes = new Attribute();
* $attributes['class'] = [];
* $attributes['class'][] = 'cat';
* @endcode
* Incorrect:
* @code
* $attributes = new Attribute();
* $attributes['class'][] = 'cat';
* @endcode
*
* @see \Drupal\Core\Template\Attribute
*/
class AttributeArray extends AttributeValueBase implements \ArrayAccess, \IteratorAggregate {
/**
* Ensures empty array as a result of array_filter will not print '$name=""'.
*
* @see \Drupal\Core\Template\AttributeArray::__toString()
* @see \Drupal\Core\Template\AttributeValueBase::render()
*/
const RENDER_EMPTY_ATTRIBUTE = FALSE;
/**
* {@inheritdoc}
*/
public function offsetGet($offset): mixed {
return $this->value[$offset];
}
/**
* {@inheritdoc}
*/
public function offsetSet($offset, $value): void {
if (isset($offset)) {
$this->value[$offset] = $value;
}
else {
$this->value[] = $value;
}
}
/**
* {@inheritdoc}
*/
public function offsetUnset($offset): void {
unset($this->value[$offset]);
}
/**
* {@inheritdoc}
*/
public function offsetExists($offset): bool {
return isset($this->value[$offset]);
}
/**
* Implements the magic __toString() method.
*/
public function __toString() {
// Filter out any empty values before printing.
$this->value = array_unique(array_filter($this->value));
return Html::escape(implode(' ', $this->value));
}
/**
* {@inheritdoc}
*/
public function getIterator(): \ArrayIterator {
return new \ArrayIterator($this->value);
}
/**
* Exchange the array for another one.
*
* @see ArrayObject::exchangeArray
*
* @param array $input
* The array input to replace the internal value.
*
* @return array
* The old array value.
*/
public function exchangeArray($input) {
$old = $this->value;
$this->value = $input;
return $old;
}
}
Function Calls
None |
Stats
MD5 | ec335fb45c91dd95c3ec1c2f36c2633c |
Eval Count | 0 |
Decode Time | 79 ms |