Skip to content

1.0.0

Latest

Choose a tag to compare

@AJenbo AJenbo released this 23 Nov 13:28
· 4 commits to main since this release
Immutable release. Only release title and notes can be modified.

Highlights

Ahead of 1.0: renamed settings and identifiers

  • One naming scheme for diagnostic identifiers. invalid_member_access is now inaccessible_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] and report-magic-properties is now magic-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 on message may need updating.
  • Mismatches caused only by null or false are off by default. Turn them back on with possibly-empty-mismatches = true, which replaces downgrade-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() and do_action(), $wpdb and the other globals are typed, and core functions return what their arguments ask for. php-stubs/wordpress-stubs works 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.php templates 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() and pluck() infer keys and values from property paths. (@shuvroroy)
  • Singular relationships can be null. $post->author is ?Author unless the relation uses withDefault(). (@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 .env sets 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, and match expressions missing a value are now reported.
  • Class-level checks. Uninitialized typed properties, #[\Override] with nothing to override, conflicting trait properties, @readonly writes 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 catch that nothing in its try can throw is reported too.
  • Tunable strictness. partial-union-mismatches, docblock-type-mismatches and partial-union-members tune how strict type checks are, and enabled = false turns 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() or tearDown() that skips its parent is reported, and so is a data provider PHPUnit cannot call.
  • Pest. $this is 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 null PHP 8.4 now requires.
  • Deprecated calls. phpantom_lsp fix rewrites deprecated calls to their replacement across a project.
  • Filter analyze by code. Use --code and --exclude-code. (@stubbedev)
  • Member types in completion. Suggestions show their return type next to the name. (@EranNL)

Configuration and indexing

  • Stubs that override. [stubs] paths takes your own stubs, and Composer stub packages work with no configuration.
  • Extra include paths. [indexing] include indexes 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 = false under [formatting]. (@enwi)
  • Unknown config keys are reported. Typos in .phpantom.toml no 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-arm elseif chain went from 20 seconds to a twentieth of a second.
  • analyze no longer stalls on large projects. On laravel/framework it 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.
  • 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

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

Full Changelog: 0.11.1...1.0.0