├── .gitignore ├── demo.gif ├── icon.png ├── logo.sketch ├── .vscodeignore ├── jsconfig.json ├── example.json ├── CHANGELOG.md ├── .eslintrc.json ├── test ├── extension.test.js └── index.js ├── .vscode └── launch.json ├── README.md ├── vsc-extension-quickstart.md ├── package.json ├── extension.js ├── .php_cs └── .php_cs.dist /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode-test/ 3 | .vsix 4 | .DS_Store 5 | .php_cs.cache -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/calebporzio/simple-php-cs-fixer/HEAD/demo.gif -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/calebporzio/simple-php-cs-fixer/HEAD/icon.png -------------------------------------------------------------------------------- /logo.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/calebporzio/simple-php-cs-fixer/HEAD/logo.sketch -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | test/** 4 | .gitignore 5 | jsconfig.json 6 | vsc-extension-quickstart.md 7 | .eslintrc.json 8 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es6", 5 | "lib": [ 6 | "es6" 7 | ] 8 | }, 9 | "exclude": [ 10 | "node_modules" 11 | ] 12 | } -------------------------------------------------------------------------------- /example.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | 4 | 5 | 6 | // With this user setting: 7 | 8 | "files.associations": { 9 | ".php_cs": "php", 10 | ".php_cs.dist": "php" 11 | }, 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to the "simple-php-cs-fixer" extension will be documented in this file. 3 | 4 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 5 | 6 | ## [Unreleased] 7 | - Initial release -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": false, 4 | "commonjs": true, 5 | "es6": true, 6 | "node": true 7 | }, 8 | "parserOptions": { 9 | "ecmaFeatures": { 10 | "jsx": true 11 | }, 12 | "sourceType": "module" 13 | }, 14 | "rules": { 15 | "no-const-assign": "warn", 16 | "no-this-before-super": "warn", 17 | "no-undef": "warn", 18 | "no-unreachable": "warn", 19 | "no-unused-vars": "warn", 20 | "constructor-super": "warn", 21 | "valid-typeof": "warn" 22 | } 23 | } -------------------------------------------------------------------------------- /test/extension.test.js: -------------------------------------------------------------------------------- 1 | /* global suite, test */ 2 | 3 | // 4 | // Note: This example test is leveraging the Mocha test framework. 5 | // Please refer to their documentation on https://mochajs.org/ for help. 6 | // 7 | 8 | // The module 'assert' provides assertion methods from node 9 | const assert = require('assert'); 10 | 11 | // You can import and use all API from the 'vscode' module 12 | // as well as import your extension to test it 13 | const vscode = require('vscode'); 14 | const myExtension = require('../extension'); 15 | 16 | // Defines a Mocha test suite to group tests of similar kind together 17 | suite("Extension Tests", function() { 18 | 19 | // Defines a Mocha unit test 20 | test("Something 1", function() { 21 | assert.equal(-1, [1, 2, 3].indexOf(5)); 22 | assert.equal(-1, [1, 2, 3].indexOf(0)); 23 | }); 24 | }); -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | { 3 | "version": "0.1.0", 4 | "configurations": [ 5 | { 6 | "name": "Extension", 7 | "type": "extensionHost", 8 | "request": "launch", 9 | "runtimeExecutable": "${execPath}", 10 | "args": [ 11 | "${workspaceFolder}/../deadhappy", 12 | "--extensionDevelopmentPath=${workspaceRoot}" 13 | ], 14 | "stopOnEntry": false 15 | }, 16 | { 17 | "name": "Extension Tests", 18 | "type": "extensionHost", 19 | "request": "launch", 20 | "runtimeExecutable": "${execPath}", 21 | "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/test" ], 22 | "stopOnEntry": false 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simple PHP CS Fixer README 2 | 3 | A simple extension for using php-cs-fixer in VS Code. 4 | 5 | If no .php_cs.dist file (or other configuration) is found, it will use the default configuration for the Laravel project: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200 6 | 7 | ![Demo Gif](demo.gif) 8 | 9 | --- 10 | 11 | ## The Command: 12 | `simple-php-cs-fixer.fix` 13 | 14 | --- 15 | 16 | ## Config: 17 | 18 | Look for a custom project specific config file? 19 | 20 | `"simple-php-cs-fixer.useConfig": true` 21 | 22 | The path to that config file. (relative to the project root) 23 | 24 | `"simple-php-cs-fixer.config": ".php_cs.dist"` 25 | 26 | Run the fixer on save? 27 | 28 | `"simple-php-cs-fixer.save": false` 29 | 30 | Whether php-cs-fixer should be using a cache 31 | 32 | `"simple-php-cs-fixer.usingCache": false` 33 | 34 | A comma separated list of rules to be used by php-cs-fixer 35 | 36 | `"simple-php-cs-fixer.rules": "@PSR1,@PSR2,trailing_comma_in_multiline_array"` 37 | 38 | --- 39 | 40 | \- Enjoy! 41 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | // 2 | // PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING 3 | // 4 | // This file is providing the test runner to use when running extension tests. 5 | // By default the test runner in use is Mocha based. 6 | // 7 | // You can provide your own test runner if you want to override it by exporting 8 | // a function run(testRoot: string, clb: (error:Error) => void) that the extension 9 | // host can call to run the tests. The test runner is expected to use console.log 10 | // to report the results back to the caller. When the tests are finished, return 11 | // a possible error to the callback or null if none. 12 | 13 | const testRunner = require('vscode/lib/testrunner'); 14 | 15 | // You can directly control Mocha options by uncommenting the following lines 16 | // See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info 17 | testRunner.configure({ 18 | ui: 'tdd', // the TDD UI is being used in extension.test.js (suite, test, etc.) 19 | useColors: true // colored output from test results 20 | }); 21 | 22 | module.exports = testRunner; -------------------------------------------------------------------------------- /vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your VS Code Extension 2 | 3 | ## What's in the folder 4 | * This folder contains all of the files necessary for your extension. 5 | * `package.json` - this is the manifest file in which you declare your extension and command. 6 | The sample plugin registers a command and defines its title and command name. With this information 7 | VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. 8 | * `extension.js` - this is the main file where you will provide the implementation of your command. 9 | The file exports one function, `activate`, which is called the very first time your extension is 10 | activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. 11 | We pass the function containing the implementation of the command as the second parameter to 12 | `registerCommand`. 13 | 14 | ## Get up and running straight away 15 | * Press `F5` to open a new window with your extension loaded. 16 | * Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`. 17 | * Set breakpoints in your code inside `extension.js` to debug your extension. 18 | * Find output from your extension in the debug console. 19 | 20 | ## Make changes 21 | * You can relaunch the extension from the debug toolbar after changing code in `extension.js`. 22 | * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. 23 | 24 | ## Explore the API 25 | * You can open the full set of our API when you open the file `node_modules/vscode/vscode.d.ts`. 26 | 27 | ## Run tests 28 | * Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Launch Tests`. 29 | * Press `F5` to run the tests in a new window with your extension loaded. 30 | * See the output of the test result in the debug console. 31 | * Make changes to `test/extension.test.js` or create new test files inside the `test` folder. 32 | * By convention, the test runner will only consider files matching the name pattern `**.test.js`. 33 | * You can create folders inside the `test` folder to structure your tests any way you want. 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "simple-php-cs-fixer", 3 | "displayName": "Simple PHP CS Fixer", 4 | "description": "A simple way to fire php-cs-fixer with custom config and optionally on save.", 5 | "icon": "icon.png", 6 | "galleryBanner": { 7 | "color": "#f0f1f6", 8 | "theme": "light" 9 | }, 10 | "version": "1.0.3", 11 | "publisher": "calebporzio", 12 | "engines": { 13 | "vscode": "^1.17.0" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/calebporzio/simple-php-cs-fixer.git" 18 | }, 19 | "categories": [ 20 | "Linters", 21 | "Other" 22 | ], 23 | "activationEvents": [ 24 | "*" 25 | ], 26 | "main": "./extension", 27 | "contributes": { 28 | "commands": [ 29 | { 30 | "command": "simple-php-cs-fixer.fix", 31 | "title": "Simple PHP CS Fixer: fix" 32 | } 33 | ], 34 | "configuration": { 35 | "title": "Simple PHP CS Fixer Config", 36 | "type": "object", 37 | "properties": { 38 | "simple-php-cs-fixer.useConfig": { 39 | "type": "boolean", 40 | "default": true, 41 | "description": "Whether to use a custom config file" 42 | }, 43 | "simple-php-cs-fixer.config": { 44 | "type": "string", 45 | "default": ".php_cs.dist", 46 | "description": "PHP CS Fixer custom config file name" 47 | }, 48 | "simple-php-cs-fixer.save": { 49 | "type": "boolean", 50 | "default": false, 51 | "description": "Run PHP CS Fixer on save" 52 | }, 53 | "simple-php-cs-fixer.usingCache": { 54 | "type": "boolean", 55 | "default": false, 56 | "description": "Whether to use the php-cs-fixer cache" 57 | }, 58 | "simple-php-cs-fixer.rules": { 59 | "type": "string", 60 | "default": "", 61 | "description": "A comma separated list of rules php-cs-fixer will apply using the --rules option" 62 | } 63 | } 64 | } 65 | }, 66 | "scripts": { 67 | "postinstall": "node ./node_modules/vscode/bin/install", 68 | "test": "node ./node_modules/vscode/bin/test" 69 | }, 70 | "devDependencies": { 71 | "@types/mocha": "^2.2.48", 72 | "@types/node": "^7.10.9", 73 | "eslint": "^4.19.1", 74 | "mocha": "^6.2.2", 75 | "typescript": "^2.9.2", 76 | "vscode": "^1.1.36" 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /extension.js: -------------------------------------------------------------------------------- 1 | const vscode = require('vscode'); 2 | const cp = require('child_process'); 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | 6 | let willFixOnSave = undefined; 7 | 8 | function PhpCsFixer() { 9 | // 10 | } 11 | 12 | PhpCsFixer.prototype.fix = function (document) { 13 | if (document.languageId !== 'php') { 14 | return; 15 | } 16 | 17 | const process = cp.spawn('php-cs-fixer', this.getArgs(document)); 18 | 19 | this.handleProcessOutput(process); 20 | } 21 | 22 | PhpCsFixer.prototype.getArgs = function (document) { 23 | let args = ['fix', document.fileName]; 24 | 25 | if (this.useConfigFile) { 26 | const configFilePath = path.join(vscode.workspace.workspaceFolders[0].uri.path, this.configFile); 27 | const fallbackConfigPath = path.resolve(__dirname, '.php_cs.dist'); 28 | 29 | if (fs.existsSync(configFilePath)) { 30 | args.push('--config=' + configFilePath); 31 | } else if (fs.existsSync(fallbackConfigPath)) { 32 | args.push('--config=' + fallbackConfigPath) 33 | } else { 34 | vscode.window.showErrorMessage(`Simple PHP CS Fixer: Can't find config file: [${this.configFile}]`); 35 | } 36 | } 37 | 38 | if (!this.usingCache) { 39 | args.push('--using-cache=no'); 40 | } 41 | 42 | if (this.rules) { 43 | args.push('--rules=' + this.rules) 44 | } 45 | 46 | return args; 47 | } 48 | 49 | PhpCsFixer.prototype.handleProcessOutput = function (process) { 50 | process.stderr.on('data', buffer => { 51 | console.log(buffer.toString()); 52 | }); 53 | 54 | process.on('close', (code) => { 55 | let codeHandlers = { 56 | 0: () => { 57 | vscode.window.setStatusBarMessage('Simple PHP CS Fixer: Fixed all files!', 2500); 58 | }, 59 | 16: () => { 60 | vscode.window.showErrorMessage('Simple PHP CS Fixer: Config error.'); 61 | }, 62 | 32: () => { 63 | vscode.window.showErrorMessage('Simple PHP CS Fixer: Fixer error.'); 64 | }, 65 | 'fallback': () => { 66 | vscode.window.showErrorMessage('Simple PHP CS Fixer: Unknown error.'); 67 | } 68 | }; 69 | 70 | codeHandlers[code in codeHandlers ? code : 'fallback'](); 71 | }); 72 | } 73 | 74 | PhpCsFixer.prototype.loadConfig = function () { 75 | const config = vscode.workspace.getConfiguration('simple-php-cs-fixer'); 76 | 77 | this.useConfigFile = config.get('useConfig'); 78 | this.configFile = config.get('config'); 79 | this.runOnSave = config.get('save'); 80 | this.usingCache = config.get('usingCache'); 81 | this.rules = config.get('rules'); 82 | 83 | if (this.runOnSave && ! willFixOnSave) { 84 | willFixOnSave = vscode.workspace.onDidSaveTextDocument(document => { 85 | this.fix(document); 86 | }); 87 | } else if (!this.runOnSave && willFixOnSave) { 88 | willFixOnSave.dispose(); 89 | willFixOnSave = undefined; 90 | } 91 | } 92 | 93 | function activate(context) { 94 | const phpCsFixer = new PhpCsFixer; 95 | 96 | context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(() => { 97 | phpCsFixer.loadConfig(); 98 | })); 99 | 100 | phpCsFixer.loadConfig(); 101 | 102 | vscode.commands.registerTextEditorCommand 103 | 104 | vscode.commands.registerTextEditorCommand('simple-php-cs-fixer.fix', (textEditor) => { 105 | phpCsFixer.fix(textEditor.document); 106 | }); 107 | } 108 | exports.activate = activate; 109 | 110 | function deactivate() { 111 | if (willFixOnSave) { 112 | willFixOnSave.dispose(); 113 | willFixOnSave = undefined; 114 | } 115 | } 116 | exports.deactivate = deactivate; 117 | -------------------------------------------------------------------------------- /.php_cs: -------------------------------------------------------------------------------- 1 | ['syntax' => 'short'], 8 | 'binary_operator_spaces' => [ 9 | 'default' => 'single_space', 10 | 'operators' => ['=>' => null] 11 | ], 12 | 'blank_line_after_namespace' => true, 13 | 'blank_line_after_opening_tag' => true, 14 | 'blank_line_before_statement' => [ 15 | 'statements' => ['return'] 16 | ], 17 | 'braces' => true, 18 | 'cast_spaces' => true, 19 | 'class_attributes_separation' => [ 20 | 'elements' => ['method'] 21 | ], 22 | 'class_definition' => true, 23 | 'concat_space' => [ 24 | 'spacing' => 'none' 25 | ], 26 | 'declare_equal_normalize' => true, 27 | 'elseif' => true, 28 | 'encoding' => true, 29 | 'full_opening_tag' => true, 30 | 'fully_qualified_strict_types' => true, // added by Shift 31 | 'function_declaration' => true, 32 | 'function_typehint_space' => true, 33 | 'heredoc_to_nowdoc' => true, 34 | 'include' => true, 35 | 'increment_style' => ['style' => 'post'], 36 | 'indentation_type' => true, 37 | 'linebreak_after_opening_tag' => true, 38 | 'line_ending' => true, 39 | 'lowercase_cast' => true, 40 | 'lowercase_constants' => true, 41 | 'lowercase_keywords' => true, 42 | 'lowercase_static_reference' => true, // added from Symfony 43 | 'magic_method_casing' => true, // added from Symfony 44 | 'magic_constant_casing' => true, 45 | 'method_argument_space' => true, 46 | 'native_function_casing' => true, 47 | 'no_alias_functions' => true, 48 | 'no_extra_blank_lines' => [ 49 | 'tokens' => [ 50 | 'extra', 51 | 'throw', 52 | 'use', 53 | 'use_trait', 54 | ] 55 | ], 56 | 'no_blank_lines_after_class_opening' => true, 57 | 'no_blank_lines_after_phpdoc' => true, 58 | 'no_closing_tag' => true, 59 | 'no_empty_phpdoc' => true, 60 | 'no_empty_statement' => true, 61 | 'no_leading_import_slash' => true, 62 | 'no_leading_namespace_whitespace' => true, 63 | 'no_mixed_echo_print' => [ 64 | 'use' => 'echo' 65 | ], 66 | 'no_multiline_whitespace_around_double_arrow' => true, 67 | 'multiline_whitespace_before_semicolons' => [ 68 | 'strategy' => 'no_multi_line' 69 | ], 70 | 'no_short_bool_cast' => true, 71 | 'no_singleline_whitespace_before_semicolons' => true, 72 | 'no_spaces_after_function_name' => true, 73 | 'no_spaces_around_offset' => true, 74 | 'no_spaces_inside_parenthesis' => true, 75 | 'no_trailing_comma_in_list_call' => true, 76 | 'no_trailing_comma_in_singleline_array' => true, 77 | 'no_trailing_whitespace' => true, 78 | 'no_trailing_whitespace_in_comment' => true, 79 | 'no_unneeded_control_parentheses' => true, 80 | 'no_unreachable_default_argument_value' => true, 81 | 'no_useless_return' => true, 82 | 'no_whitespace_before_comma_in_array' => true, 83 | 'no_whitespace_in_blank_line' => true, 84 | 'normalize_index_brace' => true, 85 | 'not_operator_with_successor_space' => true, 86 | 'object_operator_without_whitespace' => true, 87 | 'ordered_imports' => ['sortAlgorithm' => 'alpha'], 88 | 'phpdoc_indent' => true, 89 | 'phpdoc_inline_tag' => true, 90 | 'phpdoc_no_access' => true, 91 | 'phpdoc_no_package' => true, 92 | 'phpdoc_no_useless_inheritdoc' => true, 93 | 'phpdoc_scalar' => true, 94 | 'phpdoc_single_line_var_spacing' => true, 95 | 'phpdoc_summary' => true, 96 | 'phpdoc_to_comment' => true, 97 | 'phpdoc_trim' => true, 98 | 'phpdoc_types' => true, 99 | 'phpdoc_var_without_name' => true, 100 | 'psr4' => true, 101 | 'self_accessor' => true, 102 | 'short_scalar_cast' => true, 103 | 'simplified_null_return' => true, 104 | 'single_blank_line_at_eof' => true, 105 | 'single_blank_line_before_namespace' => true, 106 | 'single_class_element_per_statement' => true, 107 | 'single_import_per_statement' => true, 108 | 'single_line_after_imports' => true, 109 | 'single_line_comment_style' => [ 110 | 'comment_types' => ['hash'] 111 | ], 112 | 'single_quote' => true, 113 | 'space_after_semicolon' => true, 114 | 'standardize_not_equals' => true, 115 | 'switch_case_semicolon_to_colon' => true, 116 | 'switch_case_space' => true, 117 | 'ternary_operator_spaces' => true, 118 | 'trailing_comma_in_multiline_array' => true, 119 | 'trim_array_spaces' => true, 120 | 'unary_operator_spaces' => true, 121 | 'visibility_required' => [ 122 | 'elements' => ['method', 'property'] 123 | ], 124 | 'whitespace_after_comma_in_array' => true, 125 | ]; 126 | 127 | $finder = Finder::create() 128 | ->notPath('bootstrap') 129 | ->notPath('storage') 130 | ->notPath('vendor') 131 | ->in(getcwd()) 132 | ->name('*.php') 133 | ->notName('*.blade.php') 134 | ->notName('index.php') 135 | ->notName('server.php') 136 | ->ignoreDotFiles(true) 137 | ->ignoreVCS(true); 138 | 139 | return Config::create() 140 | ->setFinder($finder) 141 | ->setRules($rules) 142 | ->setRiskyAllowed(true) 143 | ->setUsingCache(true); 144 | -------------------------------------------------------------------------------- /.php_cs.dist: -------------------------------------------------------------------------------- 1 | ['syntax' => 'short'], 8 | 'binary_operator_spaces' => [ 9 | 'default' => 'single_space', 10 | 'operators' => ['=>' => null] 11 | ], 12 | 'blank_line_after_namespace' => true, 13 | 'blank_line_after_opening_tag' => true, 14 | 'blank_line_before_statement' => [ 15 | 'statements' => ['return'] 16 | ], 17 | 'braces' => true, 18 | 'cast_spaces' => true, 19 | 'class_attributes_separation' => [ 20 | 'elements' => ['method'] 21 | ], 22 | 'class_definition' => true, 23 | 'concat_space' => [ 24 | 'spacing' => 'none' 25 | ], 26 | 'declare_equal_normalize' => true, 27 | 'elseif' => true, 28 | 'encoding' => true, 29 | 'full_opening_tag' => true, 30 | 'fully_qualified_strict_types' => true, // added by Shift 31 | 'function_declaration' => true, 32 | 'function_typehint_space' => true, 33 | 'heredoc_to_nowdoc' => true, 34 | 'include' => true, 35 | 'increment_style' => ['style' => 'post'], 36 | 'indentation_type' => true, 37 | 'linebreak_after_opening_tag' => true, 38 | 'line_ending' => true, 39 | 'lowercase_cast' => true, 40 | 'lowercase_constants' => true, 41 | 'lowercase_keywords' => true, 42 | 'lowercase_static_reference' => true, // added from Symfony 43 | 'magic_method_casing' => true, // added from Symfony 44 | 'magic_constant_casing' => true, 45 | 'method_argument_space' => true, 46 | 'native_function_casing' => true, 47 | 'no_alias_functions' => true, 48 | 'no_extra_blank_lines' => [ 49 | 'tokens' => [ 50 | 'extra', 51 | 'throw', 52 | 'use', 53 | 'use_trait', 54 | ] 55 | ], 56 | 'no_blank_lines_after_class_opening' => true, 57 | 'no_blank_lines_after_phpdoc' => true, 58 | 'no_closing_tag' => true, 59 | 'no_empty_phpdoc' => true, 60 | 'no_empty_statement' => true, 61 | 'no_leading_import_slash' => true, 62 | 'no_leading_namespace_whitespace' => true, 63 | 'no_mixed_echo_print' => [ 64 | 'use' => 'echo' 65 | ], 66 | 'no_multiline_whitespace_around_double_arrow' => true, 67 | 'multiline_whitespace_before_semicolons' => [ 68 | 'strategy' => 'no_multi_line' 69 | ], 70 | 'no_short_bool_cast' => true, 71 | 'no_singleline_whitespace_before_semicolons' => true, 72 | 'no_spaces_after_function_name' => true, 73 | 'no_spaces_around_offset' => true, 74 | 'no_spaces_inside_parenthesis' => true, 75 | 'no_trailing_comma_in_list_call' => true, 76 | 'no_trailing_comma_in_singleline_array' => true, 77 | 'no_trailing_whitespace' => true, 78 | 'no_trailing_whitespace_in_comment' => true, 79 | 'no_unneeded_control_parentheses' => true, 80 | 'no_unreachable_default_argument_value' => true, 81 | 'no_useless_return' => true, 82 | 'no_whitespace_before_comma_in_array' => true, 83 | 'no_whitespace_in_blank_line' => true, 84 | 'normalize_index_brace' => true, 85 | 'not_operator_with_successor_space' => true, 86 | 'object_operator_without_whitespace' => true, 87 | 'ordered_imports' => ['sortAlgorithm' => 'alpha'], 88 | 'phpdoc_indent' => true, 89 | 'phpdoc_inline_tag' => true, 90 | 'phpdoc_no_access' => true, 91 | 'phpdoc_no_package' => true, 92 | 'phpdoc_no_useless_inheritdoc' => true, 93 | 'phpdoc_scalar' => true, 94 | 'phpdoc_single_line_var_spacing' => true, 95 | 'phpdoc_summary' => true, 96 | 'phpdoc_to_comment' => true, 97 | 'phpdoc_trim' => true, 98 | 'phpdoc_types' => true, 99 | 'phpdoc_var_without_name' => true, 100 | 'psr4' => true, 101 | 'self_accessor' => true, 102 | 'short_scalar_cast' => true, 103 | 'simplified_null_return' => true, 104 | 'single_blank_line_at_eof' => true, 105 | 'single_blank_line_before_namespace' => true, 106 | 'single_class_element_per_statement' => true, 107 | 'single_import_per_statement' => true, 108 | 'single_line_after_imports' => true, 109 | 'single_line_comment_style' => [ 110 | 'comment_types' => ['hash'] 111 | ], 112 | 'single_quote' => true, 113 | 'space_after_semicolon' => true, 114 | 'standardize_not_equals' => true, 115 | 'switch_case_semicolon_to_colon' => true, 116 | 'switch_case_space' => true, 117 | 'ternary_operator_spaces' => true, 118 | 'trailing_comma_in_multiline_array' => true, 119 | 'trim_array_spaces' => true, 120 | 'unary_operator_spaces' => true, 121 | 'visibility_required' => [ 122 | 'elements' => ['method', 'property'] 123 | ], 124 | 'whitespace_after_comma_in_array' => true, 125 | ]; 126 | 127 | $finder = Finder::create() 128 | ->notPath('bootstrap') 129 | ->notPath('storage') 130 | ->notPath('vendor') 131 | ->in(getcwd()) 132 | ->name('*.php') 133 | ->notName('*.blade.php') 134 | ->notName('index.php') 135 | ->notName('server.php') 136 | ->ignoreDotFiles(true) 137 | ->ignoreVCS(true); 138 | 139 | return Config::create() 140 | ->setFinder($finder) 141 | ->setRules($rules) 142 | ->setRiskyAllowed(true) 143 | ->setUsingCache(true); 144 | --------------------------------------------------------------------------------