=== Preflight — Deploy Readiness ===
Contributors: cliff
Tags: developer, deployment, environment, compatibility, site-health
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 0.5.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Will THIS code run on THAT host? Preflight fuses an environment parity diff with a code
compatibility scan into a single go/no-go deploy-readiness verdict.

== Description ==

WordPress already ships **Site Health** (it inspects *one* environment) and the ecosystem
has **PHP compatibility checkers** (they lint code in isolation). Neither answers the
question a developer actually has before shipping: *will my code run on the host I'm about
to deploy to?*

Preflight combines the two. Point it at a target host and it:

* **Diffs the environments** — PHP, database, web server, memory/time limits, HTTPS and
  WordPress version, this site vs the target — colour-coded match / risk / unknown, each
  with a plain-English consequence.
* **Scans your code** for version-sensitive syntax and functions the target PHP can't
  run, with file and line — a dependency-free tokenizer engine that runs on any host.
* **Returns a verdict** — READY / CAUTION / NOT READY, plus what to fix. Code that would
  fatal on the target turns the verdict red.

= Code scanner coverage (v0.2.0) =
Detects, per target PHP version: arrow functions, `??=`, numeric separators (7.4);
`match`, nullsafe `?->`, `str_contains`/`str_starts_with`/`str_ends_with` &amp; other 8.0
functions, constructor promotion, attributes, `mixed` return (8.0); enums, `readonly`,
first-class callable `(...)`, `never` return, `Fiber`, `array_is_list` (8.1);
`readonly class`, named attributes (8.2); typed-const/`json_validate`/`#[\Override]` (8.3);
`array_find`/`array_any`/`array_all` &amp; `#[\Deprecated]` (8.4).

Known limitations (static analysis only): does not yet flag named arguments, typed
properties, union/intersection/DNF types, or `mixed`/`never` outside return position;
namespaced (non-global) function calls are not matched. No runtime detection.

= Optional deep engine (Phase 3) =
When the host can run PHP_CodeSniffer with the PHPCompatibility standard, Preflight
escalates to it automatically for broader coverage; otherwise the tokenizer floor stands.
Tools → Preflight shows what this host supports. To enable: install phpcs + the
PHPCompatibility standard (e.g. via Composer) and either put `phpcs` on the PATH or add
`define( 'PREFLIGHT_PHPCS', '/path/to/phpcs' );` to wp-config.php. Never bundled — this
avoids shipping the alpha PHPCompatibility packages needed for PHP 8.1–8.4 coverage.

= Progressive target detection =
Preflight uses the best data it can get, with graceful fallback:

1. **Companion probe** on the live site (authenticated) — *Phase 4*.
2. **Passive auto-detect** — reads what the live server leaks over HTTP. No plugin needed.
3. **Paste** the live site's Site Health export.
4. **Manual** profile / host preset.

== Installation ==

1. Copy or symlink this folder into wp-content/plugins/.
2. Activate through the 'Plugins' menu.
3. Go to Tools → Preflight and check a target host.

== Screenshots ==

1. Tools → Preflight: a NOT READY verdict with the environment-parity diff and code
   compatibility findings, checking this site against an older shared host (PHP 8.0 / Apache).

== Roadmap ==

* Phase 1 — Environment parity diff + verdict. (done, 0.1.0)
* Phase 2 — Tokenizer code-compatibility scanner (PHP 7.4–8.4). (done, 0.2.0)
* Phase 3 — Optional deep scan via PHP_CodeSniffer + PHPCompatibility. (done, 0.5.0)
* Phase 4 — Companion probe / authenticated live fetch. (done, 0.3.0)
* Phase 5 — Exportable branded readiness report. (done, 0.4.0)

== Changelog ==

= 0.5.0 =
* Optional deep-scan engine: runs real PHPCompatibility via phpcs when the host supports
  it (auto-detected), for broader coverage; graceful fallback to the tokenizer otherwise.
* Host-capability report (exec, memory/time, WP-CLI, deep-engine availability) on the
  Preflight screen.

= 0.4.0 =
* Exportable readiness report: download a self-contained, printable HTML document of a
  run (verdict + environment parity + code findings) — a pre-launch / client-handoff artifact.

= 0.3.0 =
* Companion mode: an authenticated REST endpoint lets one Preflight installation fetch
  another live site's full environment (Tier A) — the most accurate target source.
* Disabled by default; token-guarded (denies bad/missing token and when disabled).

= 0.2.0 =
* Tokenizer-based PHP compatibility scanner (dependency-free, runs on any host).
* Scans active plugins + theme against the target PHP version; findings show file + line.
* Code findings fold into the readiness verdict (incompatible code turns it NOT READY).

= 0.1.0 =
* Initial release: environment parity engine, three target-acquisition tiers
  (passive probe, Site Health paste, manual profile), readiness verdict.
