|
| 1 | +# Lendable JSON Serializer |
| 2 | + |
| 3 | +Provides an opinionated object-oriented interface for handling JSON serialization and deserialization in PHP. It is deliberately restrictive rather than a generic solution: it fits the `data array(s) <=> json` part of the flow where object graphs are converted to data arrays (and back) elsewhere in the calling code. |
| 4 | + |
| 5 | +- `Serializer::serialize(array $data): string` — serializes a data array into a JSON string. Throws `SerializationFailed` on failure. |
| 6 | +- `Serializer::deserialize(string $json): array` — deserializes a JSON string into an array. Throws `DeserializationFailed` on failure to deserialize, and `InvalidDeserializedData` if the resulting data is not an array (e.g. root is a scalar). |
| 7 | + |
| 8 | +Unlike raw `json_encode()`/`json_decode()`, this library always throws on failure instead of returning `false` or requiring `json_last_error()` checks, and applies sane default serialization flags. |
| 9 | + |
| 10 | +## Layout |
| 11 | + |
| 12 | +- `src/` — library source, PSR-4 autoloaded under `Lendable\Json\`. |
| 13 | + - `Serializer.php` — the main API. |
| 14 | + - `SerializationFailed.php`, `DeserializationFailed.php`, `InvalidDeserializedData.php`, `Failure.php` — exception types. |
| 15 | +- `tests/unit/` — PHPUnit unit tests, autoloaded under `Tests\Lendable\Json\Unit\`. |
| 16 | + |
| 17 | +## Requirements |
| 18 | + |
| 19 | +PHP `^8.4`. CI additionally runs against PHP 8.5, and against lowest/highest/locked Composer dependency sets. |
| 20 | + |
| 21 | +## Common commands |
| 22 | + |
| 23 | +Run via Composer: |
| 24 | + |
| 25 | +```bash |
| 26 | +composer lint # parallel-lint over src/ and tests/ |
| 27 | +composer phpstan # PHPStan (max strictness — phpstan-strict-rules, phpstan-deprecation-rules, phpstan-phpunit) |
| 28 | +composer code-style:check # php-cs-fixer dry-run |
| 29 | +composer code-style:fix # php-cs-fixer, applies fixes |
| 30 | +composer rector:check # Rector dry-run |
| 31 | +composer rector:fix # Rector, applies fixes |
| 32 | +composer phpunit:unit # PHPUnit unit test suite |
| 33 | +composer infection # Infection mutation testing (--min-msi=100 --min-covered-msi=100) |
| 34 | +composer tests:unit # phpunit:unit + infection |
| 35 | +composer static-analysis # composer validate + lint + phpstan + rector:check |
| 36 | +composer ci # static-analysis + code-style:check + tests:unit — mirrors the CI pipeline |
| 37 | +``` |
| 38 | + |
| 39 | +Infection requires 100% mutation score (`--min-msi=100 --min-covered-msi=100`), so new code needs tests that actually kill mutants, not just line coverage. |
| 40 | + |
| 41 | +## Conventions |
| 42 | + |
| 43 | +- PR titles must follow Conventional Commits (validated by `.github/commitlint.config.js`): lower-case `type`, non-empty `scope`, no trailing period on the subject. Allowed types: `build`, `chore`, `ci`, `docs`, `feat`, `fix`, `perf`, `refactor`, `revert`, `style`, `test`. |
| 44 | +- Releases are automated via release-please on `master`/`releases/**` — don't hand-edit `CHANGELOG.md` or version tags. |
| 45 | + |
| 46 | +## Consuming shared agent assets |
| 47 | + |
| 48 | +Shared agent assets (skills, agents, commands, hooks, MCP servers) live under `.agents/` and are managed by the Lendable agents CLI ([`@lendable/ai-agents-cli`](https://jfrog.shared.prod.zable.co.uk/artifactory/api/npm/npm/@lendable/ai-agents-cli)). Per-harness directories (`.claude/`, `.codex/`, `.cursor/`) contain only CLI-managed symlinks and sidecar config — never edit them by hand. |
| 49 | + |
| 50 | +Install a shared `@lendable/ai-agent-*` package: |
| 51 | + |
| 52 | +```bash |
| 53 | +npm exec --yes --package=@lendable/ai-agents-cli@latest -- agents add <package-name> |
| 54 | +``` |
| 55 | + |
| 56 | +Verify the working tree matches `.agents/lendable-manifest.json` (this is what CI runs): |
| 57 | + |
| 58 | +```bash |
| 59 | +npm exec --yes --package=@lendable/ai-agents-cli@latest -- agents check |
| 60 | +``` |
| 61 | + |
| 62 | +Validate skill frontmatter and get recommendations: |
| 63 | + |
| 64 | +```bash |
| 65 | +npm exec --yes --package=@lendable/ai-agents-cli@latest -- agents lint --source=all |
| 66 | +``` |
| 67 | + |
| 68 | +If you hit HTTP 401/403 fetching from the registry, this machine isn't authenticated to Lendable's Artifactory yet. Open the Getting Started guide and copy the Bootstrap prompt from there: https://automatic-sniffle-qjwj75e.pages.github.io/packages/ai-agents-cli/getting-started/ |
0 commit comments