DevToolsPathResolver

Class
Final: Yes

Resolves canonical paths for the DevTools package itself.

Table of Contents

Constants

 = 'bin/dev-tools'
 = 'resources'
 = '/vendor/fast-forward/dev-tools'

Methods

getBinaryCommand()

Returns the packaged DevTools binary command with a subcommand.

 : string
getBinaryPath()

Returns the packaged DevTools binary path.

 : string
getPackagePath()

Returns the DevTools package directory or a path under it.

 : string
getPackagePathRelativeToProject()

Returns a packaged path rendered relative to the active project root when possible.

 : string
getPreferredToolBinaryPath()

Returns the preferred tooling binary path for the active project and DevTools runtime.

 : string
getPreferredVendorPath()

Returns the preferred Composer vendor path for the active project and DevTools runtime.

 : string
getResourcesPath()

Returns the packaged resources directory or a path under it.

 : string
getRuntimeAutoloadPath()

Returns the active Composer autoload file for the current DevTools installation mode.

 : string
getRuntimeToolBinaryPath()

Returns the active Composer runtime binary path for the current DevTools installation mode.

 : string
getRuntimeVendorPath()

Returns the active Composer vendor path for the current DevTools installation mode.

 : string
isInstalledAsDependency()

Detects whether the provided path belongs to an installed vendor copy of DevTools.

 : bool
isRepositoryCheckout()

Detects whether the provided path belongs to the DevTools repository checkout itself.

 : bool
assertRelativePackagePath()

Ensures packaged paths stay relative to the DevTools package root.

 : void
getProjectVendorPath()

Returns a vendor path under the active project root.

 : string
getRuntimeVendorRoot()

Returns the active Composer vendor root for the current DevTools installation mode.

 : string
normalizeVendorRelativePath()

Normalizes a path relative to the Composer vendor root.

 : string
preferExistingPath()

Returns the preferred path when a project-local candidate exists.

 : string
relativizePathFromProject()

Returns a path relative to the project root when possible.

 : string
resolvePackageRelativePath()

Returns a canonical path under the DevTools package root.

 : string
resolvePackageRoot()

Returns the canonical DevTools package root.

 : string
resolveProjectPath()

Returns the canonical working project root.

 : string
Constants

Constants

BINARY

Public
public string BINARY = 'bin/dev-tools'

Description

the relative path to the packaged DevTools binary

RESOURCES

Public
public string RESOURCES = 'resources'

Description

the resources directory segment within the package

VENDOR_PACKAGE_PATH

Private
private string VENDOR_PACKAGE_PATH = '/vendor/fast-forward/dev-tools'

Description

the vendor install path fragment used when DevTools runs as a dependency

Methods

getBinaryCommand()

Public Static

Returns the packaged DevTools binary command with a subcommand.

public static getBinaryCommand( string  $command) : string
Parameters
$command : string

Description

the DevTools subcommand to append

Return values
string

getBinaryPath()

Public Static

Returns the packaged DevTools binary path.

public static getBinaryPath() : string
Return values
string

getPackagePath()

Public Static

Returns the DevTools package directory or a path under it.

public static getPackagePath([ string  $path = '']) : string
Parameters
$path : string = ''

Description

the optional relative segment to append under the package directory

Return values
string

getPackagePathRelativeToProject()

Public Static

Returns a packaged path rendered relative to the active project root when possible.

public static getPackagePathRelativeToProject( string  $path[, string  $projectPath = ''][, string  $packagePath = '']) : string

Description

When the project root and package root do not share a filesystem root, the packaged absolute path MUST be returned unchanged so globally installed DevTools can still point hooks at the packaged fallback file.

Parameters
$path : string

Description

the relative path under the package root

$projectPath : string = ''

Description

an optional project root path; defaults to the working project root

$packagePath : string = ''

Description

an optional package root path; defaults to the current package root

Return values
string

getPreferredToolBinaryPath()

Public Static

Returns the preferred tooling binary path for the active project and DevTools runtime.

public static getPreferredToolBinaryPath( string  $binary[, string  $projectPath = ''][, string  $packagePath = '']) : string

Description

Consumer projects SHOULD take precedence when they provide a local vendor/bin/<binary> entry. If the binary is absent locally, the method MUST fall back to the active DevTools runtime binary path.

Parameters
$binary : string

Description

the binary name relative to vendor/bin

$projectPath : string = ''

Description

an optional project root path; defaults to the working project root

$packagePath : string = ''

Description

an optional package root path; defaults to the current package root

Return values
string

getPreferredVendorPath()

Public Static

Returns the preferred Composer vendor path for the active project and DevTools runtime.

public static getPreferredVendorPath( string  $path[, string  $projectPath = ''][, string  $packagePath = '']) : string

Description

Consumer projects SHOULD take precedence when they provide the requested vendor path locally. If the path is absent locally, the method MUST fall back to the active DevTools runtime vendor path.

Parameters
$path : string

Description

