Skip to content

Commit 3d17552

Browse files
committed
skip deprecated colliding method names
1 parent 98a08ba commit 3d17552

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

.github/workflows/sdk-build-validation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ jobs:
173173
;;
174174
php)
175175
composer install
176-
composer test
176+
find . -name "*.php" ! -path "./vendor/*" -exec php -l {} +
177177
;;
178178
python)
179179
pip install -e .

templates/php/src/Services/Service.php.twig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,17 @@ class {{ service.name | caseUcfirst }} extends Service
3030
parent::__construct($client);
3131
}
3232
33+
{% set nonDeprecatedMethodNames = [] %}
3334
{% for method in service.methods %}
35+
{% if not method.deprecated %}
36+
{% set nonDeprecatedMethodNames = nonDeprecatedMethodNames|merge([method.name | caseCamel | lower]) %}
37+
{% endif %}
38+
{% endfor %}
39+
{% for method in service.methods %}
40+
{% set methodNameLower = method.name | caseCamel | lower %}
41+
{% if method.deprecated and methodNameLower in nonDeprecatedMethodNames %}
42+
{# Skip deprecated methods that have namespace collisions with non-deprecated methods #}
43+
{% else %}
3444
{% set deprecated_message = '' %}
3545
/**
3646
{% if method.description %}
@@ -72,6 +82,7 @@ class {{ service.name | caseUcfirst }} extends Service
7282
}
7383
{%~ if not loop.last %}
7484
85+
{%~ endif %}
7586
{%~ endif %}
7687
{%~ endfor %}
7788
}

templates/php/tests/Services/ServiceTest.php.twig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ final class {{service.name | caseUcfirst}}Test extends TestCase {
1616
$this->{{ service.name | caseCamel }} = new {{ service.name | caseUcfirst }}($this->client);
1717
}
1818
19+
{% set nonDeprecatedMethodNames = [] %}
1920
{% for method in service.methods %}
21+
{% if not method.deprecated %}
22+
{% set nonDeprecatedMethodNames = nonDeprecatedMethodNames|merge([method.name | caseCamel | lower]) %}
23+
{% endif %}
24+
{% endfor %}
25+
{% for method in service.methods %}
26+
{% set methodNameLower = method.name | caseCamel | lower %}
27+
{% if method.deprecated and methodNameLower in nonDeprecatedMethodNames %}
28+
{# Skip deprecated methods that have namespace collisions with non-deprecated methods #}
29+
{% else %}
2030
public function testMethod{{method.name | caseUcfirst}}(): void {
2131
{%~ if method.responseModel and method.responseModel != 'any' ~%}
2232
$data = array(
@@ -40,5 +50,6 @@ final class {{service.name | caseUcfirst}}Test extends TestCase {
4050
$this->assertSame($data, $response);
4151
}
4252
53+
{% endif %}
4354
{% endfor %}
4455
}

0 commit comments

Comments
 (0)