Skip to content

Conversation

taka-oyama
Copy link
Contributor

@taka-oyama taka-oyama commented May 9, 2025

#55607 added generics to Schema\Builder class, but it's used incorrectly.

If you define a template for a class, the type should appear in the constructor which doesn't happen in this case.

The author probably thought @template was a type alias (like @phpstan-type or @psalm-type).

This PR removes the @template and just embeds type in the docs.

@taka-oyama taka-oyama changed the title fix: incorrect use of generics in Schema\Builder [12.x] incorrect use of generics in Schema\Builder May 9, 2025
@taylorotwell taylorotwell merged commit 678f8b6 into laravel:12.x May 9, 2025
58 checks passed
@shaedrich
Copy link
Contributor

Ahem, what made you think that? @template is used for generic

@taka-oyama taka-oyama deleted the fix/wrong-use-of-generics branch May 12, 2025 01:56
LukeTowers added a commit to LukeTowers/framework that referenced this pull request Jul 23, 2025
Fixes laravel#56152 which was caused by the incorrect parameters being used for a more specific type hint docblock merged in laravel#55687. 

This currently causes issues with projects that use static analysis and make use of the $builder->blueprintResolver() method to resolve custom blueprints.

Example below:

 ------ ---------------------------------------------------------------------------------------------------------- 
  Line   Database/DatabaseServiceProvider.php                                                                      
 ------ ---------------------------------------------------------------------------------------------------------- 
  :109   Parameter laravel#1 $connection of class Winter\Storm\Database\Schema\Blueprint constructor expects              
         Illuminate\Database\Connection, string given.                                                             
         🪪  argument.type                                                                                         
  :109   Parameter laravel#2 $table of class Winter\Storm\Database\Schema\Blueprint constructor expects string, Closure   
         given.                                                                                                    
         🪪  argument.type                                                                                         
  :109   Parameter laravel#3 $callback of class Winter\Storm\Database\Schema\Blueprint constructor expects Closure|null,  
         string given.                                                                                             
         🪪  argument.type                                                                                         
 ------ ----------------------------------------------------------------------------------------------------------
taylorotwell pushed a commit that referenced this pull request Jul 23, 2025
* Fix incorrect docblock for custom builder resolvers

Fixes #56152 which was caused by the incorrect parameters being used for a more specific type hint docblock merged in #55687. 

This currently causes issues with projects that use static analysis and make use of the $builder->blueprintResolver() method to resolve custom blueprints.

Example below:

 ------ ---------------------------------------------------------------------------------------------------------- 
  Line   Database/DatabaseServiceProvider.php                                                                      
 ------ ---------------------------------------------------------------------------------------------------------- 
  :109   Parameter #1 $connection of class Winter\Storm\Database\Schema\Blueprint constructor expects              
         Illuminate\Database\Connection, string given.                                                             
         🪪  argument.type                                                                                         
  :109   Parameter #2 $table of class Winter\Storm\Database\Schema\Blueprint constructor expects string, Closure   
         given.                                                                                                    
         🪪  argument.type                                                                                         
  :109   Parameter #3 $callback of class Winter\Storm\Database\Schema\Blueprint constructor expects Closure|null,  
         string given.                                                                                             
         🪪  argument.type                                                                                         
 ------ ----------------------------------------------------------------------------------------------------------

* Update src/Illuminate/Database/Schema/Builder.php

* Apply suggestions from code review
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