
nette-dev
- GitHub stars
- 47
Install
/plugin install nette-dev@netteRun it inside Claude Code after adding the marketplace with /plugin marketplace add nette/claude-code.
Contents
Discovered from sourceSkills 4
Commit Message Style
Follow these conventions for commit messages:
Basic Rules
- Subject line in lowercase, description (if present) uses normal sentence case
- No period at the end of subject line
- Use past tense for verbs ("added", "fixed", not "add", "fix") - the commit describes what happened, so the git log reads as a chronological history
- Nouns are fine as-is ("fix" as noun is OK, e.g., "compatibility fix")
- Keep first line under 70 characters when possible
- Write in English only
Format
Use plain subject for straightforward changes:
added support for localefixed escaping after {contentType xml}
Use [subject]: [description] when it clarifies which part of the codebase changed:
CSS: reorganizationEngine: refactoring traverser logicFilters: added escapeHtml()
Omit the subject when the change affects the whole project generically.
Multi-line Messages
For changes that need more context, add a blank line after the subject and then a description:
added support for custom authenticators
The IAuthenticator interface now accepts a factory callback.
This enables lazy initialization of auth providers.
Use multi-line messages when the "why" isn't obvious from the subject alone.
Common Patterns
- Feature additions:
added [feature] - Bug fixes:
fixed [issue] - Releases:
Released version X.Y.Z(exception to the lowercase rule) - Deprecations:
[method] deprecated - Breaking changes: include "(BC break)" in message
- Work in progress:
wip
Routine/Maintenance Commits
Keep these simple, no additional context needed:
vendor- dependency updatescs- coding style fixestypos- typo corrections
PHP Coding Standards
Using DressCode
The Nette repositories are checked by DressCode with the dresscode.neon in their root. Install it globally using /php-fixer:install-php-fixer; after that, PHP files are automatically fixed when edited, by that configuration - see the php-auto-fixer skill for editing workflow rules (especially use statement ordering).
General Rules
- Every PHP file must include
declare(strict_types=1) - Use two empty lines between methods - Nette convention for visual separation in longer classes
- Every
@,==and!=carries a comment saying it is deliberate, see below - Multiple exceptions can be written in a single
exceptions.phpfile, and multiple enums intoenums.php - Interface methods don't need visibility as they're always public
- All properties, return values, and parameters must have types
- Final constants don't need types as they're self-evident
- Write all code, comments, and variables in English only (even if communicating with the user in Czech)
Comments for @, == and !=
DressCode reports these operators unless their line ends with a comment in exactly this form:
@unlink($tmp); // @ file may not exist
$content = @file_get_contents($file); // @ is escalated to exception
if ($v != null) { // intentionally !=, skips null and empty string
// @ <reason>: the concrete cause and why it is harmless (a file that may not exist, a disabled function), never a vaguemay trigger error; lower case, no dash, colon or full stop.is escalated to exceptiononly where the code really checks the result and throws// intentionally ==or// intentionally !=, the operator being the one on the line; a reason after a comma only where the intent is not obvious- The comment goes on the line holding the operator, one per line
Strings
- Use single quotes - they signal "no interpolation here," making code easier to scan
- Use double quotes only when the string contains apostrophes or interpolation is needed
- In HTML attributes, double quotes are standard
Naming Conventions
- Avoid abbreviations unless the full name is too long
- Use UPPERCASE for two-letter abbreviations (
IO,DB), PascalCase/camelCase for longer ones (Http,Xml) - Use nouns or noun phrases for class names
- Class names should include both specificity and generality (e.g.,
ArrayIterator) - Never let a method name be a bare noun - a method is an action:
getProvider(), notprovider(). A verb is the usual form; the exceptions are settled conventions, namely static factories (fromFile()), conversions (toArray()), interface methods (jsonSerialize()) and fluent interfaces whose names echo the domain rather than an action, as a query builder echoes SQL clauses - PascalCase for classes and class constants/enums
- camelCase for methods and properties
- Boolean query methods are
is*/has*/can*; a boolean property is named by the state itself ($active), never$isActive - Never use prefixes/suffixes like
Abstract,Interface, orI- the type system already distinguishes them
Method Order
- Place a new method deliberately - the order of methods is the outline a reader gets, saying which parts are primary and which are derived. The three rules below are in order of precedence: when they disagree, the earlier one wins
- Keep a method with those covering the same subject, and never break up a group that belongs together, not even with a method on that same subject - it goes before the whole group or after it
- Put the general before the special: a variant of an existing method goes right after it, never before, so the reader meets the plain form first and the special case second. A method serving one narrow use case follows the general ones rather than sitting among them
- A helper goes after the method that needs it, after all of them when it serves several. Where exactly is settled by the two rules above and by what surrounds it: it may follow immediately, it may sit after the whole group, it may close the class. Visibility does not decide the order - a private helper is not moved to the end of the class for being private
- Leave existing methods where they are - reordering them buries the real change in the diff
Formatting
- Use TABs for indentation everywhere (PHP, JS, HTML, CSS/SCSS, NEON, Latte, ...)
- PHP follows the Nette coding standard (PER Coding Style) with these modifications:
- No space before parentheses in arrow functions:
fn($a) => $b - No blank lines required between different
useimport types - When parameters span multiple lines, return type and opening brace go on separate lines:
- No space before parentheses in arrow functions:
// Short params - standard single-line
public function getItems(string $type): array
{
// method body
}
// Multi-line params - return type and brace on separate lines
public function example(
string $param,
array $options,
): string
{
// method body
}
Global Functions and Constants
- Write global functions/constants without leading backslash:
count($arr)not\count($arr) - Leave
use functionanduse constimports to DressCode, which adds and removes them
Code Style Preferences
- Uses DOM API with HTML5 parser Lexbor for HTML processing
- Prefer modern PHP syntax and concise expressions:
- Example:
if (is_array($response['data'] ?? null))instead ofif (isset($response['data']) && is_array($response['data']))
- Example:
- Use named arguments for boolean parameters whose meaning isn't obvious from context (e.g.,
is_a($obj, $class, allow_string: true)), but not when the method name makes it clear (e.g.,setReadonly(true)) - Place interface/base class outside the namespace containing its implementations (e.g.,
Foo\Networknext toFoo\Networks\*, not inside it) - this keeps the interface discoverable at the package level - For structured data, prefer typed classes (DTOs) with public typed properties and default values over plain
array. Arrays lose type information; typed objects let PHPStan catch errors at analysis time and give full IDE support. - Don't add comments referencing specific bug fixes, issues, or tickets ("fixes #123", "workaround for bug X", "added in PR #456"). Only write comments with general validity that explain non-obvious logic any reader would benefit from. Git history provides the fix-specific context and doesn't rot over time.
Documentation
The full Nette Coding Standard is bundled with the plugin; read it for rules this skill does not cover.
Documentation (phpDoc)
Golden Rule
Never duplicate signature information without adding value. If the class name, method name, parameter names, and PHP types already tell the full story, skip the docblock entirely.
Skip documentation when:
- The method is trivial and self-explanatory (getters, setters, simple delegations)
- The docblock would only repeat what the signature already says
- Parameter names are descriptive enough (
$width,$height,$name)
Write documentation when:
- The method has non-obvious behavior (returns null in specific conditions, throws exceptions)
- Array contents need specification (
@return string[]) - Parameters have constraints, formats, or valid ranges not captured by PHP types
- The "why" behind a design choice matters for callers
Writing Style
- Always American English (color, not colour; behavior, not behaviour)
- Start method descriptions with 3rd person singular present tense verb: Returns, Formats, Checks, Creates, Converts, Sets
- Skip phrases like "Class that...", "Interface for...", "Method that..."
- Don't duplicate method lists or implementation details in class docblocks
- Use active phrasing describing main responsibility
Preferred Phrases
Use consistent phrasing for recurring situations:
| Situation | Phrase |
|---|---|
| Returns a value | "Returns..." |
| Returns null on failure | "Returns X, or null if..." |
| Checks a condition | "Checks whether..." |
| Creates an object | "Creates..." |
| Converts format | "Converts X to Y." |
| Sets a value | "Sets..." |
| Finds/searches | "Finds...", "Searches for..." |
| Removes | "Removes..." |
| Validates | "Validates..." |
| Parses | "Parses..." |
Boolean / predicate methods
Describe the condition the method tests, not when it returns true. The return type already says it is a yes/no answer, so naming the truthy branch ("Returns true for...", "Returns true if...") just restates the signature.
- Write what is being checked: "Checks whether...", "Determines whether...", "Tells whether..."
- Don't enumerate the
truecase ("Returns true when...", "Returns true for..."). - Edge cases worth noting belong in the same sentence as the condition, not as a list of return values.
For example, a validator method is documented as "Checks whether the address is a syntactically valid IPv4 or IPv6 address, including IPv4-mapped IPv6." - the focus is the condition, and the special case rides along in the same clause.
Consistency
Across the whole codebase keep documentation uniform:
- All comments should look like they're from one author
- Same level of detail for similar methods
- Same formulations for similar situations
Property Documentation
Use single-line format for simple @var annotations:
/** @var string[] */
private array $name;
Short comments for non-obvious properties:
/** for back compatibility */
protected Explorer $context;
Parameters and Return Values
- Prefer
?TypeoverType|nullfor nullable types - Only document parameters when adding information beyond PHP types
- Order the tags
@param,@return,@throws; the tag name@paramis followed by two spaces, every other tag name by one:/** * @param mixed $var description here * @return string primary column sequence name */
Include parameter docs only when explaining:
- Additional context or constraints
- Limitations or conditions
- Unusual usage patterns
Generic Array Types
Array key types
array<T>=array<int|string, T>- any keys (omitting key type means int|string)array<int, T>- int keys only (not necessarily sequential)array<string, T>- string keys onlylist<T>- sequential int keys starting from 0 (0, 1, 2...)
Input vs output distinction
- @return:
list<T>is accurate if the function always returns sequential keys - @param:
list<T>can be too restrictive - may reject valid inputs with non-sequential keys
When to use list<T> for input
Analyze the implementation:
foreach ($arr as $v)- doesn't use keys →array<T>is sufficient$arr[0],$arr[1]- accesses by index → requireslist<T>
Conditional return types
For return types dependent on parameters:
/**
* @return ($flag is true ? list<array{string, int}> : list<string>)
*/
How to determine the correct type
- Examine the implementation - how is the array used?
- Write a test script that outputs the result structure if needed
- For nested arrays, analyze each nesting level separately
Exception Documentation
- Use a single natural-language sentence describing the problem
- Avoid phrases like "Exception that is thrown when..."
- Use consistent phrases:
- "does not exist" - for missing items
- "failed to" - for operation failures
- "cannot" - for impossible operations
- "is not supported" - for unsupported features
Examples:
- "The file does not exist."
- "Cannot access the requested class property."
- "The value is outside the allowed range."
- "Failed to read from or write to a stream."
Examples
Good Documentation
Clear purpose, adding array contents info:
/**
* Returns list of supported languages.
* @return string[] Array of language codes
*/
public function getSupportedLanguages(): array
Describing unusual behavior:
/**
* Creates new transaction. Returns null if user has exceeded daily limit.
*/
public function createTransaction(float $amount): ?Transaction
When to Skip
// Signature says it all - no docblock needed
protected readonly string $name;
public function getWidth(): int
public function setName(string $name): void
Self-explanatory parameters - document only the method purpose:
/**
* Calculates dimensions of image cutout.
*/
public function calculateCutout(int $left, int $top, int $width, int $height): array
PHPStan Analysis
Running PHPStan
Never use --error-format=json - its output format can change between PHPStan versions and is not designed for stable machine consumption. For machine-readable output, use --error-format=raw.
Take the verdict from the exit code, never from grepping the output. A filter defines what you see, so anything it misses reads as success - and some findings (an unmatched ignoreErrors pattern, for one) are not tied to any file and carry no file prefix at all.
Target Levels
Target level for Nette libraries is 8. Levels higher than 8 are not worth pursuing - the additional strictness (e.g., non-empty-string, positive-int) catches very few real bugs relative to the annotation burden.
- Level 7: Union types checked
- Level 8: Null checks, strict types (our target)
nette/phpstan-rules
Installed by all Nette libraries. It works in both directions, and mixing them up is a real hazard:
- It narrows types and silences false positives — many PHPStan errors disappear without manual fixes. Don't fight those (list below).
- It also REPORTS errors of its own and turns on stricter reporting. Two rules of its own:
nette.abortException(anAbortExceptioncaught and not rethrown — the fix is to rethrow it in its owncatch, which is not guessable) andnette.strings.regexpPattern(an invalid regular expression). On top of thatextension.neonforces nine flags on, includingcheckMissingCallableSignature,reportMaybesInMethodSignaturesandreportAlwaysTrueInLastCondition— so some errors exist only because this extension is installed. Those are genuine findings; never silence them.
It also registers universalObjectCratesClasses for DefaultTemplate, Database\Row,
SessionSection, SimpleIdentity and Html, so the most common property.notFound in a Nette
app is already solved — don't add @property annotations for those.
Don't add asserts, casts, or @var for errors that fall into these categories:
- Nette helpers:
Strings::match(),Arrays::invoke(),Helpers::falseToNull(),Expect::array(),Htmlmagic methods (setXxx/getXxx/addXxx),Container::getComponent()and$this['name'], Form$form['name'] - Native PHP functions:
|false/|nullremoved where unrealistic (getcwd,json_encode,preg_*, intl/GD/DOM/etc.)- For
preg_*with theumodifier,falsecan genuinely occur on invalid UTF-8 input, yet it is stripped by design — a regex call site should not double as input validation. So a dead=== falsecheck afterpreg_*(identical.alwaysFalse) is not a bug in the extension: refactor to an explicit up-frontpreg_match('##u', $s)validation, the one form wherefalseis preserved.
- For
- After
Tester\Assert:notNull(),type(),true(), etc. narrow the type - Silenced false positives: arrow fns passed to
test()/Assert::exception(), runtime variadic-closure type validation, Form event-handler callbacks with narrow data parameter
Two features require config in phpstan.neon (NOT app's common.neon):
Database row mapping — narrows Explorer::table(), ActiveRow::related(), ::ref() to concrete row classes. Keys may contain a single * wildcard; a bare * is the catch-all and substitutes PascalCase of the table name into * in the value. Exact keys win over wildcards; wildcards are tried in declaration order.
parameters:
nette:
database:
mapping:
tables:
booking: App\Entity\BookingRow # exact match
event_*: App\Entity\Event*Row # event_video → EventVideoRow
*: App\Entity\*Row # catch-all fallback
Asset type narrowing — narrows Registry::getMapper() / getAsset() / tryGetAsset() (and FilesystemMapper::getAsset() / ViteMapper::getAsset()) based on mapper ID and file extension. Values file and vite are shortcuts for the built-in FilesystemMapper / ViteMapper; any other value is treated as an FQCN of a custom mapper class.
parameters:
nette:
assets:
mapping:
default: file # FilesystemMapper
images: file
vite: vite # ViteMapper
custom: App\MyMapper # custom mapper FQCN
Full reference: Nette PHPStan Rules, bundled with the plugin.
Error Resolution Strategy
Resolution Priority
Resolve every error in this order of preference. Only fall back to the next step when the current one genuinely doesn't apply — this ladder is the backbone of the whole skill:
- Refactoring - if an error reveals a design weakness, fix the design first
- phpDoc - if the code is correct but its types are imprecise
assert()- sparingly, only when the type cannot be expressed otherwise- Ignore in
phpstan.neon- for systematic or intentional patterns, always with a comment explaining why - Baseline - last resort, keep minimal
Two hard rules override the ladder at every step:
- Never silence errors - a fix must not hide a potential problem (see "Never Silence Errors" below).
- Never use
@phpstan-ignoreannotations - keep checker-specific directives out of source code; ignore inphpstan.neoninstead.
Agree on the Resolutions First
Before changing code, present the errors grouped by identifier, with the rung of the ladder chosen for each group and the reason.
Refactoring as First Choice
Always ask: does this error reveal a real design issue? Examples:
- Overly broad return types - method returns
mixedorobjectbut always returns a specific type; narrow the return type - Interface too loose - code calls a method on implementation but not on interface; extend the interface
- Mixed responsibilities - class handles too many types; split it
- Unnecessary dynamic access -
__get/__setwhere typed properties would work
The goal is not to "make PHPStan happy" but to use its feedback as a catalyst for better code.
Code Fixes Guidelines
Never Silence Errors
The code worked before. A fix that hides an error degrades code quality.
// Before - json_encode returns false on error and we find out (type error)
function foo(): string {
return json_encode($this->value);
}
// WRONG - error is hidden
function foo(): string {
return (string) json_encode($this->value);
}
Better solutions, in order: use Json::encode(), or add an explicit check that throws. Only when neither applies, fall back to the baseline (last resort, per the resolution priority).
Throw Expression Pattern
// Before - fopen can return false
$f = fopen($file, 'r');
// Correct fix
$f = fopen($file, 'r') ?: throw new IOException("Cannot open file $file");
Beware of /** @var */ in Method Bodies
/** @var Type */ in method body is taken authoritatively by PHPStan - it completely disables type checking for that variable. Use only when no better solution exists.
Don't "refine" bare callable into callable(...mixed): mixed
When PHPStan reports a missing callable signature (missingType.callable), it's tempting to write callable(...mixed): mixed. Don't. That type is narrower than bare callable, not wider, because of parameter contravariance:
callable(...mixed): mixedclaims the callee may be invoked with any arguments, so only callbacks whose parameters are allmixed-compatible (or which have no required typed params) satisfy it.- A normal callback like
function (UiForm $form, mixed $value): void {}is then rejected at call sites:expects callable(mixed...): mixed, Closure(UiForm, mixed): void given.
Bare callable is PHPStan's top type for callables — it accepts anything invokable regardless of signature, and $cb(...$args) inside the function still type-checks. So for "invoke arbitrary user callbacks" APIs keep callable (e.g. @param iterable<callable> $callbacks) and, if missingType.callable fires, ignore it for that file in phpstan.neon with a comment. An explicit signature buys nothing and introduces false positives. (nette/utils Arrays::invoke() is an example.)
The same applies to bare \Closure — when the value is guaranteed to be a closure (stored property, result of Closure::fromCallable(), etc.) but its signature is unknown or intentionally polymorphic, use plain \Closure without parameters. missingType.callable then fires on it too and is ignored on the same grounds.
phpDoc and Type Annotations
For phpDoc conventions (when to skip docs, array types, writing style), see the php-doc skill.
Key rules specific to PHPStan compatibility:
- phpDoc type must always match the native type:
| Native Type | Wrong phpDoc | Correct phpDoc |
|---|---|---|
array|string | mixed[] | mixed[]|string |
array|null | int[] | int[]|null |
object|array | stdClass | stdClass|array |
- Don't use overly granular types (
positive-int,non-empty-string,non-empty-array,non-falsy-string) - they rarely catch real bugs but add significant annotation maintenance burden - Use
class-string<T>,array<string, Foo>,list<int>,array{name: string, age: int}- these are useful for PHPStan and worth maintaining
Array notation preference:
foo[]- always prefer for simple types (shortest notation)array<foo|bar>- for union types (more readable than(foo|bar)[])array<string, foo>orlist<foo>- when keys are not generic
Common Nette Error Patterns
property.nonObject - property access on array|object
In DI Extensions, $this->config returns array|object but is stdClass. This is one of the legitimate cases for /** @var */ in method body - the type cannot be expressed otherwise:
public function loadConfiguration(): void
{
/** @var \stdClass $config */
$config = $this->config;
}
method.notFound / staticMethod.notFound / arguments.count
Calling method on interface that exists only on implementation. Fix type if possible, or use assert():
$component = $container->getComponent($name);
assert($component instanceof Component);
$component->saveState($params);
Note: when accessing components via $this['name'] or $this->getComponent('name') with a constant string and a matching createComponent<Name>() factory on the same class, phpstan-rules narrows the type automatically — no assert needed. The assert pattern above applies when the name is dynamic or the factory lives elsewhere.
property.uninitializedReadonly / property.readOnlyAssignNotInConstructor
Readonly properties initialized via inject methods (Nette DI pattern). Ignore - this is an intentional framework pattern.
new.static - unsafe usage of new static()
If intentional design pattern (derive/factory methods), ignore in phpstan.neon. Or change to new self if subclassing isn't expected.
closure.unusedUse
Variable in use ($var) used in require'd file. Ignore - false positive.
function.alreadyNarrowedType
PHPStan knows the type is already narrowed. Remove unnecessary condition, or ignore if it serves as runtime validation.
catch.neverThrown
Verify if the catch is actually needed. If so, ignore.
Ignoring Errors
Ignoring sits at the bottom of the resolution ladder (see "Resolution Priority") — exhaust refactoring, phpDoc, and assert() first. When ignoring is genuinely the right call, prefer phpstan.neon for systematic or intentional patterns (always with a comment) over phpstan-baseline.neon (last resort, minimize).
Forbidden and Discouraged Suppressions
These rules apply to both phpstan.neon ignoreErrors and phpstan-baseline.neon.
MUST NOT be suppressed — always fix:
phpDoc.parseError— broken phpDoc syntax. Suppressing it leaves the phpDoc permanently unparseable; fix the syntax.argument.templateType— a generic template parameter cannot be inferred from arguments. The template is either misdesigned or redundant; redesign the generic or drop the template parameter.- Anything in
tests/types/*— these files are the library's type contract (TypeAssert/assertType). Suppressing an error here silently invalidates the contract and defeats the purpose of type tests.
SHOULD NOT be suppressed — fix unless truly unavoidable:
missingType.*(e.g.missingType.iterableValue,missingType.parameter,missingType.return) — the type is almost always expressible (array<…>, concrete class,list<>,array{…}). Suppress only when the type genuinely cannot be expressed. Exception:missingType.callablefor "invoke arbitrary user callbacks" APIs (see "Don't refine barecallable" above) — that one is legitimate.parameter.phpDocType— phpDoc type doesn't match native type. This is almost always a real documentation bug; fix the phpDoc rather than hide it.
Systematic Patterns in phpstan.neon
Target ignores narrowly — never write a blank check. An entry like
# WRONG — blanket suppression hides every future method.notFound in this file
- identifier: method.notFound
path: src/Forms/Controls/SubmitButton.php
silences not only the intended pattern but every future legitimate method.notFound in that file — including real typos and broken refactorings.
The model pattern: one bullet = one specific phenomenon
Each entry should describe a single concrete phenomenon — a specific message in a specific scope — not "ignore identifier X in file Y". Constraining tools, in order of strength:
message:— regex matching the exact error message. The strongest safeguard: protects against future drift of different errors with the sameidentifierin the same file. Always include it when the message is reasonably stable.count:— pin the number of occurrences. If a new instance appears (or one disappears), PHPStan reports a mismatch and the developer is forced to look.identifier:— narrows to one error kind.- Path scoping — three forms, choose the most specific:
path: src/Foo/Bar.php— single file (preferred when the phenomenon lives in one file)path: src/Foo/Bar/*— wildcard mask for a directory tree (when the same phenomenon recurs across siblings)paths: [...]— explicit list of files (when the phenomenon lives in a handful of unrelated files)
Important: count: requires path: (singular), not paths: (plural). With a wildcard mask in path: you still get count: — that's the compact form for "this phenomenon appears N times across this tree". With paths: you sacrifice count: for enumeration; compensate with a tight message: regex.
Canonical examples
parameters:
ignoreErrors:
# One phenomenon across a directory tree (wildcard path + count)
- # Latte nodes use new static() by design for extensibility
identifier: new.static
path: src/Bridges/FormsLatte/Nodes/*
count: 6
# One phenomenon across an explicit list of files (paths array + tight message regex)
- # parent::getControl()/getLabel() returns the wider public contract (Html|string|null),
# but BaseControl implementation deterministically returns Html, so chaining is safe.
identifier: method.nonObject
message: '#^Cannot call method \w+\(\) on Nette\\Utils\\Html\|string(\|null)?\.$#'
paths:
- src/Forms/Controls/Checkbox.php
- src/Forms/Controls/CheckboxList.php
- src/Forms/Controls/RadioList.php
# One phenomenon in one file (single path + message + count — strongest form)
- # SubmitButton::getScopeForValidation() walks getParent() which is typed as
# Container|Control; lookupPath() exists on Container at runtime.
identifier: method.notFound
message: '#^Call to an undefined method Nette\\Forms\\Container\|Nette\\Forms\\Control::lookupPath\(\)\.$#'
path: src/Forms/Controls/SubmitButton.php
count: 1
Canonical reference: nette/forms phpstan.neon follows this pattern throughout — use it as the template when refactoring other configs.
Always include a comment explaining why the error is ignored.
Baseline
vendor/bin/phpstan analyse --generate-baseline
Use only for false positives that are not systematic, or individual cases where fix requires BC break.
phpstan.neon Structure
parameters:
level: 8
paths:
- src
excludePaths:
- src/compatibility.php
# other files for historical compatibility
ignoreErrors:
# systematic patterns with comments
includes:
- phpstan-baseline.neon
Exclude files for backward compatibility with historical versions (compatibility.php, Latte 2 support, etc.).
Type Tests
Files in tests/types/*.php verify that types in the library are defined correctly.
Purpose:
- Guarantee that the library won't cause type problems for users
- Protect against unintended type changes during refactoring
- Especially important for complex generics
These tests must always pass and must never be ignored.
Using TypeAssert (from nette/phpstan-rules):
use Nette\PHPStan\Tester\TypeAssert;
TypeAssert::assertTypes(__DIR__ . '/data/types.php');
TypeAssert::assertNoErrors(__DIR__ . '/data/clean.php');
Data file with assertType:
use function PHPStan\Testing\assertType;
assertType('non-empty-string', getcwd());
assertType('string', Normalizer::normalize('foo'));
After the Fixes
Run the tests: a refactoring done for PHPStan can change behavior.
Sponsors
Details
- Marketplace
- nette/claude-code
- Source
- plugins/nette-dev
- Category
- Development