Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPStan setup #276

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[*]
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true

[*.{yml,yaml}]
indent_size = 2
23 changes: 15 additions & 8 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
/.github/ export-ignore
/bin/ export-ignore
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/package.xml.tpl export-ignore
/phpdoc.ini.dist export-ignore
/phpunit.xml.dist export-ignore
/.github/ export-ignore
/bin/ export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/CHANGELOG.md export-ignore
/CONTRIBUTING.md export-ignore
/package.xml.tpl export-ignore
/phpdoc.ini.dist export-ignore
/phpunit.dist.xml export-ignore
/.php-cs-fixer.dist.php export-ignore
/phpstan.dist.neon export-ignore
/phpstan-baseline.neon export-ignore
/README.md export-ignore
84 changes: 58 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,75 @@ name: Build

on:
push:
branches: [master]
branches: [ master ]
pull_request:
release:
types: [created]
types: [ created ]

jobs:
check_composer:
name: Check composer.json
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '8.3'
- run: composer validate --strict --no-check-lock

check_code_style:
name: Check code style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '8.3'
- name: Install dependencies
run: composer update
- run: ./vendor/bin/php-cs-fixer fix --dry-run --diff --show-progress=dots

static_analysis:
name: Static analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '8.3'
- name: Install dependencies
run: composer update
- run: ./vendor/bin/phpstan analyze

tests:
runs-on: ubuntu-latest
name: Build and test
strategy:
fail-fast: false
matrix:
php: [8.1, 8.2, 8.3, 8.4]
php: [ 8.1, 8.2, 8.3, 8.4 ]
composer-flags: [ "" ]
symfony-version: [ "" ]
include:
- php: 8.1
symfony-version: '^5.4'
- php: 8.1
symfony-version: '^6.4'

- php: 8.1
symfony-version: '^5.4'
- php: 8.1
symfony-version: '^6.4'
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
ini-file: "development"
coverage: none

- name: Update Symfony version
if: matrix.symfony-version != ''
run: composer require --no-update "symfony/symfony:${{ matrix.symfony-version }}"

- name: Install dependencies
run: composer update ${{ matrix.composer-flags }}

- name: Run tests (phpunit)
run: ./vendor/bin/phpunit
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php }}"
ini-file: "development"
coverage: none
- name: Update Symfony version
if: matrix.symfony-version != ''
run: composer require --no-update "symfony/symfony:${{ matrix.symfony-version }}"
- name: Install dependencies
run: composer update ${{ matrix.composer-flags }}
- name: Run tests (phpunit)
run: ./vendor/bin/phpunit
2 changes: 1 addition & 1 deletion .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Update Cucumber

on:
schedule:
- cron: '0 7 * * *'
- cron: '0 7 * * *'

jobs:
cucumber-update:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ vendor
composer.phar
composer.lock
.phpunit.result.cache
phpunit.xml
.php-cs-fixer.php
.php-cs-fixer.cache
phpstan.neon
28 changes: 28 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->notPath('i18n.php');

return (new PhpCsFixer\Config())
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setRiskyAllowed(true)
->setRules([
'@PER-CS' => true,
'@Symfony' => true,
'header_comment' => [
'header' => <<<'TEXT'
This file is part of the Behat Gherkin Parser.
(c) Konstantin Kudryashov <[email protected]>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
TEXT
],
'yoda_style' => false,
'concat_space' => ['spacing' => 'one'],
'phpdoc_types_order' => ['null_adjustment' => 'always_first'],
'phpdoc_array_type' => true,
'phpdoc_list_type' => true,
])
->setFinder($finder);
1 change: 1 addition & 0 deletions .phpunit.cache/test-results

Large diffs are not rendered by default.

49 changes: 28 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
Contributing
------------
# Contributing

Gherkin is an open source, community-driven project. If you'd like to contribute, feel free to do this, but remember to follow this few simple rules:
Gherkin is an open source, community-driven project. If you'd like to contribute, feel free to do this, but remember to
follow this few simple rules:

- Make your feature addition or bug fix,
- Always use the `master` branch as base for your changes (all new development happens in `master`),
- Add tests for those changes (please look into `tests/` folder for some examples). This is important so we don't break it in a future version unintentionally,
- Commit your code, but do not mess with `CHANGES.md`,
- __Remember__: when you create Pull Request, always select `master` branch as target (done by default), otherwise it will be closed.
- Add tests for those changes (please look into `tests/` folder for some examples). This is important so we don't break
it in a future version unintentionally,
- Commit your code, but do not mess with `CHANGELOG.md`,
- _Remember_: when you create a Pull Request, always select `master` branch as target (done by default), otherwise it
will be closed.

Running tests
-------------
## Running tests

Make sure that you don't break anything with your changes by running:

