php-cs-fixer

php-cs-fixer : keep brace on the same line of function declaration

て烟熏妆下的殇ゞ 提交于 2021-01-27 05:40:34
问题 Php cs fixer is doing : function foobar() { .... } and I want: function foobar() { .... } I can't see what is the config to keep braces on the same line in my config .php_cs file, nor on https://github.com/FriendsOfPHP/PHP-CS-Fixer. I'm using php-cs-fixerV2. My config file: https://pastebin.com/v03v9Lb5 回答1: You have PSR-2 enabled, which requires the braces on the next line. From the documentation it looks like you can set braces.position_after_functions_and_oop_constructs to same (default

使用 PHP-CS-Fixer 自动规范化你的 PHP 代码

随声附和 提交于 2020-03-14 20:32:42
良好的代码规范可以提高代码可读性,团队沟通维护成本。最推荐大家遵守的是 php-fig (PHP Framework Interop Group) 组织定义的 PSR-1 、 PSR-2 两个。不了解的同学可以先通过连接点击过去阅读下。 PHP-CS-Fixer 项目地址: https://github.com/FriendsOfPHP/PHP-CS-Fixer 用来自动格式化你的代码。 通过安装 Composer 安装 composer.phar global require fabpot/php-cs-fixer 请确保 ~/.composer/vendor/bin 目录在你的系统PATH中。 export PATH="$PATH:$HOME/.composer/vendor/bin" 更多请查看 installation 使用fix命令 使用 fix 指令修复文件夹或文件的代码风格 php php-cs-fixer.phar fix /path/to/dir php php-cs-fixer.phar fix /path/to/file 使用 --level 选项设置修复至的「规范」。 php php-cs-fixer.phar fix /path/to/project --level=psr0 php php-cs-fixer.phar fix /path/to

Getting Non PHP File Extensions in Symfony Finder / PHP-CS-Fixer

给你一囗甜甜゛ 提交于 2020-01-07 09:54:21
问题 Struggling with adding non php extensions to my finder. Done a long google search but came up blank. Found this but couldn't quite understand: How to use other file extensions in php-cs-fixer, for example .ctp? This is what I have: <?php $finder = PhpCsFixer\Finder::create() ->notPath('path/to/some/file.inc') ->notPath('path/to/some/file.class') ->in(__DIR__) ->name('*.php') ->name('*.inc') ->name('*.class'); return PhpCsFixer\Config::create() ->setRules( array( 'Rule 1' => true, ... 'Rule n'

GIt preCommit (maybe with help PhpStorm) and php-cs-fixer

最后都变了- 提交于 2019-12-24 10:10:08
问题 I want automatic process, when I commit file my php-cs-fixer trn and fix all files which add to commit, maybe PhpStorm have some opportunity, running external tools before commit or push. I found only after commit, but I don't need after, need before. And I try tune my git, using pre-commit event I create in my project file, like example, just without extension sudo gedit .git/hooks/pre-commit then add code #!/usr/bin/env bash ROOT="/home/ivan/host/master" echo "php-cs-fixer pre commit hook

How to use other file extensions in php-cs-fixer, for example .ctp?

假如想象 提交于 2019-12-11 05:03:48
问题 How to use other file extensions in php-cs-fixer, for example cakephp template .ctp files ? I have trying this code: <?php $finder = PhpCsFixer\Finder::create() ->notPath('bootstrap/cache') ->notPath('storage') ->notPath('vendor') ->in(__DIR__) ->name('*.php') // <===== *.ctp ->notName('*.blade.php') ->ignoreDotFiles(true) ->ignoreVCS(true) ; return PhpCsFixer\Config::create() ->setRules(array( '@Symfony' => true, 'binary_operator_spaces' => ['align_double_arrow' => false], 'array_syntax' =>

PHP CS Fixer File Watcher causes File Cache Conflict in PHPStorm

痞子三分冷 提交于 2019-12-08 01:40:58
问题 I use a File Watcher defined as this Here is my watchers.xml file: <?xml version="1.0" encoding="UTF-8"?> <TaskOptions> <TaskOptions> <option name="arguments" value="fix $FileDir$/$FileName$ --verbose " /> <option name="checkSyntaxErrors" value="false" /> <option name="description" /> <option name="exitCodeBehavior" value="ERROR" /> <option name="fileExtension" value="php" /> <option name="immediateSync" value="true" /> <option name="name" value="PHP CS Fixer" /> <option name="output" value="

PHP CS Fixer File Watcher causes File Cache Conflict in PHPStorm

。_饼干妹妹 提交于 2019-12-06 07:58:24
I use a File Watcher defined as this Here is my watchers.xml file: <?xml version="1.0" encoding="UTF-8"?> <TaskOptions> <TaskOptions> <option name="arguments" value="fix $FileDir$/$FileName$ --verbose " /> <option name="checkSyntaxErrors" value="false" /> <option name="description" /> <option name="exitCodeBehavior" value="ERROR" /> <option name="fileExtension" value="php" /> <option name="immediateSync" value="true" /> <option name="name" value="PHP CS Fixer" /> <option name="output" value="" /> <option name="outputFilters"> <array /> </option> <option name="outputFromStdout" value="false" />

Sublime Text 3配置php语法错误提示插件PHPCS (windows7环境)

爱⌒轻易说出口 提交于 2019-11-30 19:26:49
第一步:下载 php code sniffer插件安装包 地址 https://github.com/benmatselby/sublime-phpcs ; 解压安装包得到sublime-phpcs-master,把sublime-phpcs-master文件夹放到sublime安装目录下的Data/Packages/目录下;重启sublime, 打开 Sublime Text 3->Preferences-> Package Settings -> Php Code Sniffer 证明插件安装成功; 第二步:下载 php-cs-fixer.phar 地址 http://cs.sensiolabs.org/get/php-cs-fixer.phar ; 第三步:把 php-cs-fixer.phar 放到 你的 php.exe 安装目录 (例如 (mine is C:/WAMP/php/php.exe) ); 第四步: 下载 http://download.pear.php.net/package/PHP_CodeSniffer-1.5.0RC4.tgz ,解压,然后找到scripts目录下的 phpcs.bat,放到 php.exe 安装目录; 第五步:解压打开 第一步下载的 php code sniffer安装包,在子文件example-settings下有个文件