code
stringlengths 31
1.39M
| docstring
stringlengths 23
16.8k
| func_name
stringlengths 1
126
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
166
| url
stringlengths 50
220
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
public static function getReference($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['reference'])) {
return null;
}
return $installed['versions'][$packageName]['reference'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
|
@param string $packageName
@return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
getReference
|
php
|
deptrac/deptrac
|
vendor/composer/InstalledVersions.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/InstalledVersions.php
|
MIT
|
public static function getInstallPath($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
|
@param string $packageName
@return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
getInstallPath
|
php
|
deptrac/deptrac
|
vendor/composer/InstalledVersions.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/InstalledVersions.php
|
MIT
|
public static function getRootPackage()
{
$installed = self::getInstalled();
return $installed[0]['root'];
}
|
@return array
@psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
|
getRootPackage
|
php
|
deptrac/deptrac
|
vendor/composer/InstalledVersions.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/InstalledVersions.php
|
MIT
|
public static function getRawData()
{
@\trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', \E_USER_DEPRECATED);
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (\substr(__DIR__, -8, 1) !== 'C') {
self::$installed = (include __DIR__ . '/installed.php');
} else {
self::$installed = array();
}
}
return self::$installed;
}
|
Returns the raw installed.php data for custom implementations
@deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
@return array[]
@psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
|
getRawData
|
php
|
deptrac/deptrac
|
vendor/composer/InstalledVersions.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/InstalledVersions.php
|
MIT
|
public static function getAllRawData()
{
return self::getInstalled();
}
|
Returns the raw data of all installed.php which are currently loaded for custom implementations
@return array[]
@psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
getAllRawData
|
php
|
deptrac/deptrac
|
vendor/composer/InstalledVersions.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/InstalledVersions.php
|
MIT
|
public static function reload($data)
{
self::$installed = $data;
self::$installedByVendor = array();
// when using reload, we disable the duplicate protection to ensure that self::$installed data is
// always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not,
// so we have to assume it does not, and that may result in duplicate data being returned when listing
// all installed packages for example
self::$installedIsLocalDir = \false;
}
|
Lets you reload the static array from another file
This is only useful for complex integrations in which a project needs to use
this class but then also needs to execute another project's autoloader in process,
and wants to ensure both projects have access to their version of installed.php.
A typical case would be PHPUnit, where it would need to make sure it reads all
the data it needs from this class, then call reload() with
`require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
the project in which it runs can then also use this class safely, without
interference between PHPUnit's dependencies and the project's dependencies.
@param array[] $data A vendor/composer/installed.php data set
@return void
@psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
|
reload
|
php
|
deptrac/deptrac
|
vendor/composer/InstalledVersions.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/InstalledVersions.php
|
MIT
|
private static function getInstalled()
{
if (null === self::$canGetVendors) {
self::$canGetVendors = \method_exists('DEPTRAC_INTERNAL\\Composer\\Autoload\\ClassLoader', 'getRegisteredLoaders');
}
$installed = array();
$copiedLocalDir = \false;
if (self::$canGetVendors) {
$selfDir = \strtr(__DIR__, '\\', '/');
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
$vendorDir = \strtr($vendorDir, '\\', '/');
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (\is_file($vendorDir . '/composer/installed.php')) {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = (require $vendorDir . '/composer/installed.php');
self::$installedByVendor[$vendorDir] = $required;
$installed[] = $required;
if (self::$installed === null && $vendorDir . '/composer' === $selfDir) {
self::$installed = $required;
self::$installedIsLocalDir = \true;
}
}
if (self::$installedIsLocalDir && $vendorDir . '/composer' === $selfDir) {
$copiedLocalDir = \true;
}
}
}
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (\substr(__DIR__, -8, 1) !== 'C') {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = (require __DIR__ . '/installed.php');
self::$installed = $required;
} else {
self::$installed = array();
}
}
if (self::$installed !== array() && !$copiedLocalDir) {
$installed[] = self::$installed;
}
return $installed;
}
|
@return array[]
@psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
getInstalled
|
php
|
deptrac/deptrac
|
vendor/composer/InstalledVersions.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/InstalledVersions.php
|
MIT
|
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
$this->count = $count;
}
|
@param 0|positive-int $count
@param array<int|string, list<string|null>> $matches
|
__construct
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/MatchAllResult.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/MatchAllResult.php
|
MIT
|
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
$this->count = $count;
}
|
@param 0|positive-int $count
@param array<list<string>> $matches
|
__construct
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/MatchAllStrictGroupsResult.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/MatchAllStrictGroupsResult.php
|
MIT
|
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
$this->count = $count;
}
|
@param 0|positive-int $count
@param array<int|string, list<array{string|null, int}>> $matches
@phpstan-param array<int|string, list<array{string|null, int<-1, max>}>> $matches
|
__construct
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/MatchAllWithOffsetsResult.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/MatchAllWithOffsetsResult.php
|
MIT
|
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
}
|
@param 0|positive-int $count
@param array<string|null> $matches
|
__construct
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/MatchResult.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/MatchResult.php
|
MIT
|
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
}
|
@param 0|positive-int $count
@param array<string> $matches
|
__construct
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/MatchStrictGroupsResult.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/MatchStrictGroupsResult.php
|
MIT
|
public function __construct(int $count, array $matches)
{
$this->matches = $matches;
$this->matched = (bool) $count;
}
|
@param 0|positive-int $count
@param array<array{string|null, int}> $matches
@phpstan-param array<int|string, array{string|null, int<-1, max>}> $matches
|
__construct
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/MatchWithOffsetsResult.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/MatchWithOffsetsResult.php
|
MIT
|
public static function fromFunction($function, $pattern)
{
$code = \preg_last_error();
if (\is_array($pattern)) {
$pattern = \implode(', ', $pattern);
}
return new PcreException($function . '(): failed executing "' . $pattern . '": ' . self::pcreLastErrorMessage($code), $code);
}
|
@param string $function
@param string|string[] $pattern
@return self
|
fromFunction
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/PcreException.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/PcreException.php
|
MIT
|
public static function match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0) : int
{
self::checkOffsetCapture($flags, 'matchWithOffsets');
$result = \preg_match($pattern, $subject, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset);
if ($result === \false) {
throw PcreException::fromFunction('preg_match', $pattern);
}
return $result;
}
|
@param non-empty-string $pattern
@param array<mixed> $matches Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
@return 0|1
@param-out array<int|string, string|null> $matches
|
match
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function matchStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0) : int
{
$result = self::match($pattern, $subject, $matchesInternal, $flags, $offset);
$matches = self::enforceNonNullMatches($pattern, $matchesInternal, 'match');
return $result;
}
|
Variant of `match()` which outputs non-null matches (or throws)
@param non-empty-string $pattern
@param array<mixed> $matches Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
@return 0|1
@throws UnexpectedNullMatchException
@param-out array<int|string, string> $matches
|
matchStrictGroups
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function matchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0) : int
{
$result = \preg_match($pattern, $subject, $matches, $flags | \PREG_UNMATCHED_AS_NULL | \PREG_OFFSET_CAPTURE, $offset);
if ($result === \false) {
throw PcreException::fromFunction('preg_match', $pattern);
}
return $result;
}
|
Runs preg_match with PREG_OFFSET_CAPTURE
@param non-empty-string $pattern
@param array<mixed> $matches Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_OFFSET_CAPTURE are always set, no other flags are supported
@return 0|1
@param-out array<int|string, array{string|null, int<-1, max>}> $matches
|
matchWithOffsets
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function matchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0) : int
{
self::checkOffsetCapture($flags, 'matchAllWithOffsets');
self::checkSetOrder($flags);
$result = \preg_match_all($pattern, $subject, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset);
if (!\is_int($result)) {
// PHP < 8 may return null, 8+ returns int|false
throw PcreException::fromFunction('preg_match_all', $pattern);
}
return $result;
}
|
@param non-empty-string $pattern
@param array<mixed> $matches Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
@return 0|positive-int
@param-out array<int|string, list<string|null>> $matches
|
matchAll
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function matchAllStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0) : int
{
$result = self::matchAll($pattern, $subject, $matchesInternal, $flags, $offset);
$matches = self::enforceNonNullMatchAll($pattern, $matchesInternal, 'matchAll');
return $result;
}
|
Variant of `match()` which outputs non-null matches (or throws)
@param non-empty-string $pattern
@param array<mixed> $matches Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
@return 0|positive-int
@throws UnexpectedNullMatchException
@param-out array<int|string, list<string>> $matches
|
matchAllStrictGroups
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function matchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0) : int
{
self::checkSetOrder($flags);
$result = \preg_match_all($pattern, $subject, $matches, $flags | \PREG_UNMATCHED_AS_NULL | \PREG_OFFSET_CAPTURE, $offset);
if (!\is_int($result)) {
// PHP < 8 may return null, 8+ returns int|false
throw PcreException::fromFunction('preg_match_all', $pattern);
}
return $result;
}
|
Runs preg_match_all with PREG_OFFSET_CAPTURE
@param non-empty-string $pattern
@param array<mixed> $matches Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
@return 0|positive-int
@param-out array<int|string, list<array{string|null, int<-1, max>}>> $matches
|
matchAllWithOffsets
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function replace($pattern, $replacement, $subject, int $limit = -1, ?int &$count = null) : string
{
if (!\is_scalar($subject)) {
if (\is_array($subject)) {
throw new \InvalidArgumentException(static::ARRAY_MSG);
}
throw new \TypeError(\sprintf(static::INVALID_TYPE_MSG, \gettype($subject)));
}
$result = \preg_replace($pattern, $replacement, $subject, $limit, $count);
if ($result === null) {
throw PcreException::fromFunction('preg_replace', $pattern);
}
return $result;
}
|
@param string|string[] $pattern
@param string|string[] $replacement
@param string $subject
@param int $count Set by method
@param-out int<0, max> $count
|
replace
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, ?int &$count = null, int $flags = 0) : string
{
if (!\is_scalar($subject)) {
if (\is_array($subject)) {
throw new \InvalidArgumentException(static::ARRAY_MSG);
}
throw new \TypeError(\sprintf(static::INVALID_TYPE_MSG, \gettype($subject)));
}
$result = \preg_replace_callback($pattern, $replacement, $subject, $limit, $count, $flags | \PREG_UNMATCHED_AS_NULL);
if ($result === null) {
throw PcreException::fromFunction('preg_replace_callback', $pattern);
}
return $result;
}
|
@param string|string[] $pattern
@param ($flags is PREG_OFFSET_CAPTURE ? (callable(array<int|string, array{string|null, int<-1, max>}>): string) : callable(array<int|string, string|null>): string) $replacement
@param string $subject
@param int $count Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
@param-out int<0, max> $count
|
replaceCallback
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function replaceCallbackStrictGroups(string $pattern, callable $replacement, $subject, int $limit = -1, ?int &$count = null, int $flags = 0) : string
{
return self::replaceCallback($pattern, function (array $matches) use($pattern, $replacement) {
return $replacement(self::enforceNonNullMatches($pattern, $matches, 'replaceCallback'));
}, $subject, $limit, $count, $flags);
}
|
Variant of `replaceCallback()` which outputs non-null matches (or throws)
@param string $pattern
@param ($flags is PREG_OFFSET_CAPTURE ? (callable(array<int|string, array{string, int<0, max>}>): string) : callable(array<int|string, string>): string) $replacement
@param string $subject
@param int $count Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
@param-out int<0, max> $count
|
replaceCallbackStrictGroups
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, ?int &$count = null, int $flags = 0) : string
{
if (!\is_scalar($subject)) {
if (\is_array($subject)) {
throw new \InvalidArgumentException(static::ARRAY_MSG);
}
throw new \TypeError(\sprintf(static::INVALID_TYPE_MSG, \gettype($subject)));
}
$result = \preg_replace_callback_array($pattern, $subject, $limit, $count, $flags | \PREG_UNMATCHED_AS_NULL);
if ($result === null) {
$pattern = \array_keys($pattern);
throw PcreException::fromFunction('preg_replace_callback_array', $pattern);
}
return $result;
}
|
@param ($flags is PREG_OFFSET_CAPTURE ? (array<string, callable(array<int|string, array{string|null, int<-1, max>}>): string>) : array<string, callable(array<int|string, string|null>): string>) $pattern
@param string $subject
@param int $count Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
@param-out int<0, max> $count
|
replaceCallbackArray
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function split(string $pattern, string $subject, int $limit = -1, int $flags = 0) : array
{
if (($flags & \PREG_SPLIT_OFFSET_CAPTURE) !== 0) {
throw new \InvalidArgumentException('PREG_SPLIT_OFFSET_CAPTURE is not supported as it changes the type of $matches, use splitWithOffsets() instead');
}
$result = \preg_split($pattern, $subject, $limit, $flags);
if ($result === \false) {
throw PcreException::fromFunction('preg_split', $pattern);
}
return $result;
}
|
@param int-mask<PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_OFFSET_CAPTURE> $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE
@return list<string>
|
split
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function splitWithOffsets(string $pattern, string $subject, int $limit = -1, int $flags = 0) : array
{
$result = \preg_split($pattern, $subject, $limit, $flags | \PREG_SPLIT_OFFSET_CAPTURE);
if ($result === \false) {
throw PcreException::fromFunction('preg_split', $pattern);
}
return $result;
}
|
@param int-mask<PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_OFFSET_CAPTURE> $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE, PREG_SPLIT_OFFSET_CAPTURE is always set
@return list<array{string, int}>
@phpstan-return list<array{string, int<0, max>}>
|
splitWithOffsets
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function grep(string $pattern, array $array, int $flags = 0) : array
{
$result = \preg_grep($pattern, $array, $flags);
if ($result === \false) {
throw PcreException::fromFunction('preg_grep', $pattern);
}
return $result;
}
|
@template T of string|\Stringable
@param string $pattern
@param array<T> $array
@param int-mask<PREG_GREP_INVERT> $flags PREG_GREP_INVERT
@return array<T>
|
grep
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function isMatch(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0) : bool
{
return (bool) static::match($pattern, $subject, $matches, $flags, $offset);
}
|
Variant of match() which returns a bool instead of int
@param non-empty-string $pattern
@param array<mixed> $matches Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
@param-out array<int|string, string|null> $matches
|
isMatch
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function isMatchStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0) : bool
{
return (bool) self::matchStrictGroups($pattern, $subject, $matches, $flags, $offset);
}
|
Variant of `isMatch()` which outputs non-null matches (or throws)
@param non-empty-string $pattern
@param array<mixed> $matches Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
@throws UnexpectedNullMatchException
@param-out array<int|string, string> $matches
|
isMatchStrictGroups
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function isMatchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0) : bool
{
return (bool) static::matchAll($pattern, $subject, $matches, $flags, $offset);
}
|
Variant of matchAll() which returns a bool instead of int
@param non-empty-string $pattern
@param array<mixed> $matches Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
@param-out array<int|string, list<string|null>> $matches
|
isMatchAll
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function isMatchAllStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0) : bool
{
return (bool) self::matchAllStrictGroups($pattern, $subject, $matches, $flags, $offset);
}
|
Variant of `isMatchAll()` which outputs non-null matches (or throws)
@param non-empty-string $pattern
@param array<mixed> $matches Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
@param-out array<int|string, list<string>> $matches
|
isMatchAllStrictGroups
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function isMatchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0) : bool
{
return (bool) static::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
}
|
Variant of matchWithOffsets() which returns a bool instead of int
Runs preg_match with PREG_OFFSET_CAPTURE
@param non-empty-string $pattern
@param array<mixed> $matches Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
@param-out array<int|string, array{string|null, int<-1, max>}> $matches
|
isMatchWithOffsets
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function isMatchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0) : bool
{
return (bool) static::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
}
|
Variant of matchAllWithOffsets() which returns a bool instead of int
Runs preg_match_all with PREG_OFFSET_CAPTURE
@param non-empty-string $pattern
@param array<mixed> $matches Set by method
@param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
@param-out array<int|string, list<array{string|null, int<-1, max>}>> $matches
|
isMatchAllWithOffsets
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
private static function enforceNonNullMatches(string $pattern, array $matches, string $variantMethod)
{
foreach ($matches as $group => $match) {
if (\is_string($match) || \is_array($match) && \is_string($match[0])) {
continue;
}
throw new UnexpectedNullMatchException('Pattern "' . $pattern . '" had an unexpected unmatched group "' . $group . '", make sure the pattern always matches or use ' . $variantMethod . '() instead.');
}
/** @var array<string> */
return $matches;
}
|
@param array<int|string, string|null|array{string|null, int}> $matches
@return array<int|string, string>
@throws UnexpectedNullMatchException
|
enforceNonNullMatches
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
private static function enforceNonNullMatchAll(string $pattern, array $matches, string $variantMethod)
{
foreach ($matches as $group => $groupMatches) {
foreach ($groupMatches as $match) {
if (null === $match) {
throw new UnexpectedNullMatchException('Pattern "' . $pattern . '" had an unexpected unmatched group "' . $group . '", make sure the pattern always matches or use ' . $variantMethod . '() instead.');
}
}
}
/** @var array<int|string, list<string>> */
return $matches;
}
|
@param array<int|string, list<string|null>> $matches
@return array<int|string, list<string>>
@throws UnexpectedNullMatchException
|
enforceNonNullMatchAll
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Preg.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Preg.php
|
MIT
|
public static function match(string $pattern, string $subject, int $flags = 0, int $offset = 0) : MatchResult
{
self::checkOffsetCapture($flags, 'matchWithOffsets');
$count = Preg::match($pattern, $subject, $matches, $flags, $offset);
return new MatchResult($count, $matches);
}
|
@param non-empty-string $pattern
@param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
|
match
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Regex.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Regex.php
|
MIT
|
public static function matchStrictGroups(string $pattern, string $subject, int $flags = 0, int $offset = 0) : MatchStrictGroupsResult
{
// @phpstan-ignore composerPcre.maybeUnsafeStrictGroups
$count = Preg::matchStrictGroups($pattern, $subject, $matches, $flags, $offset);
return new MatchStrictGroupsResult($count, $matches);
}
|
Variant of `match()` which returns non-null matches (or throws)
@param non-empty-string $pattern
@param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
@throws UnexpectedNullMatchException
|
matchStrictGroups
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Regex.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Regex.php
|
MIT
|
public static function matchWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0) : MatchWithOffsetsResult
{
$count = Preg::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
return new MatchWithOffsetsResult($count, $matches);
}
|
Runs preg_match with PREG_OFFSET_CAPTURE
@param non-empty-string $pattern
@param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
|
matchWithOffsets
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Regex.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Regex.php
|
MIT
|
public static function matchAll(string $pattern, string $subject, int $flags = 0, int $offset = 0) : MatchAllResult
{
self::checkOffsetCapture($flags, 'matchAllWithOffsets');
self::checkSetOrder($flags);
$count = Preg::matchAll($pattern, $subject, $matches, $flags, $offset);
return new MatchAllResult($count, $matches);
}
|
@param non-empty-string $pattern
@param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
|
matchAll
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Regex.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Regex.php
|
MIT
|
public static function matchAllStrictGroups(string $pattern, string $subject, int $flags = 0, int $offset = 0) : MatchAllStrictGroupsResult
{
self::checkOffsetCapture($flags, 'matchAllWithOffsets');
self::checkSetOrder($flags);
// @phpstan-ignore composerPcre.maybeUnsafeStrictGroups
$count = Preg::matchAllStrictGroups($pattern, $subject, $matches, $flags, $offset);
return new MatchAllStrictGroupsResult($count, $matches);
}
|
Variant of `matchAll()` which returns non-null matches (or throws)
@param non-empty-string $pattern
@param int-mask<PREG_UNMATCHED_AS_NULL> $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported
@throws UnexpectedNullMatchException
|
matchAllStrictGroups
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Regex.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Regex.php
|
MIT
|
public static function matchAllWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0) : MatchAllWithOffsetsResult
{
self::checkSetOrder($flags);
$count = Preg::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
return new MatchAllWithOffsetsResult($count, $matches);
}
|
Runs preg_match_all with PREG_OFFSET_CAPTURE
@param non-empty-string $pattern
@param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported
|
matchAllWithOffsets
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Regex.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Regex.php
|
MIT
|
public static function replace($pattern, $replacement, $subject, int $limit = -1) : ReplaceResult
{
$result = Preg::replace($pattern, $replacement, $subject, $limit, $count);
return new ReplaceResult($count, $result);
}
|
@param string|string[] $pattern
@param string|string[] $replacement
@param string $subject
|
replace
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Regex.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Regex.php
|
MIT
|
public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0) : ReplaceResult
{
$result = Preg::replaceCallback($pattern, $replacement, $subject, $limit, $count, $flags);
return new ReplaceResult($count, $result);
}
|
@param string|string[] $pattern
@param ($flags is PREG_OFFSET_CAPTURE ? (callable(array<int|string, array{string|null, int<-1, max>}>): string) : callable(array<int|string, string|null>): string) $replacement
@param string $subject
@param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
|
replaceCallback
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Regex.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Regex.php
|
MIT
|
public static function replaceCallbackStrictGroups($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0) : ReplaceResult
{
$result = Preg::replaceCallbackStrictGroups($pattern, $replacement, $subject, $limit, $count, $flags);
return new ReplaceResult($count, $result);
}
|
Variant of `replaceCallback()` which outputs non-null matches (or throws)
@param string $pattern
@param ($flags is PREG_OFFSET_CAPTURE ? (callable(array<int|string, array{string, int<0, max>}>): string) : callable(array<int|string, string>): string) $replacement
@param string $subject
@param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
|
replaceCallbackStrictGroups
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Regex.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Regex.php
|
MIT
|
public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, int $flags = 0) : ReplaceResult
{
$result = Preg::replaceCallbackArray($pattern, $subject, $limit, $count, $flags);
return new ReplaceResult($count, $result);
}
|
@param ($flags is PREG_OFFSET_CAPTURE ? (array<string, callable(array<int|string, array{string|null, int<-1, max>}>): string>) : array<string, callable(array<int|string, string|null>): string>) $pattern
@param string $subject
@param int-mask<PREG_UNMATCHED_AS_NULL|PREG_OFFSET_CAPTURE> $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set
|
replaceCallbackArray
|
php
|
deptrac/deptrac
|
vendor/composer/pcre/src/Regex.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/pcre/src/Regex.php
|
MIT
|
public function useOriginal() : array
{
$this->getDataAndReset();
return [];
}
|
Use the original PHP configuration
@return string[] Empty array of PHP cli options
|
useOriginal
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/PhpConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/PhpConfig.php
|
MIT
|
public function useStandard() : array
{
$data = $this->getDataAndReset();
if ($data !== null) {
return ['-n', '-c', $data['tmpIni']];
}
return [];
}
|
Use standard restart settings
@return string[] PHP cli options
|
useStandard
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/PhpConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/PhpConfig.php
|
MIT
|
public function usePersistent() : array
{
$data = $this->getDataAndReset();
if ($data !== null) {
$this->updateEnv('PHPRC', $data['tmpIni']);
$this->updateEnv('PHP_INI_SCAN_DIR', '');
}
return [];
}
|
Use environment variables to persist settings
@return string[] Empty array of PHP cli options
|
usePersistent
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/PhpConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/PhpConfig.php
|
MIT
|
private function getDataAndReset() : ?array
{
$data = XdebugHandler::getRestartSettings();
if ($data !== null) {
$this->updateEnv('PHPRC', $data['phprc']);
$this->updateEnv('PHP_INI_SCAN_DIR', $data['scanDir']);
}
return $data;
}
|
Returns restart data if available and resets the environment
@phpstan-return restartData|null
|
getDataAndReset
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/PhpConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/PhpConfig.php
|
MIT
|
private function updateEnv(string $name, $value) : void
{
Process::setEnv($name, \false !== $value ? $value : null);
}
|
Updates a restart settings value in the environment
@param string $name
@param string|false $value
|
updateEnv
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/PhpConfig.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/PhpConfig.php
|
MIT
|
public static function escapeShellCommand(array $args) : string
{
$command = '';
$module = \array_shift($args);
if ($module !== null) {
$command = self::escape($module, \true, \true);
foreach ($args as $arg) {
$command .= ' ' . self::escape($arg);
}
}
return $command;
}
|
Escapes an array of arguments that make up a shell command
@param string[] $args Argument list, with the module name first
|
escapeShellCommand
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/Process.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/Process.php
|
MIT
|
public static function setEnv(string $name, ?string $value = null) : bool
{
$unset = null === $value;
if (!\putenv($unset ? $name : $name . '=' . $value)) {
return \false;
}
if ($unset) {
unset($_SERVER[$name]);
} else {
$_SERVER[$name] = $value;
}
// Update $_ENV if it is being used
if (\false !== \stripos((string) \ini_get('variables_order'), 'E')) {
if ($unset) {
unset($_ENV[$name]);
} else {
$_ENV[$name] = $value;
}
}
return \true;
}
|
Makes putenv environment changes available in $_SERVER and $_ENV
@param string $name
@param ?string $value A null value unsets the variable
|
setEnv
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/Process.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/Process.php
|
MIT
|
public function __construct(string $envAllowXdebug, bool $debug)
{
$start = \getenv(self::ENV_RESTART);
Process::setEnv(self::ENV_RESTART);
$this->time = \is_numeric($start) ? \round((\microtime(\true) - $start) * 1000) : 0;
$this->envAllowXdebug = $envAllowXdebug;
$this->debug = $debug && \defined('STDERR');
$this->modeOff = \false;
}
|
@param string $envAllowXdebug Prefixed _ALLOW_XDEBUG name
@param bool $debug Whether debug output is required
|
__construct
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/Status.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/Status.php
|
MIT
|
public function setLogger(LoggerInterface $logger) : void
{
$this->logger = $logger;
}
|
Activates status message output to a PSR3 logger
@return void
|
setLogger
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/Status.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/Status.php
|
MIT
|
public function report(string $op, ?string $data) : void
{
if ($this->logger !== null || $this->debug) {
$param = (string) $data;
switch ($op) {
case self::CHECK:
$this->reportCheck($param);
break;
case self::ERROR:
$this->reportError($param);
break;
case self::INFO:
$this->reportInfo($param);
break;
case self::NORESTART:
$this->reportNoRestart();
break;
case self::RESTART:
$this->reportRestart();
break;
case self::RESTARTED:
$this->reportRestarted();
break;
case self::RESTARTING:
$this->reportRestarting($param);
break;
default:
throw new \InvalidArgumentException('Unknown op handler: ' . $op);
}
}
}
|
Calls a handler method to report a message
@throws \InvalidArgumentException If $op is not known
|
report
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/Status.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/Status.php
|
MIT
|
private function getEnvAllow() : string
{
return $this->envAllowXdebug . '=' . \getenv($this->envAllowXdebug);
}
|
Returns the _ALLOW_XDEBUG environment variable as name=value
|
getEnvAllow
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/Status.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/Status.php
|
MIT
|
private function getLoadedMessage() : string
{
$loaded = $this->loaded !== null ? \sprintf('loaded %s', $this->loaded) : 'not loaded';
return 'The Xdebug extension is ' . $loaded;
}
|
Returns the Xdebug status and version
|
getLoadedMessage
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/Status.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/Status.php
|
MIT
|
public function __construct(string $envPrefix)
{
if ($envPrefix === '') {
throw new \RuntimeException('Invalid constructor parameter');
}
self::$name = \strtoupper($envPrefix);
$this->envAllowXdebug = self::$name . self::SUFFIX_ALLOW;
$this->envOriginalInis = self::$name . self::SUFFIX_INIS;
self::setXdebugDetails();
self::$inRestart = \false;
if ($this->cli = \PHP_SAPI === 'cli') {
$this->debug = (string) \getenv(self::DEBUG);
}
$this->statusWriter = new Status($this->envAllowXdebug, (bool) $this->debug);
}
|
Constructor
The $envPrefix is used to create distinct environment variables. It is
uppercased and prepended to the default base values. For example 'myapp'
would result in MYAPP_ALLOW_XDEBUG and MYAPP_ORIGINAL_INIS.
@param string $envPrefix Value used in environment variables
@throws \RuntimeException If the parameter is invalid
|
__construct
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
public function setLogger(LoggerInterface $logger) : self
{
$this->statusWriter->setLogger($logger);
return $this;
}
|
Activates status message output to a PSR3 logger
|
setLogger
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
public function setMainScript(string $script) : self
{
$this->script = $script;
return $this;
}
|
Sets the main script location if it cannot be called from argv
|
setMainScript
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
public function setPersistent() : self
{
$this->persistent = \true;
return $this;
}
|
Persist the settings to keep Xdebug out of sub-processes
|
setPersistent
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
public function check() : void
{
$this->notify(Status::CHECK, self::$xdebugVersion . '|' . self::$xdebugMode);
$envArgs = \explode('|', (string) \getenv($this->envAllowXdebug));
if (!(bool) $envArgs[0] && $this->requiresRestart(self::$xdebugActive)) {
// Restart required
$this->notify(Status::RESTART);
$command = $this->prepareRestart();
if ($command !== null) {
$this->restart($command);
}
return;
}
if (self::RESTART_ID === $envArgs[0] && \count($envArgs) === 5) {
// Restarted, so unset environment variable and use saved values
$this->notify(Status::RESTARTED);
Process::setEnv($this->envAllowXdebug);
self::$inRestart = \true;
if (self::$xdebugVersion === null) {
// Skipped version is only set if Xdebug is not loaded
self::$skipped = $envArgs[1];
}
$this->tryEnableSignals();
// Put restart settings in the environment
$this->setEnvRestartSettings($envArgs);
return;
}
$this->notify(Status::NORESTART);
$settings = self::getRestartSettings();
if ($settings !== null) {
// Called with existing settings, so sync our settings
$this->syncSettings($settings);
}
}
|
Checks if Xdebug is loaded and the process needs to be restarted
This behaviour can be disabled by setting the MYAPP_ALLOW_XDEBUG
environment variable to 1. This variable is used internally so that
the restarted process is created only once.
|
check
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
public static function getAllIniFiles() : array
{
if (self::$name !== null) {
$env = \getenv(self::$name . self::SUFFIX_INIS);
if (\false !== $env) {
return \explode(\PATH_SEPARATOR, $env);
}
}
$paths = [(string) \php_ini_loaded_file()];
$scanned = \php_ini_scanned_files();
if ($scanned !== \false) {
$paths = \array_merge($paths, \array_map('trim', \explode(',', $scanned)));
}
return $paths;
}
|
Returns an array of php.ini locations with at least one entry
The equivalent of calling php_ini_loaded_file then php_ini_scanned_files.
The loaded ini location is the first entry and may be an empty string.
@return non-empty-list<string>
|
getAllIniFiles
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
public static function getRestartSettings() : ?array
{
$envArgs = \explode('|', (string) \getenv(self::RESTART_SETTINGS));
if (\count($envArgs) !== 6 || !self::$inRestart && \php_ini_loaded_file() !== $envArgs[0]) {
return null;
}
return ['tmpIni' => $envArgs[0], 'scannedInis' => (bool) $envArgs[1], 'scanDir' => '*' === $envArgs[2] ? \false : $envArgs[2], 'phprc' => '*' === $envArgs[3] ? \false : $envArgs[3], 'inis' => \explode(\PATH_SEPARATOR, $envArgs[4]), 'skipped' => $envArgs[5]];
}
|
Returns an array of restart settings or null
Settings will be available if the current process was restarted, or
called with the settings from an existing restart.
@phpstan-return restartData|null
|
getRestartSettings
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
public static function getSkippedVersion() : string
{
return (string) self::$skipped;
}
|
Returns the Xdebug version that triggered a successful restart
|
getSkippedVersion
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
public static function isXdebugActive() : bool
{
self::setXdebugDetails();
return self::$xdebugActive;
}
|
Returns whether Xdebug is loaded and active
true: if Xdebug is loaded and is running in an active mode.
false: if Xdebug is not loaded, or it is running with xdebug.mode=off.
|
isXdebugActive
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
protected function requiresRestart(bool $default) : bool
{
return $default;
}
|
Allows an extending class to decide if there should be a restart
The default is to restart if Xdebug is loaded and its mode is not "off".
|
requiresRestart
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
protected function restart(array $command) : void
{
$this->doRestart($command);
}
|
Allows an extending class to access the tmpIni
@param non-empty-list<string> $command
|
restart
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
private function doRestart(array $command) : void
{
if (\PHP_VERSION_ID >= 70400) {
$cmd = $command;
$displayCmd = \sprintf('[%s]', \implode(', ', $cmd));
} else {
$cmd = Process::escapeShellCommand($command);
if (\defined('PHP_WINDOWS_VERSION_BUILD')) {
// Outer quotes required on cmd string below PHP 8
$cmd = '"' . $cmd . '"';
}
$displayCmd = $cmd;
}
$this->tryEnableSignals();
$this->notify(Status::RESTARTING, $displayCmd);
$process = \proc_open($cmd, [], $pipes);
if (\is_resource($process)) {
$exitCode = \proc_close($process);
}
if (!isset($exitCode)) {
// Unlikely that php or the default shell cannot be invoked
$this->notify(Status::ERROR, 'Unable to restart process');
$exitCode = -1;
} else {
$this->notify(Status::INFO, 'Restarted process exited ' . $exitCode);
}
if ($this->debug === '2') {
$this->notify(Status::INFO, 'Temp ini saved: ' . $this->tmpIni);
} else {
@\unlink((string) $this->tmpIni);
}
exit($exitCode);
}
|
Executes the restarted command then deletes the tmp ini
@param non-empty-list<string> $command
@phpstan-return never
|
doRestart
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
private function prepareRestart() : ?array
{
if (!$this->cli) {
$this->notify(Status::ERROR, 'Unsupported SAPI: ' . \PHP_SAPI);
return null;
}
if (($argv = $this->checkServerArgv()) === null) {
$this->notify(Status::ERROR, '$_SERVER[argv] is not as expected');
return null;
}
if (!$this->checkConfiguration($info)) {
$this->notify(Status::ERROR, $info);
return null;
}
$mainScript = (string) $this->script;
if (!$this->checkMainScript($mainScript, $argv)) {
$this->notify(Status::ERROR, 'Unable to access main script: ' . $mainScript);
return null;
}
$tmpDir = \sys_get_temp_dir();
$iniError = 'Unable to create temp ini file at: ' . $tmpDir;
if (($tmpfile = @\tempnam($tmpDir, '')) === \false) {
$this->notify(Status::ERROR, $iniError);
return null;
}
$error = null;
$iniFiles = self::getAllIniFiles();
$scannedInis = \count($iniFiles) > 1;
if (!$this->writeTmpIni($tmpfile, $iniFiles, $error)) {
$this->notify(Status::ERROR, $error ?? $iniError);
@\unlink($tmpfile);
return null;
}
if (!$this->setEnvironment($scannedInis, $iniFiles, $tmpfile)) {
$this->notify(Status::ERROR, 'Unable to set environment variables');
@\unlink($tmpfile);
return null;
}
$this->tmpIni = $tmpfile;
return $this->getCommand($argv, $tmpfile, $mainScript);
}
|
Returns the command line array if everything was written for the restart
If any of the following fails (however unlikely) we must return false to
stop potential recursion:
- tmp ini file creation
- environment variable creation
@return non-empty-list<string>|null
|
prepareRestart
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
private function writeTmpIni(string $tmpFile, array $iniFiles, ?string &$error) : bool
{
// $iniFiles has at least one item and it may be empty
if ($iniFiles[0] === '') {
\array_shift($iniFiles);
}
$content = '';
$sectionRegex = '/^\\s*\\[(?:PATH|HOST)\\s*=/mi';
$xdebugRegex = '/^\\s*(zend_extension\\s*=.*xdebug.*)$/mi';
foreach ($iniFiles as $file) {
// Check for inaccessible ini files
if (($data = @\file_get_contents($file)) === \false) {
$error = 'Unable to read ini: ' . $file;
return \false;
}
// Check and remove directives after HOST and PATH sections
if (Preg::isMatchWithOffsets($sectionRegex, $data, $matches)) {
$data = \substr($data, 0, $matches[0][1]);
}
$content .= Preg::replace($xdebugRegex, ';$1', $data) . \PHP_EOL;
}
// Merge loaded settings into our ini content, if it is valid
$config = \parse_ini_string($content);
$loaded = \ini_get_all(null, \false);
if (\false === $config || \false === $loaded) {
$error = 'Unable to parse ini data';
return \false;
}
$content .= $this->mergeLoadedConfig($loaded, $config);
// Work-around for https://bugs.php.net/bug.php?id=75932
$content .= 'opcache.enable_cli=0' . \PHP_EOL;
return (bool) @\file_put_contents($tmpFile, $content);
}
|
Returns true if the tmp ini file was written
@param non-empty-list<string> $iniFiles All ini files used in the current process
|
writeTmpIni
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
private function getCommand(array $argv, string $tmpIni, string $mainScript) : array
{
$php = [\PHP_BINARY];
$args = \array_slice($argv, 1);
if (!$this->persistent) {
// Use command-line options
\array_push($php, '-n', '-c', $tmpIni);
}
return \array_merge($php, [$mainScript], $args);
}
|
Returns the command line arguments for the restart
@param non-empty-list<string> $argv
@return non-empty-list<string>
|
getCommand
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
private function setEnvironment(bool $scannedInis, array $iniFiles, string $tmpIni) : bool
{
$scanDir = \getenv('PHP_INI_SCAN_DIR');
$phprc = \getenv('PHPRC');
// Make original inis available to restarted process
if (!\putenv($this->envOriginalInis . '=' . \implode(\PATH_SEPARATOR, $iniFiles))) {
return \false;
}
if ($this->persistent) {
// Use the environment to persist the settings
if (!\putenv('PHP_INI_SCAN_DIR=') || !\putenv('PHPRC=' . $tmpIni)) {
return \false;
}
}
// Flag restarted process and save values for it to use
$envArgs = [self::RESTART_ID, self::$xdebugVersion, (int) $scannedInis, \false === $scanDir ? '*' : $scanDir, \false === $phprc ? '*' : $phprc];
return \putenv($this->envAllowXdebug . '=' . \implode('|', $envArgs));
}
|
Returns true if the restart environment variables were set
No need to update $_SERVER since this is set in the restarted process.
@param non-empty-list<string> $iniFiles All ini files used in the current process
|
setEnvironment
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
private function mergeLoadedConfig(array $loadedConfig, array $iniConfig) : string
{
$content = '';
foreach ($loadedConfig as $name => $value) {
// Value will either be null, string or array (HHVM only)
if (!\is_string($value) || \strpos($name, 'xdebug') === 0 || $name === 'apc.mmap_file_mask') {
continue;
}
if (!isset($iniConfig[$name]) || $iniConfig[$name] !== $value) {
// Double-quote escape each value
$content .= $name . '="' . \addcslashes($value, '\\"') . '"' . \PHP_EOL;
}
}
return $content;
}
|
Returns default, changed and command-line ini settings
@param mixed[] $loadedConfig All current ini settings
@param mixed[] $iniConfig Settings from user ini files
|
mergeLoadedConfig
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
private function checkMainScript(string &$mainScript, array $argv) : bool
{
if ($mainScript !== '') {
// Allow an application to set -- for standard input
return \file_exists($mainScript) || '--' === $mainScript;
}
if (\file_exists($mainScript = $argv[0])) {
return \true;
}
// Use a backtrace to resolve Phar and chdir issues.
$trace = \debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS);
$main = \end($trace);
if ($main !== \false && isset($main['file'])) {
return \file_exists($mainScript = $main['file']);
}
return \false;
}
|
Returns true if the script name can be used
@param non-empty-list<string> $argv
|
checkMainScript
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
private function setEnvRestartSettings(array $envArgs) : void
{
$settings = [\php_ini_loaded_file(), $envArgs[2], $envArgs[3], $envArgs[4], \getenv($this->envOriginalInis), self::$skipped];
Process::setEnv(self::RESTART_SETTINGS, \implode('|', $settings));
}
|
Adds restart settings to the environment
@param non-empty-list<string> $envArgs
|
setEnvRestartSettings
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
private function syncSettings(array $settings) : void
{
if (\false === \getenv($this->envOriginalInis)) {
// Called by another app, so make original inis available
Process::setEnv($this->envOriginalInis, \implode(\PATH_SEPARATOR, $settings['inis']));
}
self::$skipped = $settings['skipped'];
$this->notify(Status::INFO, 'Process called with existing restart settings');
}
|
Syncs settings and the environment if called with existing settings
@phpstan-param restartData $settings
|
syncSettings
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
private function checkConfiguration(?string &$info) : bool
{
if (!\function_exists('proc_open')) {
$info = 'proc_open function is disabled';
return \false;
}
if (!\file_exists(\PHP_BINARY)) {
$info = 'PHP_BINARY is not available';
return \false;
}
if (\extension_loaded('uopz') && !(bool) \ini_get('uopz.disable')) {
// uopz works at opcode level and disables exit calls
if (\function_exists('uopz_allow_exit')) {
@\uopz_allow_exit(\true);
} else {
$info = 'uopz extension is not compatible';
return \false;
}
}
// Check UNC paths when using cmd.exe
if (\defined('PHP_WINDOWS_VERSION_BUILD') && \PHP_VERSION_ID < 70400) {
$workingDir = \getcwd();
if ($workingDir === \false) {
$info = 'unable to determine working directory';
return \false;
}
if (0 === \strpos($workingDir, '\\\\')) {
$info = 'cmd.exe does not support UNC paths: ' . $workingDir;
return \false;
}
}
return \true;
}
|
Returns true if there are no known configuration issues
|
checkConfiguration
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
private function tryEnableSignals() : void
{
if (\function_exists('pcntl_async_signals') && \function_exists('pcntl_signal')) {
\pcntl_async_signals(\true);
$message = 'Async signals enabled';
if (!self::$inRestart) {
// Restarting, so ignore SIGINT in parent
\pcntl_signal(\SIGINT, \SIG_IGN);
} elseif (\is_int(\pcntl_signal_get_handler(\SIGINT))) {
// Restarted, no handler set so force default action
\pcntl_signal(\SIGINT, \SIG_DFL);
}
}
if (!self::$inRestart && \function_exists('sapi_windows_set_ctrl_handler')) {
// Restarting, so set a handler to ignore CTRL events in the parent.
// This ensures that CTRL+C events will be available in the child
// process without having to enable them there, which is unreliable.
\sapi_windows_set_ctrl_handler(function ($evt) {
});
}
}
|
Enables async signals and control interrupts in the restarted process
Available on Unix PHP 7.1+ with the pcntl extension and Windows PHP 7.4+.
|
tryEnableSignals
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
private function checkServerArgv() : ?array
{
$result = [];
if (isset($_SERVER['argv']) && \is_array($_SERVER['argv'])) {
foreach ($_SERVER['argv'] as $value) {
if (!\is_string($value)) {
return null;
}
$result[] = $value;
}
}
return \count($result) > 0 ? $result : null;
}
|
Returns $_SERVER['argv'] if it is as expected
@return non-empty-list<string>|null
|
checkServerArgv
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
private static function setXdebugDetails() : void
{
if (self::$xdebugActive !== null) {
return;
}
self::$xdebugActive = \false;
if (!\extension_loaded('xdebug')) {
return;
}
$version = \phpversion('xdebug');
self::$xdebugVersion = $version !== \false ? $version : 'unknown';
if (\version_compare(self::$xdebugVersion, '3.1', '>=')) {
$modes = \xdebug_info('mode');
self::$xdebugMode = \count($modes) === 0 ? 'off' : \implode(',', $modes);
self::$xdebugActive = self::$xdebugMode !== 'off';
return;
}
// See if xdebug.mode is supported in this version
$iniMode = \ini_get('xdebug.mode');
if ($iniMode === \false) {
self::$xdebugActive = \true;
return;
}
// Environment value wins but cannot be empty
$envMode = (string) \getenv('XDEBUG_MODE');
if ($envMode !== '') {
self::$xdebugMode = $envMode;
} else {
self::$xdebugMode = $iniMode !== '' ? $iniMode : 'off';
}
// An empty comma-separated list is treated as mode 'off'
if (Preg::isMatch('/^,+$/', \str_replace(' ', '', self::$xdebugMode))) {
self::$xdebugMode = 'off';
}
self::$xdebugActive = self::$xdebugMode !== 'off';
}
|
Sets static properties $xdebugActive, $xdebugVersion and $xdebugMode
|
setXdebugDetails
|
php
|
deptrac/deptrac
|
vendor/composer/xdebug-handler/src/XdebugHandler.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/composer/xdebug-handler/src/XdebugHandler.php
|
MIT
|
public static function trigger(string $package, string $link, string $message, ...$args) : void
{
$type = self::$type ?? self::getTypeFromEnv();
if ($type === self::TYPE_NONE) {
return;
}
if (isset(self::$ignoredLinks[$link])) {
return;
}
if (array_key_exists($link, self::$triggeredDeprecations)) {
self::$triggeredDeprecations[$link]++;
} else {
self::$triggeredDeprecations[$link] = 1;
}
if (self::$deduplication === \true && self::$triggeredDeprecations[$link] > 1) {
return;
}
if (isset(self::$ignoredPackages[$package])) {
return;
}
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
$message = sprintf($message, ...$args);
self::delegateTriggerToBackend($message, $backtrace, $link, $package);
}
|
Trigger a deprecation for the given package and identfier.
The link should point to a Github issue or Wiki entry detailing the
deprecation. It is additionally used to de-duplicate the trigger of the
same deprecation during a request.
@param float|int|string $args
|
trigger
|
php
|
deptrac/deptrac
|
vendor/doctrine/deprecations/src/Deprecation.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/doctrine/deprecations/src/Deprecation.php
|
MIT
|
public static function triggerIfCalledFromOutside(string $package, string $link, string $message, ...$args) : void
{
$type = self::$type ?? self::getTypeFromEnv();
if ($type === self::TYPE_NONE) {
return;
}
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
// first check that the caller is not from a tests folder, in which case we always let deprecations pass
if (isset($backtrace[1]['file'], $backtrace[0]['file']) && strpos($backtrace[1]['file'], DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR) === \false) {
$path = DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $package) . DIRECTORY_SEPARATOR;
if (strpos($backtrace[0]['file'], $path) === \false) {
return;
}
if (strpos($backtrace[1]['file'], $path) !== \false) {
return;
}
}
if (isset(self::$ignoredLinks[$link])) {
return;
}
if (array_key_exists($link, self::$triggeredDeprecations)) {
self::$triggeredDeprecations[$link]++;
} else {
self::$triggeredDeprecations[$link] = 1;
}
if (self::$deduplication === \true && self::$triggeredDeprecations[$link] > 1) {
return;
}
if (isset(self::$ignoredPackages[$package])) {
return;
}
$message = sprintf($message, ...$args);
self::delegateTriggerToBackend($message, $backtrace, $link, $package);
}
|
Trigger a deprecation for the given package and identifier when called from outside.
"Outside" means we assume that $package is currently installed as a
dependency and the caller is not a file in that package. When $package
is installed as a root package then deprecations triggered from the
tests folder are also considered "outside".
This deprecation method assumes that you are using Composer to install
the dependency and are using the default /vendor/ folder and not a
Composer plugin to change the install location. The assumption is also
that $package is the exact composer packge name.
Compared to {@link trigger()} this method causes some overhead when
deprecation tracking is enabled even during deduplication, because it
needs to call {@link debug_backtrace()}
@param float|int|string $args
|
triggerIfCalledFromOutside
|
php
|
deptrac/deptrac
|
vendor/doctrine/deprecations/src/Deprecation.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/doctrine/deprecations/src/Deprecation.php
|
MIT
|
private static function delegateTriggerToBackend(string $message, array $backtrace, string $link, string $package) : void
{
$type = self::$type ?? self::getTypeFromEnv();
if (($type & self::TYPE_PSR_LOGGER) > 0) {
$context = ['file' => $backtrace[0]['file'] ?? null, 'line' => $backtrace[0]['line'] ?? null, 'package' => $package, 'link' => $link];
assert(self::$logger !== null);
self::$logger->notice($message, $context);
}
if (!(($type & self::TYPE_TRIGGER_ERROR) > 0)) {
return;
}
$message .= sprintf(' (%s:%d called by %s:%d, %s, package %s)', self::basename($backtrace[0]['file'] ?? 'native code'), $backtrace[0]['line'] ?? 0, self::basename($backtrace[1]['file'] ?? 'native code'), $backtrace[1]['line'] ?? 0, $link, $package);
@trigger_error($message, E_USER_DEPRECATED);
}
|
@param list<array{function: string, line?: int, file?: string, class?: class-string, type?: string, args?: mixed[], object?: object}> $backtrace
|
delegateTriggerToBackend
|
php
|
deptrac/deptrac
|
vendor/doctrine/deprecations/src/Deprecation.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/doctrine/deprecations/src/Deprecation.php
|
MIT
|
private static function basename(string $filename) : string
{
$pos = strrpos($filename, DIRECTORY_SEPARATOR);
if ($pos === \false) {
return $filename;
}
return substr($filename, $pos + 1);
}
|
A non-local-aware version of PHPs basename function.
|
basename
|
php
|
deptrac/deptrac
|
vendor/doctrine/deprecations/src/Deprecation.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/doctrine/deprecations/src/Deprecation.php
|
MIT
|
public static function getTriggeredDeprecations() : array
{
return self::$triggeredDeprecations;
}
|
Returns each triggered deprecation link identifier and the amount of occurrences.
@return array<string,int>
|
getTriggeredDeprecations
|
php
|
deptrac/deptrac
|
vendor/doctrine/deprecations/src/Deprecation.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/doctrine/deprecations/src/Deprecation.php
|
MIT
|
public function __construct($bin_str)
{
$this->s = $bin_str;
}
|
Constructor for \Aerospike\Bytes class.
@param string $bin_str a PHP binary-string such as gzdeflate() produces.
|
__construct
|
php
|
deptrac/deptrac
|
vendor/jetbrains/phpstorm-stubs/aerospike/Bytes.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/jetbrains/phpstorm-stubs/aerospike/Bytes.php
|
MIT
|
public function serialize()
{
return $this->s;
}
|
Returns a serialized representation of the binary-string.
Called by serialize()
@return string
|
serialize
|
php
|
deptrac/deptrac
|
vendor/jetbrains/phpstorm-stubs/aerospike/Bytes.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/jetbrains/phpstorm-stubs/aerospike/Bytes.php
|
MIT
|
public function unserialize($bin_str)
{
return $this->s = $bin_str;
}
|
Re-wraps the binary-string when called by unserialize().
@param string $bin_str a PHP binary-string. Called by unserialize().
@return string
|
unserialize
|
php
|
deptrac/deptrac
|
vendor/jetbrains/phpstorm-stubs/aerospike/Bytes.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/jetbrains/phpstorm-stubs/aerospike/Bytes.php
|
MIT
|
public function __toString()
{
return $this->s;
}
|
Returns the binary-string held in the \Aerospike\Bytes object.
@return string
|
__toString
|
php
|
deptrac/deptrac
|
vendor/jetbrains/phpstorm-stubs/aerospike/Bytes.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/jetbrains/phpstorm-stubs/aerospike/Bytes.php
|
MIT
|
public static function unwrap(Bytes $bytes_wrap)
{
return $bytes_wrap->s;
}
|
Unwraps an \Aerospike\Bytes object, returning the binary-string inside.
@param \Aerospike\Bytes $bytes_wrap
@return string
|
unwrap
|
php
|
deptrac/deptrac
|
vendor/jetbrains/phpstorm-stubs/aerospike/Bytes.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/jetbrains/phpstorm-stubs/aerospike/Bytes.php
|
MIT
|
#[Deprecated(replacement: "%class%->setReadTimout(%parameter0%)")]
public function setTimeout($timeout)
{
}
|
Sets the interval of time to wait for income activity from AMQP broker
@param float $timeout
@throws AMQPConnectionException If timeout is less than 0.
@return bool
|
setTimeout
|
php
|
deptrac/deptrac
|
vendor/jetbrains/phpstorm-stubs/amqp/amqp.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/jetbrains/phpstorm-stubs/amqp/amqp.php
|
MIT
|
#[Deprecated(replacement: '%class%->getReadTimout(%parameter0%)')]
public function getTimeout()
{
}
|
Get the configured interval of time to wait for income activity
from AMQP broker
@return float
|
getTimeout
|
php
|
deptrac/deptrac
|
vendor/jetbrains/phpstorm-stubs/amqp/amqp.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/jetbrains/phpstorm-stubs/amqp/amqp.php
|
MIT
|
#[Pure]
#[LanguageLevelTypeAware(["8.0" => "string"], default: "?string")]
function bcsqrt(string $num, ?int $scale)
{
}
|
Get the square root of an arbitrary precision number
@link https://php.net/manual/en/function.bcsqrt.php
@param string $num <p>
The operand, as a string.
</p>
@param int|null $scale [optional]
@return string|null the square root as a string, or <b>NULL</b> if
<i>operand</i> is negative.
|
bcsqrt
|
php
|
deptrac/deptrac
|
vendor/jetbrains/phpstorm-stubs/bcmath/bcmath.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/jetbrains/phpstorm-stubs/bcmath/bcmath.php
|
MIT
|
#[LanguageLevelTypeAware(['7.3' => 'int'], default: 'bool')]
function bcscale(#[PhpStormStubsElementAvailable(from: '5.3', to: '7.2')] int $scale, #[PhpStormStubsElementAvailable(from: '7.3')] #[LanguageLevelTypeAware(['8.0' => 'int|null'], default: 'int')] $scale = null)
{
}
|
Set default scale parameter for all bc math functions
@link https://php.net/manual/en/function.bcscale.php
@param int $scale
@return int|bool
|
bcscale
|
php
|
deptrac/deptrac
|
vendor/jetbrains/phpstorm-stubs/bcmath/bcmath.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/jetbrains/phpstorm-stubs/bcmath/bcmath.php
|
MIT
|
#[Pure]
function bccomp(string $num1, string $num2, ?int $scale = null) : int
{
}
|
Compare two arbitrary precision numbers
@link https://php.net/manual/en/function.bccomp.php
@param string $num1 <p>
The left operand, as a string.
</p>
@param string $num2 <p>
The right operand, as a string.
</p>
@param int|null $scale <p>
The optional <i>scale</i> parameter is used to set the
number of digits after the decimal place which will be used in the
comparison.
</p>
@return int 0 if the two operands are equal, 1 if the
<i>left_operand</i> is larger than the
<i>right_operand</i>, -1 otherwise.
|
bccomp
|
php
|
deptrac/deptrac
|
vendor/jetbrains/phpstorm-stubs/bcmath/bcmath.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/jetbrains/phpstorm-stubs/bcmath/bcmath.php
|
MIT
|
#[Pure]
function bzopen($file, string $mode)
{
}
|
Opens a bzip2 compressed file
@link https://php.net/manual/en/function.bzopen.php
@param string $file <p>
The name of the file to open, or an existing stream resource.
</p>
@param string $mode <p>
Similar to the <b>fopen</b> function, only 'r' (read)
and 'w' (write) are supported. Everything else will cause bzopen
to return <b>FALSE</b>.
</p>
@return resource|false If the open fails, <b>bzopen</b> returns <b>FALSE</b>, otherwise
it returns a pointer to the newly opened file.
|
bzopen
|
php
|
deptrac/deptrac
|
vendor/jetbrains/phpstorm-stubs/bz2/bz2.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/jetbrains/phpstorm-stubs/bz2/bz2.php
|
MIT
|
#[Pure]
#[LanguageLevelTypeAware(['8.1' => 'int', '8.0' => 'int|false'], default: 'int')]
function bzerrno($bz)
{
}
|
Returns a bzip2 error number
@link https://php.net/manual/en/function.bzerrno.php
@param resource $bz <p>
The file pointer. It must be valid and must point to a file
successfully opened by <b>bzopen</b>.
</p>
@return int the error number as an integer.
|
bzerrno
|
php
|
deptrac/deptrac
|
vendor/jetbrains/phpstorm-stubs/bz2/bz2.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/jetbrains/phpstorm-stubs/bz2/bz2.php
|
MIT
|
#[Pure]
#[LanguageLevelTypeAware(['8.1' => 'string', '8.0' => 'string|false'], default: 'string')]
function bzerrstr($bz)
{
}
|
Returns a bzip2 error string
@link https://php.net/manual/en/function.bzerrstr.php
@param resource $bz <p>
The file pointer. It must be valid and must point to a file
successfully opened by <b>bzopen</b>.
</p>
@return string a string containing the error message.
|
bzerrstr
|
php
|
deptrac/deptrac
|
vendor/jetbrains/phpstorm-stubs/bz2/bz2.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/jetbrains/phpstorm-stubs/bz2/bz2.php
|
MIT
|
#[Pure]
#[LanguageLevelTypeAware(['8.1' => 'array', '8.0' => 'array|false'], default: 'array')]
#[ArrayShape(["errno" => "int", "errstr" => "string"])]
function bzerror($bz)
{
}
|
Returns the bzip2 error number and error string in an array
@link https://php.net/manual/en/function.bzerror.php
@param resource $bz <p>
The file pointer. It must be valid and must point to a file
successfully opened by <b>bzopen</b>.
</p>
@return array an associative array, with the error code in the
errno entry, and the error message in the
errstr entry.
|
bzerror
|
php
|
deptrac/deptrac
|
vendor/jetbrains/phpstorm-stubs/bz2/bz2.php
|
https://github.com/deptrac/deptrac/blob/master/vendor/jetbrains/phpstorm-stubs/bz2/bz2.php
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.