php

package
v0.0.0-...-0c0f0b0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const PHPContextKey phpContextKey = "php.context"

PHPContextKey is the key used to store PHP context in the context.Context

Variables

This section is empty.

Functions

func AssistantArgumentReference

func AssistantArgumentReference(
	ctx context.Context,
	node *phpsyntax.Node,
	tag string,
) (cst.TextRange, bool)

AssistantArgumentReference recognizes a direct string argument whose resolved function, constructor, or method parameter carries the requested PHPDoc assistant tag, such as #Route or #Service. Parameter tags declared on inherited interfaces, parents, and traits are included.

func AssistantArgumentTags

func AssistantArgumentTags(
	ctx context.Context,
	node *phpsyntax.Node,
	tags ...string,
) (cst.TextRange, []string)

AssistantArgumentTags recognizes a direct string call argument and returns the requested assistant tags carried by its resolved parameter. Resolution includes function, constructor, method, named/variadic argument, and inherited parameter contracts.

func AssistantSiblingStringArgument

func AssistantSiblingStringArgument(
	ctx context.Context,
	node *phpsyntax.Node,
	tag string,
) (string, bool)

AssistantSiblingStringArgument returns the direct string value passed to a parameter carrying tag on the same resolved call. It is used by contracts such as #TranslationKey, whose key domain is supplied by a sibling #TranslationDomain parameter.

func DebugAST

func DebugAST(filePath string)

DebugAST parses a PHP file and prints the pure-Go CST structure.

func GuessedControllerTemplate

func GuessedControllerTemplate(
	root,
	method *phpsyntax.Node,
) string

GuessedControllerTemplate returns Symfony's conventional template name for a controller method with an empty #[Template] attribute.

func ReferenceAt

func ReferenceAt(document *semantic.Document, offset uint32) (semantic.Reference, bool)

func SymbolAt

func SymbolAt(
	document *semantic.Document,
	snapshot *semantic.Snapshot,
	offset uint32,
) (semantic.Symbol, bool)

SymbolAt resolves a declaration or linked name reference at a byte offset.

Types

type EmbeddedCSSSelector

type EmbeddedCSSSelector = EmbeddedPHPString

EmbeddedCSSSelector names a decoded static PHP string recognized as a CSS selector by a typed Symfony DomCrawler or CssSelector call.

func EmbeddedCSSSelectors

func EmbeddedCSSSelectors(
	index *PHPIndex,
	path string,
	version int,
	source string,
	root *cst.Node,
) []EmbeddedCSSSelector

EmbeddedCSSSelectors recognizes the CSS selector signatures injected by the reference plugin: Crawler::filter(), Crawler::children(), and CssSelectorConverter::toXPath().

type EmbeddedJSONLiteral

type EmbeddedJSONLiteral = EmbeddedPHPString

EmbeddedJSONLiteral names an EmbeddedPHPString recognized in a Symfony JsonResponse JSON entry point.

func EmbeddedJSONLiterals

func EmbeddedJSONLiterals(
	index *PHPIndex,
	path string,
	version int,
	source string,
	root *cst.Node,
) []EmbeddedJSONLiteral

EmbeddedJSONLiterals returns direct, static string arguments of JsonResponse::fromJsonString() and JsonResponse::setJson(). Receiver types are resolved semantically, so aliases and subclasses are supported while unrelated methods with the same name are ignored.

type EmbeddedLanguage

type EmbeddedLanguage uint8
const (
	EmbeddedLanguageJSON EmbeddedLanguage = iota + 1
	EmbeddedLanguageCSS
	EmbeddedLanguageXPath
)

type EmbeddedLanguageString

type EmbeddedLanguageString struct {
	EmbeddedPHPString
	Language EmbeddedLanguage
}

func EmbeddedLanguageStrings

func EmbeddedLanguageStrings(
	index *PHPIndex,
	path string,
	version int,
	source string,
	root *cst.Node,
) []EmbeddedLanguageString

EmbeddedLanguageStrings recognizes all static PHP argument signatures used by the reference plugin's JSON, CSS selector, and XPath injections. It scans the CST and performs semantic receiver analysis once per document.

