Code Monkey home page Code Monkey logo

netbeans-php-cs-fixer-plugin's Introduction

NetBeans PHP CS Fixer Plugin

This plugin provides support for the PHP CS Fixer. You can run fix command with this plugin.

PHP CS Fixer

https://github.com/FriendsOfPHP/PHP-CS-Fixer

Available versions of PHP CS Fixer

  • 1.x
  • 2.x (v0.6.0)

Requirements

  • NetBeans 8.2+

Available Commands

  • fix
  • fix --dry-run
  • self-update

Features

  • Run commands
  • Run on Save

Settings

Global

Tools > Options > PHP > Framework & Tools > PHP CS Fixer

  • set PHP CS Fixer path
  • select a version
  • set fix command options

Project

project properties > PHP CS Fixer

  • If you would like to use settings each projects, please, check use project settings

Customizing Options

If you would like to use some options, please check the custom checkbox, then please add them to it.

e.g. --cache-file=/path/to/.php_cs.cache

Show an output window

If you would like to avoid showing the output window, please uncheck it. (Checked by default)

Run self-update command on boot

If you would like to run the self-update command on boot, please check it. (Unchecked by default)

Usage

  1. Right-click
    • Project
    • Directory
    • File
    • Editor
  2. PHP CS Fixer
    • fix
    • fix --dry-run
    • self-update

Download

NOTE

  • Run on save feature may not work sometimes. Now after 1 second, the command is run. But I don't have another idea at the moment, sorry.

Donation

License

The Apache License, Version 2.0

Copyright 2022 junichi11.

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.

netbeans-php-cs-fixer-plugin's People

Contributors

junichi11 avatar keradus avatar krzysiekpiasecki avatar samnela avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

netbeans-php-cs-fixer-plugin's Issues

Browse Button Not Working

Issue type

  • bug
  • enhancement

Overview description

The browse button does not set the PHP CS Fixer path field when setting the path to a PHP CS Fixer phar. This is reproducible in NetBeans 19, 20, and 21 on Windows 10 and 11.

Steps to reproduce

  1. Open the PHP CS Fixer options page (Tools > Options > PHP > PHP CS Fixer)
  2. Click the Browse... button on the left side of the PHP CS Fixer field and navigate to the location of your PHP CS Fixer phar
  3. Select your PHP CS Fixer phar file and click Open

Actual results

The PHP CS Fixer path remains blank

Expected results

The PHP CS Fixer path is set to the path selected in the file explorer window

Your environment (NetBeans and plugin version, e.t.c.)

Windows 10, NetBeans 21, PHP CS Fixer Plugin 0.12.0

Keyboard shortcut

It would be useful to have keyboard shortcut instead of right-clicking and searching the context menu everytime you want to fix your cs.

Problem for "run on save"

I can implement "run on save".
But there is a problem. Editor is not reloaded after plugin run fix command on save.
I confirmed that fix command was run once I close the file and reopen it.
So, I'll not provide this feature yet.

How to pass multiple arguments?

Issue type

  • bug
  • enhancement

Overview description

Hello @junichi11. Currently I'm encounter a problem when trying to pass two arguments:

  1. --config
  2. --path-mode

and got an error "Cannot read config file ".php_cs.dist --path-mode=intersection"". This is because plugin execute script in this way:

"/usr/bin/php" "/home/blad/php-cs-fixer.phar" "fix" "test.php" "--config=.php_cs.dist --path-mode=intersection" "--ansi" "--no-interaction"

Steps to reproduce

  1. In plugin config set "custom" input to "--config=<path_to_config> --path-mode=intersection" with/without quotes
  2. Execute php-cs-fixer with plugin

Actual results

"Cannot read config file ".php_cs.dist --path-mode=intersection""

Expected results

php-cs-fixer.phar recieve all passed arguments

Your environment (NetBeans and plugin version, e.t.c.)

Linux
NetBeans 11.2
PHP CS Fixer - plugin 0.10.0
PHP CS Fixer 2.16.1

Add the ability to fix multiple files

Hi,

It would be great to be able to highlight a few files in the projects window (shift + click), then right click and run php cs fixer (fix) - and have it fix all three files. Currently it just fixes the one you've clicked (even if you have selected 3 files - it only fixes the one).

