Skip to content

Commit

Permalink
Merge pull request #76 from Quetzacoalt91/suggest-instead-of-require
Browse files Browse the repository at this point in the history
Suggest dependencies instead of requiring them
  • Loading branch information
M0rgan01 committed May 23, 2024
2 parents 717a519 + d751102 commit ed55ffc
Show file tree
Hide file tree
Showing 7 changed files with 2,413 additions and 1,875 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ jobs:
name: Custom rules check
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4

- name: Checkout
uses: actions/checkout@v2.0.0


# Docker images prestashop/prestashop may be used, even if the shop remains uninstalled
- name: Run constant test
run: |
Expand Down
52 changes: 22 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@ Related packages:

## Installation

```
```bash
composer require --dev prestashop/php-dev-tools

## Development dependencies runtimes
composer require --dev friendsofphp/php-cs-fixer
composer require --dev phpstan/phpstan
composer require --dev prestashop/header-stamp
composer require --dev prestashop/autoindex
composer require --dev squizlabs/php_codesniffer
```

When this project is successfully added to your dependencies, you can enable each review tool on your projet.
Expand All @@ -35,55 +42,40 @@ When this project is successfully added to your dependencies, you can enable eac
[lib-3-repo]: https://github.com/PrestaShop/php-dev-tools/tree/3.x
[lib-4-repo]: https://github.com/PrestaShop/php-dev-tools/tree/master

### PHP Cs fixer

```bash
$ php vendor/bin/prestashop-coding-standards cs-fixer:init [--dest /path/to/my/project]
```

It'll create a configuration file `.php-cs-fixer.dist.php` in the root of your project.

**Upgrade note :** When upgrading from 4.1.0 to newer version, you should re-run the init script or rename your ``.php_cs.dist`` file to ``.php-cs-fixer.dist.php`` in order to match the new requirements of cs-fixer.

### Phpstan
## Usage

```bash
$ php vendor/bin/prestashop-coding-standards phpstan:init [--dest /path/to/my/project]
```
The configuration files added in your project can be freely modified in order to match your needs.

It'll create a default file `phpstan.neon` in `tests/phpstan`, that are required to run phpstan.
The default phpstan level is the lowest available, but we recommend you to update this value to get more recommandations.
Running the tools can be done by calling their respective binary:

PHPStan is not provided by our dependencies, because of the PHP compatibility from projects using this repository. We recommend you to install it globally on your environment:
### PHP CS Fixer

```
composer global require phpstan/phpstan:^0.12
Initialize the configuration with:
```bash
$ php vendor/bin/prestashop-coding-standards cs-fixer:init [--dest /path/to/my/project]
```

## Usage

The configuration files added in your project can be freely modified in order to match your needs.

Running the tools can be done by calling its binary:
It'll create a configuration file `.php-cs-fixer.dist.php` in the root of your project.

### PHP CS Fixer
**Upgrade note :** When upgrading from 4.1.0 to newer version, you should re-run the init script or rename your ``.php_cs.dist`` file to ``.php-cs-fixer.dist.php`` in order to match the new requirements of cs-fixer.

```bash
$ vendor/bin/php-cs-fixer fix
```

### PHPStan

If you have installed PHPStan globally and made the folder available in your PATH:

```php
$ _PS_ROOT_DIR_=<Path_to_PrestaShop> phpstan --configuration=tests/phpstan/phpstan.neon analyse <path1 [path2 [...]]>
```bash
$ php vendor/bin/prestashop-coding-standards phpstan:init [--dest /path/to/my/project]
```

Otherwise, you can specify the path to the PHPStan binary. For instance:
It'll create a default file `phpstan.neon` in `tests/phpstan`, that are required to run phpstan.
The default phpstan level is the lowest available, but we recommend you to update this value to get more recommandations.

```php
$ _PS_ROOT_DIR_=<Path_to_PrestaShop> php ~/.composer/vendor/bin/phpstan.phar --configuration=tests/phpstan/phpstan.neon analyse <path1 [path2 [...]]>
$ _PS_ROOT_DIR_=<Path_to_PrestaShop> php vendor/bin/phpstan --configuration=tests/phpstan/phpstan.neon analyse <path1 [path2 [...]]>
```

### Autoindex
Expand Down
15 changes: 10 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
"require": {
"php": ">=7.2.5",
"symfony/console": "~3.2 || ~4.0 || ~5.0 || ~6.0 || ~7.0",
"friendsofphp/php-cs-fixer": "^3.2",
"squizlabs/php_codesniffer": "^3.4",
"symfony/filesystem": "~3.2 || ~4.0 || ~5.0 || ~6.0 || ~7.0",
"symfony/filesystem": "~3.2 || ~4.0 || ~5.0 || ~6.0 || ~7.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.2"
},
"suggest": {
"prestashop/header-stamp": "^2.0",
"prestashop/autoindex": "^2.0"
"prestashop/autoindex": "^2.0",
"squizlabs/php_codesniffer": "^3.4",
"phpstan/phpstan": "^0.12"
},
"bin": [
"bin/prestashop-coding-standards"
Expand All @@ -24,5 +29,5 @@
"php": "7.2.5"
}
},
"author": "PrestaShop"
"authors": [{"name": "PrestaShop"}]
}
Loading

0 comments on commit ed55ffc

Please sign in to comment.