Skip to content

fix(database): correct return type for Blueprint::foreign()#7682

Merged
limingxinleo merged 1 commit intohyperf:masterfrom
binaryfire:fix/blueprint-foreign-return-type
Jan 25, 2026
Merged

fix(database): correct return type for Blueprint::foreign()#7682
limingxinleo merged 1 commit intohyperf:masterfrom
binaryfire:fix/blueprint-foreign-return-type

Conversation

@binaryfire
Copy link
Contributor

The foreign() method always returns ForeignKeyDefinition, not Fluent|ForeignKeyDefinition as the docblock claimed. This caused phpstan errors in downstream code:

Call to an undefined method Hyperf\Support\Fluent::references()

The method creates a ForeignKeyDefinition and returns it directly, so the union type was wrong. ForeignKeyDefinition extends Fluent and has the references(), on(), onDelete() etc. methods via @method annotations.

The foreign() method always returns ForeignKeyDefinition, not
Fluent|ForeignKeyDefinition as the docblock claimed. This caused
phpstan errors in downstream code:

  Call to an undefined method Hyperf\Support\Fluent::references()

The method creates a ForeignKeyDefinition and returns it directly,
so the union type was misleading. ForeignKeyDefinition extends Fluent
and has the references(), on(), onDelete() etc. methods via @method
annotations.
@binaryfire binaryfire force-pushed the fix/blueprint-foreign-return-type branch from 98a3e99 to 51dc0ac Compare December 27, 2025 16:55
@limingxinleo limingxinleo merged commit bf5ca47 into hyperf:master Jan 25, 2026
76 of 77 checks passed
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.

2 participants