This would be really useful to easily fix multiple files and even entire directories if possible.

Thanks!!
Anil

Source Inspect results not as expected - Netbeans 8.2/OSX

Overview description

Results output not as expected in Netbeans 8.2 on OSX.

Steps to reproduce

  1. configure php-cs-fixer
    Coding Standards Fixer
  2. in Netbeans do File, New project, PHP Application
  3. in the new index.php, make a poorly formatted edit, so now the total project php is like:
		<?php
		// put your code here
								echo('this is my code');
		?>

  1. Run Source, Inspect

Actual results

results show a long text output of problems incorrectly marked as line 1
php-cs-fixer result

Expected results

I expected inspector to show problem line numbers and problems as per Code Sniffer:
CodeSniffer example

Version number of the plugin

Version: 0.5.3 Source: 1456105861_org-netbeans-modules-php-phpcsfixer-0.5.3.nbm

Version information of NetBeans

Product Version: NetBeans IDE 8.2 (Build 201609300101)
Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 1
Java: 1.8.0_05; Java HotSpot(TM) 64-Bit Server VM 25.5-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_05-b13
System: Mac OS X version 10.12.4 running on x86_64; UTF-8; en_GB (nb)

Some plugins require plugin PHP Executable API to be installed.

from Paweł Madej

Some plugins require plugin PHP Executable API to be installed. The plugin PHP Executable API is requested in implementation version 201302132200. The following plugin is affected: PHP CS Fixer Some plugins require plugin PHP Module API to be installed. The plugin PHP Module API is requested in implementation version 201302132200. The following plugin is affected: PHP CS Fixer
Please provide version for NetBeans IDE 7.3.1 (Build 201306052037) or manual how to compile module on my own

NPE

Version

0.8.0

java.lang.NullPointerException
	at org.netbeans.modules.php.phpcsfixer.preferences.PhpCsFixerPreferences.getPreferences(PhpCsFixerPreferences.java:239)
	at org.netbeans.modules.php.phpcsfixer.preferences.PhpCsFixerPreferences.useProject(PhpCsFixerPreferences.java:90)
	at org.netbeans.modules.php.phpcsfixer.onsave.PhpCsFixerOnSaveTask.performTask(PhpCsFixerOnSaveTask.java:87)
	at org.netbeans.modules.editor.lib.BeforeSaveTasks$TaskRunnable$1.run(BeforeSaveTasks.java:173)
	at org.netbeans.editor.GuardedDocument.runAtomicAsUser(GuardedDocument.java:356)
	at org.netbeans.modules.editor.lib.BeforeSaveTasks$TaskRunnable.run(BeforeSaveTasks.java:156)
	at org.netbeans.modules.php.phpcsfixer.onsave.PhpCsFixerOnSaveTask.runLocked(PhpCsFixerOnSaveTask.java:108)
	at org.netbeans.modules.editor.lib.BeforeSaveTasks$TaskRunnable.run(BeforeSaveTasks.java:153)
	at org.netbeans.modules.editor.lib.TrailingWhitespaceRemove.runLocked(TrailingWhitespaceRemove.java:102)
	at org.netbeans.modules.editor.lib.BeforeSaveTasks$TaskRunnable.run(BeforeSaveTasks.java:153)
	at org.netbeans.modules.editor.impl.ReformatBeforeSaveTask.runLocked(ReformatBeforeSaveTask.java:124)
	at org.netbeans.modules.editor.lib.BeforeSaveTasks$TaskRunnable.run(BeforeSaveTasks.java:153)
	at org.netbeans.modules.editor.lib.BeforeSaveTasks.runTasks(BeforeSaveTasks.java:130)
	at org.netbeans.modules.editor.lib.BeforeSaveTasks$2.run(BeforeSaveTasks.java:111)
	at org.openide.text.CloneableEditorSupport.saveDocumentImpl(CloneableEditorSupport.java:753)
	at org.openide.text.CloneableEditorSupport.saveDocument(CloneableEditorSupport.java:644)
	at org.openide.text.DataEditorSupport.superSaveDoc(DataEditorSupport.java:607)
	at org.openide.text.DataEditorSupport$SaveImpl.run(DataEditorSupport.java:1378)
	at org.openide.filesystems.EventControl.runAtomicAction(EventControl.java:127)
	at org.openide.filesystems.FileSystem.runAtomicAction(FileSystem.java:519)
	at org.openide.filesystems.FileUtil.runAtomicAction(FileUtil.java:421)
	at org.openide.text.DataEditorSupport.saveDocument(DataEditorSupport.java:603)
	at org.netbeans.modules.csl.core.GsfDataObject$GenericEditorSupport$Environment$SaveSupport.save(GsfDataObject.java:224)
	at org.openide.loaders.DataObject$DOSavable.handleSave(DataObject.java:1485)
	at org.netbeans.spi.actions.AbstractSavable.save(AbstractSavable.java:107)
	at org.openide.actions.SaveAction.performAction(SaveAction.java:132)
	at org.openide.actions.SaveAction.performAction(SaveAction.java:109)
	at org.openide.actions.SaveAction$Delegate.actionPerformed(SaveAction.java:249)
	at org.openide.awt.ContextAction$Performer.actionPerformed(ContextAction.java:231)
	at org.openide.awt.ContextManager.actionPerformed(ContextManager.java:260)
	at org.openide.awt.ContextAction.actionPerformed(ContextAction.java:109)
	at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:93)
	at org.openide.util.actions.ActionInvoker$ActionRunnable.actionPerformed(ActionInvoker.java:162)
	at org.netbeans.core.ModuleActions.invokeAction(ModuleActions.java:109)
	at org.netbeans.modules.openide.actions.ActionsBridgeImpl.invokeAction(ActionsBridgeImpl.java:60)
	at org.openide.util.actions.ActionInvoker$ActionRunnable.doRun(ActionInvoker.java:153)
	at org.openide.util.actions.ActionInvoker$2.run(ActionInvoker.java:110)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)

