Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: PHPDoc for request() #18724

Merged
merged 2 commits into from
Jan 14, 2025
Merged

Conversation

Rom1-B
Copy link
Contributor

@Rom1-B Rom1-B commented Jan 14, 2025

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

Prevent this type of error with a PHPStan analysis at level 5 in plugins:

Parameter #1 $tableorsql of method DBmysql::request() expects array<string>|QueryUnion|string, array<string, array<string, mixed>|string> given.

Screenshots (if appropriate):

@cedric-anne
Copy link
Member

Parameter #1 $tableorsql of method DBmysql::request() expects array<string>|QueryUnion|string, array<string, array<string, mixed>|string> given.

What are the passed parameters ?

@Rom1-B
Copy link
Contributor Author

Rom1-B commented Jan 14, 2025

I have several cases, here's an example:

$request = [
            'SELECT' => ['SUM' => 'consumed as sum'],
            'FROM'   => self::getTable(),
            'WHERE'  => [
                'plugin_credit_entities_id' => $ID
            ],
        ];

        $result = $DB->request($request);

As a reminder, here's what we have on GLPI 11:
image

src/DBmysql.php Outdated Show resolved Hide resolved
@cedric-anne cedric-anne merged commit acf00e8 into glpi-project:10.0/bugfixes Jan 14, 2025
8 checks passed
@Rom1-B Rom1-B deleted the phpdoc_request branch January 14, 2025 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants