feat(polyfill): detached Worksheet + addSheet, eager alias surface, value binder, IOFactory registration#4
Merged
Conversation
… eager alias surface Three PhpSpreadsheet-parity gaps hit by a real ERP report suite: - Spreadsheet::setValueBinder()/getValueBinder(): the PhpSpreadsheet >= 2.x workbook-level binder API. The workbook binder wins over the legacy static Cell::setValueBinder(); setCellValue()/fromArray() route through it. - new Worksheet() may now be constructed detached (both ctor args optional) and attached later via the new Spreadsheet::addSheet($sheet, ?$index) — the FilterLoopReportRunner/multi-sheet idiom. Title get/set work while detached; native-touching calls throw a clear message via workbookHandle(). rebindParent() rejects cross-workbook moves. - aliasCompatSurface(): eagerly alias every Compat class at bootstrap. The engine skips autoloading for instanceof and typed-parameter checks, so a lazily-aliased class that was only ever *returned* (never explicitly loaded) failed type hints like function (Worksheet $ws): the alias did not exist yet. Lazy aliasing stays for unimplemented classes (strict throw / fallback defer). Validated against the ERP report generator suite under EASY_EXCEL_ALIAS=strict: 19/19 tests pass (previously 6 binder errors + 1 ctor error + latent type-check failures). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Mirrors PhpSpreadsheet's StringValueBinder (per-type conversion suppression, DateTime/RichText/Stringable object binding). Callers that call $spreadsheet->setValueBinder(new StringValueBinder()) previously hit UnsupportedApiException under strict aliasing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
saifulferoz
force-pushed
the
feat/spreadsheet-value-binder-add-sheet
branch
from
July 18, 2026 04:44
ef7baed to
694cad4
Compare
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.
What
Four PhpSpreadsheet-parity gaps hit by the ERP report suite, already validated against it (19/19 report generator tests under
EASY_EXCEL_ALIAS=strict):Detached
new Worksheet()+Spreadsheet::addSheet($sheet, ?$index)— the multi-sheet idiom used by composite/filter-loop reports (new Worksheet(); setTitle(); $spreadsheet->addSheet($ws, $i)) fataled with "Too few arguments to Worksheet::__construct()". Both ctor args are now optional; title get/set works while detached; every native-touching call routes throughworkbookHandle()which throws a clear "attach it first" message;rebindParent()rejects cross-workbook moves;addSheetrejects duplicate titles (matching PhpSpreadsheet).Eager alias surface (
aliasCompatSurface()) — PHP never autoloads forinstanceof/typed-parameter checks, so a lazily-aliased class that was only ever returned (e.g.WorksheetfromgetActiveSheet()) failed consumer type hints likefunction (Worksheet $ws). Every implemented Compat class is aliased at bootstrap; lazy aliasing stays for unimplemented classes (strict throw / fallback defer).Workbook-level value binder —
Spreadsheet::setValueBinder()/getValueBinder()(PhpSpreadsheet ≥ 2.x); wins over the legacy staticCell::setValueBinder();setCellValue()/fromArray()route through it.IOFactory::registerWriter()/registerReader()+createReaderForFile()— apps that plug custom writers (e.g. an Html-based Pdf writer) run unchanged; registered entries are consulted before the built-ins; newReader\IReadercontract +Writer\Exception/Reader\Exception(also open upstream as feat(polyfill): IOFactory registerWriter/registerReader + createReade… xiidea/easy-excel#2).Testing
php tests/run.phpgreen on the branch.setTitle+addSheet+ duplicate-title guard + typed-param/instanceofchecks all pass under the Compat engine, and the composite multi-sheet report saves with the correct sheet list.🤖 Generated with Claude Code