From c5d873307c3866c46108c96eb6cac5ca962e37d8 Mon Sep 17 00:00:00 2001 From: Carlos Granados Date: Wed, 26 Feb 2025 14:12:37 +0100 Subject: [PATCH 1/3] feature: Add named constructor to create CachedArrayKeywords::withDefaultKeywords Allows end-users to create an instance with the i18n file provided by this package, without having an external dependency on the path to the file. Co-authored-by: acoulton --- src/Behat/Gherkin/Keywords/CachedArrayKeywords.php | 7 ++++++- tests/Behat/Gherkin/Keywords/CachedArrayKeywordsTest.php | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Behat/Gherkin/Keywords/CachedArrayKeywords.php b/src/Behat/Gherkin/Keywords/CachedArrayKeywords.php index 71220132..f1ca123b 100644 --- a/src/Behat/Gherkin/Keywords/CachedArrayKeywords.php +++ b/src/Behat/Gherkin/Keywords/CachedArrayKeywords.php @@ -19,6 +19,11 @@ */ class CachedArrayKeywords extends ArrayKeywords { + public static function withDefaultKeywords(): self + { + return new self(__DIR__ . '/../../../../i18n.php'); + } + /** * Initializes holder with file. * @@ -26,6 +31,6 @@ class CachedArrayKeywords extends ArrayKeywords */ public function __construct($file) { - parent::__construct(include $file); + parent::__construct(require $file); } } diff --git a/tests/Behat/Gherkin/Keywords/CachedArrayKeywordsTest.php b/tests/Behat/Gherkin/Keywords/CachedArrayKeywordsTest.php index 09809418..159b76f4 100644 --- a/tests/Behat/Gherkin/Keywords/CachedArrayKeywordsTest.php +++ b/tests/Behat/Gherkin/Keywords/CachedArrayKeywordsTest.php @@ -17,12 +17,13 @@ class CachedArrayKeywordsTest extends KeywordsTestCase { protected function getKeywords() { - return new CachedArrayKeywords(__DIR__ . '/../../../../i18n.php'); + // Test with the default i18n file provided in this repository + return CachedArrayKeywords::withDefaultKeywords(); } protected function getKeywordsArray() { - return include __DIR__ . '/../../../../i18n.php'; + return require __DIR__ . '/../../../../i18n.php'; } protected function getSteps($keywords, $text, &$line, $keywordType) From fb6ee0335468bcf970acfeb9d1e4936dab848ee0 Mon Sep 17 00:00:00 2001 From: acoulton Date: Wed, 26 Feb 2025 13:26:25 +0000 Subject: [PATCH 2/3] Add release notes for 4.12.0 --- CHANGELOG.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42b73f5c..e823540a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](http://semver.org/). This project follows the [Behat release and version support policies] (https://docs.behat.org/en/latest/releases.html). +# [4.12.0] - 2025-02-26 + +### Changed +* Gherkin::VERSION is deprecated and will not be updated, use the composer runtime API if you need to identify the + running version. This also changes the value used to namespace cached feature files. + by @acoulton in [#279](https://github.com/Behat/Gherkin/pull/279) + +### Added + +* Provide `CachedArrayKeywords::withDefaultKeywords()` to create an instance without an external dependency on the path + to the `i18n.php` file in this repo. **NOTE** that paths to source files will change in the next Gherkin release - + use the new constructor to avoid any impact. + by @carlos-granados in [#290](https://github.com/Behat/Gherkin/pull/290) + +### Internal + +* Upgrade to phpunit 10 by @uuf6429 in [#275](https://github.com/Behat/Gherkin/pull/275) +* Remove redundant files by @uuf6429 in [#278](https://github.com/Behat/Gherkin/pull/278) +* Update documentation by @uuf6429 in [#274](https://github.com/Behat/Gherkin/pull/274) +* Adopt PHP CS Fixer and apply code styles by @uuf6429 in [#277](https://github.com/Behat/Gherkin/pull/277) +* Add PHPStan and improve / fix docblock annotations and type-safety within methods to achieve level 5 by + @uuf6429 in [#276](https://github.com/Behat/Gherkin/pull/276), [#281](https://github.com/Behat/Gherkin/pull/281), + [#282](https://github.com/Behat/Gherkin/pull/282), and [#287](https://github.com/Behat/Gherkin/pull/287) + # [4.11.0] - 2024-12-06 ### Changed @@ -420,4 +444,5 @@ This project follows the [Behat release and version support policies] - 47 brand new translations (see i18n) - Full test suite for everything from AST nodes to translations +[4.12.0]: https://github.com/Behat/Gherkin/compare/v4.11.0...v4.12.0 [4.11.0]: https://github.com/Behat/Gherkin/compare/v4.10.0...v4.11.0 From 44ea93661092b5e86cb076a93bf54c4e1c4e74d6 Mon Sep 17 00:00:00 2001 From: acoulton Date: Wed, 26 Feb 2025 14:34:32 +0000 Subject: [PATCH 3/3] fix: Update CachedArrayKeywords to accommodate the new file paths As expected, this needs to be updated to reflect the file having moved in #288. --- src/Keywords/CachedArrayKeywords.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Keywords/CachedArrayKeywords.php b/src/Keywords/CachedArrayKeywords.php index f1ca123b..f01670e8 100644 --- a/src/Keywords/CachedArrayKeywords.php +++ b/src/Keywords/CachedArrayKeywords.php @@ -21,7 +21,7 @@ class CachedArrayKeywords extends ArrayKeywords { public static function withDefaultKeywords(): self { - return new self(__DIR__ . '/../../../../i18n.php'); + return new self(__DIR__ . '/../../i18n.php'); } /**