Skip to content

Commit f8cd1c7

Browse files
authored
Merge pull request #31 from stechstudio/Fixer-3.0-Support
Fixer 3.0 Support
2 parents 867d5d3 + 707d63e commit f8cd1c7

17 files changed

+846
-351
lines changed

.devcontainer/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Update the VARIANT arg in docker-compose.yml to pick a PHP version: 7, 7.4, 7.3
2+
ARG VARIANT=8
3+
FROM mcr.microsoft.com/vscode/devcontainers/php:0-${VARIANT}
4+
5+
# Install MariaDB client
6+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
7+
&& apt-get install -y mariadb-client \
8+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
9+
10+
# Update args in docker-compose.yaml to set the UID/GID of the "vscode" user.
11+
ARG USER_UID=1000
12+
ARG USER_GID=$USER_UID
13+
RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then groupmod --gid $USER_GID vscode && usermod --uid $USER_UID --gid $USER_GID vscode; fi
14+
15+
RUN pecl install -o -f redis \
16+
&& rm -rf /tmp/pear \
17+
&& docker-php-ext-enable redis
18+
19+
# Install php-mysql driver
20+
RUN docker-php-ext-install mysqli pdo pdo_mysql
21+
22+
# [Optional] Install a version of Node.js using nvm for front end dev
23+
ARG INSTALL_NODE="true"
24+
ARG NODE_VERSION="lts/*"
25+
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
26+
RUN rm -rf /usr/local/etc/php/conf.d/xdebug.ini
27+
# [Optional] Uncomment this section to install additional OS packages.
28+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
29+
# && apt-get -y install --no-install-recommends <your-package-list-here>
30+
31+
# [Optional] Uncomment this line to install global node packages.
32+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
33+

.devcontainer/devcontainer.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/php-mariadb
3+
// Update the VARIANT arg in docker-compose.yml to pick a PHP version: 7, 7.3, 7.4
4+
{
5+
"name": "metrics-app",
6+
"dockerComposeFile": "docker-compose.yml",
7+
"service": "app",
8+
"workspaceFolder": "/workspace",
9+
10+
// Set *default* container specific settings.json values on container create.
11+
"settings": {
12+
"terminal.integrated.shell.linux": "/bin/bash"
13+
},
14+
15+
// Add the IDs of extensions you want installed when the container is created.
16+
"extensions": [
17+
"eamodio.gitlens",
18+
"mikestead.dotenv",
19+
"felixfbecker.php-debug",
20+
"marabesi.php-import-checker",
21+
"fterrag.vscode-php-cs-fixer",
22+
"marsl.vscode-php-refactoring",
23+
"coenraads.bracket-pair-colorizer-2",
24+
"bmewburn.vscode-intelephense-client"
25+
],
26+
27+
// For use with PHP or Apache (e.g.php -S localhost:8080 or apache2ctl start)
28+
"forwardPorts": [8080, 3306],
29+
30+
// Use 'postCreateCommand' to run commands after the container is created.
31+
// "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html"
32+
33+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
34+
"remoteUser": "vscode"
35+
}

.devcontainer/docker-compose.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
version: '3'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
args:
9+
# [Choice] PHP version: 7, 7.4, 7.3
10+
VARIANT: "8"
11+
# [Option] Install Node.js
12+
INSTALL_NODE: "true"
13+
NODE_VERSION: "lts/*"
14+
# On Linux, you may need to update USER_UID and USER_GID below if not your local UID is not 1000.
15+
USER_UID: 1000
16+
USER_GID: 1000
17+
18+
volumes:
19+
- ..:/workspace:cached
20+
21+
# Overrides default command so things don't shut down after the process ends.
22+
command: sleep infinity
23+
24+
# Uncomment the next line to use a non-root user for all processes.
25+
# user: vscode

README.md

Lines changed: 27 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -19,93 +19,23 @@ do all the other laravel packages you use.
1919

