# Implementation Plan: Full PHP 7.4 Compatibility

## Approach

Fix 4 syntax violations across 2 files. Replace PHP 8.0-only syntax with PHP 7.4-compatible equivalents. Then remove the PHP version gate from both plugin entry files so the plugin runs on all versions.

No logic changes. Surgical edits only.

---

## Changes

### 1. `includes/Features/ActivityLogDB.php`

**Line 8 — Union typed property `\QM_DB|\wpdb $wpdb`**

`wpdb` is always a `\wpdb` instance. `QM_DB` extends `\wpdb` (Query Monitor plugin). Union type is documentation only — actual runtime object is always wpdb-compatible. Remove union type, keep docblock.

```php
// BEFORE:
// phpcs:ignore PHPCompatibility.Classes.NewTypedProperties.Found
protected \QM_DB|\wpdb $wpdb;

// AFTER:
/** @var \wpdb */
protected $wpdb;
```

**Lines 93 and 112 — Union return types `array|object|null`**

`wpdb::get_results()` returns `array|object|null` depending on output type. Move type info to `@return` docblock.

```php
// BEFORE:
public function get_logs(): array|object|null {

// AFTER:
// phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations
public function get_logs() {
```

```php
// BEFORE:
public function get_logs_by_page( $page = 1, $per_page = 20 ): array|object|null {

// AFTER:
// phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations
public function get_logs_by_page( $page = 1, $per_page = 20 ) {
```

Docblocks already have `@return array|object|null` — no docblock changes needed.

---

### 2. `includes/Features/BackgroundProcess.php`

**Line 58 — `mixed` return type on `task()`**

`task()` always returns `false` in this implementation (background process contract). Replace `mixed` with no return type (docblock already says `@return false`).

```php
// BEFORE:
// phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.class_nameFound
protected function task( $item ): mixed {

// AFTER:
protected function task( $item ) {
```

---

### 3. `archive-master.php` (Free) — Remove PHP gate

Remove the `version_compare` block that bails on PHP < 8.0. Plugin now runs on 7.4.

```php
// REMOVE this entire block:
if ( version_compare( PHP_VERSION, '8.0.0', '<' ) ) {
    add_action( 'admin_notices', function () { ... } );
    return;
}
```

---

### 4. `archive-master-pro/archve-master.php` (Pro) — Remove PHP gate

Same — remove the `version_compare` bail block added in the previous patch.

---

## File Change Summary

| File | Change |
|------|--------|
| `includes/Features/ActivityLogDB.php` | 3 syntax fixes (union property + 2 union return types) |
| `includes/Features/BackgroundProcess.php` | 1 syntax fix (`mixed` return type) |
| `archive-master.php` | Remove PHP < 8.0 gate + polyfills still loaded |
| `archve-master.php` (Pro) | Remove PHP < 8.0 gate |

---

## Test Checklist

- [ ] PHP 7.4 — plugin activates, NO admin notice shown
- [ ] PHP 7.4 — WooCommerce order archiving works end-to-end
- [ ] PHP 7.4 — activity log insert/retrieve works
- [ ] PHP 7.4 — background process runs without parse error
- [ ] PHP 8.0 — all features work normally
- [ ] PHP 8.1 / 8.2 — no deprecation notices
- [ ] `debug.log` clean on all versions
