Skip to content

0.11.1

Latest

Choose a tag to compare

@AJenbo AJenbo released this 07 Oct 04:25
· 93 commits to main since this release
Immutable release. Only release title and notes can be modified.

PHPantom 0.11.1

Highlights

New editor features

  • Unreachable code is dimmed. Code that can never run, such as statements after a return or throw, is greyed out the way an unused import is (@petrovo-as).

Laravel

  • Translations across locales. Navigation, completion and hover work across JSON and PHP language files and every locale, and a missing key gets a quick fix when its PHP group file exists (@shuvroroy).
  • Package translations. Paths registered with loadTranslationsFrom() now support completion, navigation, hover and key diagnostics (@shuvroroy).
  • Config keys set by a package's provider. A key set with config([...]) or Config::set() is known, so auth('sanctum') is no longer reported as an unknown guard.

Blade

  • Fewer false syntax errors. An Alpine or Vue :attr binding on a plain HTML tag is no longer parsed as PHP, and a directive newer than your Laravel is plain text, so a JSON-LD "@context" key no longer produces syntax errors before Laravel 11.
  • @break and @continue keep their condition. @break($done) and @continue($skip) now only jump when the condition holds.
  • @use imports. The first import no longer breaks a template that opens with a block, unused imports are dimmed and removed by phpantom_lsp fix, and a group wrapped over several lines no longer shifts the lines below it.
  • Stable analyze output. Blade diagnostics no longer vary between runs and now match what the editor shows.

Type checking

  • match (true) arms know the arms above them. default => strtoupper($name) no longer reports $name as possibly null (@phcorp, #464).
  • Type checks narrow properties. is_resource($this->stream) narrows a resource|null property the way it narrows a variable (@phcorp, #466).
  • Integer range() calls are lists of integers. array_map(fn (int $i) => …, range(0, $n - 1)) no longer reports that the callback is passed int|float (@phcorp, #467).
  • More accurate narrowing. in_array() only narrows by what the list proves, match arms narrow the way the equivalent if does, and a ternary to the right of && or || sees what the left side proved.
  • Unsealed array shapes are checked. A type such as array{foo: int, ...} no longer accepts any non-empty array, and the entries it lists must fit the typed array it is passed to.

Code actions

  • Safer class moves. In the editor and with phpantom_lsp move, moves that would pull other declarations into the new namespace, or break a file with several namespace blocks, are refused, and the rest touch only their own block.
  • Imports respect each namespace block. In a file with several namespace blocks, new imports go into the block that needs them, and an import only another block uses is dimmed as unused.
  • Member actions appear at column 0. Actions on a property or method, such as getter/setter and visibility, are now offered with the cursor at column 0 or on a whole-line selection.

Configuration and indexing

  • PHP_CodeSniffer only runs where you use it. A vendor/bin/phpcs installed by another package no longer produces warnings unless squizlabs/php_codesniffer is in require-dev, a ruleset file exists, or .phpantom.toml sets [phpcs] standard.
  • laravel-ide-helper files are skipped. _ide_helper.php and _ide_helper_models.php are no longer indexed, since PHPantom resolves facades and models natively; list them with a leading ! in [indexing] exclude to index them anyway.
  • Files outside the project no longer break indexing. A PHP file opened from elsewhere, or a change in another workspace folder, no longer stops the server when the configuration changes.

Performance

  • Blade indexing. Templates with no DocBlock declaring their variables are indexed much faster, with the work spread across every core.
  • Long scripts and large classes. A long file of top-level code no longer takes minutes and gigabytes of memory to analyze, and untyped methods in a large generated class are inferred much faster.
  • Files full of diagnostics. Files full of calls to undefined functions no longer take minutes to analyze, and files that produce thousands of diagnostics report them much faster.
  • Untyped code. Code lenses, hover and diagnostics are faster in projects where untyped methods call other untyped methods.

Other

  • Pragtical setup guide. The editor setup guide now covers Pragtical (@juliardi).
  • Non-ASCII class names. An import such as use App\Models\Øl; no longer stops a file's diagnostics and code actions.
  • Watched files. A function declared in a file created or changed on disk is found right away instead of being reported as undefined.
  • \extract() and \compact(). Both are recognised with a leading backslash, so the variables they define or read are no longer reported as undefined or unused.

Thanks

Thank you to everyone who contributed to this release:

  • @phcorp for the match, type-check and range() fixes
  • @petrovo-as for dimming unreachable code and a visibility-check cleanup
  • @shuvroroy for the Laravel translation work
  • @juliardi for the Pragtical setup guide

Full changelog: https://github.com/PHPantom-dev/phpantom_lsp/blob/main/docs/CHANGELOG.md