Skip to content

refactor: split the engine base classes and constants out of WeatherMap.class.php - #344

Merged
TheWitness merged 6 commits into
developfrom
refactor/split-weathermap-engine
Nov 11, 2026
Merged

TheWitness merged 6 commits into
developfrom
refactor/split-weathermap-engine

Conversation

@somethingwithproof

@somethingwithproof somethingwithproof commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Fixes #342

Move the global constants into lib/WeatherMap.constants.php, where every define is guarded, and move each base class into its own lib file: WeatherMapDataSource, PreProcessor, PostProcessor, Base, ConfigItem and Item. WeatherMap.class.php still requires them all, so existing callers are unchanged.

  • The class bodies are moved byte for byte; the PHPDoc for them is in a separate commit. Constant values and order are identical.
  • The datasource test harness now loads the real WeatherMapDataSource instead of a stub. That removes the redeclaration fatal when a later test loads the engine.
  • Risk: include order. WeatherMapNode and WeatherMapLink need WeatherMapItem defined first, so the base classes are required before them.
  • Tests: new standalone-load tests run each new file in a fresh process; an end-to-end test renders a doc example through ReadConfig, ReadData, DrawMap and MakeHTML.
  • Verified: the full Pest suite passes on PHP 8.4 (360 tests).
  • Assertion count: the count drops because DataSourceContractTest asserts once per line and now scans the 119-line base class file instead of the whole engine.

#345 is stacked on this PR, so merge this one first.

Each define() is wrapped in defined() so loading the file after a caller
or test has already declared IN/OUT no longer warns. Values, order and
the point at which WeatherMap.class.php defines them are unchanged.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
WeatherMapDataSource, WeatherMapPreProcessor, WeatherMapPostProcessor,
WeatherMapBase, WeatherMapConfigItem and WeatherMapItem each move to
their own lib/*.class.php file with their bodies unchanged.
WeatherMap.class.php requires them before WeatherMapNode and
WeatherMapLink, which extend WeatherMapItem and previously relied on it
being hoisted from the same file. Existing callers keep including
WeatherMap.class.php only.

The source-scanning ReadData contract tests now read
WeatherMapDataSource.class.php, and the syntax smoke list covers the
new files.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The harness declared its own WeatherMapDataSource and IN/OUT, so any
later test in the same process that loaded WeatherMap.class.php hit a
class redeclaration fatal. It now requires the guarded constants file
and the real base class, which are require_once-safe, and the stub is
dropped. The real base adds only no-op Register() and Prefetch().

The patch-coverage allowlist note for lib/editor.actions.php no longer
cites the collision.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Class and method summaries for the files moved out of
WeatherMap.class.php, and a docblock per constant group. Comment-only;
kept separate from the move so that commit stays a verbatim copy.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
EngineFileLoadingTest loads each split file in a fresh PHP process:
the constants file twice and after a caller-defined IN, each base class
on its own, and the datasource base, harness and engine in that order.
EngineRenderEndToEndTest reads the published traffic-pulse example from
a temp dir, then runs ReadData, DrawMap and MakeHTML and checks the PNG
and the imagemap areas for both nodes and the link.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The standalone-load checks run in child processes, so patch coverage
does not see the moved base-class defaults. Exercise them in-process.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@alcatron

alcatron commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Tested 555e557 in a separate checkout: all 364 PHP tests passed, including the new class-loading and end-to-end rendering tests. I also ran the suite with #345 on top; that passed as well.

No new failure found from the class split in those checks. The combined batch also passed its PHP suite after correcting the separate test-fixture issues in #348.

@alcatron alcatron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecked in the combined batch: 648 PHP tests and all 33 browser test files pass, including the engine loading and rendering checks. No further issue found from the class split. Looks good to me.

@TheWitness
TheWitness merged commit cc2b83f into develop Nov 11, 2026
9 checks passed
@TheWitness
TheWitness deleted the refactor/split-weathermap-engine branch November 11, 2026 02: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.

Split the engine base classes and constants out of WeatherMap.class.php

3 participants