Skip to content

Commit 9bcbe0d

Browse files
authored
fix(FunctionComment): stdclass is auto-corrected to object but it should not be (#3313246)
1 parent 9575535 commit 9bcbe0d

File tree

6 files changed

+10
-14
lines changed

6 files changed

+10
-14
lines changed

coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ class FunctionCommentSniff implements Sniff
3737
'Boolean' => 'bool',
3838
'integer' => 'int',
3939
'str' => 'string',
40-
'stdClass' => 'object',
41-
'\stdClass' => 'object',
4240
'number' => 'int',
4341
'String' => 'string',
4442
'type' => 'mixed',

tests/Drupal/Commenting/FunctionCommentUnitTest.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ function test21($arg1, $arg2, $arg3) {
245245
*
246246
* @param array|bool|float|int|mixed|object|string|resource|callable $arg1
247247
* All of the above types are valid.
248-
* @param Array|boolean|integer|str|stdClass|NULL $arg2
248+
* @param Array|boolean|integer|str|NULL $arg2
249249
* All of the above types are invalid.
250250
* @param array()|Boolean|number|String $arg3
251251
* All of the above types are invalid.
@@ -443,7 +443,7 @@ function test34($a, $b) {
443443
}
444444

445445
/**
446-
* Using \stdClass as type hint is ok, but not in the documentation.
446+
* Using \stdClass as type hint and doc type is ok.
447447
*
448448
* @param object $name
449449
* Some description.

tests/Drupal/Commenting/FunctionCommentUnitTest.inc.fixed

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ function test21($arg1, $arg2, $arg3) {
257257
*
258258
* @param array|bool|float|int|mixed|object|string|resource|callable $arg1
259259
* All of the above types are valid.
260-
* @param array|bool|int|string|object|null $arg2
260+
* @param array|bool|int|string|null $arg2
261261
* All of the above types are invalid.
262262
* @param array|bool|int|string $arg3
263263
* All of the above types are invalid.
@@ -383,7 +383,7 @@ class Test2 extends AbstractTest {
383383
/**
384384
* Run method with missing described variable.
385385
*
386-
* @param object $start
386+
* @param \stdClass $start
387387
* Start point.
388388
*
389389
* @return bool
@@ -469,11 +469,11 @@ function test34($a, $b) {
469469
}
470470

471471
/**
472-
* Using \stdClass as type hint is ok, but not in the documentation.
472+
* Using \stdClass as type hint and doc type is ok.
473473
*
474474
* @param object $name
475475
* Some description.
476-
* @param object $param2
476+
* @param \stdClass $param2
477477
* Some description.
478478
*/
479479
function test35(\stdClass $name, \stdClass $param2) {
@@ -483,7 +483,7 @@ function test35(\stdClass $name, \stdClass $param2) {
483483
/**
484484
* Allow "object" as real type hint (PHP 7.2).
485485
*
486-
* @param object $arg
486+
* @param \stdClass $arg
487487
* Something here.
488488
* @param object $blarg
489489
* Another thing.

tests/Drupal/Commenting/FunctionCommentUnitTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,14 @@ protected function getErrorList(string $testFile): array
6464
357 => 1,
6565
360 => 1,
6666
371 => 1,
67-
374 => 1,
6867
389 => 2,
6968
390 => 2,
7069
401 => 1,
7170
414 => 1,
7271
416 => 1,
7372
426 => 2,
7473
427 => 2,
75-
450 => 1,
76-
460 => 1,
74+
465 => 1,
7775
538 => 1,
7876
540 => 1,
7977
];

tests/Drupal/Commenting/VariableCommentUnitTest.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Test {
2727
/**
2828
* Test for some common misspellings.
2929
*
30-
* @var Boolean|stdClass|NULL|FALSE|TRUE|[]
30+
* @var Boolean|NULL|FALSE|TRUE|[]
3131
*/
3232
protected $someVar;
3333

tests/Drupal/Commenting/VariableCommentUnitTest.inc.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Test {
2727
/**
2828
* Test for some common misspellings.
2929
*
30-
* @var bool|object|null|false|true|array
30+
* @var bool|null|false|true|array
3131
*/
3232
protected $someVar;
3333

0 commit comments

Comments
 (0)