type EmbeddedPHPString

type EmbeddedPHPString struct {
	Value         string
	ContentRange  cst.TextRange
	SourceOffsets []uint32
}

EmbeddedPHPString is a decoded, static PHP string. SourceOffsets maps each decoded byte boundary back to the corresponding absolute byte offset in the PHP document, so embedded parser ranges remain exact through PHP escapes.

func (EmbeddedPHPString) SourceRange

func (literal EmbeddedPHPString) SourceRange(
	embedded cst.TextRange,
) cst.TextRange

SourceRange maps a byte range in Value back into the host PHP document.

type EmbeddedXPathExpression

type EmbeddedXPathExpression = EmbeddedPHPString

EmbeddedXPathExpression names a decoded static PHP string recognized as an XPath expression by a typed Symfony DomCrawler call.

func EmbeddedXPathExpressions

func EmbeddedXPathExpressions(
	index *PHPIndex,
	path string,
	version int,
	source string,
	root *cst.Node,
) []EmbeddedXPathExpression

EmbeddedXPathExpressions recognizes the reference plugin's Crawler filterXPath() and evaluate() injection signatures.

type NameResolver

type NameResolver struct {
	// contains filtered or unexported fields
}

NameResolver is the compatibility-free project-facing wrapper around the semantic PHP name resolver. Symfony configuration indexing uses it without depending on binder internals.

func NameResolverFor

func NameResolverFor(ctx context.Context, root *phpsyntax.Node) *NameResolver

NameResolverFor returns the import resolver for root, sharing one resolver through the request's PHP context when the same tree is queried repeatedly. Reference lookups inspect many literals of one document; building a fresh resolver per literal re-walks the whole syntax tree each time.

func NewNameResolver

func NewNameResolver(root *phpsyntax.Node) *NameResolver

func (*NameResolver) Namespace

func (r *NameResolver) Namespace() string

func (*NameResolver) Resolve

func (r *NameResolver) Resolve(name string) string

type PHPContext

type PHPContext struct {
	InsideClass *semantic.Symbol
	Node        *phpsyntax.Node
	Document    *semantic.Document
	Snapshot    *semantic.Snapshot
	// contains filtered or unexported fields
}

func GetPHPContext

func GetPHPContext(ctx context.Context) *PHPContext

type PHPIndex

type PHPIndex struct {
	// contains filtered or unexported fields
}

PHPIndex owns the persisted compact workspace graphs and publishes immutable workspace snapshots. A document update becomes visible only after the shared index transaction commits.

func NewPHPIndex

func NewPHPIndex(configDir string, stores ...*indexer.Store) (*PHPIndex, error)

func (*PHPIndex) AddAnalyzedDocumentContext

func (p *PHPIndex) AddAnalyzedDocumentContext(
	ctx context.Context,
	node *phpsyntax.Node,
	document *semantic.Document,
) context.Context

AddAnalyzedDocumentContext enriches a context with an existing linked document. Request-time LSP features use it to share one semantic analysis instead of rebuilding the same open document for assistant-tag queries.

func (*PHPIndex) AddAnalyzedSnapshotContext

func (p *PHPIndex) AddAnalyzedSnapshotContext(
	ctx context.Context,
	node *phpsyntax.Node,
	document *semantic.Document,
	snapshot *semantic.Snapshot,
) context.Context

AddAnalyzedSnapshotContext enriches a request with a semantic document and its already-constructed overlay snapshot. LSP requests use this boundary to share one revision-aware analysis instead of rebuilding the open document and its overlay for every provider fan-out.

func (*PHPIndex) AddContext

func (p *PHPIndex) AddContext(ctx context.Context, node *phpsyntax.Node, documentContent []byte) context.Context

func (*PHPIndex) AddDocumentContext

func (p *PHPIndex) AddDocumentContext(
	ctx context.Context,
	path string,
	version int,
	node *phpsyntax.Node,
	root *phpsyntax.Node,
) context.Context

func (*PHPIndex) AddParsedFileContext