the vendor-relative path to resolve

$projectPath : string = ''

Description

an optional project root path; defaults to the working project root

$packagePath : string = ''

Description

an optional package root path; defaults to the current package root

Return values
string

getResourcesPath()

Public Static

Returns the packaged resources directory or a path under it.

public static getResourcesPath([ string  $path = '']) : string
Parameters
$path : string = ''

Description

the optional relative segment to append under resources

Return values
string

getRuntimeAutoloadPath()

Public Static

Returns the active Composer autoload file for the current DevTools installation mode.

public static getRuntimeAutoloadPath([ string  $packagePath = '']) : string

Description

When DevTools runs as a dependency, the runtime autoloader lives at the Composer vendor root. Repository checkouts instead use the package-local vendor/autoload.php.

Parameters
$packagePath : string = ''

Description

an optional package root path; defaults to the current package root

Return values
string

getRuntimeToolBinaryPath()

Public Static

Returns the active Composer runtime binary path for the current DevTools installation mode.

public static getRuntimeToolBinaryPath( string  $binary[, string  $packagePath = '']) : string

Description

Repository checkouts use the package-local vendor/bin/<binary>, while dependency installs resolve binaries from the active Composer vendor root.

Parameters
$binary : string

Description

the binary name relative to vendor/bin

$packagePath : string = ''

Description

an optional package root path; defaults to the current package root

Return values
string

getRuntimeVendorPath()

Public Static

Returns the active Composer vendor path for the current DevTools installation mode.

public static getRuntimeVendorPath( string  $path[, string  $packagePath = '']) : string

Description

Relative vendor paths MAY be passed either with or without a leading vendor/ prefix.

Parameters
$path : string

Description

the vendor-relative path to resolve

$packagePath : string = ''

Description

an optional package root path; defaults to the current package root

Return values
string

isInstalledAsDependency()

Public Static

Detects whether the provided path belongs to an installed vendor copy of DevTools.

public static isInstalledAsDependency([ string  $packagePath = '']) : bool
Parameters
$packagePath : string = ''

Description

an optional path within the package; defaults to the package root

Return values
bool

isRepositoryCheckout()

Public Static

Detects whether the provided path belongs to the DevTools repository checkout itself.

public static isRepositoryCheckout([ string  $packagePath = '']) : bool
Parameters
$packagePath : string = ''

Description

an optional path within the package; defaults to the package root

Return values
bool

assertRelativePackagePath()

Private Static

Ensures packaged paths stay relative to the DevTools package root.

private static assertRelativePackagePath( string  $path) : void
Parameters
$path : string

Description

the package-relative path to validate

getProjectVendorPath()

Private Static

Returns a vendor path under the active project root.

private static getProjectVendorPath( string  $path[, string  $projectPath = '']) : string
Parameters
$path : string

Description

the vendor-relative path to resolve

$projectPath : string = ''

Description

an optional project root path; defaults to the working project root

Return values
string

getRuntimeVendorRoot()

Private Static

Returns the active Composer vendor root for the current DevTools installation mode.

private static getRuntimeVendorRoot([ string  $packagePath = '']) : string
Parameters
$packagePath : string = ''

Description

an optional package root path; defaults to the current package root

Return values
string

normalizeVendorRelativePath()

Private Static

Normalizes a path relative to the Composer vendor root.

private static normalizeVendorRelativePath( string  $path) : string
Parameters
$path : string

Description

the vendor-relative path to normalize

Return values
string

preferExistingPath()

Private Static

Returns the preferred path when a project-local candidate exists.

private static preferExistingPath( string  $preferredPath, string  $fallbackPath) : string
Parameters
$preferredPath : string

Description

the project-local candidate path

$fallbackPath : string

Description

the runtime fallback path

Return values
string

relativizePathFromProject()

Private Static

Returns a path relative to the project root when possible.

private static relativizePathFromProject( string  $path, string  $projectPath) : string

Description

When paths do not share the same filesystem root, the original absolute path MUST be returned unchanged so callers still receive a usable path.

Parameters
$path : string

Description

the absolute path to relativize

$projectPath : string

Description

the absolute project root used as base path

Return values
string

resolvePackageRelativePath()

Private Static

Returns a canonical path under the DevTools package root.

private static resolvePackageRelativePath([ string  $path = ''][, string  $packagePath = '']) : string
Parameters
$path : string = ''

Description

the package-relative path to resolve

$packagePath : string = ''

Description

an optional package root path; defaults to the current package root

Return values
string

resolvePackageRoot()

Private Static

Returns the canonical DevTools package root.

private static resolvePackageRoot([ string  $packagePath = '']) : string
Parameters
$packagePath : string = ''

Description

an optional package root path; defaults to the current package root

Return values
string

resolveProjectPath()

Private Static

Returns the canonical working project root.

private static resolveProjectPath([ string  $projectPath = '']) : string
Parameters
$projectPath : string = ''

Description

an optional project root path; defaults to the working project root

Return values
string