1
0
mirror of https://github.com/php/php-src.git synced 2026-04-24 08:28:26 +02:00
Files
archived-php-src/ext/spl/tests/arrayObject_setFlags_basic2.phpt
T
Nikita Popov c9f27ee422 Display EngineExceptions like ordinary exceptions
TypeException stays as-is for now because it uses messages that are
incompatible with the way exception messages are displayed.

closure_038.phpt and a few others now show that we're generating
too many exceptions for compound operations on undefined properties
-- this needs to be fixed in a followup.
2015-05-15 23:40:32 +02:00

33 lines
629 B
PHP

--TEST--
SPL: Ensure access to non-visible properties falls back to dimension access with ArrayObject::ARRAY_AS_PROPS.
--FILE--
<?php
class C extends ArrayObject {
private $x = 'secret';
static function go($c) {
var_dump($c->x);
}
}
$c = new C(array('x'=>'public'));
$c->setFlags(ArrayObject::ARRAY_AS_PROPS);
C::go($c);
var_dump($c->x);
$c->setFlags(0);
C::go($c);
var_dump($c->x);
?>
--EXPECTF--
string(6) "secret"
string(6) "public"
string(6) "secret"
Fatal error: Uncaught exception 'EngineException' with message 'Cannot access private property C::$x' in %s:19
Stack trace:
#0 {main}
thrown in %s on line 19