junstyle / vscode-php-cs-fixer

PHP CS Fixer extension for VS Code
https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer
MIT License
357 stars 45 forks source link

Command php-cs-fixer.fix resulted in an an error #157

Closed ericknyoto closed 1 year ago

ericknyoto commented 3 years ago

I got an error message pop up window like this when I use the command php-cs-fixer: fix from Control Shift P

Command 'php-cs-fixer: fix' resulted in an error (Running the contributed command: 'php-cs-fixer.fix2' failed.)

I tried to re-install and it was not fixed the problem. Do I need to install the php-cs-fixer? I thought the php-cs-fixer was included in the extensions.

Is I missing something? Thanks.

junstyle commented 3 years ago

try context menu 'format document with'

ericknyoto commented 3 years ago

Another error comes up when I tried the context menu.

Command 'Format Document With...' resulted in an error (The argument 'file' cannot be empty. Received'')

This is the settings.json


        * PHP CS Fixer
        **/
        "[php]": {
            "editor.defaultFormatter": "junstyle.php-cs-fixer"
        },
        "php-cs-fixer.onsave": true,
        "php-cs-fixer.showOutput": false,
        "php-cs-fixer.autoFixByBracket": false,
        "php-cs-fixer.rules": "@PSR2",
ngdangtu-vn commented 3 years ago

try context menu 'format document with'

In my case, it doesn't have Format Document with. I think vscode (my case vscodium) doesn't recognize this extension a formatter. Here is my config on workspace scope:

    "editor.tabCompletion": "on",
    "editor.defaultFormatter": "EditorConfig.EditorConfig",
    "editor.formatOnSave": true,
    "php-cs-fixer.onsave": true,
    "php-cs-fixer.formatHtml": true,
    "php-cs-fixer.config": ".vscode/.php_cs",
    "[php]": {
        "editor.defaultFormatter": "junstyle.php-cs-fixer",
    },
    "[scss]": {
        "editor.defaultFormatter": "GrantBartlett.scss-allman-formatter"
    },

And here is related config on global scope:

    "php.validate.executablePath": "C:/Program Files/php/php.exe",
    "files.associations": {
        ".php_cs": "php"
    },
    "php-cs-fixer.executablePathWindows": "php-cs-fixer.bat",

I got the similar error when I attempt to call command directly.

For detail:

junstyle commented 3 years ago

@ngdangtu-vn did you modified "php-cs-fixer.documentFormattingProvider"? "php-cs-fixer.documentFormattingProvider": true

ngdangtu-vn commented 3 years ago

php-cs-fixer.documentFormattingProvider

I didn't (I didn't even know we have that option). After I saw your reply, I've checked the setting and it was set true in global scope.

Update: I tried to toggle it for a few time but nothing works.

junstyle commented 3 years ago

maybe extension not loaded? can you see commands by F1 in dropdownlist , or see logs in devoloper tools, maybe some errors

ngdangtu-vn commented 3 years ago

image image

In console, there is an error but it belongs to another extension (and I haven't had any problem with that ext so far)

TypeError: Cannot read property 'document' of undefined
    at getEnabledClosingsRegex (c:\Users\user\.vscode-oss\extensions\jomeinaster.bracket-peek-1.4.2\src\utils\closures.js:38:20)
    at regexLastIndexOfClosing (c:\Users\user\.vscode-oss\extensions\jomeinaster.bracket-peek-1.4.2\src\utils\indexOf.js:12:19)
    at c:\Users\user\.vscode-oss\extensions\jomeinaster.bracket-peek-1.4.2\src\extension.js:58:26
    at c.fire (c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712)
    at y.$acceptEditorPropertiesChanged (c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:95:63328)
    at i._doInvokeHandler (c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:13543)
    at i._invokeHandler (c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:13227)
    at i._receiveRequest (c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:11889)
    at i._receiveOneMessage (c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:10567)
    at c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:8663
    at c.fire (c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712)
    at l.fire (c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:15781)
    at c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:30187
    at c.fire (c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712)
    at l.fire (c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:15781)
    at r._receiveMessage (c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:21051)
    at c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:17929
    at c.fire (c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712)
    at v.acceptChunk (c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:13142)
    at c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:12490
    at Socket.w (c:\Program Files\VSCodium\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:13350)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)
junstyle commented 3 years ago

vscodium ? i did not test this extension on vscodium. maybe some problems on vscodium. someone opened issue you can git clone the codes and debug yourself

ngdangtu-vn commented 3 years ago

vscodium ? i did not test this extension on vscodium. maybe some problems on vscodium. someone opened issue you can git clone the codes and debug yourself

Can you teach me how to that? What (variables, functions, objects) should I support to observe?

junstyle commented 3 years ago

open the folder with vsc, then F5, start to debug

ngdangtu-vn commented 3 years ago

That's not what I asked, but anyway here is what I got from run debug "Launch Extension"

(node:15520) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `VSCodium --trace-deprecation ...` to show where the warning was created)

Quokka.js Live Share integration disabled, VSLS not found.

c:\Program Files\VSCodium\resources\app\out\bootstrap-fork.js:5
ApplicationInsights:CorrelationIdManager (1) [Error: self signed certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1497:34)
    at TLSSocket.e…]
arg1:(1) [Error: self signed certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1497:34)
    at TLSSocket.e…]
0:Error: self signed certificate\n\tat TLSSocket.onConnectSecure (_tls_wrap.js:1497:34)\n\tat TLSSocket.emit (events.js:315:20)\n\tat TLSSocket._finishInit (_tls_wrap.js:932:8)\n\tat TLSWrap.onhandshakedone (_tls_wrap.js:706:12)\n\tat TLSWrap.callbackTrampoline (internal/async_hooks.js:131:14) {code: 'DEPTH_ZERO_SELF_SIGNED_CERT', stack: 'Error: self signed certificate\n\tat TLSSocket.…ckTrampoline (internal/async_hooks.js:131:14)', message: 'self signed certificate'}
length:1
__proto__:Array(0)
<anonymous> @ c:\Program Files\VSCodium\resources\app\out\bootstrap-fork.js:5:6
ngdangtu-vn commented 3 years ago

If I install this extension ukoloff.win-ca and restart the computer will fix the problem.

junstyle commented 3 years ago

do you still not resolve the problem?

ngdangtu-vn commented 3 years ago

? I told you, install this extension ukoloff.win-ca will fix the problem

(But now I got a new problem...)

Or maybe this bug was fixed by your new update... :?