Unable to set Rules from rules field

Issue type

  • bug
  • enhancement

Overview description

The rules field does not seem to be used when set.

Steps to reproduce

  1. Under Tools > Options > PHP > PHP CS Fixer check the box for --rules= and set the field to array_syntax
  2. Create a simple PHP file with the following:
$test = array();
  1. Right click the workarea and run PHP CS Fixer fix command

Actual results

$test = array(); still shows.

Expected results

$test = [];

Your environment (NetBeans and plugin version, e.t.c.)

Windows 10, NetBeans 21, PHP CS Fixer plugin 0.12.0, PHP CS Fixer 3.51.0

Add the ability to bind php cs fixer to a keymap (shortcut)

Currently the only way I can find to run php cs fixer is using the mouse and right clicking on the file and selecting php cs fixer > Fix.

It would be great if you could add the php cs fixer application to the keyboard shortcuts list in netbeans (Keymap) so I could bind keyboard shortcuts to it.

I would suggest 2 entries for the keyboard shortcut.

  1. php cs fixer --dry-run
  2. php cs fixer --fix

So I could map them to something like CMD + SHIFT + CS (dry run) & CMD + CS (to fix) - or whatever the user prefers.

You probably know what I mean already, but I have attached a screenshot anyways!

screen shot 2014-06-25 at 14 52 03

p.s: I love all your netbeans plugins!!! they are FREAKING AWESOME!! ;)

Thanks!! 👍

Put the cache file in the metadata directory

When I create a project in Netbeans I tick the box "Put NetBeans metadata into a separate directory" to reduce clutter in my project.

image

However, the PHP CS Fixer plugin creates its .php_cs.cache in my project directory, which is extra clutter. Is there a way to use the project metadata directory instead? Or perhaps the NetBeans cache directory, which is found in Help -> About?

Edit: I have worked around this issue by adding --using-cache=false but it would be nice to be able to use the cache.

Thanks.

NetBeans: 8.2 (Build 201705191307)
PHP CS Fixer Plugin: 0.8.1

Feature request - disable output window

IDE real estate is becoming more and more valuable. When doing simple edits to a class, I often find myself running cs-fixer as a formatting tool. Each time it is run, it also writes to and opens the output pane in the netbeans IDE. This can be quite annoying sine the output only tells me which files have been changed, which is kinda redundant since I only selected a single file.

To add to the annoyance, the output pane always opens at it's last open size. While debugging the is often quite large, taking up about half of the screen.

