@ 2014-05-07T04:57:36Z <?php
class ExtendedArrayObject extends ArrayObject {
function offsetExists($offset) {
echo __METHOD__, PHP_EOL;
return parent::offsetExists($offset);
}
function offsetGet($offset) {
echo __METHOD__, PHP_EOL;
return parent::offsetGet($offset);
}
}
class ExtendedArrayAccess implements ArrayAccess {
private $data = array();
function __construct(array $array = array()) {
$this->data = $array;
}
function offsetExists($offset) {
return array_key_exists($offset, $this->data);
}
function offsetGet($offset) {
return $this->data[$offset];
}
function offsetSet($offset, $value) {
$this->data[$offset] = $value;
}
function offsetUnset($offset) {
unset($this->data[$offset]);
}
}
function createInputs() {
return array(
array(),
new ArrayObject(),
new ExtendedArrayObject(),
new ExtendedArrayAccess(),
);
}
class Tests {
function isset_existing_key_with_not_empty_value($array) {
$array['foo'] = 1;
$this->expect(isset($array['foo']) === true, __FUNCTION__, $array);
}
function empty_existing_key_with_not_empty_value($array) {
$array['foo'] = 1;
$this->expect(empty($array['foo']) === false, __FUNCTION__, $array);
}
function isset_existing_key_with_empty_value($array) {
$array['foo'] = 0;
$this->expect(isset($array['foo']) === true, __FUNCTION__, $array);
}
function empty_existing_key_with_empty_value($array) {
$array['foo'] = 0;
$this->expect(empty($array['foo']) === true, __FUNCTION__, $array);
}
function isset_non_existent_key($array) {
$this->expect(isset($array['foo']) === false, __FUNCTION__, $array);
}
function empty_non_existent_key($array) {
$this->expect(empty($array['foo']) === true, __FUNCTION__, $array);
}
function isset_existing_key_with_null_value($array) {
$array['foo'] = null;
$this->expect(isset($array['foo']) === false, __FUNCTION__, $array);
}
function empty_existing_key_with_null_value($array) {
$array['foo'] = null;
$this->expect(empty($array['foo']) === true, __FUNCTION__, $array);
}
private function getType($v) {
return is_array($v) ? 'array' : get_class($v);
}
private function expect($condition, $function, $array) {
if (!$condition) {
echo $this->getType($array), ' failed ', $function, PHP_EOL;
}
}
}
$tests = new Tests;
foreach (get_class_methods($tests) as $test) {
echo "$test:", PHP_EOL;
foreach (createInputs() as $structure) {
$tests->$test($structure);
}
echo PHP_EOL;
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Deprecated: Return type of ExtendedArrayObject::offsetExists($offset) should either be compatible with ArrayObject::offsetExists(mixed $key): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/iL2eK on line 4
Deprecated: Return type of ExtendedArrayObject::offsetGet($offset) should either be compatible with ArrayObject::offsetGet(mixed $key): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/iL2eK on line 8
Deprecated: Return type of ExtendedArrayAccess::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/iL2eK on line 19
Deprecated: Return type of ExtendedArrayAccess::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/iL2eK on line 22
Deprecated: Return type of ExtendedArrayAccess::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/iL2eK on line 25
Deprecated: Return type of ExtendedArrayAccess::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/iL2eK on line 28
isset_existing_key_with_not_empty_value:
ExtendedArrayObject::offsetExists
empty_existing_key_with_not_empty_value:
ExtendedArrayObject::offsetExists
ExtendedArrayObject::offsetGet
isset_existing_key_with_empty_value:
ExtendedArrayObject::offsetExists
empty_existing_key_with_empty_value:
ExtendedArrayObject::offsetExists
ExtendedArrayObject::offsetGet
isset_non_existent_key:
ExtendedArrayObject::offsetExists
empty_non_existent_key:
ExtendedArrayObject::offsetExists
isset_existing_key_with_null_value:
ExtendedArrayObject::offsetExists
ExtendedArrayObject failed isset_existing_key_with_null_value
ExtendedArrayAccess failed isset_existing_key_with_null_value
empty_existing_key_with_null_value:
ExtendedArrayObject::offsetExists
ExtendedArrayObject::offsetGet
Output for 5.6.8 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.25 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 isset_existing_key_with_not_empty_value:
ExtendedArrayObject::offsetExists
empty_existing_key_with_not_empty_value:
ExtendedArrayObject::offsetExists
ExtendedArrayObject::offsetGet
isset_existing_key_with_empty_value:
ExtendedArrayObject::offsetExists
empty_existing_key_with_empty_value:
ExtendedArrayObject::offsetExists
ExtendedArrayObject::offsetGet
isset_non_existent_key:
ExtendedArrayObject::offsetExists
empty_non_existent_key:
ExtendedArrayObject::offsetExists
isset_existing_key_with_null_value:
ExtendedArrayObject::offsetExists
ExtendedArrayObject failed isset_existing_key_with_null_value
ExtendedArrayAccess failed isset_existing_key_with_null_value
empty_existing_key_with_null_value:
ExtendedArrayObject::offsetExists
ExtendedArrayObject::offsetGet
Output for 5.3.11 - 5.3.29 , 5.4.1 - 5.4.45 , 5.5.24 - 5.5.35 isset_existing_key_with_not_empty_value:
ExtendedArrayObject::offsetExists
empty_existing_key_with_not_empty_value:
ExtendedArrayObject::offsetExists
isset_existing_key_with_empty_value:
ExtendedArrayObject::offsetExists
empty_existing_key_with_empty_value:
ExtendedArrayObject::offsetExists
ExtendedArrayObject failed empty_existing_key_with_empty_value
isset_non_existent_key:
ExtendedArrayObject::offsetExists
empty_non_existent_key:
ExtendedArrayObject::offsetExists
isset_existing_key_with_null_value:
ExtendedArrayObject::offsetExists
ExtendedArrayObject failed isset_existing_key_with_null_value
ExtendedArrayAccess failed isset_existing_key_with_null_value
empty_existing_key_with_null_value:
ExtendedArrayObject::offsetExists
ExtendedArrayObject failed empty_existing_key_with_null_value
Output for 5.2.2 - 5.2.17 , 5.3.0 - 5.3.10 , 5.4.0 isset_existing_key_with_not_empty_value:
ExtendedArrayObject::offsetExists
empty_existing_key_with_not_empty_value:
ExtendedArrayObject::offsetExists
isset_existing_key_with_empty_value:
ExtendedArrayObject::offsetExists
empty_existing_key_with_empty_value:
ExtendedArrayObject::offsetExists
ExtendedArrayObject failed empty_existing_key_with_empty_value
isset_non_existent_key:
ExtendedArrayObject::offsetExists
empty_non_existent_key:
ExtendedArrayObject::offsetExists
isset_existing_key_with_null_value:
ArrayObject failed isset_existing_key_with_null_value
ExtendedArrayObject::offsetExists
ExtendedArrayObject failed isset_existing_key_with_null_value
ExtendedArrayAccess failed isset_existing_key_with_null_value
empty_existing_key_with_null_value:
ExtendedArrayObject::offsetExists
ExtendedArrayObject failed empty_existing_key_with_null_value
Output for 5.2.1 isset_existing_key_with_not_empty_value:
ExtendedArrayObject::offsetExists
empty_existing_key_with_not_empty_value:
ExtendedArrayObject::offsetExists
isset_existing_key_with_empty_value:
ExtendedArrayObject::offsetExists
ExtendedArrayObject failed isset_existing_key_with_empty_value
empty_existing_key_with_empty_value:
ExtendedArrayObject::offsetExists
isset_non_existent_key:
ExtendedArrayObject::offsetExists
empty_non_existent_key:
ExtendedArrayObject::offsetExists
isset_existing_key_with_null_value:
ArrayObject failed isset_existing_key_with_null_value
ExtendedArrayObject::offsetExists
ExtendedArrayAccess failed isset_existing_key_with_null_value
empty_existing_key_with_null_value:
ExtendedArrayObject::offsetExists
Output for 5.1.0 - 5.1.6 , 5.2.0 isset_existing_key_with_not_empty_value:
ExtendedArrayObject::offsetExists
empty_existing_key_with_not_empty_value:
ExtendedArrayObject::offsetExists
isset_existing_key_with_empty_value:
ExtendedArrayObject::offsetExists
empty_existing_key_with_empty_value:
ArrayObject failed empty_existing_key_with_empty_value
ExtendedArrayObject::offsetExists
ExtendedArrayObject failed empty_existing_key_with_empty_value
isset_non_existent_key:
ExtendedArrayObject::offsetExists
empty_non_existent_key:
ExtendedArrayObject::offsetExists
isset_existing_key_with_null_value:
ArrayObject failed isset_existing_key_with_null_value
ExtendedArrayObject::offsetExists
ExtendedArrayObject failed isset_existing_key_with_null_value
ExtendedArrayAccess failed isset_existing_key_with_null_value
empty_existing_key_with_null_value:
ArrayObject failed empty_existing_key_with_null_value
ExtendedArrayObject::offsetExists
ExtendedArrayObject failed empty_existing_key_with_null_value
Output for 5.0.0 - 5.0.5 Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/iL2eK on line 16
Process exited with code 255 . Output for 4.4.2 - 4.4.9 Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/iL2eK on line 14
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 Parse error: parse error, unexpected T_STRING, expecting '{' in /in/iL2eK on line 14
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error, expecting `'{'' in /in/iL2eK on line 14
Process exited with code 255 . preferences:dark mode live preview
233.55 ms | 401 KiB | 329 Q