func (p *PHPIndex) AddParsedFileContext(
	ctx context.Context,
	file *indexer.ParsedFile,
	node *phpsyntax.Node,
) context.Context

AddParsedFileContext enriches a context with the semantic document shared by indexers preparing one immutable file.

func (*PHPIndex) AnalyzeDocument

func (idx *PHPIndex) AnalyzeDocument(
	path string,
	version int,
	root *phpsyntax.Node,
) *semantic.Document

AnalyzeDocument creates an unsaved-document overlay and links it against a workspace generation containing the overlay's declarations.

func (*PHPIndex) AnalyzeParsedFile

func (idx *PHPIndex) AnalyzeParsedFile(
	file *indexer.ParsedFile,
) *semantic.Document

AnalyzeParsedFile returns the fully linked semantic document shared by indexers preparing the same immutable file. FileScanner releases the cached value before persistence begins, so semantic documents do not become long-lived index state.

func (*PHPIndex) BeginIndexingBatch

func (idx *PHPIndex) BeginIndexingBatch(candidateFiles []string)

BeginIndexingBatch defers immutable workspace publication until all file transactions in the scanner run have either committed or rolled back.

func (*PHPIndex) ClassNames

func (idx *PHPIndex) ClassNames() []string

func (*PHPIndex) ClassNamesView

func (idx *PHPIndex) ClassNamesView() []string

ClassNamesView is the immutable counterpart of ClassNames for request paths that only read the workspace class-name catalog.

func (*PHPIndex) ClassSymbols

func (idx *PHPIndex) ClassSymbols() []semantic.Symbol

ClassSymbols returns all source class-like declarations in deterministic name/path order. Internal runtime stub classes are omitted.

func (*PHPIndex) ClassSymbolsIn

func (idx *PHPIndex) ClassSymbolsIn(path string) []semantic.Symbol

func (*PHPIndex) ClassSymbolsView

func (idx *PHPIndex) ClassSymbolsView() []semantic.Symbol

ClassSymbolsView returns an immutable generation-scoped view of source class-like declarations. Callers must not modify the slice or its symbols. Repeated diagnostics can share this view without rematerializing the entire PHP workspace catalog for every document.

func (*PHPIndex) Clear

func (idx *PHPIndex) Clear() error

func (*PHPIndex) ClearIn

func (idx *PHPIndex) ClearIn(mutation *indexer.Mutation) error

func (*PHPIndex) Close

func (idx *PHPIndex) Close() error

func (*PHPIndex) ConfigureProject

func (idx *PHPIndex) ConfigureProject(root string) error

ConfigureProject loads Composer roots/version information and publishes the matching runtime stub document.

func (*PHPIndex) ConfigureProjectWithExtensions

func (idx *PHPIndex) ConfigureProjectWithExtensions(
	root string,
	enabled,
	disabled []string,
) error

func (*PHPIndex) ConstantSymbolName

func (idx *PHPIndex) ConstantSymbolName(
	symbol semantic.Symbol,
) string

ConstantSymbolName renders a global or class constant as it appears in Symfony configuration.

func (*PHPIndex) ConstantSymbols

func (idx *PHPIndex) ConstantSymbols() []semantic.Symbol

ConstantSymbols returns all constant declarations in deterministic display-name/path order.

func (*PHPIndex) Constants

func (idx *PHPIndex) Constants(
	className string,
) []semantic.Symbol

Constants returns every constant visible on a class, including inherited constants and enum cases.

func (*PHPIndex) EndIndexingBatch

func (idx *PHPIndex) EndIndexingBatch() error

EndIndexingBatch publishes every successfully committed PHP document in one generation. Nested batches are supported for direct coordinator reuse.

func (*PHPIndex) FindClass

func (idx *PHPIndex) FindClass(name string) (semantic.Symbol, bool)

FindClass returns the preferred class-like declaration for a fully qualified PHP name. Source declarations win over internal runtime stubs.

func (*PHPIndex) FindConstants

func (idx *PHPIndex) FindConstants(
	className,
	constantName string,
) []semantic.Symbol

FindConstants resolves a class constant or enum case, including inherited and trait declarations.

func (*PHPIndex) FindGlobalConstants

func (idx *PHPIndex) FindGlobalConstants(
	name string,
) []semantic.Symbol

FindGlobalConstants returns declarations for a fully qualified global constant name.

func (*PHPIndex) FindMethods

func (idx *PHPIndex) FindMethods(
	className,
	methodName string,
) []semantic.Symbol

FindMethods resolves a method on a class, including inherited and trait methods, and returns specialized parameter types for generic ancestors.

func (*PHPIndex) FindProperties

func (idx *PHPIndex) FindProperties(
	className,
	propertyName string,
) []semantic.Symbol

FindProperties resolves a property on a class, including inherited and trait declarations.

func (*PHPIndex) ID

func (idx *PHPIndex) ID() string

func (*PHPIndex) Index

func (idx *PHPIndex) Index(file *indexer.ParsedFile) error

func (*PHPIndex) IndexPrepared

func (idx *PHPIndex) IndexPrepared(
	file *indexer.ParsedFile,
	value any,
) error

func (*PHPIndex) IsMethodCalledName

func (s *PHPIndex) IsMethodCalledName(ctx context.Context, node *phpsyntax.Node, content []byte, methodNames ...string) bool

func (*PHPIndex) IsMethodCalledOnClass

func (s *PHPIndex) IsMethodCalledOnClass(ctx context.Context, node *phpsyntax.Node, content []byte, className string) bool

func (*PHPIndex) IsSubtypeOf

func (idx *PHPIndex) IsSubtypeOf(className, targetName string) (bool, error)

IsSubtypeOf reports whether className is targetName, extends it, or implements it through the workspace hierarchy.

func (*PHPIndex) Methods

func (idx *PHPIndex) Methods(className string) []semantic.Symbol

Methods returns every method visible on a class, including inherited and trait declarations.

func (*PHPIndex) Prepare

func (idx *PHPIndex) Prepare(file *indexer.ParsedFile) (any, error)

func (*PHPIndex) Project

func (idx *PHPIndex) Project() *project.Model

func (*PHPIndex) Properties

func (idx *PHPIndex) Properties(className string) []semantic.Symbol

Properties returns every property visible on a class, including inherited and trait declarations.

func (*PHPIndex) RegisterTypeExtension

func (idx *PHPIndex) RegisterTypeExtension(extension inference.Extension)

RegisterTypeExtension adds a framework-specific call inference provider.

func (*PHPIndex) RemovedFiles

func (idx *PHPIndex) RemovedFiles(paths []string) error

func (*PHPIndex) RemovedFilesIn

func (idx *PHPIndex) RemovedFilesIn(paths []string, mutation *indexer.Mutation) error

func (*PHPIndex) Revision

func (idx *PHPIndex) Revision() uint64

func (*PHPIndex) SemanticDocument

func (idx *PHPIndex) SemanticDocument(path string) (*semantic.Document, bool)

SemanticDocument reconstructs a fully linked document for an indexed path. The long-lived index intentionally persists only compact workspace graphs; detailed scopes and flow facts are parsed from source on demand.

func (*PHPIndex) SemanticSnapshot

func (idx *PHPIndex) SemanticSnapshot() *semantic.Snapshot

SemanticSnapshot returns the current immutable workspace generation.

func (*PHPIndex) ShouldEnterDirectory

func (idx *PHPIndex) ShouldEnterDirectory(path string) bool

ShouldEnterDirectory selectively reopens Composer source roots that live in globally skipped directories such as tests/. Only the PHP index opts into these paths; generated assets and unrelated test trees remain excluded.

func (*PHPIndex) ShouldIndexPath

func (idx *PHPIndex) ShouldIndexPath(path string) bool

func (*PHPIndex) ShouldPreparsePath

func (idx *PHPIndex) ShouldPreparsePath(path string) bool

func (*PHPIndex) TwigTemplateVariableSources

func (idx *PHPIndex) TwigTemplateVariableSources(
	name string,
	templateNames ...string,
) ([]TwigTemplateVariable, error)

