DevToolsPathResolver
Resolves canonical paths for the DevTools package itself.
Constants
Methods
Returns the packaged DevTools binary command with a subcommand.
Returns the packaged DevTools binary path.
Returns the DevTools package directory or a path under it.
Returns a packaged path rendered relative to the active project root when possible.
Returns the preferred tooling binary path for the active project and DevTools runtime.
Returns the preferred Composer vendor path for the active project and DevTools runtime.
Returns the packaged resources directory or a path under it.
Returns the active Composer autoload file for the current DevTools installation mode.
Returns the active Composer runtime binary path for the current DevTools installation mode.
Returns the active Composer vendor path for the current DevTools installation mode.
Detects whether the provided path belongs to an installed vendor copy of DevTools.
Detects whether the provided path belongs to the DevTools repository checkout itself.
Ensures packaged paths stay relative to the DevTools package root.
Returns a vendor path under the active project root.
Returns the active Composer vendor root for the current DevTools installation mode.
Normalizes a path relative to the Composer vendor root.
Returns the preferred path when a project-local candidate exists.
Returns a path relative to the project root when possible.
Returns a canonical path under the DevTools package root.
Returns the canonical DevTools package root.
Returns the canonical working project root.
public
string
BINARY
=
'bin/dev-tools'
Description
the relative path to the packaged DevTools binary
public
string
RESOURCES
=
'resources'
Description
the resources directory segment within the package
private
string
VENDOR_PACKAGE_PATH
=
'/vendor/fast-forward/dev-tools'
Description
the vendor install path fragment used when DevTools runs as a dependency
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
Returns the packaged DevTools binary path.
public
static
getBinaryPath() : string
Return values
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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