| applyTo | pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/**/*.inc |
|---|
These rules apply to every PHP .inc file under pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/. Path-specific instructions in sibling files extend these for Models/, Endpoints/, Validators/, Dispatchers/, and Tests/.
Authoritative reference: AGENTS.md and .github/skills/.
<?php
namespace RESTAPI\<Subnamespace>;
require_once 'RESTAPI/autoloader.inc';
use RESTAPI\Core\<...>;- File extension is
.inc(not.php). - File name matches the class name exactly (
SystemHostname.inc→class SystemHostname). - Namespace mirrors the directory:
RESTAPI\Models,RESTAPI\Endpoints,RESTAPI\Validators,RESTAPI\Dispatchers,RESTAPI\Tests, etc.
- PHP 8.2. Use named arguments at call sites — the codebase consistently does this (
new StringField(required: true, default: '', ...)). - Comments:
#for short inline notes (matches existing code). Use/** ... */PHPDoc on every public class and method — PHPDoc rendering is gated by CI. response_idvalues:UPPER_SNAKE_CASE, prefixed with the class/feature (e.g.INVALID_FIREWALL_ALIAS_NAME,IP_ADDRESS_VALIDATOR_FAILED).- Throw, don't return errors. Use a
RESTAPI\Responses\*class with a stableresponse_id. Never throw bare\Exception. - Shell execution: use
RESTAPI\Core\Command, never bareexec()/shell_exec()/passthru(). - Sensitive values: mark Fields
sensitive: true. Never log secrets.
Never reference symbols, files, or behaviors that exist only in pfSense Plus. If you cannot find it in pfSense CE source, do not use it.
Code must pass:
./node_modules/.bin/prettier --check ./pfSense-pkg-RESTAPI/files
phplint -vvv --no-cache
./phpdocCI enforces all three.