-
Notifications
You must be signed in to change notification settings - Fork 11
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
PHP CS Fixer 2.0.x not working #15
Comments
OK, Thanks, here are my current Settings ✏️ OS.
VSCode version.
PHP CS Fixer version.
PHPFormatter version
PHPFormatter user settings. {
"window.zoomLevel": 1.5,
"editor.lineHeight": 28,
"telemetry.enableTelemetry": false,
"telemetry.enableCrashReporter": false,
"php.validate.executablePath": "c:/xampp/php/php.exe",
"phpformatter.phpPath": "C:/xampp/php/php.exe",
"phpformatter.pharPath": "c:/xampp/php/php-cs-fixer.phar",
"phpformatter.logging": true
} PHPFormatter logging output (use phpformatter.logging: true). If possible, a snippet or screenshot of the code that needs formatting. class ControllerErrorPermission extends Controller {
public function index() {
$this->load->language('error/permission');
$this->document->setTitle($this->language->get('heading_title'));
$data['heading_title'] = $this->language->get('heading_title');
$data['text_permission'] = $this->language->get('text_permission');
$data['breadcrumbs'] = array();
$data['breadcrumbs'][] = array(
'text' => $this->language->get('text_home'),
'href' => $this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL')
);
$data['breadcrumbs'][] = array(
'text' => $this->language->get('heading_title'),
'href' => $this->url->link('error/permission', 'token=' . $this->session->data['token'], 'SSL')
);
$data['header'] = $this->load->controller('common/header');
$data['column_left'] = $this->load->controller('common/column_left');
$data['footer'] = $this->load->controller('common/footer');
$this->response->setOutput($this->load->view('error/permission.tpl', $data));
}
public function check() {
if (isset($this->request->get['route'])) {
$route = '';
$part = explode('/', $this->request->get['route']);
if (isset($part[0])) {
$route .= $part[0];
}
if (isset($part[1])) {
$route .= '/' . $part[1];
}
$ignore = array(
'common/dashboard',
'common/login',
'common/logout',
'common/forgotten',
'common/reset',
'error/not_found',
'error/permission',
'dashboard/order',
'dashboard/sale',
'dashboard/customer',
'dashboard/online',
'dashboard/map',
'dashboard/activity',
'dashboard/chart',
'dashboard/recent'
);
if (!in_array($route, $ignore) && !$this->user->hasPermission('access', $route)) {
return new Action('error/permission');
}
}
}
} |
I am experiencing a similar error:
OS: Windows 10 Pro x64
Later edit: issue persists after updating VSCode to version 1.8.0 |
"phpformatter.composer": true,
"phpformatter.logging": true
public function actionItemDetail()
{
$title = Yii::$app->request->get('title');
$data = $this->data();
$itemFound = null;
foreach ($data as $d) {
if ($d['title'] == $title) {
$itemFound = $d;
}
}
return $this->render('itemDetail', ['title' => $title, 'itemFound' => $itemFound]);
} |
Klick HELP -> Toggle Developer Tool -> Console |
OK, here is the output in the console. (I use the same versions as here). Using Composer: [Extension Host] PHPFormatter: Creating temp file.
[Extension Host] PHPFormatter: Tempfile fd: 61
[Extension Host] PHPFormatter: Tempfile name: /tmp/phpfmt-5947C8m6dUBQqw4n.tmp
[Extension Host] PHPFormatter: Writing current document content to temp file. Until VSCode will have a way of querying encoding, utf8 will be used for reading and writing.
[Extension Host] PHPFormatter: Full command being executed: php-cs-fixer fix "/tmp/phpfmt-5947C8m6dUBQqw4n.tmp" --level=psr2
[Extension Host] PHPFormatter: Logging PHP-CS-Fixer command stderr result
[Extension Host] PHPFormatter:
[Symfony\Component\Console\Exception\RuntimeException]
The "--level" option does not exist.
fix [--path-mode PATH-MODE] [--allow-risky ALLOW-RISKY] [--config CONFIG] [--dry-run] [--rules RULES] [--using-cache USING-CACHE] [--cache-file CACHE-FILE] [--diff] [--format FORMAT] [--] [<path>]...
[Extension Host] PHPFormatter: Reading temp file content.
[Extension Host] PHPFormatter: Replacing editor content with formatted code.
[Extension Host] PHPFormatter: Document successfully formatted (19 lines). Using [Extension Host] PHPFormatter: Creating temp file.
[Extension Host] PHPFormatter: Tempfile fd: 61
[Extension Host] PHPFormatter: Tempfile name: /tmp/phpfmt-5947Q0cGP1CpJXtR.tmp
[Extension Host] PHPFormatter: Writing current document content to temp file. Until VSCode will have a way of querying encoding, utf8 will be used for reading and writing.
[Extension Host] PHPFormatter: Full command being executed: "/opt/lampp/bin/php" "$HOME/phar/php-cs-fixer.phar" fix "/tmp/phpfmt-5947Q0cGP1CpJXtR.tmp" --level=psr2
[Extension Host] PHPFormatter: Logging PHP-CS-Fixer command stderr result
[Extension Host] PHPFormatter:
[RuntimeException]
The "--level" option does not exist.
fix [--path-mode="..."] [--allow-risky="..."] [--config="..."] [--dry-run] [--rules="..."] [--using-cache="..."] [--cache-file="..."] [--diff] [--format="..."] [path1] ... [pathN]
[Extension Host] PHPFormatter: Reading temp file content.
[Extension Host] PHPFormatter: Replacing editor content with formatted code.
[Extension Host] PHPFormatter: Document successfully formatted (19 lines). Sample case: My code snippet: <?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
use app\models\Room;
class RoomsController extends Controller
{
public function actionCreate()
{
$model = new Room();
$modelCanSave = false;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$modelCanSave = true;
}return $this->render('create', [
'model' => $model,
'modelSaved' => $modelCanSave
]);
}
} |
@yaliv and this extension will add just found it was discussed at #13 |
OK, it works with Using <?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
use app\models\Room;
class RoomsController extends Controller
{
public function actionCreate()
{
$model = new Room();
$modelCanSave = false;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$modelCanSave = true;
}
return $this->render('create', [
'model' => $model,
'modelSaved' => $modelCanSave
]);
}
} Using <?php
namespace app\controllers;
use Yii;
use yii\web\Controller;
use app\models\Room;
class RoomsController extends Controller
{
public function actionCreate()
{
$model = new Room();
$modelCanSave = false;
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
$modelCanSave = true;
}
return $this->render('create', [
'model' => $model,
'modelSaved' => $modelCanSave,
]);
}
} The most difficult to format is the indentation for multi-line array. Any solution? |
it's php-cs-fixer problem and seem it still not ... ready |
Thank you all for reporting in. I have been struggling with maintaining support for both versions of PHP CS Fixer for a while now. So in a next update I will be integrating PHP CS Fixer 2.0.0 to circumvent all this. I will be leaving this issue open so people will have a place to go in the mean time. |
[Symfony\Component\Filesystem\Exception\IOException] My setting |
I encountered the same 'Failed to write file ".php_cs.cache"' error. Caching only seems useful when fixing multiple files at once, so I skipped caching by adding '--using-cache false' to the phpformatter.arguments setting. This is a temporary fix to make the formatter work. |
ai can't wowrking at all this extention |
when a save the file with debuug on i have "spawn php EMFILE" |
for me i have change addon. |
I changed this setting from default value
to this
It work well |
@lesydat's solution worked for me. |
Tried every possible solution - nothing helps. I call this extension bullshit. |
@lesydat |
change argument {
"phpformatter.composer": true,
"phpformatter.logging": true,
"phpformatter.arguments": ["--rules=@PSR2"]
} |
|
A lot of users are reporting that this extension does not work with PHP CS Fixer 2.0.x. So this issue will be here to accumulate as much info about the problem at hand.
If you are running into this issue as well, please post the following info:
phpformatter.logging: true
).I will try to work out a solution soon enough. Time might be an issue around all the upcoming festivities, however.
Thanks!
The text was updated successfully, but these errors were encountered: