Discussion: Missing PHP return type declarations in Session, Config, and Console classes #57364
Replies: 3 comments 1 reply
-
If you add return types will result in bugs and breaking changes. |
Beta Was this translation helpful? Give feedback.
-
As they are potential breaking changes, these should be directed at |
Beta Was this translation helpful? Give feedback.
-
TBF, some of the bugs I've seen from the added return types boil down to the framework's apparent philosophy of "types are optional" colliding with the greater PHP ecosystem's shift toward well typed applications and integrations (one PR was reverted this week because folks were returning a value not implementing an interface in their test factories, and the proper signature broke their tests, so the framework instead made a change to keep this undocumented use case supported). So long as the framework treats ignoring the doc block type information as a feature, there's no point in trying to go any further with these changes. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
PR #57343 was recently closed, which aimed to add missing PHP return type declarations to various Laravel framework classes. The PR included improvements to type safety and developer experience by adding explicit return type declarations to methods that had docblock types but were missing PHP return types.
Affected Areas
The PR addressed missing return type declarations in:
Session Classes
EncryptedStore::getEncrypter(): EncrypterContract
CacheBasedSessionHandler::getCache(): CacheContract
SessionManager
methods:shouldBlock(): bool
,blockDriver(): ?string
, etc.Config Classes
Repository
methods:has(): bool
,get(): mixed
,getMany(): array
, etc.Console Classes
PruneStaleTagsCommand::getArguments(): array
ConfigMakeCommand::promptForMissingArgumentsUsing(): array
ConfigCacheCommand::handle(): void
Benefits of Adding Return Types
Questions for Discussion
Policy Clarification: Is there a specific policy or guideline regarding when to add return type declarations to existing methods?
Incremental Approach: Would a more targeted approach be preferred (e.g., focusing on one subsystem at a time)?
Breaking Changes Concern: Are there concerns about potential breaking changes, even though return type declarations are generally backward compatible?
Timing: Is this type of improvement better suited for major version releases?
Community Input: Should this type of enhancement go through an RFC process or community discussion first?
Proposed Next Steps
Related
Note: This issue is created to foster discussion and understanding, not to challenge the maintainers' decision. The goal is to learn and potentially find alternative approaches that align with the project's direction.
Beta Was this translation helpful? Give feedback.
All reactions