Skip to content

Add return types to method signatures#8173

Merged
dereuromark merged 2 commits into5.xfrom
docs-add-return-types
Jan 28, 2026
Merged

Add return types to method signatures#8173
dereuromark merged 2 commits into5.xfrom
docs-add-return-types

Conversation

@dereuromark
Copy link
Member

Summary

  • Add scalar/simple return types to 243 method signatures across 28 documentation files
  • Return types include string, int, float, bool, void, array, mixed, null, self, static, and union types (e.g., string|null, int|false)
  • All return types cross-referenced against the CakePHP 5.x source code
  • Object return types (Query, Entity, Response, etc.) are intentionally left out for a separate pass

Files Changed

Core Libraries (14 files): app, caching, collections, hash, inflector, logging, number, plugin, security, text, time, xml
Controllers (3 files): controllers, request-response
ORM (4 files): database-basics, deleting-data, saving-data, table-objects
Views (6 files): views, form helper, html helper, paginator helper, text helper, url helper
Development (2 files): configuration, debugging
Console Commands (2 files): input-output, option-parsers

@LordSimal
Copy link
Contributor

Instead of having to keep them up2date manually in here we could make a custom markdown extension which fetches most of that info from the source code. I talked to @josbeir about that and he said that wouldn't be that hard.

@dereuromark
Copy link
Member Author

Sure, I am just getting a head start on that for now, with AI its not that much of work to add for the time being until we have an automated solution.

One open question is the return types of objects, with FQCN or not.
And how to deal with really long lines, as they can become unreadable.

@josbeir
Copy link
Contributor

josbeir commented Jan 28, 2026

One open question is the return types of objects, with FQCN or not.

I would not add this if it's a full snippet. Illustrate an import instead.

And how to deal with really long lines, as they can become unreadable.

Can you give an example? For backticked code blocks this is handled with overflow.

@dereuromark
Copy link
Member Author

Illustrate an import instead.

We dont even need that IMO. Its just the docs. If someone wants the full one, they can also see the actual API docs maybe.

@dereuromark
Copy link
Member Author

Once those are merged, we can also more easily see the remaining edge case.
Prelim results on this are:

│ No return type in source │ 13 │ Medium │
├───────────────────────────────────────┼───────┼──────────┤
│ Fluent methods (return $this/static) │ 9 │ Medium │
├───────────────────────────────────────┼───────┼──────────┤
│ Not found / inherited / traits │ 33 │ Low │
├───────────────────────────────────────┼───────┼──────────┤
│ Callback class convention │ 1 │ N/A │
└───────────────────────────────────────┴───────┴──────────┘

Add scalar/simple return types (string, int, float, bool, void, array,
mixed, null, self, static, and union types) to 243 method signatures
across 28 doc files, cross-referenced against the CakePHP 5.x source.
Add `: void` to 29 event callback method signatures across Table,
Controller, Component, Helper, and Command documentation.
@dereuromark dereuromark force-pushed the docs-add-return-types branch from 7f4b739 to 7cb6b5c Compare January 28, 2026 12:18
@dereuromark dereuromark merged commit 526b1ef into 5.x Jan 28, 2026
5 checks passed
@dereuromark dereuromark deleted the docs-add-return-types branch January 28, 2026 12:19
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