Skip to content

fix(tests): the ObjectEntity stub declared return types wider than the contract - #528

Merged
rubenvdlinde merged 2 commits into
developmentfrom
fix/stub-return-types-match-the-contract
Aug 16, 2026
Merged

fix(tests): the ObjectEntity stub declared return types wider than the contract#528
rubenvdlinde merged 2 commits into
developmentfrom
fix/stub-return-types-match-the-contract

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

13 of 37 jobs on development were red on one fatal thrown at class load, before any test ran:

PHP Fatal error: Declaration of OCA\OpenRegister\Db\ObjectEntity::getUuid() must be
compatible with OCA\OpenRegister\Contract\ObjectEntityInterface::getUuid(): ?string

The stub implements ObjectEntityInterface but declared getUuid, getObject, getRegister and getSchema with no return type at all. A return type may be narrowed by an implementor, never widened — and an omitted type is the widest there is, so an untyped getUuid() against the contract's ?string is invalid, not merely loose.

The four abstracts now carry the contract's own types, and the anonymous subclass in MergeOrganisatieServiceTest follows them. It is the only subclass of this stub in the repo.

Because the fatal happens at class load, it took down all six PHPUnit cells and all four PHP quality tools together.

…e contract

Every PHPUnit cell and all four PHP quality tools were failing on
development with one fatal, thrown at class load before any test ran:

  PHP Fatal error: Declaration of OCA\OpenRegister\Db\ObjectEntity::getUuid()
  must be compatible with OCA\OpenRegister\Contract\ObjectEntityInterface::getUuid(): ?string

The stub implements ObjectEntityInterface but declared getUuid, getObject,
getRegister and getSchema with no return type at all. A return type may be
narrowed by an implementor, never widened, and an omitted type is the widest
there is — so `abstract public function getUuid();` against the contract's
`?string` is not loose, it is invalid.

The four abstracts now carry the contract's own types, and the anonymous
subclass in MergeOrganisatieServiceTest follows them; it was the only
subclass in the repo.

13 of 37 jobs were red on this one declaration.
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/softwarecatalog @ 97a5071

Check PHP Vue Security License Tests
lint
phpcs
phpmd
psalm
phpstan
phpmetrics
eslint
stylelint
build
check-manifest
check-vue-demi
test-l10n
format
composer ✅ 130/130
npm ✅ 704/704
app:check-code ⏭️
info.xml
REUSE
PHPUnit
Newman ⏭️
Playwright
Hydra gates

Quality workflow — 2026-08-16 10:30 UTC

Download the full PDF report from the workflow artifacts.

With the stub fatal gone PHPUnit actually runs (698 tests, 2644 assertions),
which exposed 53 errors that could not previously be reached. Four causes:

38 — five test helpers declared `: ObjectService` (the concrete class) while
returning `createMock(ObjectServiceInterface::class)`. The helpers now
declare what they return.

8 — OrganisationMembersControllerTest passed $this->container in the logger
slot and omitted $organisationService entirely; the mock it needed was
already built two lines up, it was just being reached through the container.

2 — OrganizationSyncService guarded two batch loops with
`$this->objectService instanceof ObjectService === false`, testing the
CONCRETE class against a property typed as the interface. The property is
promoted, readonly and non-nullable, so it can never be unresolved: in
production the guard was dead, and against any other implementation it
logged "could not resolve ObjectService" and returned early — silently
skipping the whole organisation batch and every contact rather than syncing
them.

1 — ViewService::getObjectService() declares `?ObjectServiceInterface` but
resolved `ObjectService::class` out of the container. It now asks for the
contract, which is what the return type promises.
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/softwarecatalog @ d2ee9e2

Check PHP Vue Security License Tests
lint
phpcs
phpmd
psalm
phpstan
phpmetrics
eslint
stylelint
build
check-manifest
check-vue-demi
test-l10n
format
composer ✅ 130/130
npm ✅ 704/704
app:check-code ⏭️
info.xml
REUSE
PHPUnit
Newman ⏭️
Playwright
Hydra gates

Quality workflow — 2026-08-16 11:06 UTC

Download the full PDF report from the workflow artifacts.

@rubenvdlinde
rubenvdlinde merged commit 89a7ea1 into development Aug 16, 2026
55 of 81 checks passed
@rubenvdlinde
rubenvdlinde deleted the fix/stub-return-types-match-the-contract branch August 16, 2026 11:22
rubenvdlinde pushed a commit that referenced this pull request Aug 16, 2026
`development` gained #528 (`fix/stub-return-types-match-the-contract`)
while this branch was open. It fixes `tests/Stubs/Db/ObjectEntity.php`
with the same four return types and the same reasoning as this branch's
`b711474c`, and it goes further: it also repairs the test helpers and the
two services whose failures that class-load fatal was hiding.

Conflict in `tests/Stubs/Db/ObjectEntity.php` resolved by taking
`development`'s version wholesale. The two are equivalent in effect —
`getUuid(): ?string`, `getObject(): array`, `getRegister(): ?string`,
`getSchema(): ?string`, with `getId()` and `setObject()` left untyped
because neither is on the contract — and #528's comment sits better.
`tests/Unit/Service/MergeOrganisatieServiceTest.php` auto-merged to
`development`'s content for the same reason.

Both files are now byte-identical to `origin/development`. What remains
on this branch is only the composition root itself, which #528 did NOT
touch: `Application.php:730` still passes 11 arguments to a 13-parameter
constructor, so `/api/me` still returns 500 for every user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant