Repository navigation
Phoxite 0.8.0
-
CodeIgniter (4, and 3). In a CodeIgniter application the names its helper functions
take are references: views (view(),$this->extend(),$this->include(), a
module'sBlog\Views\list), helpers (helper(),$helpers), language lines
(lang('File.key')), routes (route_to(),redirect()->route()↔ theasof a
route, its path when it has none, or its handler), filter aliases ('filter' => 'auth'
↔Config\Filters::$aliases), configurations, models, services, view cells
(view_cell('Card::render')), events (Events::on()↔Events::trigger()),
validation rules (each rule of'required|min_length[3]'↔ the methods of the rule
sets) and rule groups, tables and columns ($db->table('books'), a model's$table
and$allowedFields,->where('title', …)↔ the migrations), and a route's handler
('Books::show/$1', in the namespace of its group). Each goes to what it names and has
Find References and a hover; a route name, a filter alias and an event are renamed.- Types:
service('name'),model('BookModel')andconfig('App')are the service,
the model and the configuration class; a model'sfind(),first()andfindAll()
follow its$returnType;$db->table('books')is a builder of that table. - A view has the variables its controller passes it, with their types
(view('books/list', ['books' => $books])), as have the layout it extends and the
views it includes. They aren't reported as undefined. - Inspections for a name that names nothing:
PhpUndefinedCodeIgniterView,
PhpUndefinedCodeIgniterHelper,PhpUndefinedCodeIgniterLanguageLine,
PhpUndefinedCodeIgniterRoute,PhpUnknownCodeIgniterFilter,
PhpUndefinedCodeIgniterController,PhpUnknownCodeIgniterRule,
PhpUnknownCodeIgniterRuleGroup,PhpUndefinedCodeIgniterModel,
PhpUndefinedCodeIgniterConfig,PhpUndefinedCodeIgniterService,
PhpUndefinedCodeIgniterCell. Off unless turned on, as what they look for may be
defined outside the project:PhpUndefinedCodeIgniterEvent,
PhpUnknownCodeIgniterTable,PhpUnknownCodeIgniterColumn. - Several columns in one string (
select('title, price')), a column in an expression
(where('COUNT(price) >', 3)), the table and field ofis_unique[books.title], the
routesresource()andpresenter()make, and a path (site_url('books/show'),
redirect()->to(): its route, else the method auto-routing would call) are names too. - Modules (the
$psr4ofConfig/Autoload.php, Composer's namespaces) bring their
views, helpers, language files and routes;Config/Paths.phpsays where a moved
app,systemor views folder is. - CodeIgniter 3:
$this->load->view(),->model(),->library(),->helper(),
$this->lang->line(),$this->config->item()and the path ofsite_url()and
redirect()are references;$this->load,$this->db,$this->session, a loaded
model (under its own name or another) and a library of the application are typed in
controllers, models and views; a path goes through the routes ofconfig/routes.php;
the tables and fields ofapplication/migrationsare the names of$this->db's
methods.
- Types:
-
A property a framework gives a class isn't reported as undefined, and a string in PHP
embedded in markup (<a href="<?= site_url('books') ?>">) is found where it was taken
for part of the attribute. -
An inline
/** @var Type $name */declares a variable that nothing in the file sets
($routesat the top of a routes file), instead of only retyping one that exists. -
Drupal (8 and later). In a Drupal site, or a module or theme opened on its own, the
names its YAML files declare are references: services (\Drupal::service(),
$container->get()), routes (Url::fromRoute(),redirect(),setRedirect()),
permissions, libraries ('#attached' => ['library' => […]]), configuration and
modules. So are the entity types and plugins that attributes and annotations declare,
the theme hooks ofhook_theme()('#theme' => '…', with the template), and hooks
(invokeAll(),alter(),#[Hook]↔ thehook_…()function). Each completes, goes
to its declaration, has Find References and a hover; services, routes, permissions and
libraries are renamed with the YAML files that name them.- Types:
\Drupal::service('id')and$container->get('id')are the service's
class;getStorage('node')is the entity type's storage, and what it loads is the
entity; the parameters of a hook's implementation (mymodule_form_alter(), a method
with#[Hook]) have the types the hook's function gives them. .module,.install,.theme,.profile,.engineand.incfiles are PHP: they
are indexed, the server watches them, and the VS Code extension opens them as PHP.- The
templatesfolder of a module or theme is the Twig namespace of its name
(@shop/card.html.twig). - The YAML files are answered in too: Go to Definition, hover, Find References, Rename
and completion on the services, routes, permissions and libraries they name, and
Go to Definition on their classes and controller methods. The server asks the client
for*.ymlfiles only while a Drupal project is open. - Configuration keys (
\Drupal::config('shop.settings')->get('mail.from')), the
plugins a links or layouts file declares, derivative plugin ids, theme hook
suggestions (node__article) and the preprocess functions of a theme hook. - Go to Definition on the name of a function implementing a hook goes to the hook.
- A template completes the variables its theme hook declares, and
attach_library('…')in it is a library. *.api.phpfiles, which document hooks as empty functions, no longer report unused
parameters.- A template's variable has the type a preprocess function assigns it
($variables['book'] = …), so{{ book.title }}completes. - A configuration only a schema describes (
config/schema) has its name and keys;
migrations and breakpoints are plugins; a#[Hook]on a class types the method it
names. - In a YAML file, a line is read under the key above it (list items, bracketed lists
over several lines),service.id:methodis a service and its method, and class
names complete afterclass:and_controller:. - Drupal 7: a site or a module with a
.infofile is detected;module_invoke_all(),
drupal_alter(),theme(),user_access()andmodule_exists()name hooks, theme
hooks, permissions (hook_permission()) and modules, and a hook's implementation
is typed and goes to its hook. - More of Drupal 7: menu paths (
drupal_goto('admin/shop')↔hook_menu(), also
through%placeholders), variables (variable_get()↔variable_set()), a form's
function indrupal_get_form(), and its.infofiles (dependencies[],files[]). ->get('key')on a configuration has the type its schema gives the key; a template's
variable has the type a render array passes it ('#book' => $book).- In a YAML file, a mapping in braces and an alias (
*defaults) are read. - Database tables:
db_select('node')and the connection'sselect(),insert()…
go to the table's entry inhook_schema(), and a column of a query
($query->condition('n.nid', 5),->fields('n', ['title'])) goes to its field
there and completes, along a chain of calls and through the alias of a joined table
(u.uidafter->join('users', 'u', …)). - A configuration key also takes its type from the value a file installs; a render
array built up in a function ($build['#book'] = $book) types its template's
variable. - Nothing of Drupal is bundled.
- Types:
-
The YAML reader follows anchors and aliases (
&defaults,*defaults) and merges
<<: *defaults: a Symfony or Drupal service defined that way has its class. -
A callback under a key named as one (
callback,…_callback,…_cb,page callback) is a callable in any array, not only one that is a call's argument:
$items['x'] = ['access callback' => 'my_access'];. -
A string under a key of an array can be a reference wherever the array is written
(CalleePattern::Entry): Drupal's render arrays use it. -
WordPress. In a WordPress project (its core, a plugin or a theme), the names
WordPress keeps in its registries are references: hooks (add_action('init', …)↔
do_action('init'), filters alike), shortcodes, post types, taxonomies, script and
style handles, options, image sizes, menu locations, blocks (registered in PHP or
declared by ablock.json) and REST routes (rest_url('shop/v1/books')↔
register_rest_route('shop/v1', '/books'), patterns in the route included). A
list of names counts where one is taken (is_singular(['book', 'page']),
'post_type' => ['book']). Each completes, goes to the
call that fires or registers it, has Find References and a hover, and is renamed when
the project declares it itself (not a name of WordPress or of a library). A hook fired
under a name put together at run time ("save_post_{$post->post_type}") is found by
its pattern.get_template_part('template-parts/content', 'page')goes to the theme's file and
completes the theme's templates. So doget_header('shop'),get_footer(),
get_sidebar(),locate_template(),get_theme_file_path()and
get_theme_file_uri(). A child theme's file is looked for first, then its parent's.- Find References lists the project's scripts too, searched as text: a block's name, a
REST route's path, and theactionof an AJAX request for itswp_ajax_…hook.
Renaming a block, the last part of a REST route or the action of an AJAX hook
changes PHP, the scripts and theblock.json. - In a script and in a
block.json, a string naming a block, a REST route or an AJAX
action has Go to Definition, hover, Find References, Rename and completion. The
server asks the client for those documents only while a WordPress project is open
(it registers for them, and unregisters when none is left): in other projects
scripts aren't sent to it. - A hook's callback knows what the hook passes: the parameters of a closure given to
add_action()oradd_filter(), and of a function or method registered by name
('shop_saved',[$this, 'saved']), take the types the docblock at the firing call
documents. global $wpdb, $post;has the types the@globaltags document: the function's
own, else what the project's functions (WordPress's among them) say of that name.
So have$GLOBALS['wpdb']and a variable a file reads at its top level without
setting it (a theme's template reads$post). This holds in any PHP project.- Callbacks given under a key of an array (
register_rest_route(…, ['callback' => [$this, 'run']]),sanitize_callback,render_callback…) are string callables
like the others. PhpUndefinedHookreports a hook listened to that nothing fires. It is off until
turned on ("PhpUndefinedHook": { "enabled": true }): a hook may be fired by a
plugin that isn't in the workspace.
Nothing of WordPress is bundled. A plugin or theme opened on its own knows WordPress's
functions and hooks from a stubs package installed with Composer
(php-stubs/wordpress-stubs) or from a WordPress folder named inincludePaths. -
The status item names the frameworks of the open projects (
Phoxite: WordPress,
Phoxite: Laravel, Symfony), not only Laravel. The server says them in
phoxite/laravel/statusandphoxite/laravel/statusChanged(frameworks). -
The
stubssetting's description no longer names awordpressstub set: there is
none. -
A string that names a function or a method where a callable is expected is a name like
any other:array_map('App\\trim_all', …),call_user_func('Foo::make'),
usort($rows, [$this, 'compare']),[Foo::class, 'make']. Go to Definition and hover
work on it, Find References counts it, and renaming the function, the method or the
class changes it (before, a rename left these strings as they were). Function names
complete inside such a string, and method names in[$o, '…']and after'Foo::. The
same for a string a function declared to return a callable returns, and one assigned to
a property typed as a callable. Only where a callable is expected and nothing else a
string could be: forcallable|stringthe string is left alone. -
In a Symfony project, the template names PHP writes (
render(),renderView(),
renderBlock(),renderForm(),stream()on a controller;render(),display(),
load()on Twig's environment) complete, go to the template, and have Find References
(the PHP strings and the templates naming it) and hover. -
PhpUndefinedTemplate: a Twig template PHP names that the project's template folders
don't have. Not for a@Namespace/…name, which can be a bundle's, nor in a project
without any template. -
#[Template('page.html.twig')]names a template, and#[Autowire(service: 'mailer')]
and#[Autowire(param: 'app.locale')]a service and a parameter: an attribute's
arguments are read like a call's. -
Service ids and parameters are renamed: the key in the YAML file, the PHP strings, the
attributes, and@mailer/%app.locale%in the YAML files belowconfig/, which are
Find References' too. A service whose id is its class name isn't renamed this way. -
XLIFF (
.xlf,.xliff; 1.2 and 2.0) and JSON translation catalogues are read beside the
YAML ones, and translation keys complete before|transin a template. -
Translation keys are renamed: in every catalogue, in PHP and in the templates. Of a
nested key (form: { title: … }) the last part is renamed, to a name without a dot. -
A service after
alias:orparent:in a YAML file is a usage of it, and the
parameters and services of the files inconfig/packagesare known without a services
file importing them. -
In a template, a member of what the controller passes (
post.title,post.author.name)
has a hover with its type and goes to the property, or to the getter Twig calls. -
The usages of a route, a template or a translation key, and their renames, read a Twig
template with unsaved changes as the editor has it. -
A Twig template knows what the controller rendering it passes: the keys of
render('page.html.twig', ['post' => $post])complete as variables with their types, and
after a.the public properties and methods of the variable's class do, a getter under
the name Twig reads it by (getTitle()astitle). A{% for %}loop's variable is an
element of what the loop goes through. -
The filters, functions and tests a project's own Twig extensions add (
new TwigFilter('price', …),#[AsTwigFilter('price')]) complete in templates, and go to
where PHP names them. -
Translation keys (
$translator->trans('form.title'),new TranslatableMessage(…),
t(), and'form.title'|transin a template) complete from the YAML catalogues of
translations/, go to the key in every locale, and have Find References and a hover
with the translations. -
Doctrine: a property with
#[ORM\OneToMany(targetEntity: Comment::class)]or
#[ORM\ManyToMany]declared as a bareCollectionis aCollection<int, Comment>, and
one with#[ORM\ManyToOne]or#[ORM\OneToOne]and no class in its type is the target.
The keys of a repository'sfindBy([...]),findOneBy([...])andcount([...])complete
with the entity's fields and go to the property. -
Service ids (
$container->get('mailer'),has()) and parameters (getParameter('app.locale'),
a parameter bag'sget()) complete from the project's services files, go to their key in
the YAML file, and have Find References and hover. They aren't renamed yet. -
Rename of a Twig template, from PHP or from a template naming it: the file moves, and its
name changes in every PHP string and every{% extends %},{% include %}and the like. -
Route names inside a template's
path('…')andurl('…')complete, go to the route,
and are usages of it: Find References on a route lists the templates too, and renaming a
route renames it there. -
Twig templates (
*.twig) are served: the outline; completion of tags, filters,
functions, tests, the variables and macros in scope and template names; hover on the
built-ins and on macros; Go to Definition for template names, macro calls and the block a
block overrides; Find References on a template name; Rename of a block (in every template
of itsextendsandusefamily) and of a macro (where it is declared, imported and
called); Format Document, which indents every line by the HTML elements and Twig blocks around it
and puts the spacing inside the tags right ({{x|upper}}→{{ x|upper }}), without
moving anything to another line (the code of a<script>or a<style>is indented by
its brackets); semantic tokens; and
syntax errors as you type. A tag Twig itself doesn't have is not an error, since
extensions add tags, and"TwigSyntax": { "enabled": false }underinspectionsturns
the errors off. With Symfony's Twig bridge installed, its tags, filters and functions
are known too. None of it needs the index. -
Format Document can use the project's Prettier for Twig templates:
format.twig
(phoxite.format.twigin VS Code) set toprettierrunsnode_modules/prettieron the
template's text, with the project's Prettier configuration and its Twig plugin
(@zackad/prettier-plugin-twig, say). Prettier also rewraps lines and formats the
JavaScript and CSS inside, which the built-in formatter doesn't. In a trusted workspace
only; without Prettier, for a selection, and when Prettier fails, the built-in formatter
answers.analyzers.nodePathnames the Node.js that runs it (nodeonPATHwhen
empty). Tested against a stand-in and, by hand, against Prettier 3 with that plugin. -
The VS Code extension has a Twig language: highlighting in the text, inside HTML tags
and attribute values and in scripts and styles, snippets for the tags, and a warning when
another extension defines the language too. -
phoxite-lsp checkreports the syntax errors of the Twig templates in the project's
template folders (TwigSyntax). -
Clients are asked to watch
*.twigand the YAML files belowconfig/: a route or a
service added to a YAML file outside the editor is known without a restart. -
Symfony route names (
generateUrl(),redirectToRoute(), a URL generator's
generate(),path()andurl()) have Go to Definition, Find References, Rename and
hover: to the key in a YAML routes file or thenameof the#[Route]attribute.
Renaming a route whose class has a name prefix changes the part the attribute writes.
Completion and the undefined-route warning work as before. -
Completion, hover, Go to Definition and Rename work in strings inside attributes
(#[Route('/x', name: 'home')]): the#of#[was read as the start of a comment. -
A new setting,
frameworks(phoxite.frameworksin VS Code), turns each framework's
supportenabledordisabled;auto, the default, detects it.frameworks.laravel
wins overlaravel.detectionunless it isauto. Laravel, Symfony,
WordPress, Drupal and CodeIgniter have support today; the other names (yii,
cakephp,laminas,magento) are read now and take effect as each one's support is
released.