2020
## Versions and compatibility
2121
> **Note:** This documentation was written for Laravel 5.5.
22-
* PHP Version: ">=7.0"
23-
* Laravel/Lumen: "^5.4|^6.0"
24-
* PHP-CS-Fixer: "2.14.*"
22+
* PHP Version: "^7.1.3 || ^8.0"
23+
* Laravel/Lumen: "^5.4|^6.0|^7.0|^8.0"
24+
* PHP-CS-Fixer: "^3.0.0"
2525

2626
## Installation
2727

2828
```
2929
composer require stechstudio/laravel-php-cs-fixer
3030
```
3131

32-
> **Note**: If you are using Laravel 5.5 or greater, no need to register the provider. Laravel PHP CS Fixer supports Laravel new [Package Discovery](https://laravel.com/docs/5.5/packages#package-discovery).
33-
34-
### Manually Register the Provider for Laravel 5.4:
35-
36-
#### Laravel
37-
Add the following to the `providers` array in `config/app.php`.:
38-
39-
```php
40-
STS\Fixer\FixerServiceProvider::class,
41-
```
42-
43-
#### Lumen
44-
Add the following to `bootstrap/app.php`.:
45-
46-
```php
47-
$app->register(STS\Fixer\FixerServiceProvider::class);
48-
```
49-
5032
## Configuration
51-
The default rule configuration is in the `fixer.php` and is intended to match the rules used by the Laravel Framework.
52-
53-
```php
54-
return [
55-
'rules' => [
56-
'psr0' => false,
57-
'@PSR2' => true,
58-
'blank_line_after_namespace' => true,
59-
'braces' => true,
60-
'class_definition' => true,
61-
'elseif' => true,
62-
'function_declaration' => true,
63-
'indentation_type' => true,
64-
'line_ending' => true,
65-
'lowercase_constants' => true,
66-
'lowercase_keywords' => true,
67-
'method_argument_space' => [
68-
'ensure_fully_multiline' => true, ],
69-
'no_break_comment' => true,
70-
'no_closing_tag' => true,
71-
'no_spaces_after_function_name' => true,
72-
'no_spaces_inside_parenthesis' => true,
73-
'no_trailing_whitespace' => true,
74-
'no_trailing_whitespace_in_comment' => true,
75-
'single_blank_line_at_eof' => true,
76-
'single_class_element_per_statement' => [
77-
'elements' => ['property'],
78-
],
79-
'single_import_per_statement' => true,
80-
'single_line_after_imports' => true,
81-
'switch_case_semicolon_to_colon' => true,
82-
'switch_case_space' => true,
83-
'visibility_required' => true,
84-
'encoding' => true,
85-
'full_opening_tag' => true,
86-
],
87-
];
88-
```
33+
The default rule configuration is in the [fixer.php](https://github.com/stechstudio/Laravel-PHP-CS-Fixer/blob/master/config/fixer.php) and is intended to match the rules used by Laravel Shift.
8934

9035
if you want to modify this yourself, just use artisan `php artisan vendor:publish --provider="STS\Fixer\FixerServiceProvider"`
9136
and it will put the default configuration in 'config/fixer.php'. Check the
9237
[PHP-CS-Fixer/README](https://github.com/FriendsOfPHP/PHP-CS-Fixer#usage) for valid rules.
9338

94-
> Note: There are some static configuration settings in the finder that have yet to be moved to the configuration file
95-
> that you should be aware of! We plan to move these to the config file soon.
96-
97-
```php
98-
$finder = Finder::create()
99-
->notPath('bootstrap/cache')
100-
->notPath('storage')
101-
->notPath('vendor')
102-
->in(base_path())
103-
->name('*.php')
104-
->notName('*.blade.php')
105-
->ignoreDotFiles(true)
106-
->ignoreVCS(true);
107-
```
108-
10939
## Usage
11040
#### Fix Your Code
11141
Fix your code with Laravel Coding Standards.
@@ -118,37 +48,30 @@ $ php artisan fixer:fix [options]
11848
Example:
11949
```
12050
Usage:
121-
fixer:fix [options]
51+
fixer:fix [options] [--] [<path>...]
52+
53+
Arguments:
54+
path The path. Can be a list of space separated paths
12255
12356
Options:
124-
--path[=PATH] The path. (multiple values allowed)
125-
--path-mode[=PATH-MODE] Specify path mode (can be override or intersection). [default: "override"]
126-
--allow-risky[=ALLOW-RISKY] Are risky fixers allowed (can be yes or no).
127-
--config[=CONFIG] The path to a .php_cs file.
128-
--dry-run Only shows which files would have been modified.
129-
--rules[=RULES] The Rules
130-
--using-cache[=USING-CACHE] Does cache should be used (can be yes or no). [default: "yes"]
131-
--cache-file[=CACHE-FILE] The path to the cache file.
132-
--diff Also produce diff for each file.
133-
--diff-format[=DIFF-FORMAT] Specify diff format.
134-
--format[=FORMAT] To output results in other formats.
135-
--stop-on-violation Stop execution on first violation.
136-
--show-progress[=SHOW-PROGRESS] Type of progress indicator (none, run-in, estimating or estimating-max).
137-
-h, --help Display this help message
138-
-q, --quiet Do not output any message
139-
-V, --version Display this application version
140-
--ansi Force ANSI output
141-
--no-ansi Disable ANSI output
142-
-n, --no-interaction Do not ask any interactive question
143-
--env[=ENV] The environment the command should run under
144-
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
57+
--path-mode=PATH-MODE Specify path mode (can be override or intersection). [default: "override"]
58+
--allow-risky=ALLOW-RISKY Are risky fixers allowed (can be yes or no).
59+
--config=CONFIG The path to a .php-cs-fixer.php file.
60+
--dry-run Only shows which files would have been modified.
61+
--rules=RULES The rules.
62+
--using-cache=USING-CACHE Does cache should be used (can be yes or no).
63+
--cache-file=CACHE-FILE The path to the cache file.
64+
--diff Also produce diff for each file.
65+
--format=FORMAT To output results in other formats.
66+
--stop-on-violation Stop execution on first violation.
67+
--show-progress=SHOW-PROGRESS Type of progress indicator (none, dots).
68+
-h, --help Display help for the given command. When no command is given display help for the list command
69+
-q, --quiet Do not output any message
70+
-V, --version Display this application version
71+
--ansi Force ANSI output
72+
--no-ansi Disable ANSI output
73+
-n, --no-interaction Do not ask any interactive question
74+
--env[=ENV] The environment the command should run under
75+
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
14576
146-
// Only shows which files would have been modified
147-
$ php artisan fixer:fix --dry-run
148-
149-
// Modify the files that need to be fixed
150-
$ php artisan fixer:fix
151-
152-
// Check all the files in the `app` directory
153-
$ php artisan fixer:fix --path app --dry-run
15477
```

composer.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,26 @@
1414
"fixer"
1515
],
1616
"autoload": {
17-
"classmap": [
18-
],
17+
"classmap": [],
1918
"psr-4": {
2019
"STS\\Fixer\\": "src"
2120
},
22-
"files": [
23-
]
21+
"files": []
2422
},
2523
"authors": [
2624
{
2725
"name": "Bubba Hines",
2826
"email": "rob@stechstudio.com"
29-
}
27+
}
3028
],
3129
"require": {
32-
"php": ">=7.0",
30+
"php": "^7.1.3 || ^8.0",
3331
"illuminate/support": "^5.4|^6.0|^7.0|^8.0",
34-
"friendsofphp/php-cs-fixer": "^2.18.6"
32+
"friendsofphp/php-cs-fixer": "^3.0.0"
3533
},
3634
"require-dev": {
37-
"illuminate/console": "^5.4|^6.0"
35+
"illuminate/console": "^5.4|^6.0|^7.0|^8.0",
36+
"orchestra/testbench": "^6.17"
3837
},
3938
"extra": {
4039
"laravel": {
@@ -43,5 +42,10 @@
4342
]
4443
}
4544
},
45+
"scripts": {
46+
"post-autoload-dump": [
47+
"@php ./vendor/bin/testbench package:discover --ansi"
48+
]
49+
},
4650
"minimum-stability": "stable"
4751
}

0 commit comments

Comments
 (0)