```bash
$> phpunit
```shell
composer test
```

Contributing to Gherkin Translations
------------------------------------
## Running Linters

Gherkin supports &rarr;40 different languages and you could add more! You might notice
`i18n.php` file in the root of the library. This file is downloaded and **autogenerated**
from original [cucumber/gherkin translations](https://github.com/cucumber/cucumber/blob/master/gherkin/gherkin-languages.json).
So, in order to fix/update/add some translation, you should send Pull Request to the
`cucumber/gherkin` repository. `Behat\Gherkin` will redownload/regenerate translations
from there before each release.
We use automated tools to ensure that the code has a consistent style and is of good quality.

It might sounds difficult, but this way of dictionary sharing gives you ability to
migrate your `*.feature` files from language to language and library to library without
the need to rewrite/modify them - same dictionary (Gherkin) used everywhere.
```shell
composer lint
```

## Contributing to Gherkin Translations

Gherkin supports &rarr;40 different languages and you could add more! You might notice `i18n.php` file in the root of
the library. This file is downloaded and **autogenerated** from
original [cucumber/gherkin translations](https://github.com/cucumber/cucumber/blob/master/gherkin/gherkin-languages.json).
So, in order to fix/update/add some translation, you should send a Pull Request to the `cucumber/gherkin` repository.
`Behat\Gherkin` will re-download/regenerate translations from there before each release.

It might sound difficult, but this way of dictionary-sharing gives us the ability to migrate `*.feature` files from
language to language and library to library without the need to rewrite/modify them - with the same (Gherkin) dictionary
used everywhere.
23 changes: 9 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
Behat Gherkin Parser
====================
# Behat Gherkin Parser

This is the php Gherkin parser for Behat. It comes bundled with more than 40 native languages
(see `i18n.php`) support & clean architecture.

Useful Links
------------
## Useful Links

- Official Google Group is at [http://groups.google.com/group/behat](http://groups.google.com/group/behat)
- IRC channel on [#freenode](http://freenode.net/) is `#behat`
- [Note on Patches/Pull Requests](CONTRIBUTING.md)

Usage Example
-------------
## Usage Example

``` php
```php
<?php

$keywords = new Behat\Gherkin\Keywords\ArrayKeywords(array(
Expand Down Expand Up @@ -49,16 +46,14 @@ $parser = new Behat\Gherkin\Parser($lexer);
$feature = $parser->parse(file_get_contents('some.feature'));
```

Installing Dependencies
-----------------------
## Installing Dependencies

``` bash
$> curl http://getcomposer.org/installer | php
$> php composer.phar update
```shell
curl https://getcomposer.org/installer | php
php composer.phar update
```

Contributors
------------
## Contributors

* Konstantin Kudryashov [everzet](http://github.com/everzet) [lead developer]
* Other [awesome developers](https://github.com/Behat/Gherkin/graphs/contributors)
33 changes: 28 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"name": "behat/gherkin",
"description": "Gherkin DSL parser for PHP",
"keywords": ["BDD", "parser", "DSL", "Behat", "Gherkin", "Cucumber"],
"homepage": "http://behat.org/",
"homepage": "https://behat.org/",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Konstantin Kudryashov",
"email": "[email protected]",
"homepage": "http://everzet.com"
"homepage": "https://everzet.com"
}
],

Expand All @@ -19,8 +19,13 @@

"require-dev": {
"symfony/yaml": "^5.4 || ^6.4 || ^7.0",
"phpunit/phpunit": "^9.6",
"cucumber/cucumber": "dev-gherkin-24.1.0"
"phpunit/phpunit": "^10.5",
"cucumber/cucumber": "dev-gherkin-24.1.0",
"friendsofphp/php-cs-fixer": "^3.65",
"phpstan/phpstan": "^2",
"phpstan/extension-installer": "^1",
"phpstan/phpstan-phpunit": "^2",
"phpstan/phpstan-strict-rules": "^2"
},

"suggest": {
Expand Down Expand Up @@ -63,5 +68,23 @@
}
}
}
]
],

"scripts": {
"lint": [
"Composer\\Config::disableProcessTimeout",
"vendor/bin/php-cs-fixer fix --dry-run --diff --show-progress=dots",
"vendor/bin/phpstan analyse --memory-limit 512M"
],
"test": [
"Composer\\Config::disableProcessTimeout",
"vendor/bin/phpunit ./tests"
]
},

"config": {
"allow-plugins": {
"phpstan/extension-installer": true
}
}
}
10 changes: 9 additions & 1 deletion libpath.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<?php

return __DIR__;
/*
* This file is part of the Behat Gherkin Parser.
* (c) Konstantin Kudryashov <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

return __DIR__;
4 changes: 3 additions & 1 deletion package.xml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
<file role="php" baseinstalldir="gherkin" name="vendor/.composer/autoload.php" />
<file role="php" baseinstalldir="gherkin" name="vendor/.composer/autoload_namespaces.php" />
<file role="php" baseinstalldir="gherkin" name="phpdoc.ini.dist" />
<file role="php" baseinstalldir="gherkin" name="phpunit.xml.dist" />
<file role="php" baseinstalldir="gherkin" name="phpunit.dist.xml" />
<file role="php" baseinstalldir="gherkin" name=".php-cs-fixer.dist.php" />
<file role="php" baseinstalldir="gherkin" name="phpstan.dist.xml" />
<file role="php" baseinstalldir="gherkin" name="CHANGES.md" />
<file role="php" baseinstalldir="gherkin" name="LICENSE" />
<file role="php" baseinstalldir="gherkin" name="README.md" />
Expand Down
Loading
Loading