Skip to content
getnextpdf.com

Enterprise edition

PHPStan — Deep Reference

  • One public class: EditionBoundaryRule, a custom PHPStan rule over use statements.
  • Enforces the one-directional edition dependency order. Core never imports Pro or Enterprise. Pro never imports Enterprise.
  • Violations report the identifier nextpdf.editionBoundaryViolation on the offending use line.
  • Build-time only. The rule has no runtime path and no effect on generated PDFs.
  • Ships in nextpdf/enterprise. Registration uses standard PHPStan configuration.

This capability ships in NextPDF Enterprise (nextpdf/enterprise) and activates with an Enterprise-tier license envelope. It is a build-time static-analysis rule with no runtime path: the nextpdf/enterprise package boundary gates it, and it carries no separate per-feature capability code. Core and Pro do not ship an equivalent. Compare editions and get a license.

Install the package, then register the rule in PHPStan configuration.

Terminal window
composer require nextpdf/enterprise:^3
rules:
- NextPDF\Enterprise\PHPStan\EditionBoundaryRule
SymbolParametersDefault behaviorReturnsThrows or fails withNotes
EditionBoundaryRuleNone (no constructor arguments)Stateless PHPStan rule subscribed to use statementsNever throwsfinal; implements PHPStan\Rules\Rule over Use_
EditionBoundaryRule::getNodeType()NoneDeclares the AST node type the rule subscribes tostring (Use_::class)Never throwsStandard PHPStan Rule contract method
EditionBoundaryRule::processNode()Node $node, Scope $scopeChecks each imported symbol against the prefixes forbidden for the analyzed namespacelist<IdentifierRuleError> (empty when compliant)Never throws; violations surface as rule errorsError identifier nextpdf.editionBoundaryViolation
final class EditionBoundaryRule implements Rule
{
public function getNodeType(): string;
public function processNode(Node $node, Scope $scope): array;
}

EditionBoundaryRule implements the standard PHPStan Rule contract over the Use_ node type. For each use statement it compares the analyzed file’s namespace against every imported symbol’s namespace prefix and enforces a one-directional dependency order.

Analyzed namespaceEdition labelForbidden import prefixes
NextPDF\* sub-namespaces, excluding Pro and EnterpriseCoreNextPDF\Pro\, NextPDF\Enterprise\
NextPDF\Pro and NextPDF\Pro\*ProNextPDF\Enterprise\
NextPDF\Enterprise and NextPDF\Enterprise\*EnterpriseNone (top tier)
Any namespace outside NextPDF\None (unconstrained)

When an import crosses the boundary, the rule reports an error under the identifier nextpdf.editionBoundaryViolation, anchored to the offending use statement line. The message names the imported symbol, the importing namespace, the forbidden prefix, and human-readable edition labels. Each imported symbol produces at most one error: prefix matching stops at the first forbidden prefix that matches.

The check is static and advisory. It reports boundary violations on import statements. It does not prove the analyzed program is otherwise correct.

  • Namespaces outside NextPDF\ and namespaceless files produce no errors; the rule returns an empty list.
  • Code declared in the exact root namespace NextPDF (no sub-namespace segment) is not constrained; boundary detection matches NextPDF\ sub-namespaces.
  • Enterprise files are never flagged for importing Pro or Core symbols (top tier, by design).
  • Prefix matching is separator-aware. A namespace such as NextPDF\Professional classifies as Core, not Pro, and imports under it never false-positive against the NextPDF\Pro\ prefix.
  • Importing the literal names NextPDF\Pro or NextPDF\Enterprise with no further segment is not flagged; only symbols under those prefixes match.
  • The rule does not filter by import kind: class, function, and const imports under a forbidden prefix all report.
  • Inline fully-qualified references written without a use statement are out of scope. Prefer imports so the boundary is enforced.
  • Group use declarations parse as the distinct GroupUse node type and fall outside the rule’s Use_ subscription; plain per-symbol imports keep the boundary checked.
  • processNode() never throws; all outcomes surface as PHPStan rule errors or an empty result.
  • Not a runtime component. It performs no cryptographic operations, and FIPS mode is not applicable.

No standards conformance is claimed. This is a developer-tooling rule that enforces an internal architectural constraint (edition layering) in downstream builds. It implements the PHPStan rule extension contract, which is a third-party tool API, not a formal standard. The rule makes no compliance, certification, or correctness guarantee about analyzed code; it reports edition-boundary import violations only and is advisory.

  • The rule executes inside PHPStan during analysis, reads source structure only, and has no effect on generated PDFs or any deployed service.
  • Registering the rule and choosing the PHPStan level remain the integrator’s responsibility.
  • The class is final and stateless, so it is safe under PHPStan’s parallel analysis workers.
  • Analysis output is deterministic for a given source tree: the same inputs yield the same error list.
  • Available since nextpdf/enterprise 2.1.0; the contract above reflects 3.1.0.

This page documents externally observable behavior and the supported public API surface only. Internal namespace paths, helper classes, mechanism tables, runbook filenames, and ticket prefixes are out of scope.