From 2f431e919cdb8431ee005bf1bbd16cb7837054d1 Mon Sep 17 00:00:00 2001 From: Niraj Acharya Date: Fri, 25 Jul 2025 14:28:08 +0545 Subject: [PATCH] support doc comments for php --- CHANGELOG.md | 1 + src/language/phpLanguage.ts | 6 +++--- test/language/testdata/php/StepDefinitions.php | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 019fcdb4..7130f2bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - Missing `parameter:cucumber` token for Scenario Outline ([#246](https://github.com/cucumber/language-service/issues/246)) +- support doc comments for php ([#253](https://github.com/cucumber/language-service/pull/253)) ## [1.7.0] - 2025-05-18 ### Added diff --git a/src/language/phpLanguage.ts b/src/language/phpLanguage.ts index 374b3376..f8971e1a 100644 --- a/src/language/phpLanguage.ts +++ b/src/language/phpLanguage.ts @@ -7,7 +7,7 @@ export const phpLanguage: Language = { toStepDefinitionExpression(node) { // match multiline comment const text = node.text - const match = text.match(/^(\/\*\*[\s*]*)([\s\S]*)(\n[\s]*\*\/)/) + const match = text.match(/@(Given |When |Then )(.*)/) if (!match) throw new Error(`Could not match ${text}`) return behatifyStep(match[2]) }, @@ -36,9 +36,9 @@ export const phpLanguage: Language = { }, defaultSnippetTemplate: ` /** - * {{ keyword }} {{ expression }} + * @{{ keyword }} {{ expression }} */ - public function {{ #camelize }}{{ expression }}{{ /camelize }}({{ #parameters }}{{ #seenParameter }}, {{ /seenParameter }}{{ name }}{{ /parameters }}) + public function {{ #camelize }}{{ expression }}{{ /camelize }}({{ #parameters }}{{ #seenParameter }}, {{ /seenParameter }}\${{ name }}{{ /parameters }}) { // {{ blurb }} } diff --git a/test/language/testdata/php/StepDefinitions.php b/test/language/testdata/php/StepDefinitions.php index 5b7d6ba7..7f55c3c1 100644 --- a/test/language/testdata/php/StepDefinitions.php +++ b/test/language/testdata/php/StepDefinitions.php @@ -6,6 +6,8 @@ class StepDefinitions { /** * @Given ^a regexp$ + * + * @return void */ public function regexp() {