TwigTemplateVariableSources returns every indexed controller source for one variable name instead of merging duplicate providers.

func (*PHPIndex) TwigTemplateVariables

func (idx *PHPIndex) TwigTemplateVariables(
	templateNames ...string,
) ([]TwigTemplateVariable, error)

TwigTemplateVariables returns the merged PHP context for every portable name of one Twig file. A concrete inferred type wins over an unknown value.

func (*PHPIndex) WorkspaceSymbols

func (idx *PHPIndex) WorkspaceSymbols(
	file *indexer.ParsedFile,
	value any,
) ([]indexer.WorkspaceSymbol, error)

WorkspaceSymbols reuses the compact semantic graph produced by Prepare. It deliberately runs before the graph is released, avoiding a decode from SQLite and keeping symbol catalog population part of the file transaction.

type TwigTemplateContext

type TwigTemplateContext struct {
	Template  string
	Variables []TwigTemplateVariable
}

type TwigTemplateVariable

type TwigTemplateVariable struct {
	Template string
	Name     string
	Type     string
	File     string
	Range    cst.TextRange
}

TwigTemplateVariable describes one PHP value exposed to a Twig template. Type is persisted in canonical PHP type syntax instead of as types.Type, whose immutable representation intentionally has no exported fields.

Directories

Path Synopsis
Package binder converts the lossless PHP CST into immutable semantic documents.
Package binder converts the lossless PHP CST into immutable semantic documents.
Package imports analyzes namespace imports against the current PHP snapshot.
Package imports analyzes namespace imports against the current PHP snapshot.
Package inference performs local expression and control-flow type analysis over bound PHP semantic documents.
Package inference performs local expression and control-flow type analysis over bound PHP semantic documents.
Package languagelevel centralizes the PHP version required by language syntax understood by the permissive PHP parser.
Package languagelevel centralizes the PHP version required by language syntax understood by the permissive PHP parser.
Package literal derives PHP literal types directly from lossless syntax.
Package literal derives PHP literal types directly from lossless syntax.
Package phpdoc parses type-bearing PHPDoc tags into the shared semantic type algebra.
Package phpdoc parses type-bearing PHPDoc tags into the shared semantic type algebra.
Package phpstormmeta parses the declarative subset of .phpstorm.meta.php files into typed semantic contracts.
Package phpstormmeta parses the declarative subset of .phpstorm.meta.php files into typed semantic contracts.
Package project loads the Composer model that defines a PHP workspace.
Package project loads the Composer model that defines a PHP workspace.
Package refactoring builds PHP refactorings against immutable source snapshots.
Package refactoring builds PHP refactorings against immutable source snapshots.
Package resolver implements PHP name, hierarchy, member, and signature resolution over semantic snapshots.
Package resolver implements PHP name, hierarchy, member, and signature resolution over semantic snapshots.
Package phprewrite provides lossless, composable PHP source rewrites on top of the immutable PHP CST.
Package phprewrite provides lossless, composable PHP source rewrites on top of the immutable PHP CST.
Package semantic contains PHP symbols, scopes, references, and immutable document snapshots.
Package semantic contains PHP symbols, scopes, references, and immutable document snapshots.
Package stubs supplies version-aware semantic declarations for PHP runtime symbols that do not exist in project source.
Package stubs supplies version-aware semantic declarations for PHP runtime symbols that do not exist in project source.
catalog
Package catalog defines the compact, generated PHP runtime stub format.
Package catalog defines the compact, generated PHP runtime stub format.
generate
Package generate builds the embedded runtime catalog from JetBrains' phpstorm-stubs repository.
Package generate builds the embedded runtime catalog from JetBrains' phpstorm-stubs repository.
Package suppression parses source-level diagnostic suppression directives and matches them to Shopware LSP's stable PHP diagnostic identifiers.
Package suppression parses source-level diagnostic suppression directives and matches them to Shopware LSP's stable PHP diagnostic identifiers.
Package types defines the semantic PHP type algebra.
Package types defines the semantic PHP type algebra.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL