Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14577686
D13493.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13493.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -76,6 +76,7 @@
'PhagePHPAgent' => 'phage/agent/PhagePHPAgent.php',
'PhagePHPAgentBootloader' => 'phage/bootloader/PhagePHPAgentBootloader.php',
'Phobject' => 'object/Phobject.php',
+ 'PhobjectTestCase' => 'object/__tests__/PhobjectTestCase.php',
'PhutilAPCKeyValueCache' => 'cache/PhutilAPCKeyValueCache.php',
'PhutilAWSEC2Future' => 'future/aws/PhutilAWSEC2Future.php',
'PhutilAWSException' => 'future/aws/PhutilAWSException.php',
@@ -258,7 +259,6 @@
'PhutilPersonTest' => 'internationalization/__tests__/PhutilPersonTest.php',
'PhutilPersonaAuthAdapter' => 'auth/PhutilPersonaAuthAdapter.php',
'PhutilPhabricatorAuthAdapter' => 'auth/PhutilPhabricatorAuthAdapter.php',
- 'PhutilPhobjectTestCase' => 'object/__tests__/PhutilPhobjectTestCase.php',
'PhutilPhtTestCase' => 'internationalization/__tests__/PhutilPhtTestCase.php',
'PhutilProcessGroupDaemon' => 'daemon/torture/PhutilProcessGroupDaemon.php',
'PhutilProtocolChannel' => 'channel/PhutilProtocolChannel.php',
@@ -568,6 +568,7 @@
'PhagePHPAgent' => 'Phobject',
'PhagePHPAgentBootloader' => 'PhageAgentBootloader',
'Phobject' => 'Iterator',
+ 'PhobjectTestCase' => 'PhutilTestCase',
'PhutilAPCKeyValueCache' => 'PhutilKeyValueCache',
'PhutilAWSEC2Future' => 'PhutilAWSFuture',
'PhutilAWSException' => 'Exception',
@@ -762,7 +763,6 @@
),
'PhutilPersonaAuthAdapter' => 'PhutilAuthAdapter',
'PhutilPhabricatorAuthAdapter' => 'PhutilOAuthAuthAdapter',
- 'PhutilPhobjectTestCase' => 'PhutilTestCase',
'PhutilPhtTestCase' => 'PhutilTestCase',
'PhutilProcessGroupDaemon' => 'PhutilTortureTestDaemon',
'PhutilProtocolChannel' => 'PhutilChannelChannel',
diff --git a/src/object/Phobject.php b/src/object/Phobject.php
--- a/src/object/Phobject.php
+++ b/src/object/Phobject.php
@@ -19,6 +19,13 @@
*/
abstract class Phobject implements Iterator {
+ public function __get($name) {
+ throw new DomainException(
+ pht(
+ 'Attempt to read from undeclared property %s.',
+ get_class($this).'::'.$name));
+ }
+
public function __set($name, $value) {
throw new DomainException(
pht(
diff --git a/src/object/__tests__/PhutilPhobjectTestCase.php b/src/object/__tests__/PhobjectTestCase.php
rename from src/object/__tests__/PhutilPhobjectTestCase.php
rename to src/object/__tests__/PhobjectTestCase.php
--- a/src/object/__tests__/PhutilPhobjectTestCase.php
+++ b/src/object/__tests__/PhobjectTestCase.php
@@ -1,17 +1,24 @@
<?php
-final class PhutilPhobjectTestCase extends PhutilTestCase {
+final class PhobjectTestCase extends PhutilTestCase {
public function testThrowOnUndeclaredProperty() {
$object = new PhutilTestPhobject();
$caught = null;
try {
- $object->duck = 'quack';
+ $object->duck;
} catch (Exception $ex) {
$caught = $ex;
}
+ $this->assertTrue($caught instanceof DomainException);
+ $caught = null;
+ try {
+ $object->duck = 'quack';
+ } catch (Exception $ex) {
+ $caught = $ex;
+ }
$this->assertTrue($caught instanceof DomainException);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 9, 3:05 AM (7 h, 7 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6977443
Default Alt Text
D13493.diff (3 KB)
Attached To
Mode
D13493: Throw on accessing an undeclared property
Attached
Detach File
Event Timeline
Log In to Comment