Skip to content

fix: require nimbuscms/nimbus at runtime, not only in development - #2

Merged
DanMat merged 1 commit into
mainfrom
fix/runtime-requirement
Jul 21, 2026
Merged

DanMat merged 1 commit into
mainfrom
fix/runtime-requirement

Conversation

@DanMat

@DanMat DanMat commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Two fixes and a new test class, from the core audit.

The packaging bug

  "require": {
      "php": ">=8.2",
      "ext-mbstring": "*",
+     "nimbuscms/nimbus": "dev-main"
  },
  "require-dev": {
      "phpstan/phpstan": "^2.2",
-     "phpunit/phpunit": "^11.0",
-     "nimbuscms/nimbus": "dev-main"
+     "phpunit/phpunit": "^11.0"
  }

This package's production classes implement Plugin, PluginContext, FieldType and Field. With core in require-dev, Composer would install this package without checking a compatible Nimbus was present — and the failure would show up as a class-not-found at boot rather than a resolution error at install time, which is much harder to diagnose.

The registrar API

Adopts the narrowed capability from nimbus#18:

- $context->fieldTypes()->register(new MarkdownFieldType(), self::ID);
+ $context->fieldTypes()->register(new MarkdownFieldType());

The loader binds the provider id now. A plugin that could name its own provider could name someone else's — and since rollback is provider-scoped, that was a way to get another provider's types removed.

PackageIntegrationTest

MarkdownFieldTypeTest proves the field behaves correctly when handed a value. This proves something different and easier to get wrong: that a real Composer installation of this package is discovered by Nimbus's own loader, using this package's real manifest, and registers with nobody editing core.

Everything is the genuine article — the installed composer.json, the real PluginLoader, the real FieldTypeRegistry. Only the path to installed.json is synthesised, because Composer writes that file about the root project and this package is the root when its own tests run.

Covers: manifest declares core at runtime and is typed nimbuscms-plugin · discovery registers into the shared registry under this plugin's id · core types untouched · disabling leaves it unregistered with a non-failure diagnostic · with it disabled, write paths refuse the type while the admin still shows the stored source and blocks saves · re-enabling restores it · a second package cannot take this plugin's id.

[OK] No errors
OK (29 tests, 84 assertions)     # was 21

dev-main stays for now — the path to ^0.1 is tracked under Release & packaging in the core roadmap.

🤖 Generated with Claude Code

The plugin's production classes implement Nimbus interfaces — Plugin,
PluginContext, FieldType, Field — but core was listed under require-dev.
Composer would therefore have installed this package without checking that a
compatible Nimbus was present, and the failure would have surfaced as a class
not found at boot rather than as a resolution error at install time.

Also adopts the narrowed registrar API from core: the plugin no longer passes
its own provider id, because the loader binds it. A plugin that could name its
own provider could name someone else's.

Adds PackageIntegrationTest, which proves the package boundary rather than the
field. It drives the real PluginLoader with this package's real manifest:
discovery registers the type into the shared registry under this plugin's id
and leaves core types alone; disabling leaves it unregistered; with it disabled
write paths refuse the type while the admin still shows the stored source and
blocks saves; re-enabling restores it; and a second package cannot take this
plugin's id.
@DanMat
DanMat merged commit adf3ffd into main Jul 21, 2026
2 checks passed
@DanMat
DanMat deleted the fix/runtime-requirement branch July 21, 2026 19:12
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