Skip to content

Commit 59ad069

Browse files
authored
Fix #314: Fix deprecation error Method deprecated, use ::getParameters()
1 parent 5fede3d commit 59ad069

File tree

6 files changed

+44
-6
lines changed

6 files changed

+44
-6
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@v2
20+
uses: actions/checkout@v5
2121
- name: Install PHP
2222
uses: shivammathur/setup-php@v2
2323
with:
@@ -26,7 +26,7 @@ jobs:
2626
id: composer-cache
2727
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
2828
- name: Cache composer dependencies
29-
uses: actions/cache@v1
29+
uses: actions/cache@v4
3030
with:
3131
path: ${{ steps.composer-cache.outputs.dir }}
3232
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# netbeans project files
55
nbproject
66

7+
# visual studio code project files
8+
.vscode
9+
710
# zend studio for eclipse project files
811
.buildpath
912
.project

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Yii Framework 2 apidoc extension Change Log
44
3.0.8 under development
55
-----------------------
66

7-
- no changes in this release.
7+
- Bug #314: Fix deprecation error `Method deprecated, use ::getParameters()` (mspirkov)
88

99

1010
3.0.7 February 13, 2025

models/TypeDoc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ public function __construct($reflector = null, $context = null, $config = [])
223223
if ($tag instanceof Method) {
224224
$params = [];
225225

226-
foreach ($tag->getArguments() as $tagArgument) {
227-
$argumentType = (string) $tagArgument['type'];
226+
foreach ($tag->getParameters() as $parameter) {
227+
$argumentType = (string) $parameter->getType();
228228

229229
$params[] = new ParamDoc(null, $context, [
230230
'sourceFile' => $this->sourceFile,
231-
'name' => $tagArgument['name'],
231+
'name' => $parameter->getName(),
232232
'typeHint' => $argumentType,
233233
'type' => $argumentType,
234234
'types' => [],

tests/commands/ApiControllerTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,31 @@ public function testGenerateBootstrap()
118118
, $animalContent
119119
);
120120

121+
$this->assertContainsWithoutIndent(
122+
<<<HTML
123+
<tr id="isOlder()" class="">
124+
<td><a href="yiiunit-apidoc-data-api-animal-animal.html#isOlder()-detail">isOlder()</a></td>
125+
<td>Checks whether the animal is older than the specified time.</td>
126+
<td><a href="yiiunit-apidoc-data-api-animal-animal.html">yiiunit\apidoc\data\api\animal\Animal</a></td>
127+
</tr>
128+
HTML
129+
, $animalContent
130+
);
131+
132+
$this->assertContainsWithoutIndent(
133+
<<<HTML
134+
<tr><td colspan="3" class="signature"><span class="signature-defs">public</span> <span class="signature-type"><a href="https://www.php.net/language.types.boolean">boolean</a></span> <strong><a href="yiiunit-apidoc-data-api-animal-animal.html#isOlder()-detail">isOlder</a></strong> ( <span style="color: #0000BB">\$date</span> )</td></tr>
135+
<tr>
136+
<td class="param-name-col"><span style="color: #0000BB">\$date</span></td>
137+
<td class="param-type-col"><a href="https://www.php.net/language.types.integer">integer</a></td>
138+
<td class="param-desc-col">
139+
<p>Date as a UNIX timestamp.</p>
140+
</td>
141+
</tr>
142+
HTML
143+
, $animalContent
144+
);
145+
121146
// Class `Dog` :
122147
$dogFile = $outputPath . DIRECTORY_SEPARATOR . 'yiiunit-apidoc-data-api-animal-dog.html';
123148
$this->assertTrue(file_exists($dogFile));

tests/data/api/animal/Animal.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,14 @@ public function getAge()
4343
{
4444
return time() - $this->birthDate;
4545
}
46+
47+
/**
48+
* Checks whether the animal is older than the specified time.
49+
* @param int $date date as a UNIX timestamp.
50+
* @return bool
51+
*/
52+
public function isOlder($date)
53+
{
54+
return $this->getAge() > $date;
55+
}
4656
}

0 commit comments

Comments
 (0)