Conversation
Add Timber Teak and its documentation generation script, update the PHPDoc dependencies, and ignore generated class-reference output.
Add @api annotations to public builder classes, interfaces, constructors, fluent methods, and configuration methods for Teak class-reference generation.
Move exception classes into src/Exceptions, update source and test imports, and keep exception assertions aligned with the new namespace.
Add summaries and return formats to public builder methods so generated Teak references are complete.
…o fix PHP8.2 test
…der, ParentDelegationBuilder, and RepeaterBuilder
…ails and formatting improvements
…formatting Co-authored-by: Mosaad <48773133+theMosaad@users.noreply.github.com>
This was referenced Sep 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
The project needs a foundation for a more extensive documentation website in the future. This PR is the first step toward that goal: it establishes a documented public API and a repeatable class-reference generation workflow that a future
documentation site can build on.
ACF Builder's public PHP API is useful but under-documented in generated class references. Many public builder classes and methods had no
@apimarker, incomplete summaries, or missing@returninformation. The project also had no repeatable class-reference generation workflow, making it difficult to keep API documentation complete as the builder surface grows.The documentation examples also needed to reflect the actual ACF Pro field settings. The ACF Builder wiki does not expose every setting available in the installed ACF Pro source, so this PR compares the field declarations against
acf_render_field_setting()and documents the additional supported options where they map directly to existing builder methods.Solution
Documentation tooling
Added Timber Teak as a development dependency.
Added the
docs:classesComposer script:Configured generated
docs/referenceoutput to remain ignored rather than committed as source.Regenerated the class references locally to verify the documentation surface.
Coding standards tooling (PHPCS)
Added
squizlabs/php_codesniffer,wp-coding-standards/wpcs, anddealerdirect/phpcodesniffer-composer-installeras development dependencies, relaxing thephp_codesnifferconstraint to^3.13.5 || ^4.0so WPCS can be installed alongside it.Added
phpcs.xml.dist, a ruleset based onWordPress-Coreand a trimmed-downWordPress-Docs, relaxed for use as a general-purpose PSR-4 Composer library rather than a WordPress plugin/theme:@varpresence,@param/@throwscapitalization and full stops) without requiring a full doc block rewrite everywhere.Added the
csandcs:fixComposer scripts:Fixed all resulting PHPCS findings across
src/andtests/: missing/incomplete docblocks,@throws/@parampunctuation and capitalization, missing@paramtypes, stray tabs, and trailing whitespace.Automated cleanup (Rector)
composer rector:fixto apply the project's configured Rector rule set across the builders, transforms, and test suite, simplifying redundant code (e.g. collapsing unnecessary conditionals and closures) without changing behavior.Public API annotations
Added
@apiannotations to the public builder surface, including:Builder,NamedBuilder, andParentDelegationBuildercontracts/base class.FieldsBuilder,FieldBuilder,ChoiceFieldBuilder,ConditionalBuilder,GroupBuilder,RepeaterBuilder,FlexibleContentBuilder,TabBuilder, andAccordionBuilder.Method documentation
Completed summaries and return formats for public methods so Teak can generate useful method tables and detailed sections. Documentation now covers:
addChoice(),addChoices(), andsetChoices().Examples use the requested multiline PHPDoc format with fenced PHP snippets and aligned array options.
FieldsBuilder's field-adding methods (addText(),addSelect(),addRepeater(), etc.) now document their$argsoption in the WordPress hash-notation style, listing every option supported by the underlying ACF field with its type and a short description:This is an example on how the docs now automatically generate:
addButtonGroup()
addButtonGroup( string $name, array $args = [] )Returns:
\StoutLogic\AcfBuilder\FieldBuilderstringarrayPHP
ACF Pro option coverage
The field examples include settings found in the installed ACF Pro field declarations, including options such as:
The source-only ACF field types
icon_pickerandclonedo not have matching builder factories, so they are not represented as options on an existing method.Exception organization
Moved the exception classes into
src/Exceptionsand updated their namespace toStoutLogic\AcfBuilder\Exceptions:FieldNameCollisionExceptionFieldNotFoundExceptionLayoutNotFoundExceptionModifyFieldReturnTypeExceptionUpdated source imports, tests, and generated documentation behavior accordingly. The exception classes are intentionally not marked with
@api; they are documented through@throwson the public methods that emit them.Impact
Runtime behavior
The builder algorithms and generated ACF configuration behavior are unchanged. The documentation and Teak additions do not affect production execution.
The exception namespace move is the compatibility-sensitive part of this PR. Consumers that import or catch the old root-namespace exception classes must update imports to the new namespace, for example:
The exception class names and inheritance remain unchanged apart from the namespace.
Dependencies
Timber Teak and its documentation dependencies are development-only. The runtime package requirements are not changed by the documentation work in this PR. The Composer lockfile is updated to include Teak and the resolved dependency graph.
PHPCS, WPCS, and their Composer installer plugin are also development-only additions.
php_codesniffer's constraint is widened (^3.13.5 || ^4.0) to allow WPCS to resolve; production requirements are unchanged.Generated output
The class-reference Markdown files are generated artifacts and are ignored by Git. They can be reproduced with
composer docs:classes.Example:
addButtonGroup()
addButtonGroup( string $name, array $args = [] )Returns:
\StoutLogic\AcfBuilder\FieldBuilderstringarrayPHP
Performance
No production performance impact is expected. The only new runtime-facing code changes are namespace imports for existing exception classes.
Usage changes
Most users do not need to change their builder usage. The public methods retain their existing names and behavior.
Users catching or importing the moved exceptions must migrate from the old namespace:
To regenerate API references locally:
Testing
Automated validation completed on the rebased branch:
composer test composer docs:classes composer cs composer rectorResults:
composer cs) passes cleanly againstsrc/andtests/with the newphpcs.xml.distruleset.git diff --checkpassed during the documentation validation.The tests cover the updated exception imports, field manager behavior, field builder behavior, nested builders, conditional logic, repeaters, flexible content, and generated configuration behavior.
No manual WordPress/ACF admin verification was performed. The change is primarily documentation/tooling work, with the exception namespace move covered by the existing PHPUnit suite.
Considerations
I might not have documented every public method yet. As this is a big task I would love to see if others could help in this matter as well.