Skip to content

T16971 tag factory refactor#16972

Merged
niden merged 12 commits into5.0.xfrom
T16971-tag-factory-refactor
May 3, 2026
Merged

T16971 tag factory refactor#16972
niden merged 12 commits into5.0.xfrom
T16971-tag-factory-refactor

Conversation

@niden
Copy link
Copy Markdown
Member

@niden niden commented May 3, 2026

Hello!

In raising this pull request, I confirm the following:

  • I have read and understood the Contributing Guidelines
  • I have checked that another pull request for this purpose does not exist
  • I wrote some tests for this PR
  • I have updated the relevant CHANGELOG
  • I have created a PR for the documentation about this change

Changed Phalcon\Html\Escaper into a façade over five per-context escapers (Phalcon\Html\Escaper\HtmlEscaper, AttributeEscaper, CssEscaper, JsEscaper, UrlEscaper); each is reachable via getXxxEscaper()/setXxxEscaper() so individual contexts can be swapped without subclassing the façade. The legacy setEncoding(), setFlags(), and setDoubleEncode() setters fan out to all sub-escapers so existing code keeps working

Changed Phalcon\Html\Helper\AbstractSeries::__toString() to ksort() its store before rendering so entries are emitted in position order rather than registration order; Phalcon\Html\Helper\Style::add() and Phalcon\Html\Helper\Script::add() now accept an optional int $pos = -1 argument that is routed through the new protected pushOrPlace() helper (negative pushes onto the next auto-increment slot, non-negative places at that key, advancing past occupied slots)

Changed Phalcon\Html\Helper\Input\Checkbox and Phalcon\Html\Helper\Input\Radio to extend a new shared Phalcon\Html\Helper\Input\AbstractChecked; Radio no longer extends Checkbox. Two paths now render checked="checked": the unconditional opt-ins ["checked" => "checked"] (case-insensitive) and ["checked" => true], and a value-match path comparing the supplied checked attribute against the input's value (== by default for mixed int/string round-tripping, === under strict(true))

Changed Phalcon\Html\Helper\Input\Checkbox and Phalcon\Html\Helper\Input\Radio to extend a new shared Phalcon\Html\Helper\Input\AbstractChecked; Radio no longer extends Checkbox. The checked/value comparison is loose (==) by default so mixed int/string form input round-trips correctly, with strict(true) available to opt back into === matching

Changed Phalcon\Html\TagFactory to no longer extend Phalcon\Factory\AbstractFactory; the registration pipeline now accepts class-strings, closures/callables, or [className, [depKey, ...]] / [className, [depKey, ...], [extraArg, ...]] tuples, and helpers are lazily cached per name in a separate instances map so set() overrides correctly invalidate the previous instance. has() now reports against the recipe map instead of the resolved-instance map

Added Phalcon\Html\Escaper\AbstractEscaper, Phalcon\Html\Escaper\AttributeEscaper, Phalcon\Html\Escaper\CssEscaper, Phalcon\Html\Escaper\HtmlEscaper, Phalcon\Html\Escaper\JsEscaper, and Phalcon\Html\Escaper\UrlEscaper as the per-context building blocks behind Phalcon\Html\Escaper

Added Phalcon\Html\Helper\Input\Generic and Phalcon\Html\Helper\Input\AbstractChecked; Generic accepts the HTML5 type via the constructor (with setType() to change it after construction), letting TagFactory register a single class for all type-string-only inputs and differentiate them through the recipe map

Added Phalcon\Html\Helper\Input\Select::placeholder(string $text) to inject a <option value="" disabled selected>$text</option> first entry, and Phalcon\Html\Helper\Input\Select::strict(bool $flag = true) to opt the option/selected comparison from the new loose default into strict (===) matching

  • Added Phalcon\Html\Helper\Script::beginInternal() and endInternal(array $attributes = [], int $pos = -1) to capture inline JavaScript via output buffering and append it to the asset stack as a <script>...</script> block

Added Phalcon\Html\Helper\Tag (open tag) and Phalcon\Html\Helper\VoidTag (self-closing tag) as escape hatches for arbitrary tag names without a dedicated helper; available via TagFactory as tag and voidTag

Added Raw factory variants aRaw, buttonRaw, elementRaw, labelRaw, olRaw, and ulRaw to Phalcon\Html\TagFactory, each backed by a tuple recipe that pins raw = true on the constructor of the underlying helper

Removed the per-type input helpers Phalcon\Html\Helper\Input\Color, Date, DateTime, DateTimeLocal, Email, File, Hidden, Image, Input, Month, Numeric, Password, Range, Search, Submit, Tel, Text, Time, Url, and Week; their TagFactory service names (inputColor, inputDate, ...) now resolve to Phalcon\Html\Helper\Input\Generic with the appropriate type baked into the recipe, so callers using the factory keep working unchanged

Thanks

@niden niden requested a review from Jeckerson May 3, 2026 02:05
@niden niden self-assigned this May 3, 2026
@niden niden added new feature request Planned Feature or New Feature Request 5.0 The issues we want to solve in the 5.0 release labels May 3, 2026
@niden niden merged commit 88ab750 into 5.0.x May 3, 2026
150 checks passed
@niden niden deleted the T16971-tag-factory-refactor branch May 3, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5.0 The issues we want to solve in the 5.0 release new feature request Planned Feature or New Feature Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant