# Configuration

`friendsofmago/mago-mockery` does not ship a `mago.toml` preset to extend. You configure it through Mago's `[source]`, `[extension-hosts.<name>]`, and `[analyzer]` tables.

## Source includes

Mago must read Mockery's own class and interface declarations so intersection types have a valid `Mockery\MockInterface` member.

```
[source]
includes = ["vendor/mockery/mockery/library"]
```

If `[source] includes` already contains `"vendor"`, Mago already indexes `"vendor/mockery/mockery/library"`.

## Extension host settings

Register the bundled worker under `[extension-hosts.mockery]`:

```
[extension-hosts.mockery]
command = ["php", "-d", "xdebug.mode=off", "-d", "pcov.enabled=0", "-d", "memory_limit=512M", "vendor/bin/mago-mockery-worker"]
workers = 1
environment = { MAGO_MOCKERY_STRICT_METHODS = "1" }
```

| Key | Purpose |
| --- | --- |
| `command` | Command array that starts the PHP worker process. Use `vendor/bin/mago-mockery-worker` or `vendor/friendsofmago/mago-mockery/resources/worker.php`. |
| `workers` | Number of worker processes in the host pool. Setting `workers = 1` keeps memory usage low and avoids duplicating per-worker caches. |
| `environment` | Optional environment variables that Mago passes to the worker. Omit the key to keep the defaults. |

## Environment variables

The worker reads one environment variable.

| Variable | Accepted truthy values | Default | Effect |
| --- | --- | --- | --- |
| `MAGO_MOCKERY_STRICT_METHODS` | `1`, `true`, `yes`, or `on`, trimmed and case-insensitive | Off | Registers `StrictMockedMethodHook` and emits `mockery/unknown-mocked-method` for unknown literal or higher-order mocked method names. |

Any other value leaves strict mode off. If you compose plugins in PHP, pass `$strictMockedMethods` to `MockeryExtension::plugins()` to override this variable.

## Registered analyzer plugins

The extension registers two analyzer plugins. Both have `defaultEnabled = true`.

| Plugin identifier | Name | Purpose |
| --- | --- | --- |
| `mockery` | Mockery | Mock and spy return types, expectation chains, verification types, higher-order messages, argument matcher signatures, PHPUnit initializers, trait constant filter, and opt-in strict method checks. |
| `mockery-named-fetch` | Mockery Named Fetch | Resolves `fetchMock()` calls by span against same-file and trait-lifecycle `namedMock()` calls. Runs as a separate plugin so `mockery` keeps provider memoization. |

## Suppressing diagnostics

This extension emits one diagnostic code: `mockery/unknown-mocked-method`.

Ignore it across the whole project or for specific paths in `mago.toml`:

```
[analyzer]
ignore = [
    "mockery/unknown-mocked-method",
]
```

Ignore it for one directory only:

```
[analyzer]
ignore = [
    { code = "mockery/unknown-mocked-method", in = "tests/Legacy/" },
]
```

Ignore a single call with an inline Mago comment:

```
// @mago-ignore analysis:mockery/unknown-mocked-method
$mock->shouldReceive('handledByMagicCall');
```

See [Diagnostics](<https://friendsofmago.github.io/mago-mockery/analyzer/diagnostics/index.md>) for the full diagnostic reference.
