-
Notifications
You must be signed in to change notification settings - Fork 5
docs: add AGENTS.md #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5297be6
docs: add AGENTS.md
YvesCesar 5e017d6
docs: drop redundant CLAUDE.md pointer
YvesCesar 0d89853
docs: limit AGENTS.md to stable operational guidance
YvesCesar aac0dd6
docs: document that tests mirror the src tree
YvesCesar c7bb3e2
Update AGENTS.md
YvesCesar 84590a3
Update AGENTS.md
YvesCesar 05515d8
Update AGENTS.md
YvesCesar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # AGENTS.md | ||
|
|
||
| This file provides guidance to coding agents (Claude Code, Codex, etc.) when working with code in this repository. | ||
|
|
||
| ## Keeping this file current | ||
|
|
||
| Whenever a change makes any guidance here outdated, update this file in the same pull request. Keep it limited to stable operational guidance — conventions, compatibility requirements, commands, testing patterns and constraints. Implementation details (classes, methods, internal behavior) do not belong here: they go stale on the first refactor, and an agent may mistake a current limitation for a rule to preserve. | ||
|
|
||
| ## What this is | ||
|
|
||
| A thin PHP wrapper around [JSignPdf](http://jsignpdf.sourceforge.net/) (a Java CLI tool) for digitally signing PDFs with a PKCS#12 certificate. The library shells out to `java -jar JSignPdf.jar` and can download both the JRE and the JSignPdf jar on demand. | ||
|
|
||
| Package name is `jsignpdf/jsignpdf-php`, but the PSR-4 namespace is `Jeidison\JSignPDF\` (`src/`) and `Jeidison\JSignPDF\Tests\` (`tests/`). | ||
|
|
||
| ## Commands | ||
|
|
||
| Dev tooling lives in isolated `vendor-bin/*` directories managed by `bamarni/composer-bin-plugin`; `composer install` installs them all and creates bin-links in `vendor/bin`. The authoritative list of commands is the `scripts` section of `composer.json`. | ||
|
|
||
| ```bash | ||
| composer install # deps + all vendor-bin tools | ||
| composer run test:unit # PHPUnit (fails on warning/risky) | ||
| composer run test:coverage # with xdebug coverage | ||
| composer run cs:check # php-cs-fixer dry-run (CI lint) | ||
| composer run cs:fix # apply formatting | ||
| composer run psalm # static analysis, errorLevel 8 | ||
| composer run psalm:update-baseline | ||
|
|
||
| # single test / single method | ||
| vendor/bin/phpunit --filter testSignSuccess | ||
| vendor/bin/phpunit tests/Runtime/JavaRuntimeServiceTest.php | ||
| ``` | ||
|
|
||
| `example/index.php` is a runnable end-to-end smoke test (generates a self-signed cert, signs `tests/resources/pdf-test.pdf`, writes to `tmp/`). It needs a real Java + jar, so it actually downloads them on first run. | ||
|
|
||
| ## Compatibility | ||
|
|
||
| Minimum supported version is PHP 8.1 and `composer.json` pins `config.platform.php` to 8.1 — don't use syntax or stdlib newer than that. CI (on PRs only) runs php-cs-fixer, psalm, and PHPUnit on PHP 8.1–8.4. | ||
|
|
||
| ## Constraints | ||
|
|
||
| Everything reaching a shell must go through `escapeshellarg()`. Secrets (certificate passwords in particular) must never be passed through argv — use stdin instead. | ||
|
|
||
| ## Testing patterns | ||
|
|
||
| - `tests/` mirrors the `src/` tree. Preserve the same relative path and append `Test` to the source class name. For example, `src/Runtime/JavaRuntimeService.php` is covered by `tests/Runtime/JavaRuntimeServiceTest.php`. `tests/Builder/` and `tests/resources/` are examples of support directories outside this mirror. | ||
| - Shell calls are covered by declaring an `exec()` function inside the tested namespace, shadowing the global one for that file, driven by a `$mockExec` global set per test (see `tests/JSignPDFTest.php`). | ||
| - `vfsStream` fakes the filesystem (temp paths, unwritable directories, ownership) and `donatj/mock-webserver` fakes the JRE/jar http download endpoints. | ||
| - `tests/Builder/JSignParamBuilder::withDefault()` returns a `JSignParam` preloaded with `tests/resources/certificado.pfx` (password `123`) and `tests/resources/pdf-test.pdf`. | ||
| - Psalm's baseline is `tests/psalm-baseline.xml` with `findUnusedBaselineEntry` on — removing an error means the baseline entry must go too and is updated by `composer psalm:update-baseline`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.