As a feature request, can you add an option to completely disable output, or better still, the option to disable when only a single file is passed through. Something along the lines of two check boxes:

[ ] disable single file output
[ ] disable multi file output

I would submit a PR myself, but my java coding is quite honestly terrible.

Context menu options not available

On the latest version of the netbeans dev build, and using this plugin (not the one built into netbeans) several items are missing. The docs say to right click on a file or folder, and there will be 'fix' option listed. Well, there isn't.

Very easy to reproduce, just install the plugin, configure the source and default config "PHP >> Code Analysis >> Coding Standards Fixer", then right click on a file.

commands not available on right-clic

Overview description

No right-click commands available on Netbeans 8.2 on OSX.
I can't find the command anywhere on right click, what should it be called, how to enable?
I do note there are some closed issues which may be related but I can't see how theses could be resolved: #23, #20

Steps to reproduce

  1. configure php-cs-fixer
    Coding Standards Fixer
  2. in Netbeans do File, New project, PHP Application
  3. try right-clicking anywhere and see if you can find anything

Actual results

no fixer command anywhere on right click

Expected results

Expected some right-click menus as per the usage instructions:

Usage

  1. Right-click
    • Project
    • Directory
    • File
    • Editor

Version number of the plugin

Version: 0.5.3 Source: 1456105861_org-netbeans-modules-php-phpcsfixer-0.5.3.nbm

Version information of NetBeans

Product Version: NetBeans IDE 8.2 (Build 201609300101)
Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 1
Java: 1.8.0_05; Java HotSpot(TM) 64-Bit Server VM 25.5-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_05-b13
System: Mac OS X version 10.12.4 running on x86_64; UTF-8; en_GB (nb)

Netbeans 8.2 support

Hi,

I'm trying to use this plugin with Netbeans 8.2, it installed but there's no menu option to run it like was before on my netbeans 8.1.

Am I doing something wrong?

Thank you!

NullPointerException

What I did

  • install plugin
  • php-cs-fixer path is empty
  • open a file
  • right-click on editor i.e. open context menu
  • NullPointerException

PHP CS Fixer contextual menu does not appear

Hi,
I'm using NB 8.1, I have problem with this plugin:

Usage

  1. Right-click
    Project
    Directory
    File
    Editor
  2. PHP CS Fixer
    fix
    fix --dry-run
    self-update

the contextual menu does not have the "PHP CS Fixer" option; I see project configuration, but if I right click on project, or directory, or file or in the editor, I don't find the menu item; finally, I don't know how to run it.

Do you know about other plugin conflict?

Thanks in advance!

PHP-CS-Fixer 2.0 is out

This plugin is not compatible with 2.0 version.
the main reasons are that --fixers and --level params has been unified to --rules and the --config
param now is a path to .php_cs config file (like --config-file done before).
Here is a migration guide: https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v2.0.0/UPGRADE.md
I'll be very grateful if you could make this plugin (or maybe a new one) compatible with this new version

Already implemented

Hey, What are the pros to use your plugin instead of the Coding Standards FIxer in the php code analysis section of netbeans? I think that this is already implemented in netbeans.

Regards

Chris

javascript else if statements

If you have javascript code blocks inside php file that you want to fix, "else if" statements will be converted into "elseif" what causes syntax error in javascript.

Doesn't work on Windows with Apache NB 12.3

Issue type

  • bug
  • enhancement

Overview description

In tab "Frameworks & tools", the field "PHP CS Fixer" does not accept php-cs-fixer.bat, but only php-cs-fixer. Adding manually the .bat extension clears the field after validating.
If I try without the extension, due to the fact that it's a bash shell, I get the following error :

java.io.IOException: CreateProcess error=193, %1 n’est pas une application Win32 valide

Steps to reproduce

Actual results

Expected results

Your environment (NetBeans and plugin version, e.t.c.)

Apache NetBeans 12.3 x64
PHP : 8.0.6 x64
Plugin : 0.11.0
"friendsofphp/php-cs-fixer": "^3.0" (installed in the project using Composercat)

No options

I've just installed v.0.6.0 and set options, but there's no context menu item to run the fixer.

Support for Netbeans 10

Thanks for your work , Run on save feature is very useful, Have you planned to support Netbeans 10 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.