Skip to content

refactor(config): drop Repository::getEnvironment() (task 2.7) - #48

Merged
agissept merged 2 commits into
pre-release/4.2.93from
migration/2.7-config-getenvironment
Sep 16, 2026
Merged

agissept merged 2 commits into
pre-release/4.2.93from
migration/2.7-config-getenvironment

Conversation

@agissept

Copy link
Copy Markdown
Member

What

Task 2.7 (minimal scope). Removes Illuminate\Config\Repository::getEnvironment(). Loader/cascade/ctor unchanged (minimal scope — they evaporate at Wave 4 swap; see plan rationale).

  • getEnvironment() deleted (~8 lines).
  • Only fork-internal caller — the package() afterLoading closure — now reads $me->environment directly (closure bound to Repository scope).
  • $environment property + ctor (LoaderInterface, $env) + loader/package-cascade kept intentionally.

Why minimal scope

Doc 2.7 Steps also ask to remove the loader/package-cascade + change ctor to (array). That would require re-implementing the L4.2 env-subdir cascade (config/local/, config/testing/) + package-namespace cascade (config/packages/...) in a new eager loader — code that gets deleted at swap (Repository is in replace → wholesale-replaced in Wave 4). High risk, zero convergence value. Done-when doc only requires grep getEnvironment( app = 0. getEnvironment() is the sole app-facing surface whose enforcement matters.

Enforcement = runtime fatal (method removed → facade Config::getEnvironment() + injected $config->getEnvironment() become method-not-found), not grep. App-side guard is belt-and-suspenders.

Verification

  • php vendor/bin/phpunit → 1645 tests, 0 fail (21 skip baseline). Config\Repository boot via suite.
  • grep getEnvironment( src/Illuminate/Config/ = 0.

App-side

Separate dicoding branch improvement/l13-migration/config-getenvironment-conform migrates ~37 callers → App::environment() / app()->environment() + grep guard.

🤖 Generated with Claude Code

Remove getEnvironment(); the only fork-internal caller (the package
afterLoading closure) now reads $me->environment directly. Loader/cascade/
ctor unchanged (minimal scope — evaporates at Wave 4 swap). Enforcement is
runtime fatal: facade + injected callers become method-not-found.

App-side conform (getEnvironment → App::environment()/app()->environment())
ships in a separate dicoding branch.

Co-Authored-By: Claude <noreply@anthropic.com>
…task 0.2)

Task 2.7 removed Config\Repository::getEnvironment() from the fork with no
shim, so any surviving call is method-not-found (PHP+Psalm catches it). The
grep-ratchet pattern is redundant with that type enforcement and, worse,
false-positives on Queue\Listener::getEnvironment() — an unrelated worker
method — keeping the count stuck at 1.

Prune the pattern from the ratchet + baseline and move the row to a new
"already type-enforced" section of the divergence ledger. First concrete
slice of framework-first task 0.2 (demote ratchet to non-type patterns as
components get type-tightened).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Base automatically changed from migration/2.11-hashing-contracts to pre-release/4.2.93 September 16, 2026 02:58
@agissept
agissept merged commit 075febe into pre-release/4.2.93 Sep 16, 2026
2 checks passed
@agissept
agissept deleted the migration/2.7-config-getenvironment branch September 16, 2026 02:58
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