Commit ea6ca7d
authored
Suppress find()/findOrCreate()/loadInto() method overrides on Cake 5.3.6+ (#446)
* Suppress find()/findOrCreate()/loadInto() overrides on Cake 5.3.6+
Builds on PR #445. After cakephp/cakephp#19438 lands, the parent
Table::find(), Table::findOrCreate() and Table::loadInto() propagate
TEntity through their return types, so the matching plugin overrides
become redundant — and the parent's PersistenceFailedException
declaration on findOrCreate() finally survives in static analysis.
A dedicated supportsEntityTemplateFindFamily() helper splits the
find-family propagation from the class-level template gate: the
template itself landed in CakePHP 5.3.4 (cakephp/cakephp#19388),
while the find-family annotations are slated for 5.3.6. Until
#19438 actually ships, the helper's version check is a placeholder
that MUST be tightened to the real release before this PR comes
out of draft.
Per-method gating:
* find(): suppressed when tableEntityQuery emission would otherwise
fire AND the find-family parent annotations are available. Parent
now returns SelectQuery<TEntity|array>, which is strictly more
truthful than the plugin's previous SelectQuery<TEntity> override
since find() legitimately can return rows as arrays.
* findOrCreate(): suppressed when the gates hold. Kept in
genericsInParam=detailed mode because the plugin override narrows
the $search argument beyond what the parent provides.
* loadInto(): suppressed in concreteEntitiesInParam=strict mode when
the gates hold; the parent's TEntity|array<TEntity> annotation
matches the override exactly.
Also lowers supportsEntityTemplate()'s version check from 5.4.0 to
5.3.4 (the actual release that shipped #19388). The previous gate
was set anticipating 5.4 but the feature shipped earlier in the
5.3.x line.
Tests cover the new gating in three regression dimensions:
* tableEntityQuery + entity-template gates met → find() override
suppressed (and kept when tableBehaviors excludes extends);
* concreteEntitiesInParam=strict + entity-template gates met →
loadInto() override suppressed (and kept on a custom-parent
table where the template can't be assumed);
* entity-template present but find-family support NOT yet present
(the realistic in-between state between Cake 5.3.4 and 5.3.6) →
find()/findOrCreate()/loadInto() overrides kept, other methods
still suppressed.
* Revert supportsEntityTemplate() gate back to 5.4.0
Lowering the gate to 5.3.4 was out of scope for this PR and broke
fixture-comparison tests on CI (which installs Cake 5.3.5). Fixture
tests not using the mock emit '@extends Table<array{}, \Cake\ORM\Entity>'
that the saved fixtures don't have.
The gate-lowering was a factual correction but needs its own PR with
all the affected fixtures regenerated.
* Lower supportsEntityTemplate() gate to the actual ship version (5.3.4)
The TEntity template was added in cakephp/cakephp#19388 and first
released in CakePHP 5.3.4 — not 5.4 as the previous gate anticipated.
Test isolation:
* _getAnnotatorMock() now forces supportsEntityTemplate=false so the
legacy-path fixture comparisons stay stable regardless of the
installed Cake version. The entity-template path keeps its own
_getEntityTemplateAnnotatorMock() that forces it true.
* AnnotateCommandTest's CI-mode tests run the real annotator via
exec() — no mocking possible. The Awesome plugin Tables are
pre-annotated with the @extends line the 5.3.4+ annotator emits;
the affected tests skip on Cake < 5.3.4 where the annotator would
want to remove that annotation.
* Suppress marshalling-family overrides under the entity-template gate
newEntity / newEntities / patchEntity / patchEntities all resolve
their return types via the parent's TEntity (or method-level
TPatchedEntity) on Cake 5.3.4+, so the plugin overrides only carry
parameter-narrowing weight on top of that — and the narrowing is
only meaningful when the user has opted into it.
Per-method gates:
* newEntity / newEntities: keep override in detailed mode (narrows
array<string, mixed> for the data parameter). Suppress everywhere
else — the override's User[]|ResultSetInterface<User> return shape
is also technically wrong, since newEntities actually returns
array<TEntity> (no ResultSet involvement).
* patchEntity: keep override in detailed mode AND in
concreteEntitiesInParam mode (where the entity parameter is
narrowed to the concrete entity class).
* patchEntities: same as patchEntity — kept under
concreteEntitiesInParam for symmetry, even though the iterable
narrowing only kicks in when generics or strict are also on.
Tests cover the matrix: detailed mode keeps narrowed data parameter,
concrete mode keeps narrowed entity parameter for patchEntity and
patchEntities, non-narrowing scenarios suppress all four overrides.1 parent 0978666 commit ea6ca7d
6 files changed
Lines changed: 276 additions & 19 deletions
File tree
- src/Annotator
- tests
- TestCase
- Annotator
- Command
- test_app/plugins/Awesome/src/Model/Table
- test_files/Model/Table
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
250 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
251 | 257 | | |
252 | 258 | | |
253 | 259 | | |
| 260 | + | |
254 | 261 | | |
255 | 262 | | |
256 | 263 | | |
257 | 264 | | |
258 | | - | |
259 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
260 | 269 | | |
261 | 270 | | |
262 | 271 | | |
263 | 272 | | |
264 | | - | |
| 273 | + | |
265 | 274 | | |
266 | 275 | | |
267 | | - | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
268 | 279 | | |
269 | | - | |
270 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
271 | 286 | | |
272 | 287 | | |
273 | 288 | | |
| |||
284 | 299 | | |
285 | 300 | | |
286 | 301 | | |
287 | | - | |
| 302 | + | |
288 | 303 | | |
289 | 304 | | |
290 | 305 | | |
| |||
569 | 584 | | |
570 | 585 | | |
571 | 586 | | |
572 | | - | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
573 | 590 | | |
574 | 591 | | |
575 | 592 | | |
576 | 593 | | |
577 | | - | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
578 | 612 | | |
579 | 613 | | |
580 | 614 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
130 | 140 | | |
131 | 141 | | |
132 | 142 | | |
| |||
141 | 151 | | |
142 | 152 | | |
143 | 153 | | |
144 | | - | |
| 154 | + | |
145 | 155 | | |
146 | 156 | | |
147 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
148 | 180 | | |
149 | 181 | | |
150 | 182 | | |
| |||
395 | 427 | | |
396 | 428 | | |
397 | 429 | | |
398 | | - | |
| 430 | + | |
399 | 431 | | |
400 | 432 | | |
401 | 433 | | |
| |||
426 | 458 | | |
427 | 459 | | |
428 | 460 | | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
429 | 466 | | |
430 | 467 | | |
431 | 468 | | |
| |||
452 | 489 | | |
453 | 490 | | |
454 | 491 | | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
455 | 495 | | |
456 | 496 | | |
457 | 497 | | |
| |||
480 | 520 | | |
481 | 521 | | |
482 | 522 | | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
483 | 526 | | |
484 | 527 | | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
485 | 531 | | |
486 | 532 | | |
487 | 533 | | |
| |||
508 | 554 | | |
509 | 555 | | |
510 | 556 | | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
511 | 727 | | |
512 | 728 | | |
513 | 729 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
148 | 153 | | |
149 | 154 | | |
150 | 155 | | |
| |||
180 | 185 | | |
181 | 186 | | |
182 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
183 | 191 | | |
184 | 192 | | |
185 | 193 | | |
| |||
0 commit comments