Skip to content

13.0.0 — Performance, autowire caching, stampede-safe cache#489

Merged
iruzevic merged 17 commits into
release/10from
feature/improvements
May 15, 2026
Merged

13.0.0 — Performance, autowire caching, stampede-safe cache#489
iruzevic merged 17 commits into
release/10from
feature/improvements

Conversation

@iruzevic

@iruzevic iruzevic commented May 14, 2026

Copy link
Copy Markdown
Member

Summary

Major release focused on autowire performance, request-lifetime caching, and a stampede-safe manifest cache rebuild. Touches AbstractMain / Autowiring, AbstractBlocks registration, and most helper traits.

Highlights

  • Autowire is now cached. Production gets a {Namespace}ServiceClasses.json cache that sits next to the compiled PHP-DI container; dev gets a separate cache keyed by the namespace mtime and disabled under WP-CLI so scaffolding still sees freshly added classes.
  • Reflection scan reuses a shared cache across the full build, and transitive dependency resolution moved from a foreach-with-reference into an explicit work queue.
  • Manifest cache rebuild is stampede-safeCacheTrait::populateCacheData() rebuilds under an advisory flock() with a double-checked load on contention.
  • Block registration hoists Helpers::getSettings() and wrapper attribute lookups out of the per-block loop, and memoizes camel↔kebab conversions in the recursive attribute walk.
  • Request-lifetime memoization for StoreBlocksTrait::getSettings(), TailwindTrait::getTwBreakpoints(), the default RenderTrait path name, and template-file existence checks.

Added

  • Production {Namespace}ServiceClasses.json cache + dev {Namespace}DevServiceClasses.json cache (mtime-invalidated, disabled in CLI).
  • flock()-based stampede protection in CacheTrait::populateCacheData().
  • Autowiring now accepts primitive constructor parameters with default values instead of throwing.
  • Shared ReflectionClass cache across the autowire build.
  • AttributesTrait::PROPS_PASSTHROUGH_KEYS constant for the special keys propagated through props().

Changed

  • Autowiring constructor parameters promoted to readonly; redundant AbstractMain::__construct() removed (inherits from Autowiring).
  • Autowiring::buildServiceClasses() resolves transitive deps via a work queue instead of mutating the array under a foreach reference.
  • AbstractBlocks::registerBlocks() threads a shared $context (blockClassPrefix, settings/wrapper attributes) into registerBlock()/getAttributes() so it no longer recomputes per block.
  • prepareComponentAttribute/prepareComponentAttributes memoize camel↔kebab and emit one varargs array_merge instead of a chain.
  • RenderTrait drops the $renderHandlers indirection in favor of direct dispatch, caches default renderPathName, and memoizes filesystem existence checks.
  • Tighter parameter/return types in TailwindTrait::unifyClasses() / processOption() / getTwBreakpoints() and AttributesTrait::checkAttr() (now : mixed).
  • CssVariablesTrait::outputCssVariablesGlobalClean() builds output via a single implode(); outputCssVariablesGlobal/outputCssVariablesInline pass IDs through esc_attr().
  • PathsTrait::joinPaths() uses an inline strrpos extension check; getProjectPaths() uses spread-operator path composition.
  • GeneralTrait::isValidXml() collapsed to a single check; flattenArray() preserves all non-null scalars; recursiveArrayFind() annotated as array<int, mixed>.
  • SelectorsTrait serializers use implode() and route through Helpers::clsx() directly.
  • ComponentException::throwNotStringOrArray() inverted to use is_object().
  • Dev dependencies bumped: dealerdirect/phpcodesniffer-composer-installer1.2.1, infinum/eightshift-coding-standards^3.1.0.

Removed

  • RenderTrait::initializeRenderCaches() and the $renderHandlers lookup table.
  • AbstractMain::__construct() (promoted Autowiring constructor is used instead).

Fixed

  • Autowiring::buildClasses() filename regex now requires .php to terminate the filename (previously Foo.phpinfo would have matched).
  • Autowiring/AbstractMain directory walks skip . and .. via RecursiveDirectoryIterator::SKIP_DOTS.
  • CssVariablesTrait calls Helpers::getSettingsGlobalVariablesBreakpoints() instead of self:: so the trait works when consumed by classes that don't import that helper directly.
  • Removed double wp_json_encode() of the manifest payload on the cache write path.
  • flattenArray() no longer drops legitimate falsy scalars (0, false, '').

