-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on format #423
Labels
Comments
I need the file you tried to format to reproduce. |
<?php
class fbMessengerCtrl extends jController
{
const APP_ID = "################";
const APP_SECRET = "#########################";
public function pairing()
{
$token = "";
$rep = $this->getResponse("text");
$rep->content = "unauthorized operation";
if (!empty($this->param('code'))) {
$data = $this->apiCall("https://graph.facebook.com/v2.9/oauth/access_token",
array(
"client_id" => self::APP_ID,
"redirect_uri" => "https://mydomain.com/facebook_messenger/pairing",
"client_secret" => self::APP_SECRET,
"code" => $this->param('code')
));
if (!empty($data['error'])) {
$rep->content = json_encode($data['error']);
return $rep;
}
$rep->content = json_encode($data);
}
if (!empty($data['access_token'])) {
$token = $data['access_token'];
$data = $this->apiCall(
"https://graph.facebook.com/v2.9/debug_token", array(
"input_token" => $token,
"access_token" => $token
),
"get"
);
if (!empty($data['error'])) {
$rep->content = json_encode($data['error']);
return $rep;
}
$rep->content = json_encode($data);
}
if (!in_array("manage_pages", $data['data']['scopes'])
|| !in_array("pages_messaging", $data['data']['scopes'])) {
$rep->content = "need rights";
return $rep;
} else {
$data = $this->apiCall("https://graph.facebook.com/v2.9/me/accounts", array(
'access_token' => $token
));
$rep->content = json_encode($data);
return $rep;
}
return $rep;
}
public function test()
{
$rep = $this->getResponse();
$rep->addContent('<h1>Linking</h1>
<a href="https://www.facebook.com/v2.9/dialog/oauth?client_id=0000000000000&redirect_uri=https://mydomain.com/facebook_messenger/pairing&scope=manage_pages,pages_messaging">Link account</a>');
return $rep;
}
private function apiCall($url, $data, $method = "get")
{
$header = [
"Content-Type:application/json"
];
if ($method == "get") {
$url .= '?' . http_build_query($data);
}
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
if ($method == "post") {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
return json_decode($response, true);
}
} |
Same bug with another file, if this can help you.
<?php
require_once(JELIX_LIB_PATH . '../fb-messenger/fbmessenger.php');
class FbMessenger
{
/**
* Request Type get
*/
const REQUEST_GET = 'get';
/**
* Request Type post
*/
const REQUEST_POST = 'post';
/**
* Request Type delete
*/
const REQUEST_DELETE = 'delete';
/**
* Facebook Graph API Url used to send messages
*
* @var string
*/
protected static $apiUrl = 'https://graph.facebook.com/v2.9/';
/**
* Page Access Token used to send messages
*
* @var string
*/
protected static $access_token = '';
/**
* Init token
*
* @param string $token
* @return void
*/
public static function init($token)
{
self::$access_token = $token;
}
public function apiCall($url, $data, $type = self::REQUEST_POST)
{
$data['access_token'] = $access_token;
$header = [
"Content-Type:application/json"
];
if ($type == self::REQUEST_GET) {
$url .= '?' . http_build_query($data);
}
$curl = curl_init($this->apiUrl . $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
if ($type == self::REQUEST_POST || $type == self::REQUEST_DELETE) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
}
if ($type == self::REQUEST_DELETE) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
return json_decode($response, true);
}
} |
felixfbecker
added a commit
that referenced
this issue
Oct 28, 2017
felixfbecker
added a commit
that referenced
this issue
Oct 28, 2017
felixfbecker
added a commit
that referenced
this issue
Oct 28, 2017
felixfbecker
added a commit
that referenced
this issue
Oct 28, 2017
felixfbecker
added a commit
that referenced
this issue
Oct 28, 2017
felixfbecker
added a commit
that referenced
this issue
Nov 5, 2017
At this point there are countless issues about the formatting done by CodeSniffer. It plain out doesn't work in many cases, overrides format options that are contributed by other extensions in VS Code and does not reuse any of our AST parsing. For that reason, I am starting to think there is no reason to keep it in here until we have proper pretty-printing support from https://github.com/Microsoft/tolerant-php-parser that actually reuses our ASTs and can work while editing. For people who want to use CodeSniffer to format their code, there could be a standalone CodeSniffer language server (like there is a TSLint language server and ESLint language server). As said, we don't reuse our state anyway. BREAKING CHANGE: removes formatting support closes #501 closes #474 closes #473 closes #468 closes #450 closes #445 closes #443 closes #423 closes #343 closes #296 closes #293 closes #499 closes #471
cgxxv
pushed a commit
to cgxxv/php-language-server
that referenced
this issue
Mar 25, 2022
At this point there are countless issues about the formatting done by CodeSniffer. It plain out doesn't work in many cases, overrides format options that are contributed by other extensions in VS Code and does not reuse any of our AST parsing. For that reason, I am starting to think there is no reason to keep it in here until we have proper pretty-printing support from https://github.com/Microsoft/tolerant-php-parser that actually reuses our ASTs and can work while editing. For people who want to use CodeSniffer to format their code, there could be a standalone CodeSniffer language server (like there is a TSLint language server and ESLint language server). As said, we don't reuse our state anyway. BREAKING CHANGE: removes formatting support closes felixfbecker#501 closes felixfbecker#474 closes felixfbecker#473 closes felixfbecker#468 closes felixfbecker#450 closes felixfbecker#445 closes felixfbecker#443 closes felixfbecker#423 closes felixfbecker#343 closes felixfbecker#296 closes felixfbecker#293 closes felixfbecker#499 closes felixfbecker#471
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
In vs code v1.13.1, if you try to format a well formatted PHP class, you get the following error.
I'm using Mac OS X 10.11.1 (15B42) and
PHP 7.1.5 (cli) (built: May 13 2017 13:28:23) ( NTS )
The text was updated successfully, but these errors were encountered: