-
Notifications
You must be signed in to change notification settings - Fork 16
fix: new phpstan errors #273
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
base: master
Are you sure you want to change the base?
Conversation
## Walkthrough
This update introduces a new method for processing table metadata in the query processor and refines the handling of table and column metadata throughout the schema builder and grammar. The schema builder’s method for retrieving tables now accepts an optional schema parameter and processes results using the new processor method. The grammar’s table compilation logic is updated to support schema filtering and improved SQL generation. Docblocks across several methods are simplified, and minor adjustments are made to metadata key ordering, type casting, and SQL query formatting for consistency.
## Changes
| Files/Paths | Change Summary |
|-----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| src/Query/Processor.php | Added `processTables` method for standardizing table metadata; updated `processColumns` to swap order of `type` and `type_name`, add `generation` key, refine type casting; simplified docblocks for `processIndexes` and `processForeignKeys`. |
| src/Schema/Builder.php | Modified `getTables` to accept optional `$schema`, use `compileTables` with schema, assert raw results as list, and process results with `processTables`; replaced `getIndexes` with `getIndexListing` in `dropIndexIfExist` and `dropAllTables`. |
| src/Schema/Grammar.php | Updated `compileTables` to handle optional schema parameter by normalizing input; changed SQL to select `table_schema AS schema` alongside other columns; modified WHERE clause to filter by `table_type = 'BASE TABLE'` and `table_schema IN (...)`; adjusted SQL string concatenation formatting. |
| tests/Schema/BuilderTestLast.php | Adjusted expected column metadata in `test_getColumns()` to reorder keys and include new `generation` key with null value. |
## Suggested labels
`waiting for review`
## Suggested reviewers
- kt81 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
⏰ Context from checks skipped due to timeout of 90000ms (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
14082ad
to
cf3ac4e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 2
🔭 Outside diff range comments (3)
src/Schema/Grammar.php (3)
67-73
: 🛠️ Refactor suggestionUpdate compileIndexes method to use the schema parameter
The method accepts a schema parameter but doesn't use it in the SQL query. The table_schema filter is hardcoded to an empty string.
return sprintf( - 'select index_name as `index_name` from information_schema.indexes where table_schema = \'\' and table_name = %s', + 'select index_name as `index_name` from information_schema.indexes where table_schema = %s and table_name = %s', + $this->quoteString($schema ?? ''), $this->quoteString($table), );
82-88
: 🛠️ Refactor suggestionUpdate compileForeignKeys method to use the schema parameter
The method accepts a schema parameter but doesn't use it in the SQL query. The table_schema filter is hardcoded to an empty string.
return sprintf( - 'select constraint_name as `key_name` from information_schema.table_constraints where constraint_type = "FOREIGN KEY" and table_schema = \'\' and table_name = %s', + 'select constraint_name as `key_name` from information_schema.table_constraints where constraint_type = "FOREIGN KEY" and table_schema = %s and table_name = %s', + $this->quoteString($schema ?? ''), $this->quoteString($table), );
97-103
: 🛠️ Refactor suggestionUpdate compileColumns method to use the schema parameter
The method accepts a schema parameter but doesn't use it in the SQL query. The table_schema filter is hardcoded to an empty string.
return sprintf( - 'select * from information_schema.columns where table_schema = \'\' and table_name = %s', + 'select * from information_schema.columns where table_schema = %s and table_name = %s', + $this->quoteString($schema ?? ''), $this->quoteString($table), );
🛑 Comments failed to post (2)
composer.json (1)
14-14: 💡 Verification agent
🧩 Analysis chain
Updated Laravel framework dependency to support version 12.
The package now requires Laravel 12.0 or higher, which aligns with the PHPStan fixes and schema builder return type compatibility changes mentioned in the PR objectives.
🏁 Script executed:
#!/bin/bash # Verify that Laravel 12 requires PHP 8.2+ curl -s https://packagist.org/packages/laravel/framework.json | jq '.package.versions["12.0.0"].require.php'Length of output: 115
🏁 Script executed:
#!/bin/bash # Use Packagist API v2 to check the PHP requirement for Laravel 12.0.0 curl -s https://repo.packagist.org/p2/laravel/framework.json \ | jq '.packages["laravel/framework"][] | select(.version == "12.0.0") | .require["php"]'Length of output: 171
🏁 Script executed:
#!/bin/bash # List PHP requirements for Laravel 12.x versions from Packagist v1 curl -s https://packagist.org/packages/laravel/framework.json | jq -r ' .package.versions | to_entries[] | select(.key | test("^(v)?12\\.")) | "\(.key): \(.value.require.php // \"none\")" 'Length of output: 413
🏁 Script executed:
#!/bin/bash # Fetch Laravel v12.0.0 composer.json directly from GitHub to inspect the PHP requirement curl -s https://raw.githubusercontent.com/laravel/framework/12.0.0/composer.json \ | jq -r '.require.php'Length of output: 167
🏁 Script executed:
#!/bin/bash # 1. Check PHP requirement for Laravel 12.0.0 via Packagist v2 API echo "Packagist v2 API (version 12.0.0):" curl -s https://repo.packagist.org/p2/laravel/framework.json \ | jq -r '.packages["laravel/framework"][] | select(.version == "12.0.0") | .require.php // "not found"' # 2. Inspect composer.json on GitHub for branch 12.x echo "GitHub composer.json (branch 12.x):" curl -s https://raw.githubusercontent.com/laravel/framework/12.x/composer.json \ | jq -r '.require.php // "not found"'Length of output: 464
Ensure PHP version requirement is updated to ^8.2
Laravel 12 requires PHP ^8.2. Please verify that your
composer.json
require.php
entry is set accordingly to avoid compatibility issues.
- composer.json (require → php): bump version constraint to
^8.2
if not already.src/Schema/Grammar.php (1)
48-58:
⚠️ Potential issueFix SQL query syntax errors in compileTables method
There are several syntax errors in the SQL query that need to be fixed:
- Missing comma between
parent
andtable_schema
columns- Missing
AND
between the table_type condition and table_schema conditionreturn - 'select `table_name` as name, `table_type` as type, `parent_table_name` as parent `table_schema` as `schema` ' . - 'from information_schema.tables where table_type = \'BASE TABLE\'' . - 'table_schema in (' . $this->quoteString($schema) . ')'; + 'select `table_name` as name, `table_type` as type, `parent_table_name` as parent, `table_schema` as `schema` ' . + 'from information_schema.tables where table_type = \'BASE TABLE\' AND ' . + 'table_schema in (' . $this->quoteString($schema) . ')';📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.public function compileTables($schema) { if ($schema === null || (is_array($schema) && count($schema) === 0)) { $schema = ''; } return 'select `table_name` as name, `table_type` as type, `parent_table_name` as parent, `table_schema` as `schema` ' . 'from information_schema.tables where table_type = \'BASE TABLE\' AND ' . 'table_schema in (' . $this->quoteString($schema) . ')'; }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Schema/Grammar.php
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Run-PHPUnit
#274 needs to be fixed first. |
Summary by CodeRabbit
New Features
Improvements
Documentation