stdclass is auto-corrected to object but it should not be

Created on 3 October 2022, over 1 year ago
Updated 3 April 2023, about 1 year ago

Problem/Motivation

\Drupal\Sniffs\Commenting\FunctionCommentSniff auto-corrects stdClass to object but they are different types with different meaning. It is pretty well explained here: https://github.com/phpstan/phpstan/discussions/7009

Steps to reproduce

Minimum code example

/**
 * @param \stdClass $bar
 *
 * @return \stdClass
 */
function foo(\stdClass $bar): \stdClass {
  return $bar;
}

Unexpected changes by PHPCBF

/**
 * @param object $bar
 *
 * @return object
 */
function foo(\stdClass $bar): \stdClass {
  return $bar;
}

Proposed resolution

Remove this behavior

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Fixed

Version

8.3

Component

Coder Sniffer

Created by

πŸ‡­πŸ‡ΊHungary mxr576 Hungary

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024