mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Expose xhpast via Conduit
Summary: Create `phpast.{version,getast}` methods for calling xhpast with `--version` and with source code as input, respectively. Test Plan: Run `arc call-conduit` a bunch of times; delete xhpast; run it a bunch more times. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T1534 Differential Revision: https://secure.phabricator.com/D3289
This commit is contained in:
parent
d5aaa54d0b
commit
d45855e33e
3 changed files with 108 additions and 0 deletions
|
@ -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',
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_phpast_getast_Method extends ConduitAPIMethod {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Parse a piece of PHP code.";
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
return array(
|
||||
'code' => '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]);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
final class ConduitAPI_phpast_version_Method extends ConduitAPIMethod {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Get server xhpast version.";
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function defineReturnType() {
|
||||
return 'string';
|
||||
}
|
||||
|
||||
public function defineErrorTypes() {
|
||||
return array(
|
||||
'ERR-NOT-FOUND' => '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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue