Skip to content

Commit

Permalink
Merge branch 'phpro:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
bart-jaskulski authored Jan 9, 2023
2 parents b65f4a2 + 533e454 commit d83c48b
Show file tree
Hide file tree
Showing 28 changed files with 789 additions and 31 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
14 changes: 14 additions & 0 deletions .github/workflows/depsreview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: 'Dependency Review'
on: [pull_request]

permissions:
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
- name: 'Dependency Review'
uses: actions/dependency-review-action@v3
15 changes: 10 additions & 5 deletions .github/workflows/grumphp.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
name: GrumPHP

on: [push, pull_request]
permissions:
contents: read

jobs:
run:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest, macos-latest] #windows-latest currently not working
php-versions: ['7.4', '8.0', '8.1']
php-versions: ['8.0', '8.1', '8.2']
composer-options: ['', '--prefer-lowest']
composer-versions: ['composer:v2']
fail-fast: false
Expand All @@ -30,20 +33,22 @@ jobs:
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
if: matrix.php-versions != '8.2'
run: composer update --prefer-dist --no-progress --no-suggest ${{ matrix.composer-options }}
# - name: Install dependencies (Ignore platform)
# if: matrix.php-versions == '8.1'
# run: composer update --prefer-dist --no-progress --no-suggest ${{ matrix.composer-options }} --ignore-platform-req=php
- name: Install dependencies (Ignore platform)
if: matrix.php-versions == '8.2'
run: composer update --prefer-dist --no-progress --no-suggest ${{ matrix.composer-options }} --ignore-platform-req=php+
- name: Set git variables
run: |
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git config --global protocol.file.allow always
- name: Run the tests on Windows
if: runner.os == 'Windows'
run: php vendor/bin/grumphp run --no-interaction --testsuite=windows
Expand Down
8 changes: 5 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ platform:

#matrix:
# allow_failures:
# - php_version: 8.1
# - php_version: 8.2

environment:
matrix:
# TODO : NOT AVAILABLE YET !
# - dependencies: highest
# php_version: 8.2
- dependencies: highest
php_version: 8.1
- dependencies: highest
php_version: 8.0
- dependencies: highest
php_version: 7.4

project_directory: c:\projects\grumphp
composer_directory: c:\tools\composer
Expand Down Expand Up @@ -71,6 +72,7 @@ install:
- IF %dependencies%==highest composer update --prefer-dist --no-progress --no-scripts --no-suggest --profile
- git config --global user.email "[email protected]"
- git config --global user.name "GrumPHP"
- git config --global protocol.file.allow always

test_script:
- ps: cd $Env:project_directory
Expand Down
28 changes: 15 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.0",
"ext-json": "*",
"composer-plugin-api": "~2.0",
"amphp/amp": "^2.6",
"amphp/parallel": "^1.4",
"amphp/parallel-functions": "^1.1",
"doctrine/collections": "^1.6.8",
"doctrine/collections": "^1.6.8 || ^2.0",
"gitonomy/gitlib": "^1.3",
"laravel/serializable-closure": "^1.1",
"monolog/monolog": "^2.0",
"monolog/monolog": "^2.0 || ^3.0",
"ondram/ci-detector": "^4.0",
"psr/container": "^1.1 || ^2.0",
"seld/jsonlint": "~1.8",
"symfony/config": "~5.3 || ~6.0",
"symfony/console": "~5.3 || ~6.0",
"symfony/dependency-injection": "~5.3 || ~6.0",
"symfony/dotenv": "~5.3 || ~6.0",
"symfony/event-dispatcher": "~5.3 || ~6.0",
"symfony/filesystem": "~5.3 || ~6.0",
"symfony/finder": "~5.3 || ~6.0",
"symfony/options-resolver": "~5.3 || ~6.0",
"symfony/process": "~5.3 || ~6.0",
"symfony/yaml": "~5.3 || ~6.0"
"symfony/config": "~5.4 || ~6.0",
"symfony/console": "~5.4 || ~6.0",
"symfony/dependency-injection": "~5.4 || ~6.0",
"symfony/dotenv": "~5.4 || ~6.0",
"symfony/event-dispatcher": "~5.4 || ~6.0",
"symfony/filesystem": "~5.4 || ~6.0",
"symfony/finder": "~5.4 || ~6.0",
"symfony/options-resolver": "~5.4 || ~6.0",
"symfony/process": "~5.4 || ~6.0",
"symfony/yaml": "~5.4 || ~6.0"
},
"require-dev": {
"amphp/sync": "^v1.4",
Expand Down Expand Up @@ -69,11 +69,13 @@
"phan/phan": "Lets GrumPHP unleash a static analyzer on your code",
"phing/phing": "Lets GrumPHP run your automated PHP tasks.",
"php-parallel-lint/php-parallel-lint": "Lets GrumPHP quickly lint your entire code base.",
"phparkitect/phparkitect": "Let GrumPHP keep your codebase coherent and solid, by permitting to add some architectural constraint check to your workflow.",
"phpmd/phpmd": "Lets GrumPHP sort out the mess in your code",
"phpspec/phpspec": "Lets GrumPHP spec your code.",
"phpstan/phpstan": "Lets GrumPHP discover bugs in your code without running it.",
"phpunit/phpunit": "Lets GrumPHP run your unit tests.",
"povils/phpmnd": "Lets GrumPHP help you detect magic numbers in PHP code.",
"rector/rector ": "Lets GrumPHP instantly upgrade and automatically refactor your PHP code.",
"roave/security-advisories": "Lets GrumPHP be sure that there are no known security issues.",
"sebastian/phpcpd": "Lets GrumPHP find duplicated code.",
"squizlabs/php_codesniffer": "Lets GrumPHP sniff on your code.",
Expand Down
5 changes: 4 additions & 1 deletion doc/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ grumphp:
phpunitbridge: ~
phpversion: ~
progpilot: ~
psalm: ~
psalm: ~
rector: ~
robo: ~
securitychecker_enlightn: ~
securitychecker_local: ~
Expand Down Expand Up @@ -100,6 +101,7 @@ Every task has its own default configuration. It is possible to overwrite the pa
- [Phan](tasks/phan.md)
- [Phing](tasks/phing.md)
- [Php7cc](tasks/php7cc.md)
- [PhpArkitect](tasks/phparkitect.md)
- [PhpCpd](tasks/phpcpd.md)
- [Phpcs](tasks/phpcs.md)
- [PHP-CS-Fixer](tasks/phpcsfixer.md)
Expand All @@ -114,6 +116,7 @@ Every task has its own default configuration. It is possible to overwrite the pa
- [PhpVersion](tasks/phpversion.md)
- [Progpilot](tasks/progpilot.md)
- [Psalm](tasks/psalm.md)
- [Rector](tasks/rector.md)
- [Robo](tasks/robo.md)
- [Security Checker](tasks/securitychecker.md)
- [Enlightn](tasks/securitychecker/enlightn.md)
Expand Down
7 changes: 7 additions & 0 deletions doc/tasks/deptrac.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@ namespace and has following configurable parameters:
grumphp:
tasks:
deptrac:
cache_file: ~
depfile: ~
formatter: ~
output: ~
```
**cache_file**
*Default: null*
Set location where cache file will be stored. Example: `/var/www/src/.deptrac.cache`

**depfile**

*Default: null*
Expand Down
1 change: 0 additions & 1 deletion doc/tasks/paratest.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ grumphp:
phpunit: null
configuration: null
runner: null
debugger: null
coverage-clover: null
coverage-html: null
coverage-php: null
Expand Down
43 changes: 43 additions & 0 deletions doc/tasks/phparkitect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# PHPArkitect

PHPArkitect helps you to keep your PHP codebase coherent and solid, by permitting to add some architectural constraint check to your workflow.
It lives under the `phparkitect` namespace and has following configurable parameters:

PhpArkitect doesn't support checking only the changed files.
It will always run on the directory specified in your config file.

## Composer
```bash
composer require --dev phparkitect/phparkitect
```

## Config
```yaml
# grumphp.yml
grumphp:
tasks:
phparkitect:
config: ~
target_php_version: ~
stop_on_failure: ~
```
**config**
*Default: null*
With this parameter you can specify the path your project's configuration file.
By default PHPArkitect will search all rules in phparkitect.php located in the root of your project.
**target_php_version**
*Default: null*
With this parameter, you can specify which PHP version should use the parser.
This can be useful to debug problems and to understand if there are problems with a different PHP version.
**stop_on_failure**
*Default: false*
With this option the process will end immediately after the first violation.
8 changes: 7 additions & 1 deletion doc/tasks/phpcs.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ grumphp:
sniffs: []
triggered_by: [php]
exclude: []

show_sniffs_error_path: true
```
**standard**
Expand Down Expand Up @@ -130,6 +130,12 @@ This is a list of extensions to be sniffed. This list is also passed to phpcs us

A list of rules that should not be checked. Leave this option blank to run all configured rules for the selected standard.

**show_sniffs_error_path**

*Default: true*

Displays the sniff that triggered the error, allowing you to more easily find the specific rules with their namespaces.

## Framework presets

### Symfony 2
Expand Down
57 changes: 57 additions & 0 deletions doc/tasks/rector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Rector

Rector is a tool to instantly upgrade and automatically refactor your PHP 5.3+ code.
It lives under the `rector` namespace and has following configurable parameters:

## Composer
```bash
composer require --dev rector/rector
```

## Config
```yaml
# grumphp.yml
grumphp:
tasks:
rector:
config: null
triggered_by: ['php']
ignore_patterns: []
clear_cache: true
no_diffs: false
```
**config**
*Default: null*
With this parameter you can specify the path your project's configuration file. When 'null' rector will run with the default file: rector.php
**triggered_by**
*Default: [php]*
This is a list of extensions to be sniffed.
**ignore_patterns**
*Default: []*
This is a list of patterns that will be ignored by Rector. With this option you can skip files like
tests. Leave this option blank to run Rector for every php file/directory specified in your
configuration.
**clear_cache**
*Default: true*
With this parameter you can run Rector without using the cache.
**no_diffs**
*Default: false*
With this parameter you can run Rector without showing file diffs.
1 change: 1 addition & 0 deletions doc/tasks/securitychecker.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ You can use one of following tasks as a replacement:

- [securitychecker_enlightn](securitychecker/enlightn.md)
- [securitychecker_local](securitychecker/local.md)
- [securitychecker_roave](securitychecker/roave.md)
- [securitychecker_symfony](securitychecker/symfony.md)
14 changes: 14 additions & 0 deletions resources/config/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ services:
tags:
- {name: grumphp.task, task: php7cc}

GrumPHP\Task\PhpArkitect:
arguments:
- '@process_builder'
- '@formatter.raw_process'
tags:
- {name: grumphp.task, task: phparkitect}

GrumPHP\Task\PhpCpd:
arguments:
- '@process_builder'
Expand Down Expand Up @@ -308,6 +315,13 @@ services:
tags:
- {name: grumphp.task, task: psalm}

GrumPHP\Task\Rector:
arguments:
- '@process_builder'
- '@formatter.raw_process'
tags:
- { name: grumphp.task, task: rector }

GrumPHP\Task\Robo:
arguments:
- '@process_builder'
Expand Down
1 change: 1 addition & 0 deletions resources/config/util.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ services:
'7.4': '2022-11-28 23:59:59'
'8.0': '2023-11-26 23:59:59'
'8.1': '2024-11-25 23:59:59'
'8.2': '2025-12-08 23:59:59'
5 changes: 4 additions & 1 deletion src/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ public function getConfigTreeBuilder(): TreeBuilder
$rootNode->children()->arrayNode('extensions')->scalarPrototype();

// ascii
$ascii = $rootNode->children()->arrayNode('ascii')->addDefaultsIfNotSet();
$ascii = $rootNode->children()->arrayNode('ascii')->addDefaultsIfNotSet()->treatNullLike([
'failed' => null,
'succeeded' => null,
]);
$ascii->children()->variableNode('failed')->defaultValue('grumphp-grumpy.txt');
$ascii->children()->variableNode('succeeded')->defaultValue('grumphp-happy.txt');

Expand Down
2 changes: 1 addition & 1 deletion src/Console/ApplicationConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class ApplicationConfigurator
{
const APP_NAME = 'GrumPHP';
const APP_VERSION = '1.12.0';
const APP_VERSION = '1.15.0';

public function configure(Application $application): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/Parser/Php/Visitor/AbstractVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function setContext(ParserContext $context): void
protected function addError(string $message, int $line = -1, string $type = ParseError::TYPE_ERROR): void
{
$errors = $this->context->getErrors();
$fileName = $this->context->getFile()->getPath();
$fileName = $this->context->getFile()->getPathname();
$errors->add(new PhpParserError($type, $message, $fileName, $line));
}
}
Loading

0 comments on commit d83c48b

Please sign in to comment.