QA

  • Cold load on a project that uses AbstractMain: eightshift-cache/{Namespace}ServiceClasses.json is written and reused on subsequent requests.
  • In dev (no compiled container): adding/removing a service file invalidates {Namespace}DevServiceClasses.json on the next request (mtime bump).
  • WP-CLI scaffolding (wp boilerplate create-…) still picks up newly added services — dev cache must be bypassed in CLI.
  • Concurrent requests with a cold manifest cache do not double-write the cache file; the .lock file appears alongside it.
  • Existing projects: composer install succeeds with the new PHPCS installer + coding-standards versions; composer run-script standards-check is clean.
  • Block registration: nested components still resolve attribute prefixes correctly (the memoized camel↔kebab path).
  • CSS variables: rendered <style id="…"> markup matches previous output for the same global settings, with id now esc_attr'd.
  • Helpers::flattenArray() consumers that previously relied on 0/false/'' being dropped — confirm none in your project.

@iruzevic iruzevic changed the title Feature/improvements 13.0.0 — Performance, autowire caching, stampede-safe cache May 14, 2026
@iruzevic iruzevic requested a review from Copilot May 14, 2026 19:21
@iruzevic iruzevic requested a review from a team May 14, 2026 19:23
@iruzevic iruzevic self-assigned this May 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Major release focused on improving runtime performance by caching autowire/service discovery results, reducing repeated per-request computations, and adding stampede-safe manifest cache rebuilds.

Changes:

  • Added production and development service-class caches, plus reflection/autowire performance improvements.
  • Reduced repeated work during block registration/rendering and various helpers via request-lifetime memoization.
  • Made manifest cache rebuild stampede-safe via advisory flock() locking.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Main/Autowiring.php Autowire build optimizations (reflection cache, transitive deps work queue, primitive defaults handling).
src/Main/AbstractMain.php Service registration loop refactor; dev/prod service cache read/write; namespace mtime invalidation.
src/Helpers/TailwindTrait.php Breakpoints memoization; tighter types; debug-prefix slug caching.
src/Helpers/StoreBlocksTrait.php Request-lifetime memoization of global settings manifest lookup.
src/Helpers/SelectorsTrait.php Route selector serialization through Helpers::clsx(); reduce string concatenation.
src/Helpers/RenderTrait.php Remove handler table; direct dispatch; cache default render path name and file existence checks.
src/Helpers/PathsTrait.php Spread-based path composition; new (faster) “file vs folder” detection logic.
src/Helpers/GeneralTrait.php Perf/typing tweaks; JSON parsing via JSON_THROW_ON_ERROR; request-lifetime URL caching.
src/Helpers/CssVariablesTrait.php Build CSS output via implode; escape <style id>; optimize breakpoint matching and caching.
src/Helpers/CacheTrait.php Stampede-safe manifest cache rebuild using advisory flock() with double-checked load.
src/Helpers/AttributesTrait.php Add PROPS_PASSTHROUGH_KEYS; optimize merges; tighter return types; attrs output via implode.
src/Exception/ComponentException.php Adjust object-vs-non-object error message branching.
src/Blocks/AbstractBlocks.php Hoist settings/wrapper lookups; thread shared context; memoize camel/kebab conversions.
composer.json Dev dependency bumps for PHPCS installer and coding standards.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Main/AbstractMain.php
Comment thread src/Helpers/GeneralTrait.php
Comment thread src/Helpers/GeneralTrait.php
Comment thread src/Helpers/PathsTrait.php Outdated
Comment thread src/Main/Autowiring.php
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
kancijan
kancijan previously approved these changes May 15, 2026
dadadavorin
dadadavorin previously approved these changes May 15, 2026
@iruzevic iruzevic changed the base branch from main to release/10 May 15, 2026 07:16
@iruzevic iruzevic merged commit 51fba0a into release/10 May 15, 2026
2 of 3 checks passed
@iruzevic iruzevic deleted the feature/improvements branch May 15, 2026 07:17
iruzevic added a commit that referenced this pull request May 29, 2026
* 13.0.0 — Performance, autowire caching, stampede-safe cache (#489)

* major improvement on the speed security

* Adopt Rector, raise dev tooling baseline, sweep docblocks

- Bump infinum/eightshift-coding-standards to ^4.0.1, raise PHPCS minimum WP to 8.4
- Add Rector with project config and rector/fix scripts; drop php-parallel-lint
- Add phpstan-deprecation-rules and roave/security-advisories
- Apply Rector sweep across the library: constructor promotion, ::class, callable arrow syntax, type-narrowing, drop redundant @return docblocks
- Refresh 13.0.0 changelog entry to reflect the above

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* updates for the latest changes on main branch

* updates for the latest changes on main branch

* update

* updates

* updates

* updates

* updates

* updates

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants