textmate/php.tmbundle

Add support for php-cs-fixer

miken32 opened this issue · 6 comments

This tool implements code standards checking using PRS-2 and PRS-1 specifications. Would be great if this option could be available if installed, or even included (306 kb) with the bundle. More info: http://cs.sensiolabs.org/

also these tools
phpmd
phpcpd
phpcs

This is a must for me!
I'm trying to switch to TextMate as a primary editor and unfortunately this is holding me back a bit.

In Netbeans, I can Ctrl, Shift + F to format the code according to standards.

Did you already install php-cs-fixer and is that doing what you need?

If so it’s trivial to write a command that calls it:

Bundle Editor → New (⌘N) → Command

Input/output: Document/Replace Document

Key equivalent: ⌃⇧H (consistent with other “pretty print”
commands)

Then set the command to call php-cs-fixer with appropriate options.

We can add such command to the PHP bundle, but ideally it would come
from a PHP user (as a pull request) as I do not know what is “best
practice” for PHP.

On 8 Jul 2014, at 11:51, danhanly wrote:

This is a must for me!
I'm trying to switch to TextMate as a primary editor and unfortunately
this is holding me back a bit.

In Netbeans, I can Ctrl, Shift + F to format the code according to
standards.


Reply to this email directly or view it on GitHub:
#25 (comment)

I have this settled up in a very similar way.

The difference is Output: Show in Tool Tip.

And the command is:

#!/usr/bin/env php

<?php
$file = $_ENV['TM_FILEPATH'];

system(sprintf("php-cs-fixer fix %s -vvv", $file));

I’m having problems installing php-cs-fixer (tried via homebrew) but
it seems a command for the PHP bundle could simply be:

#!/bin/sh
exec php-cs-fixer fix "$TM_FILEPATH" -vvv

Or by setting up php-cs-fixer in the command’s requirements:

#!/bin/sh
exec $PHP_CS_FIXER fix "$TM_FILEPATH" -vvv

The variable introduced should not be quoted, as that way the user can
add potential custom paramters.

Can someone suggest the easiest way to install php-cs-fixer?

@infininight can you look into adding a command for this (so we can
close this issue)?

If php-cs-fixer can work with stdin/out then it might be better to make
a command that does not rely on TM_FILEPATH.

On 11 Jul 2014, at 22:39, Pera Jovic wrote:

I have this settled up in a very similar way.

The difference is Output: Show in Tool Tip.

And the command is:

php
#!/usr/bin/env php

<?php
$file = $_ENV['TM_FILEPATH'];

system(sprintf("php-cs-fixer fix %s -vvv", $file));

Reply to this email directly or view it on GitHub:
#25 (comment)

I install php cs fixer with cloning a repo and symlink bin file to /usr/local/bin/php-cs-fixer.
With homebrew you don't get really fresh version with all fixes and improvements.