Skip to content

Commit

Permalink
Merge pull request #31 from stechstudio/Fixer-3.0-Support
Browse files Browse the repository at this point in the history
Fixer 3.0 Support
  • Loading branch information
bubba-h57 authored Jul 1, 2021
2 parents 867d5d3 + 707d63e commit f8cd1c7
Show file tree
Hide file tree
Showing 17 changed files with 846 additions and 351 deletions.
33 changes: 33 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Update the VARIANT arg in docker-compose.yml to pick a PHP version: 7, 7.4, 7.3
ARG VARIANT=8
FROM mcr.microsoft.com/vscode/devcontainers/php:0-${VARIANT}

# Install MariaDB client
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get install -y mariadb-client \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

# Update args in docker-compose.yaml to set the UID/GID of the "vscode" user.
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then groupmod --gid $USER_GID vscode && usermod --uid $USER_UID --gid $USER_GID vscode; fi

RUN pecl install -o -f redis \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis

# Install php-mysql driver
RUN docker-php-ext-install mysqli pdo pdo_mysql

# [Optional] Install a version of Node.js using nvm for front end dev
ARG INSTALL_NODE="true"
ARG NODE_VERSION="lts/*"
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
RUN rm -rf /usr/local/etc/php/conf.d/xdebug.ini
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

35 changes: 35 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/php-mariadb
// Update the VARIANT arg in docker-compose.yml to pick a PHP version: 7, 7.3, 7.4
{
"name": "metrics-app",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"eamodio.gitlens",
"mikestead.dotenv",
"felixfbecker.php-debug",
"marabesi.php-import-checker",
"fterrag.vscode-php-cs-fixer",
"marsl.vscode-php-refactoring",
"coenraads.bracket-pair-colorizer-2",
"bmewburn.vscode-intelephense-client"
],

// For use with PHP or Apache (e.g.php -S localhost:8080 or apache2ctl start)
"forwardPorts": [8080, 3306],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html"

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
25 changes: 25 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: '3'

services:
app:
build:
context: .
dockerfile: Dockerfile
args:
# [Choice] PHP version: 7, 7.4, 7.3
VARIANT: "8"
# [Option] Install Node.js
INSTALL_NODE: "true"
NODE_VERSION: "lts/*"
# On Linux, you may need to update USER_UID and USER_GID below if not your local UID is not 1000.
USER_UID: 1000
USER_GID: 1000

volumes:
- ..:/workspace:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Uncomment the next line to use a non-root user for all processes.
# user: vscode
131 changes: 27 additions & 104 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,93 +19,23 @@ do all the other laravel packages you use.

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

## Installation

```
composer require stechstudio/laravel-php-cs-fixer
```

> **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).
### Manually Register the Provider for Laravel 5.4:

#### Laravel
Add the following to the `providers` array in `config/app.php`.:

```php
STS\Fixer\FixerServiceProvider::class,
```

#### Lumen
Add the following to `bootstrap/app.php`.:

```php
$app->register(STS\Fixer\FixerServiceProvider::class);
```

## Configuration
The default rule configuration is in the `fixer.php` and is intended to match the rules used by the Laravel Framework.

```php
return [
'rules' => [
'psr0' => false,
'@PSR2' => true,
'blank_line_after_namespace' => true,
'braces' => true,
'class_definition' => true,
'elseif' => true,
'function_declaration' => true,
'indentation_type' => true,
'line_ending' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'method_argument_space' => [
'ensure_fully_multiline' => true, ],
'no_break_comment' => true,
'no_closing_tag' => true,
'no_spaces_after_function_name' => true,
'no_spaces_inside_parenthesis' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'single_blank_line_at_eof' => true,
'single_class_element_per_statement' => [
'elements' => ['property'],
],
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'visibility_required' => true,
'encoding' => true,
'full_opening_tag' => true,
],
];
```
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.

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

> Note: There are some static configuration settings in the finder that have yet to be moved to the configuration file
> that you should be aware of! We plan to move these to the config file soon.
```php
$finder = Finder::create()
->notPath('bootstrap/cache')
->notPath('storage')
->notPath('vendor')
->in(base_path())
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
```

## Usage
#### Fix Your Code
Fix your code with Laravel Coding Standards.
Expand All @@ -118,37 +48,30 @@ $ php artisan fixer:fix [options]
Example:
```
Usage:
fixer:fix [options]
fixer:fix [options] [--] [<path>...]
Arguments:
path The path. Can be a list of space separated paths
Options:
--path[=PATH] The path. (multiple values allowed)
--path-mode[=PATH-MODE] Specify path mode (can be override or intersection). [default: "override"]
--allow-risky[=ALLOW-RISKY] Are risky fixers allowed (can be yes or no).
--config[=CONFIG] The path to a .php_cs file.
--dry-run Only shows which files would have been modified.
--rules[=RULES] The Rules
--using-cache[=USING-CACHE] Does cache should be used (can be yes or no). [default: "yes"]
--cache-file[=CACHE-FILE] The path to the cache file.
--diff Also produce diff for each file.
--diff-format[=DIFF-FORMAT] Specify diff format.
--format[=FORMAT] To output results in other formats.
--stop-on-violation Stop execution on first violation.
--show-progress[=SHOW-PROGRESS] Type of progress indicator (none, run-in, estimating or estimating-max).
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--path-mode=PATH-MODE Specify path mode (can be override or intersection). [default: "override"]
--allow-risky=ALLOW-RISKY Are risky fixers allowed (can be yes or no).
--config=CONFIG The path to a .php-cs-fixer.php file.
--dry-run Only shows which files would have been modified.
--rules=RULES The rules.
--using-cache=USING-CACHE Does cache should be used (can be yes or no).
--cache-file=CACHE-FILE The path to the cache file.
--diff Also produce diff for each file.
--format=FORMAT To output results in other formats.
--stop-on-violation Stop execution on first violation.
--show-progress=SHOW-PROGRESS Type of progress indicator (none, dots).
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
// Only shows which files would have been modified
$ php artisan fixer:fix --dry-run
// Modify the files that need to be fixed
$ php artisan fixer:fix
// Check all the files in the `app` directory
$ php artisan fixer:fix --path app --dry-run
```
20 changes: 12 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,26 @@
"fixer"
],
"autoload": {
"classmap": [
],
"classmap": [],
"psr-4": {
"STS\\Fixer\\": "src"
},
"files": [
]
"files": []
},
"authors": [
{
"name": "Bubba Hines",
"email": "[email protected]"
}
}
],
"require": {
"php": ">=7.0",
"php": "^7.1.3 || ^8.0",
"illuminate/support": "^5.4|^6.0|^7.0|^8.0",
"friendsofphp/php-cs-fixer": "^2.18.6"
"friendsofphp/php-cs-fixer": "^3.0.0"
},
"require-dev": {
"illuminate/console": "^5.4|^6.0"
"illuminate/console": "^5.4|^6.0|^7.0|^8.0",
"orchestra/testbench": "^6.17"
},
"extra": {
"laravel": {
Expand All @@ -43,5 +42,10 @@
]
}
},
"scripts": {
"post-autoload-dump": [
"@php ./vendor/bin/testbench package:discover --ansi"
]
},
"minimum-stability": "stable"
}
Loading

0 comments on commit f8cd1c7

Please sign in to comment.