Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3753018
D2933.id7470.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D2933.id7470.diff
View Options
diff --git a/app/Phabricator/PhabricatorAPI.php b/app/Phabricator/PhabricatorAPI.php
--- a/app/Phabricator/PhabricatorAPI.php
+++ b/app/Phabricator/PhabricatorAPI.php
@@ -114,7 +114,7 @@
/**
* Gets the first result of an API reply.
*/
- public static function getFirstResult (iterable $reply) : mixed {
+ public static function getFirstResult (iterable|\stdClass $reply) : mixed {
if (is_object($reply) && property_exists($reply, 'data')) {
$reply = $reply->data;
}
diff --git a/tests/Phabricator/PhabricatorAPITest.php b/tests/Phabricator/PhabricatorAPITest.php
--- a/tests/Phabricator/PhabricatorAPITest.php
+++ b/tests/Phabricator/PhabricatorAPITest.php
@@ -29,4 +29,18 @@
$this->expectException(\RuntimeException::class);
PhabricatorAPI::forProject("NotFound");
}
+
+ public function testGetFirstResultForObject () {
+ $result = new \stdClass;
+ $result->data = ["first", "second", "third"];
+
+ $this->assertEquals("first", PhabricatorAPI::getFirstResult($result));
+ }
+
+ public function testGetFirstResultForIterable () {
+ $result = ["first", "second", "third"];
+
+ $this->assertEquals("first", PhabricatorAPI::getFirstResult($result));
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 22:39 (20 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2251384
Default Alt Text
D2933.id7470.diff (1 KB)
Attached To
Mode
D2933: Fix PhabricatorAPI::getFirstResult signature
Attached
Detach File
Event Timeline
Log In to Comment