Skip to content

Commit 211e3b8

Browse files
committed
chore: add deprecated to php
1 parent f64266d commit 211e3b8

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/SDK/SDK.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,18 @@ public function __construct(Language $language, Spec $spec)
164164
}, ['is_safe' => ['html']]));
165165
$this->twig->addFilter(new TwigFilter('comment1', function ($value) {
166166
$value = explode("\n", $value);
167+
$prefix = " * ";
168+
$prefixLength = strlen($prefix);
169+
$maxLineLength = 75 - $prefixLength;
170+
167171
foreach ($value as $key => $line) {
168-
$value[$key] = " * " . wordwrap($line, 75, "\n * ");
172+
if (empty(trim($line))) {
173+
$value[$key] = $prefix;
174+
continue;
175+
}
176+
177+
$wrapped = wordwrap($line, $maxLineLength, "\n" . $prefix, true);
178+
$value[$key] = $prefix . $wrapped;
169179
}
170180
return implode("\n", $value);
171181
}, ['is_safe' => ['html']]));

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class {{ service.name | caseUcfirst }} extends Service
3131
}
3232
3333
{% for method in service.methods %}
34+
{% set deprecated_message = '' %}
3435
/**
3536
{% if method.description %}
3637
{{ method.description|comment1 }}
@@ -41,6 +42,15 @@ class {{ service.name | caseUcfirst }} extends Service
4142
{% endfor %}
4243
* @throws {{spec.title | caseUcfirst}}Exception
4344
* @return {{ method | getReturn }}
45+
{% if method.deprecated %}
46+
*
47+
{% set method_name = method.replaceWith | split('.') | last | caseCamel %}
48+
{% set deprecated_message = deprecated_message ~ 'Please use ' ~ method_name ~ '() instead.' %}
49+
* @deprecated {{ deprecated_message }}
50+
{% if method.replaceWith %}
51+
* @see {{ method.replaceWith | replace({'.': '::'}) | capitalizeFirst }}
52+
{% endif %}
53+
{% endif %}
4454
*/
4555
public function {{ method.name | caseCamel }}({% for parameter in method.parameters.all %}{% if not parameter.required or parameter.nullable %}?{% endif %}{{ parameter | typeName }} ${{ parameter.name | caseCamel | escapeKeyword }}{% if not parameter.required %} = null{% endif %}{% if not loop.last %}, {% endif %}{% endfor %}{% if 'multipart/form-data' in method.consumes %}, callable $onProgress = null{% endif %}): {{ method | getReturn }}
4656
{

0 commit comments

Comments
 (0)