Repository navigation
Highlights
Ahead of 1.0: renamed settings and identifiers
- One naming scheme for diagnostic identifiers.
invalid_member_accessis nowinaccessible_member, the Blade view-variable codes are now*_blade_variable, and so on. The old names keep working, with a warning. - Kebab-case configuration.
[semantic_tokens]is now[semantic-tokens]andreport-magic-propertiesis nowmagic-properties. The old names keep working, with a warning. - Consistent diagnostic messages. Names are written the way PHP spells them, and mismatches read
expects X, got Y. Ignore rules that match onmessagemay need updating. - Mismatches caused only by
nullorfalseare off by default. Turn them back on withpossibly-empty-mismatches = true, which replacesdowngrade-nullable-argument-mismatch. (@stubbedev)
New framework support
- Symfony. Services, parameters, routes, translations, templates, form options, serializer groups and bundle configuration complete, navigate, find references and report unknown names across PHP, YAML, XML and Twig. Container lookups are typed. (@sidux)
- Symfony events and Messenger. Event names lead to their listeners, and message classes link to their handlers. (@sidux, @giuseppe-esposito-87)
- Rename reaches YAML and XML configuration. This covers class, action and namespace renames. (@sidux)
- Doctrine. Entities and fields complete and navigate inside DQL. Query results are typed by what they select,
getRepository()returns the entity's own repository, and magic finders are checked. Entities and repositories link to each other. (@sidux) - Twig everywhere. Templates, blocks, filters, functions and template variables work in any project that uses Twig, not only Symfony.
- Drupal. Services, entity types and fields, hooks, routes, permissions, configuration, plugins, render arrays, theme hooks, libraries and form callbacks complete, navigate and are checked. (@giuseppe-esposito-87)
- WordPress. Hook names navigate between
add_action()anddo_action(),$wpdband the other globals are typed, and core functions return what their arguments ask for.php-stubs/wordpress-stubsworks with no configuration. - Yii 3. Covers Active Record, query tables and columns, DI definitions, routes, views and their parameters, aliases, params, translations and asset bundles.
- Tempest. Covers
.view.phptemplates and components, view data inference, routes and their placeholders, and typed model queries. (@shuvroroy)
Laravel and Blade
- Validation rules. Rules, fields, columns and enum values complete and are checked. (@shuvroroy)
- Eloquent columns. Columns complete in
create([...]),fill([...]), column attributes and queries, with computed attributes left out. (@shuvroroy) - Routes. Resource and singleton routes are known, and a quick fix creates a missing route. (@shuvroroy)
- Rate limiters and morph aliases. Rate limiter names complete and are checked, and morph aliases resolve in morph maps and type-column comparisons. (@shuvroroy)
- Middleware, Inertia pages and asset paths. These complete, navigate and report unknown names.
- Relation callbacks.
whereHas(),whereHasMorph(),withWhereHas()and friends type their closures from the related model, custom builders included. (@shuvroroy) - Collections.
keyBy(),groupBy()andpluck()infer keys and values from property paths. (@shuvroroy) - Singular relationships can be
null.$post->authoris?Authorunless the relation useswithDefault(). (@pataar) - Code lenses for related classes. Models link to their factories, policies, observers and migrations, controller actions list their routes, and events list their listeners.
- Config hover. Hovering a config key shows its value, including what
.envsets it to. - Blade. Code actions work in templates, and a project's own blade-formatter setup is used. Unknown
<x-…>and<livewire:…>components are reported, with a quick fix that renames or creates them. Nested@includes inherit their includer's data. (@zerone0x)
New diagnostics
- Runtime errors caught early. Objects used as strings, functions that can end without returning, unknown named arguments,
from()values no case backs, andmatchexpressions missing a value are now reported. - Class-level checks. Uninitialized typed properties,
#[\Override]with nothing to override, conflicting trait properties,@readonlywrites and discarded#[\NoDiscard]results are reported. - Unused code. Unused private members are reported, and unused parameters can be turned on as an opt-in check.
- Exceptions. Unhandled exceptions can be reported as an opt-in check, with an "Add @throws" fix. A
catchthat nothing in itstrycan throw is reported too. - Tunable strictness.
partial-union-mismatches,docblock-type-mismatchesandpartial-union-memberstune how strict type checks are, andenabled = falseturns diagnostics off.
Testing
- Mocks and Prophecy. Mocked method names complete, navigate and are checked, and Prophecy doubles complete their methods.
- Tests and the classes they test. A code action creates a test for a class, and CodeLens links each class to its tests and back.
- PHPUnit checks. A
setUp()ortearDown()that skips its parent is reported, and so is a data provider PHPUnit cannot call. - Pest.
$thisis the configured test case, and PHPUnit assertions narrow types.
New editor features
- Expected argument values.
#[ExpectedValues]arguments offer their flags and strings first. - Navigation and formatting. Go to declaration, go to an included file, and format selection.
- Import aliases. Alias an import or remove its alias. An aliased import is added when the short name is already taken.
- Explicitly nullable parameters. A quick fix adds the
nullPHP 8.4 now requires. - Deprecated calls.
phpantom_lsp fixrewrites deprecated calls to their replacement across a project. - Filter
analyzeby code. Use--codeand--exclude-code. (@stubbedev) - Member types in completion. Suggestions show their return type next to the name. (@EranNL)
Configuration and indexing
- Stubs that override.
[stubs] pathstakes your own stubs, and Composer stub packages work with no configuration. - Extra include paths.
[indexing] includeindexes hidden or gitignored files. (@joelwurtz) - Monorepos and multi-root workspaces. Each Composer project sees only its own dependencies, and the other workspace folders resolve.
- Turn formatting off. Set
enabled = falseunder[formatting]. (@enwi) - Unknown config keys are reported. Typos in
.phpantom.tomlno longer fail silently.
Performance
- Diagnostics while editing. After an edit inside a function, only that function is checked again. In a 1,500-line class this is about 70 times cheaper.
- Lower memory. Peak memory on a large Laravel project is down by about a fifth. (@vishnub1626) Memory used reading large files is returned right away. (@stubbedev)
- No more pathological slowdowns. Long scripts, lookup tables, method chains, and arrays filled under many
ifs are fast now. A 1,000-armelseifchain went from 20 seconds to a twentieth of a second. analyzeno longer stalls on large projects. Onlaravel/frameworkit now takes about a second instead of 10 to 30. (@stubbedev)
Type inference and fixes
- Smarter types. Each enum case is a type of its own, array shapes are sealed, integer ranges and refined strings survive arithmetic and checks, and class constants work as docblock types.
- Hundreds of fixes across inference, narrowing, generics, closures, name resolution and code actions.
@param-closure-thisunions. (@ace-of-aces)selfin traits. (@pataar)- Caller import leaks. (@arcticfulmar)
- Template assertions #473, by-reference closure writes #474, typed
Closuremethods #465, and?? nullandfinallynarrowing. (@phcorp)
- Rename safety. Renaming one implementation of an interface method is refused in favour of the interface, and a constant and a property of the same name are told apart. (@Deadsquirrel93)
- Editor stability.
- Diagnostics catch up after edits in Neovim and Emacs, and coc.nvim no longer errors. (@stubbedev)
- Inlay hints no longer blink off. (@SuperFes)
- Overlapping searches no longer leave progress stuck. (@lleviathe)
Other
- Mago dependencies updated. (@nguyentranchung)
- README corrections for PHP Tools. (@jakubmisek)
- Benchmark CI improvements. (@shuvroroy)
- A Drupal playground in
examples/drupal/. (@giuseppe-esposito-87)
Thanks
Thanks to everyone who contributed to 1.0: @shuvroroy, @giuseppe-esposito-87, @sidux, @stubbedev, @phcorp, @pataar, @Deadsquirrel93, @joelwurtz, @enwi, @vishnub1626, @ace-of-aces, @zerone0x, @SuperFes, @EranNL, @lleviathe, @arcticfulmar, @nguyentranchung and @jakubmisek.
New Contributors
- @joelwurtz made their first contribution in #336
- @vishnub1626 made their first contribution in #502
- @arcticfulmar made their first contribution in #457
- @Deadsquirrel93 made their first contribution in #493
- @stubbedev made their first contribution in #516
- @jakubmisek made their first contribution in #522
- @ace-of-aces made their first contribution in #444
- @zerone0x made their first contribution in #514
- @giuseppe-esposito-87 made their first contribution in #532
- @lleviathe made their first contribution in #552
- @pataar made their first contribution in #572
Full Changelog: 0.11.1...1.0.0