php

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func ParseComposerLock

func ParseComposerLock(pathToLockfile string) ([]lockfile.PackageDetails, error)

Types

type ComposerLock

type ComposerLock struct {
	Packages    []ComposerPackage `json:"packages"`
	PackagesDev []ComposerPackage `json:"packages-dev"`
}

type ComposerLockExtractor

type ComposerLockExtractor struct {
	lockfile.WithMatcher
}

func (ComposerLockExtractor) Extract

func (ComposerLockExtractor) IsOfficiallySupported

func (e ComposerLockExtractor) IsOfficiallySupported() bool

func (ComposerLockExtractor) PackageManager

func (e ComposerLockExtractor) PackageManager() models.PackageManager

func (ComposerLockExtractor) ShouldExtract

func (e ComposerLockExtractor) ShouldExtract(path string) bool

type ComposerMatcher

type ComposerMatcher struct{}

func (ComposerMatcher) GetSourceFile

func (matcher ComposerMatcher) GetSourceFile(sourceFile lockfile.DepFile) (lockfile.DepFile, error)

func (ComposerMatcher) Match

func (matcher ComposerMatcher) Match(sourceFile lockfile.DepFile, packages []lockfile.PackageDetails, context lockfile.ScanContext) error

Match works by leveraging the json decoder to only parse json sections of interest (e.g dependencies) Whenever the json decoder try to deserialize a file, it will look at json sections it needs to deserialize and then call the proper UnmarshallJSON method of the type. As the JSON decoder expect us to only deserialize it, not trying to find the exact location in the file of the content, it does not provide us buffer information (offset, file path, etc...)

To work around this limitation, we are pre-filling the structure with all the field we will need during the deserialization :

  • The root type to know which json section we are deserializing
  • The file path to be able to fill properly location fields of lockfile.PackageDetails
  • The line offset to be able to compute the line of any found dependencies in the file
  • And a list of pointer to the original lockfile.PackageDetails extracted by the parser to be able to modify them with the json section content

type ComposerMatcherDependencyMap

type ComposerMatcherDependencyMap struct {
	lockfile.MatcherDependencyMap
}

ComposerMatcherDependencyMap is here to have access to all lockfile.MatcherDependencyMap methods and at the same time having a different type to have a clear UnmarshallJSON method for the json decoder and avoid overlaps with other matchers.

func (*ComposerMatcherDependencyMap) UnmarshalJSON

func (depMap *ComposerMatcherDependencyMap) UnmarshalJSON(bytes []byte) error

type ComposerPackage

type ComposerPackage struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Dist    struct {
		Reference string `json:"reference"`
	} `json:"dist"`
}

Jump to

Keyboard shortcuts

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