diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index eb746cb57b..d41d493f13 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -166,6 +166,8 @@ phutil_register_library_map(array( 'ConduitAPI_phid_info_Method' => 'applications/conduit/method/phid/ConduitAPI_phid_info_Method.php', 'ConduitAPI_phid_lookup_Method' => 'applications/conduit/method/phid/ConduitAPI_phid_lookup_Method.php', 'ConduitAPI_phid_query_Method' => 'applications/conduit/method/phid/ConduitAPI_phid_query_Method.php', + 'ConduitAPI_phpast_getast_Method' => 'applications/conduit/method/phpast/ConduitAPI_phpast_getast_Method.php', + 'ConduitAPI_phpast_version_Method' => 'applications/conduit/method/phpast/ConduitAPI_phpast_version_Method.php', 'ConduitAPI_phriction_Method' => 'applications/conduit/method/phriction/ConduitAPI_phriction_Method.php', 'ConduitAPI_phriction_edit_Method' => 'applications/conduit/method/phriction/ConduitAPI_phriction_edit_Method.php', 'ConduitAPI_phriction_history_Method' => 'applications/conduit/method/phriction/ConduitAPI_phriction_history_Method.php', @@ -1343,6 +1345,8 @@ phutil_register_library_map(array( 'ConduitAPI_phid_info_Method' => 'ConduitAPI_phid_Method', 'ConduitAPI_phid_lookup_Method' => 'ConduitAPI_phid_Method', 'ConduitAPI_phid_query_Method' => 'ConduitAPI_phid_Method', + 'ConduitAPI_phpast_getast_Method' => 'ConduitAPIMethod', + 'ConduitAPI_phpast_version_Method' => 'ConduitAPIMethod', 'ConduitAPI_phriction_Method' => 'ConduitAPIMethod', 'ConduitAPI_phriction_edit_Method' => 'ConduitAPI_phriction_Method', 'ConduitAPI_phriction_history_Method' => 'ConduitAPI_phriction_Method', diff --git a/src/applications/conduit/method/phpast/ConduitAPI_phpast_getast_Method.php b/src/applications/conduit/method/phpast/ConduitAPI_phpast_getast_Method.php new file mode 100644 index 0000000000..fe0dacf4d1 --- /dev/null +++ b/src/applications/conduit/method/phpast/ConduitAPI_phpast_getast_Method.php @@ -0,0 +1,49 @@ + 'required string', + ); + } + + public function defineReturnType() { + return 'nonempty dict'; + } + + public function defineErrorTypes() { + return array( + 'ERR-XHPAST-LEY' => 'xhpast got Rickrolled', + ); + } + + protected function execute(ConduitAPIRequest $request) { + return json_decode( + xhpast_get_parser_future($request->getValue('code'))->resolvex()[0]); + } + +} diff --git a/src/applications/conduit/method/phpast/ConduitAPI_phpast_version_Method.php b/src/applications/conduit/method/phpast/ConduitAPI_phpast_version_Method.php new file mode 100644 index 0000000000..3ca3a976c9 --- /dev/null +++ b/src/applications/conduit/method/phpast/ConduitAPI_phpast_version_Method.php @@ -0,0 +1,55 @@ + 'xhpast was not found on the server', + 'ERR-COMMAND-FAILED' => 'xhpast died with a nonzero exit code', + ); + } + + protected function execute(ConduitAPIRequest $request) { + $path = xhpast_get_binary_path(); + if (!Filesystem::pathExists($path)) { + throw new ConduitException('ERR-NOT-FOUND'); + } + list($err, $stdout) = exec_manual('%s --version', $path); + if ($err) { + throw new ConduitException('ERR-COMMAND-FAILED'); + } + return trim($stdout); + } + +}