Skip to content

Commit

Permalink
chore(release): v1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
breeze2 committed Nov 24, 2020
1 parent bff511c commit 5059500
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 34 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
# Change Log

## [1.1.4] 24th November, 2020

- Fix Error when attempting to lint file [#18](https://github.com/breeze2/vscode-phpstan/issues/18). Thanks @[jasonwilliams](https://github.com/jasonwilliams) and @[Silic0nS0ldier](https://github.com/Silic0nS0ldier).

## [1.1.3] 11th November, 2019

- Use configured bindir by composer. Thanks @[mtorromeo](https://github.com/mtorromeo).

## [1.1.2] 24th September, 2019

- Refactor analysis process

## [1.1.1] 8th September, 2019

- Adjust codes. Thanks @[JohnstonCode](https://github.com/JohnstonCode).
- Use travis ci

## [1.1.0] 18th February, 2019

- Adapt to PhpStan 0.11

## [1.0.6] 28th September, 2018

- Auto find the local phpstan

## [1.0.5] 9th August, 2018

- Add phpstan error handler
- Fix phpstan stderr handler
- Fix editor change hanler

## [1.0.1] 7th August, 2018

- Support Windows

## [1.0.0] 7th August, 2018
- Initial release

- Initial release
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "phpstan",
"displayName": "PHP Static Analysis",
"description": "Static analysis support for PHP with PhpStan",
"version": "1.1.3",
"version": "1.1.4",
"license": "MIT",
"publisher": "breezelin",
"engines": {
Expand Down
63 changes: 32 additions & 31 deletions src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import * as path from "path";
import * as fs from "fs";
import * as process from "process";

interface PhpStanOuput {
interface PhpStanOutput {
totals: {
errors: number;
files: number;
Expand Down Expand Up @@ -46,7 +46,7 @@ interface PhpStanArgs {
}

export class PhpStanController {
private _isAnalysing: boolean = false;
private _analyzing: boolean = false;
private _phpstan: string = "phpstan";
private _diagnosticCollection: DiagnosticCollection;
private _disposable: Disposable;
Expand All @@ -69,11 +69,12 @@ export class PhpStanController {
this,
subscriptions
);
window.onDidChangeTextEditorSelection(
() => this.shouldAnalyseFile(),
this,
subscriptions
);
// NOTE: not analyse onDidChangeTextEditorSelection anymore
// window.onDidChangeTextEditorSelection(
// () => this.shouldAnalyseFile(),
// this,
// subscriptions
// );
window.onDidChangeWindowState(
() => this.shouldAnalyseFile(),
this,
Expand Down Expand Up @@ -166,7 +167,7 @@ export class PhpStanController {
this.analyse(dir);
}

protected setDiagnostics(data: PhpStanOuput) {
protected setDiagnostics(data: PhpStanOutput) {
if (data.files) {
let editor = window.activeTextEditor;
let document: TextDocument | null = editor ? editor.document : null;
Expand Down Expand Up @@ -211,11 +212,11 @@ export class PhpStanController {
}

protected analyse(the_path: string) {
if (this._isAnalysing) {
if (this._analyzing) {
return null;
}
this._isAnalysing = true;
this._statusBarItem.text = "[phpstan] analysing...";
this._analyzing = true;
this._statusBarItem.text = "[phpstan] analyzing...";
this._statusBarItem.show();
let args: PhpStanArgs = { ...this._config };
let cwd: string = "";
Expand Down Expand Up @@ -254,21 +255,21 @@ export class PhpStanController {
this.setCommandOptions(cwd)
);
let result = "";
let errmsg = "";
phpstan.stderr.on("data", data => (errmsg += data.toString()));
let errMsg = "";
phpstan.stderr.on("data", data => (errMsg += data.toString()));
phpstan.stdout.on("data", data => (result += data.toString()));
phpstan.on("exit", code => {
this._isAnalysing = false;
this._analyzing = false;
this._statusBarItem.show();

if (code === 0) {
// no error
this._statusBarItem.text = "[phpstan] passed";
} else if (errmsg) {
} else if (errMsg) {
// phpstan failed
console.error(`[phpstan] failed: ${errmsg}`);
window.showErrorMessage(errmsg);
console.error(`[phpstan] failed: ${errMsg}`);
this._statusBarItem.text = "[phpstan] failed";
// window.showErrorMessage(errMsg);
} else if (result) {
// phpstan error
console.log(`[phpstan] error: ${result}`);
Expand All @@ -280,18 +281,18 @@ export class PhpStanController {
this.setDiagnostics(data);
this._statusBarItem.text = "[phpstan] error " + data.totals.file_errors;
} else {
this._statusBarItem.text = "[phpstan] unknow";
this._statusBarItem.text = "[phpstan] unknown";
}
});
}

protected makeCommandPath(cwd: string) {
let bindir = "vendor/bin";
let binDir = "vendor/bin";
const basename = process.platform === "win32" ? "phpstan.bat" : "phpstan";
try {
bindir = child_process.execSync("composer config bin-dir", {cwd}).toString().trim();
binDir = child_process.execSync("composer config bin-dir", {cwd}).toString().trim();
} catch (err) {}
const binary = path.resolve(cwd, bindir, basename);
const binary = path.resolve(cwd, binDir, basename);
try {
fs.accessSync(binary, fs.constants.X_OK);
return binary;
Expand Down Expand Up @@ -387,43 +388,43 @@ export class PhpStanController {

protected upFindAutoLoadFile(basedir: string) {
let basename: string;
let parentname: string;
let parentName: string;
let autoload: string;
basename = basedir;
parentname = path.dirname(basename);
parentName = path.dirname(basename);
autoload = path.join(basename, "vendor/autoload.php");
while (1) {
if (fs.existsSync(autoload)) {
return autoload;
} else if (basename === parentname) {
} else if (basename === parentName) {
return "";
} else {
basename = parentname;
parentname = path.dirname(basename);
basename = parentName;
parentName = path.dirname(basename);
autoload = path.join(basename, "vendor/autoload.php");
}
}
}

protected upFindConfiguration(basedir: string) {
let basename: string;
let parentname: string;
let parentName: string;
let config1: string;
let config2: string;
basename = basedir;
parentname = path.dirname(basename);
parentName = path.dirname(basename);
config1 = path.join(basename, "phpstan.neon");
config2 = path.join(basename, "phpstan.neon.dist");
while (1) {
if (fs.existsSync(config1)) {
return config1;
} else if (fs.existsSync(config2)) {
return config2;
} else if (basename === parentname) {
} else if (basename === parentName) {
return "";
} else {
basename = parentname;
parentname = path.dirname(basename);
basename = parentName;
parentName = path.dirname(basename);
config1 = path.join(basename, "phpstan.neon");
config2 = path.join(basename, "phpstan.neon.dist");
}
Expand Down

0 comments on commit 5059500

Please sign in to comment.