repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
xivapi/xivapi-php | src/XIVAPI/Api/PrivateApi.php | PrivateApi.manualItemUpdate | public function manualItemUpdate(string $accessKey, int $itemId, string $server)
{
return Guzzle::get("/private/market/item/update", [
RequestOptions::QUERY => [
'access' => $accessKey,
'item_id' => $itemId,
'server' => $server,
]
]);
} | php | public function manualItemUpdate(string $accessKey, int $itemId, string $server)
{
return Guzzle::get("/private/market/item/update", [
RequestOptions::QUERY => [
'access' => $accessKey,
'item_id' => $itemId,
'server' => $server,
]
]);
} | [
"public",
"function",
"manualItemUpdate",
"(",
"string",
"$",
"accessKey",
",",
"int",
"$",
"itemId",
",",
"string",
"$",
"server",
")",
"{",
"return",
"Guzzle",
"::",
"get",
"(",
"\"/private/market/item/update\"",
",",
"[",
"RequestOptions",
"::",
"QUERY",
"=... | Request an item to be updated | [
"Request",
"an",
"item",
"to",
"be",
"updated"
] | train | https://github.com/xivapi/xivapi-php/blob/ad82f1adfb9b8eca5456c8aeef530a1e8ffb31e0/src/XIVAPI/Api/PrivateApi.php#L13-L22 |
xivapi/xivapi-php | src/XIVAPI/Guzzle/Guzzle.php | Guzzle.setClient | private static function setClient()
{
if (self::$client === null) {
self::$client = new Client([
'base_uri' => self::$environment,
'timeout' => self::TIMEOUT,
'verify' => self::VERIFY,
]);
}
} | php | private static function setClient()
{
if (self::$client === null) {
self::$client = new Client([
'base_uri' => self::$environment,
'timeout' => self::TIMEOUT,
'verify' => self::VERIFY,
]);
}
} | [
"private",
"static",
"function",
"setClient",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"client",
"===",
"null",
")",
"{",
"self",
"::",
"$",
"client",
"=",
"new",
"Client",
"(",
"[",
"'base_uri'",
"=>",
"self",
"::",
"$",
"environment",
",",
"'ti... | Set the Guzzle client | [
"Set",
"the",
"Guzzle",
"client"
] | train | https://github.com/xivapi/xivapi-php/blob/ad82f1adfb9b8eca5456c8aeef530a1e8ffb31e0/src/XIVAPI/Guzzle/Guzzle.php#L26-L35 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatBatch | public function formatBatch(array $records)
{
$logBatch = array('formatted' => '');
// ignore the logs related to the web debug toolbar
if ($this->isWebDebugToolbarLog($records)) {
return $logBatch;
}
$logBatch['formatted'] .= $this->formatLogBatchHeader($records);
foreach ($records as $key => $record) {
if ($this->isDeprecationLog($record)) {
$records[$key] = $this->processDeprecationLogRecord($record);
}
if ($this->isEventStopLog($record)) {
$records[$key] = $this->processEventStopLogRecord($record);
}
if ($this->isEventNotificationLog($record)) {
$records[$key] = $this->processEventNotificationLogRecord($records, $key);
}
if ($this->isTranslationLog($record)) {
$records[$key] = $this->processTranslationLogRecord($records, $key);
}
if ($this->isRouteMatchLog($record)) {
$records[$key] = $this->processRouteMatchLogRecord($record);
}
if ($this->isDoctrineLog($record)) {
$records[$key] = $this->processDoctrineLogRecord($record);
}
$logBatch['formatted'] .= rtrim($this->formatRecord($records, $key), PHP_EOL).PHP_EOL;
}
$logBatch['formatted'] .= PHP_EOL.PHP_EOL;
return $logBatch;
} | php | public function formatBatch(array $records)
{
$logBatch = array('formatted' => '');
// ignore the logs related to the web debug toolbar
if ($this->isWebDebugToolbarLog($records)) {
return $logBatch;
}
$logBatch['formatted'] .= $this->formatLogBatchHeader($records);
foreach ($records as $key => $record) {
if ($this->isDeprecationLog($record)) {
$records[$key] = $this->processDeprecationLogRecord($record);
}
if ($this->isEventStopLog($record)) {
$records[$key] = $this->processEventStopLogRecord($record);
}
if ($this->isEventNotificationLog($record)) {
$records[$key] = $this->processEventNotificationLogRecord($records, $key);
}
if ($this->isTranslationLog($record)) {
$records[$key] = $this->processTranslationLogRecord($records, $key);
}
if ($this->isRouteMatchLog($record)) {
$records[$key] = $this->processRouteMatchLogRecord($record);
}
if ($this->isDoctrineLog($record)) {
$records[$key] = $this->processDoctrineLogRecord($record);
}
$logBatch['formatted'] .= rtrim($this->formatRecord($records, $key), PHP_EOL).PHP_EOL;
}
$logBatch['formatted'] .= PHP_EOL.PHP_EOL;
return $logBatch;
} | [
"public",
"function",
"formatBatch",
"(",
"array",
"$",
"records",
")",
"{",
"$",
"logBatch",
"=",
"array",
"(",
"'formatted'",
"=>",
"''",
")",
";",
"// ignore the logs related to the web debug toolbar",
"if",
"(",
"$",
"this",
"->",
"isWebDebugToolbarLog",
"(",
... | @param array $records
@return array | [
"@param",
"array",
"$records"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L48-L90 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.isDeprecationLog | private function isDeprecationLog(array $record)
{
$isPhpChannel = 'php' === $record['channel'];
$isDeprecationError = isset($record['context']['type']) && E_USER_DEPRECATED === $record['context']['type'];
$looksLikeDeprecationMessage = false !== strpos($record['message'], 'deprecated since');
return $isPhpChannel && ($isDeprecationError || $looksLikeDeprecationMessage);
} | php | private function isDeprecationLog(array $record)
{
$isPhpChannel = 'php' === $record['channel'];
$isDeprecationError = isset($record['context']['type']) && E_USER_DEPRECATED === $record['context']['type'];
$looksLikeDeprecationMessage = false !== strpos($record['message'], 'deprecated since');
return $isPhpChannel && ($isDeprecationError || $looksLikeDeprecationMessage);
} | [
"private",
"function",
"isDeprecationLog",
"(",
"array",
"$",
"record",
")",
"{",
"$",
"isPhpChannel",
"=",
"'php'",
"===",
"$",
"record",
"[",
"'channel'",
"]",
";",
"$",
"isDeprecationError",
"=",
"isset",
"(",
"$",
"record",
"[",
"'context'",
"]",
"[",
... | @param array $record
@return bool | [
"@param",
"array",
"$record"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L107-L114 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.isEventNotificationLog | private function isEventNotificationLog(array $record)
{
$isEventNotifyChannel = isset($record['channel']) && '_event_notify' === $record['channel'];
$isEventChannel = isset($record['channel']) && 'event' === $record['channel'];
$contextIncludesEventNotification = isset($record['context']) && isset($record['context']['event']) && isset($record['context']['listener']);
return $isEventNotifyChannel || ($isEventChannel && $contextIncludesEventNotification);
} | php | private function isEventNotificationLog(array $record)
{
$isEventNotifyChannel = isset($record['channel']) && '_event_notify' === $record['channel'];
$isEventChannel = isset($record['channel']) && 'event' === $record['channel'];
$contextIncludesEventNotification = isset($record['context']) && isset($record['context']['event']) && isset($record['context']['listener']);
return $isEventNotifyChannel || ($isEventChannel && $contextIncludesEventNotification);
} | [
"private",
"function",
"isEventNotificationLog",
"(",
"array",
"$",
"record",
")",
"{",
"$",
"isEventNotifyChannel",
"=",
"isset",
"(",
"$",
"record",
"[",
"'channel'",
"]",
")",
"&&",
"'_event_notify'",
"===",
"$",
"record",
"[",
"'channel'",
"]",
";",
"$",... | @param array $record
@return bool | [
"@param",
"array",
"$record"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L141-L148 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.isWebDebugToolbarLog | private function isWebDebugToolbarLog(array $records)
{
foreach ($records as $record) {
if (isset($record['context']['route']) && '_wdt' === $record['context']['route']) {
return true;
}
}
return false;
} | php | private function isWebDebugToolbarLog(array $records)
{
foreach ($records as $record) {
if (isset($record['context']['route']) && '_wdt' === $record['context']['route']) {
return true;
}
}
return false;
} | [
"private",
"function",
"isWebDebugToolbarLog",
"(",
"array",
"$",
"records",
")",
"{",
"foreach",
"(",
"$",
"records",
"as",
"$",
"record",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"record",
"[",
"'context'",
"]",
"[",
"'route'",
"]",
")",
"&&",
"'_wdt'... | @param array $records
@return bool | [
"@param",
"array",
"$records"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L175-L184 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.processDoctrineLogRecord | private function processDoctrineLogRecord(array $record)
{
if (!isset($record['context']) || empty($record['context'])) {
return $record;
}
$isDatabaseQueryContext = $this->arrayContainsOnlyNumericKeys($record['context']);
if ($isDatabaseQueryContext) {
$record['context'] = array('query params' => $record['context']);
}
return $record;
} | php | private function processDoctrineLogRecord(array $record)
{
if (!isset($record['context']) || empty($record['context'])) {
return $record;
}
$isDatabaseQueryContext = $this->arrayContainsOnlyNumericKeys($record['context']);
if ($isDatabaseQueryContext) {
$record['context'] = array('query params' => $record['context']);
}
return $record;
} | [
"private",
"function",
"processDoctrineLogRecord",
"(",
"array",
"$",
"record",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"record",
"[",
"'context'",
"]",
")",
"||",
"empty",
"(",
"$",
"record",
"[",
"'context'",
"]",
")",
")",
"{",
"return",
"$",
... | @param array $record
@return array | [
"@param",
"array",
"$record"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L208-L220 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.processEventNotificationLogRecord | private function processEventNotificationLogRecord(array $records, $currentRecordIndex)
{
$record = $records[$currentRecordIndex];
$record['message'] = null;
$record['channel'] = '_event_notify';
$record['context'] = array($record['context']['event'] => $record['context']['listener']);
// if the previous record is also an event notification, combine them
if (isset($records[$currentRecordIndex - 1]) && $this->isEventNotificationLog($records[$currentRecordIndex - 1])) {
$record['_properties']['display_log_info'] = false;
}
return $record;
} | php | private function processEventNotificationLogRecord(array $records, $currentRecordIndex)
{
$record = $records[$currentRecordIndex];
$record['message'] = null;
$record['channel'] = '_event_notify';
$record['context'] = array($record['context']['event'] => $record['context']['listener']);
// if the previous record is also an event notification, combine them
if (isset($records[$currentRecordIndex - 1]) && $this->isEventNotificationLog($records[$currentRecordIndex - 1])) {
$record['_properties']['display_log_info'] = false;
}
return $record;
} | [
"private",
"function",
"processEventNotificationLogRecord",
"(",
"array",
"$",
"records",
",",
"$",
"currentRecordIndex",
")",
"{",
"$",
"record",
"=",
"$",
"records",
"[",
"$",
"currentRecordIndex",
"]",
";",
"$",
"record",
"[",
"'message'",
"]",
"=",
"null",... | In Symfony applications is common to have lots of consecutive "event notify"
log messages. This method combines them all to generate a more compact output.
@param array $records
@param int $currentRecordIndex
@return string | [
"In",
"Symfony",
"applications",
"is",
"common",
"to",
"have",
"lots",
"of",
"consecutive",
"event",
"notify",
"log",
"messages",
".",
"This",
"method",
"combines",
"them",
"all",
"to",
"generate",
"a",
"more",
"compact",
"output",
"."
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L231-L245 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.processRouteMatchLogRecord | private function processRouteMatchLogRecord(array $record)
{
if ($this->isAsseticLog($record)) {
$record['message'] = '{method}: {request_uri}';
return $record;
}
$context = $record['context'];
unset($context['method']);
unset($context['request_uri']);
$record['context'] = array_merge(
array($record['context']['method'] => $record['context']['request_uri']),
$context
);
return $record;
} | php | private function processRouteMatchLogRecord(array $record)
{
if ($this->isAsseticLog($record)) {
$record['message'] = '{method}: {request_uri}';
return $record;
}
$context = $record['context'];
unset($context['method']);
unset($context['request_uri']);
$record['context'] = array_merge(
array($record['context']['method'] => $record['context']['request_uri']),
$context
);
return $record;
} | [
"private",
"function",
"processRouteMatchLogRecord",
"(",
"array",
"$",
"record",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAsseticLog",
"(",
"$",
"record",
")",
")",
"{",
"$",
"record",
"[",
"'message'",
"]",
"=",
"'{method}: {request_uri}'",
";",
"return"... | @param array $record
@return array | [
"@param",
"array",
"$record"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L265-L284 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.processStringPlaceholders | private function processStringPlaceholders($string, array $variables)
{
foreach ($variables as $key => $value) {
if (!is_string($value) && !is_numeric($value) && !is_bool($value)) {
continue;
}
$string = str_replace('{'.$key.'}', $value, (string) $string);
}
return $string;
} | php | private function processStringPlaceholders($string, array $variables)
{
foreach ($variables as $key => $value) {
if (!is_string($value) && !is_numeric($value) && !is_bool($value)) {
continue;
}
$string = str_replace('{'.$key.'}', $value, (string) $string);
}
return $string;
} | [
"private",
"function",
"processStringPlaceholders",
"(",
"$",
"string",
",",
"array",
"$",
"variables",
")",
"{",
"foreach",
"(",
"$",
"variables",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"&&... | It interpolates the given string replacing its placeholders with the
values defined in the given variables array.
@param string $string
@param array $variables
@return string | [
"It",
"interpolates",
"the",
"given",
"string",
"replacing",
"its",
"placeholders",
"with",
"the",
"values",
"defined",
"in",
"the",
"given",
"variables",
"array",
"."
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L295-L306 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.processTranslationLogRecord | private function processTranslationLogRecord(array $records, $currentRecordIndex)
{
$record = $records[$currentRecordIndex];
if (isset($records[$currentRecordIndex - 1]) && $this->isTranslationLog($records[$currentRecordIndex - 1])) {
$record['_properties']['display_log_info'] = false;
$record['message'] = null;
}
return $record;
} | php | private function processTranslationLogRecord(array $records, $currentRecordIndex)
{
$record = $records[$currentRecordIndex];
if (isset($records[$currentRecordIndex - 1]) && $this->isTranslationLog($records[$currentRecordIndex - 1])) {
$record['_properties']['display_log_info'] = false;
$record['message'] = null;
}
return $record;
} | [
"private",
"function",
"processTranslationLogRecord",
"(",
"array",
"$",
"records",
",",
"$",
"currentRecordIndex",
")",
"{",
"$",
"record",
"=",
"$",
"records",
"[",
"$",
"currentRecordIndex",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"records",
"[",
"$",
"... | In Symfony applications is common to have lots of consecutive "translation not found"
log messages. This method combines them all to generate a more compact output.
@param array $records
@param int $currentRecordIndex
@return string | [
"In",
"Symfony",
"applications",
"is",
"common",
"to",
"have",
"lots",
"of",
"consecutive",
"translation",
"not",
"found",
"log",
"messages",
".",
"This",
"method",
"combines",
"them",
"all",
"to",
"generate",
"a",
"more",
"compact",
"output",
"."
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L317-L327 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatLogChannel | private function formatLogChannel(array $record)
{
if (!isset($record['channel'])) {
return '';
}
if ($this->isDeprecationLog($record)) {
return '** DEPRECATION **';
}
if ($this->isEventNotificationLog($record)) {
return 'NOTIFIED EVENTS';
}
$channel = $record['channel'];
$channelIcons = array(
'_event_stop' => '[!] ',
'security' => '(!) ',
);
$channelIcon = array_key_exists($channel, $channelIcons) ? $channelIcons[$channel] : '';
return sprintf('%s%s', $channelIcon, strtoupper($channel));
} | php | private function formatLogChannel(array $record)
{
if (!isset($record['channel'])) {
return '';
}
if ($this->isDeprecationLog($record)) {
return '** DEPRECATION **';
}
if ($this->isEventNotificationLog($record)) {
return 'NOTIFIED EVENTS';
}
$channel = $record['channel'];
$channelIcons = array(
'_event_stop' => '[!] ',
'security' => '(!) ',
);
$channelIcon = array_key_exists($channel, $channelIcons) ? $channelIcons[$channel] : '';
return sprintf('%s%s', $channelIcon, strtoupper($channel));
} | [
"private",
"function",
"formatLogChannel",
"(",
"array",
"$",
"record",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"record",
"[",
"'channel'",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isDeprecationLog",
"(",
"$",... | @param array $record
@return string | [
"@param",
"array",
"$record"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L334-L356 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatContext | private function formatContext(array $record)
{
$context = $this->filterVariablesUsedAsPlaceholders($record['message'], $record['context']);
$context = $this->formatDateTimeObjects($context);
$context = $this->formatThrowableObjects($context);
$contextAsString = Yaml::dump($context, $this->getInlineLevel($record), $this->prefixLength, Yaml::DUMP_OBJECT);
if (substr($contextAsString, strpos($contextAsString, self::PHP_SERIALIZED_OBJECT_PREFIX), strlen(self::PHP_SERIALIZED_OBJECT_PREFIX)) === self::PHP_SERIALIZED_OBJECT_PREFIX) {
$contextAsString = $this->formatSerializedObject($contextAsString);
}
$contextAsString = $this->formatTextBlock($contextAsString, '--> ');
$contextAsString = rtrim($contextAsString, PHP_EOL);
return $contextAsString;
} | php | private function formatContext(array $record)
{
$context = $this->filterVariablesUsedAsPlaceholders($record['message'], $record['context']);
$context = $this->formatDateTimeObjects($context);
$context = $this->formatThrowableObjects($context);
$contextAsString = Yaml::dump($context, $this->getInlineLevel($record), $this->prefixLength, Yaml::DUMP_OBJECT);
if (substr($contextAsString, strpos($contextAsString, self::PHP_SERIALIZED_OBJECT_PREFIX), strlen(self::PHP_SERIALIZED_OBJECT_PREFIX)) === self::PHP_SERIALIZED_OBJECT_PREFIX) {
$contextAsString = $this->formatSerializedObject($contextAsString);
}
$contextAsString = $this->formatTextBlock($contextAsString, '--> ');
$contextAsString = rtrim($contextAsString, PHP_EOL);
return $contextAsString;
} | [
"private",
"function",
"formatContext",
"(",
"array",
"$",
"record",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"filterVariablesUsedAsPlaceholders",
"(",
"$",
"record",
"[",
"'message'",
"]",
",",
"$",
"record",
"[",
"'context'",
"]",
")",
";",
"$",... | @param array $record
@return string | [
"@param",
"array",
"$record"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L363-L379 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatThrowableObjects | private function formatThrowableObjects(array $array)
{
array_walk_recursive($array, function (&$value) {
if ($value instanceof \Throwable) {
try {
$value = serialize($value);
} catch (\Throwable $throwable) {
$value = $this->formatThrowable($value);
}
}
});
return $array;
} | php | private function formatThrowableObjects(array $array)
{
array_walk_recursive($array, function (&$value) {
if ($value instanceof \Throwable) {
try {
$value = serialize($value);
} catch (\Throwable $throwable) {
$value = $this->formatThrowable($value);
}
}
});
return $array;
} | [
"private",
"function",
"formatThrowableObjects",
"(",
"array",
"$",
"array",
")",
"{",
"array_walk_recursive",
"(",
"$",
"array",
",",
"function",
"(",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"Throwable",
")",
"{",
"try",
... | Turns any Throwable object present in the given array into a string
representation. If the object cannot be serialized, an approximative
representation of the object is given instead.
@param array $array
@return array | [
"Turns",
"any",
"Throwable",
"object",
"present",
"in",
"the",
"given",
"array",
"into",
"a",
"string",
"representation",
".",
"If",
"the",
"object",
"cannot",
"be",
"serialized",
"an",
"approximative",
"representation",
"of",
"the",
"object",
"is",
"given",
"... | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L390-L403 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatSerializedObject | private function formatSerializedObject($objectString)
{
$objectPrefixLength = strlen(self::PHP_SERIALIZED_OBJECT_PREFIX);
$objectStart = strpos($objectString, self::PHP_SERIALIZED_OBJECT_PREFIX) + $objectPrefixLength;
$beforePrefix = substr($objectString, 0, $objectStart - $objectPrefixLength);
$objectAsString = print_r(unserialize(substr($objectString, $objectStart)), true);
return $beforePrefix.$objectAsString;
} | php | private function formatSerializedObject($objectString)
{
$objectPrefixLength = strlen(self::PHP_SERIALIZED_OBJECT_PREFIX);
$objectStart = strpos($objectString, self::PHP_SERIALIZED_OBJECT_PREFIX) + $objectPrefixLength;
$beforePrefix = substr($objectString, 0, $objectStart - $objectPrefixLength);
$objectAsString = print_r(unserialize(substr($objectString, $objectStart)), true);
return $beforePrefix.$objectAsString;
} | [
"private",
"function",
"formatSerializedObject",
"(",
"$",
"objectString",
")",
"{",
"$",
"objectPrefixLength",
"=",
"strlen",
"(",
"self",
"::",
"PHP_SERIALIZED_OBJECT_PREFIX",
")",
";",
"$",
"objectStart",
"=",
"strpos",
"(",
"$",
"objectString",
",",
"self",
... | @param $objectString
@return string | [
"@param",
"$objectString"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L423-L431 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatExtra | private function formatExtra(array $record)
{
$extra = $this->formatDateTimeObjects($record['extra']);
$extraAsString = Yaml::dump(array('extra' => $extra), 1, $this->prefixLength);
$extraAsString = $this->formatTextBlock($extraAsString, '--> ');
return $extraAsString;
} | php | private function formatExtra(array $record)
{
$extra = $this->formatDateTimeObjects($record['extra']);
$extraAsString = Yaml::dump(array('extra' => $extra), 1, $this->prefixLength);
$extraAsString = $this->formatTextBlock($extraAsString, '--> ');
return $extraAsString;
} | [
"private",
"function",
"formatExtra",
"(",
"array",
"$",
"record",
")",
"{",
"$",
"extra",
"=",
"$",
"this",
"->",
"formatDateTimeObjects",
"(",
"$",
"record",
"[",
"'extra'",
"]",
")",
";",
"$",
"extraAsString",
"=",
"Yaml",
"::",
"dump",
"(",
"array",
... | @param array $record
@return string | [
"@param",
"array",
"$record"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L438-L445 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatLogLevel | private function formatLogLevel(array $record)
{
if (!isset($record['level_name'])) {
return '';
}
$level = $record['level_name'];
$levelLabels = array(
'DEBUG' => '',
'INFO' => '',
'WARNING' => '** WARNING ** ==> ',
'ERROR' => '*** ERROR *** ==> ',
'CRITICAL' => '*** CRITICAL ERROR *** ==> ',
);
return array_key_exists($level, $levelLabels) ? $levelLabels[$level] : $level.' ';
} | php | private function formatLogLevel(array $record)
{
if (!isset($record['level_name'])) {
return '';
}
$level = $record['level_name'];
$levelLabels = array(
'DEBUG' => '',
'INFO' => '',
'WARNING' => '** WARNING ** ==> ',
'ERROR' => '*** ERROR *** ==> ',
'CRITICAL' => '*** CRITICAL ERROR *** ==> ',
);
return array_key_exists($level, $levelLabels) ? $levelLabels[$level] : $level.' ';
} | [
"private",
"function",
"formatLogLevel",
"(",
"array",
"$",
"record",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"record",
"[",
"'level_name'",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"level",
"=",
"$",
"record",
"[",
"'level_name'",
"]"... | @param array $record
@return mixed|string | [
"@param",
"array",
"$record"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L462-L478 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatMessage | private function formatMessage(array $record)
{
$message = $this->processStringPlaceholders($record['message'], $record['context']);
$message = $this->formatStringAsTextBlock($message);
return $message;
} | php | private function formatMessage(array $record)
{
$message = $this->processStringPlaceholders($record['message'], $record['context']);
$message = $this->formatStringAsTextBlock($message);
return $message;
} | [
"private",
"function",
"formatMessage",
"(",
"array",
"$",
"record",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"processStringPlaceholders",
"(",
"$",
"record",
"[",
"'message'",
"]",
",",
"$",
"record",
"[",
"'context'",
"]",
")",
";",
"$",
"mess... | @param array $record
@return string | [
"@param",
"array",
"$record"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L485-L491 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatRecord | private function formatRecord(array $records, $currentRecordIndex)
{
$record = $records[$currentRecordIndex];
$recordAsString = '';
if ($this->isLogInfoDisplayed($record)) {
$logInfo = $this->formatLogInfo($record);
$recordAsString .= $this->formatAsSection($logInfo);
}
if (isset($record['message']) && !empty($record['message'])) {
$recordAsString .= $this->formatMessage($record).PHP_EOL;
}
if (isset($record['context']) && !empty($record['context'])) {
// if the context contains an error stack trace, remove it to display it separately
$stack = null;
if (isset($record['context']['stack'])) {
$stack = $record['context']['stack'];
unset($record['context']['stack']);
}
$recordAsString .= $this->formatContext($record).PHP_EOL;
if (null !== $stack) {
$recordAsString .= '--> Stack Trace:'.PHP_EOL;
$recordAsString .= $this->formatStackTrace($stack, ' | ');
}
}
if (isset($record['extra']) && !empty($record['extra'])) {
// don't display the extra information when it's identical to the previous log record
$previousRecordExtra = isset($records[$currentRecordIndex - 1]) ? $records[$currentRecordIndex - 1]['extra'] : null;
if ($record['extra'] !== $previousRecordExtra) {
$recordAsString .= $this->formatExtra($record).PHP_EOL;
}
}
return $recordAsString;
} | php | private function formatRecord(array $records, $currentRecordIndex)
{
$record = $records[$currentRecordIndex];
$recordAsString = '';
if ($this->isLogInfoDisplayed($record)) {
$logInfo = $this->formatLogInfo($record);
$recordAsString .= $this->formatAsSection($logInfo);
}
if (isset($record['message']) && !empty($record['message'])) {
$recordAsString .= $this->formatMessage($record).PHP_EOL;
}
if (isset($record['context']) && !empty($record['context'])) {
// if the context contains an error stack trace, remove it to display it separately
$stack = null;
if (isset($record['context']['stack'])) {
$stack = $record['context']['stack'];
unset($record['context']['stack']);
}
$recordAsString .= $this->formatContext($record).PHP_EOL;
if (null !== $stack) {
$recordAsString .= '--> Stack Trace:'.PHP_EOL;
$recordAsString .= $this->formatStackTrace($stack, ' | ');
}
}
if (isset($record['extra']) && !empty($record['extra'])) {
// don't display the extra information when it's identical to the previous log record
$previousRecordExtra = isset($records[$currentRecordIndex - 1]) ? $records[$currentRecordIndex - 1]['extra'] : null;
if ($record['extra'] !== $previousRecordExtra) {
$recordAsString .= $this->formatExtra($record).PHP_EOL;
}
}
return $recordAsString;
} | [
"private",
"function",
"formatRecord",
"(",
"array",
"$",
"records",
",",
"$",
"currentRecordIndex",
")",
"{",
"$",
"record",
"=",
"$",
"records",
"[",
"$",
"currentRecordIndex",
"]",
";",
"$",
"recordAsString",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"-... | @param array $records
@param int $currentRecordIndex
@return string | [
"@param",
"array",
"$records",
"@param",
"int",
"$currentRecordIndex"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L499-L538 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatStackTrace | private function formatStackTrace(array $trace, $prefix = '')
{
$traceAsString = '';
foreach ($trace as $line) {
if (isset($line['class']) && isset($line['type']) && isset($line['function'])) {
$traceAsString .= sprintf('%s%s%s()', $line['class'], $line['type'], $line['function']).PHP_EOL;
} elseif (isset($line['class'])) {
$traceAsString .= sprintf('%s', $line['class']).PHP_EOL;
} elseif (isset($line['function'])) {
$traceAsString .= sprintf('%s()', $line['function']).PHP_EOL;
}
if (isset($line['file']) && isset($line['line'])) {
$traceAsString .= sprintf(' > %s:%d', $this->makePathRelative($line['file']), $line['line']).PHP_EOL;
}
}
$traceAsString = $this->formatTextBlock($traceAsString, $prefix, true);
return $traceAsString;
} | php | private function formatStackTrace(array $trace, $prefix = '')
{
$traceAsString = '';
foreach ($trace as $line) {
if (isset($line['class']) && isset($line['type']) && isset($line['function'])) {
$traceAsString .= sprintf('%s%s%s()', $line['class'], $line['type'], $line['function']).PHP_EOL;
} elseif (isset($line['class'])) {
$traceAsString .= sprintf('%s', $line['class']).PHP_EOL;
} elseif (isset($line['function'])) {
$traceAsString .= sprintf('%s()', $line['function']).PHP_EOL;
}
if (isset($line['file']) && isset($line['line'])) {
$traceAsString .= sprintf(' > %s:%d', $this->makePathRelative($line['file']), $line['line']).PHP_EOL;
}
}
$traceAsString = $this->formatTextBlock($traceAsString, $prefix, true);
return $traceAsString;
} | [
"private",
"function",
"formatStackTrace",
"(",
"array",
"$",
"trace",
",",
"$",
"prefix",
"=",
"''",
")",
"{",
"$",
"traceAsString",
"=",
"''",
";",
"foreach",
"(",
"$",
"trace",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"line",
"... | @param array $trace
@param string $prefix
@return string | [
"@param",
"array",
"$trace",
"@param",
"string",
"$prefix"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L546-L566 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatLogBatchHeader | private function formatLogBatchHeader(array $records)
{
$firstRecord = $records[0];
if ($this->isAsseticLog($firstRecord)) {
return $this->formatAsSubtitle('Assetic request');
}
$logDate = $firstRecord['datetime'];
$logDateAsString = $logDate->format('d/M/Y H:i:s');
return $this->formatAsTitle($logDateAsString);
} | php | private function formatLogBatchHeader(array $records)
{
$firstRecord = $records[0];
if ($this->isAsseticLog($firstRecord)) {
return $this->formatAsSubtitle('Assetic request');
}
$logDate = $firstRecord['datetime'];
$logDateAsString = $logDate->format('d/M/Y H:i:s');
return $this->formatAsTitle($logDateAsString);
} | [
"private",
"function",
"formatLogBatchHeader",
"(",
"array",
"$",
"records",
")",
"{",
"$",
"firstRecord",
"=",
"$",
"records",
"[",
"0",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"isAsseticLog",
"(",
"$",
"firstRecord",
")",
")",
"{",
"return",
"$",
"th... | @param array $records
@return string | [
"@param",
"array",
"$records"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L573-L585 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatAsTitle | private function formatAsTitle($text)
{
$titleLines = array();
$titleLines[] = str_repeat('#', $this->maxLineLength);
$titleLines[] = rtrim($this->formatAsSubtitle($text), PHP_EOL);
$titleLines[] = str_repeat('#', $this->maxLineLength);
return implode(PHP_EOL, $titleLines).PHP_EOL;
} | php | private function formatAsTitle($text)
{
$titleLines = array();
$titleLines[] = str_repeat('#', $this->maxLineLength);
$titleLines[] = rtrim($this->formatAsSubtitle($text), PHP_EOL);
$titleLines[] = str_repeat('#', $this->maxLineLength);
return implode(PHP_EOL, $titleLines).PHP_EOL;
} | [
"private",
"function",
"formatAsTitle",
"(",
"$",
"text",
")",
"{",
"$",
"titleLines",
"=",
"array",
"(",
")",
";",
"$",
"titleLines",
"[",
"]",
"=",
"str_repeat",
"(",
"'#'",
",",
"$",
"this",
"->",
"maxLineLength",
")",
";",
"$",
"titleLines",
"[",
... | @param string $text
@return string | [
"@param",
"string",
"$text"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L592-L601 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatAsSubtitle | private function formatAsSubtitle($text)
{
$subtitle = str_pad('### '.$text.' ', $this->maxLineLength, '#', STR_PAD_BOTH);
return $subtitle.PHP_EOL;
} | php | private function formatAsSubtitle($text)
{
$subtitle = str_pad('### '.$text.' ', $this->maxLineLength, '#', STR_PAD_BOTH);
return $subtitle.PHP_EOL;
} | [
"private",
"function",
"formatAsSubtitle",
"(",
"$",
"text",
")",
"{",
"$",
"subtitle",
"=",
"str_pad",
"(",
"'### '",
".",
"$",
"text",
".",
"' '",
",",
"$",
"this",
"->",
"maxLineLength",
",",
"'#'",
",",
"STR_PAD_BOTH",
")",
";",
"return",
"$",
"s... | @param string $text
@return string | [
"@param",
"string",
"$text"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L608-L613 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatAsSection | private function formatAsSection($text)
{
$section = str_pad(str_repeat('_', 3).' '.$text.' ', $this->maxLineLength, '_', STR_PAD_RIGHT);
return $section.PHP_EOL;
} | php | private function formatAsSection($text)
{
$section = str_pad(str_repeat('_', 3).' '.$text.' ', $this->maxLineLength, '_', STR_PAD_RIGHT);
return $section.PHP_EOL;
} | [
"private",
"function",
"formatAsSection",
"(",
"$",
"text",
")",
"{",
"$",
"section",
"=",
"str_pad",
"(",
"str_repeat",
"(",
"'_'",
",",
"3",
")",
".",
"' '",
".",
"$",
"text",
".",
"' '",
",",
"$",
"this",
"->",
"maxLineLength",
",",
"'_'",
",",
... | @param string $text
@return string | [
"@param",
"string",
"$text"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L620-L625 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatStringAsTextBlock | private function formatStringAsTextBlock($string)
{
if (!is_string($string)) {
return '';
}
$string = wordwrap($string, $this->maxLineLength - $this->prefixLength);
$stringLines = explode(PHP_EOL, $string);
foreach ($stringLines as &$line) {
$line = str_repeat(' ', $this->prefixLength).$line;
}
$string = implode(PHP_EOL, $stringLines);
// needed to remove the unnecessary prefix added to the first line
$string = trim($string);
return $string;
} | php | private function formatStringAsTextBlock($string)
{
if (!is_string($string)) {
return '';
}
$string = wordwrap($string, $this->maxLineLength - $this->prefixLength);
$stringLines = explode(PHP_EOL, $string);
foreach ($stringLines as &$line) {
$line = str_repeat(' ', $this->prefixLength).$line;
}
$string = implode(PHP_EOL, $stringLines);
// needed to remove the unnecessary prefix added to the first line
$string = trim($string);
return $string;
} | [
"private",
"function",
"formatStringAsTextBlock",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"string",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"string",
"=",
"wordwrap",
"(",
"$",
"string",
",",
"$",
"this",
"->",
"max... | @param string $string
@return string | [
"@param",
"string",
"$string"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L632-L651 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.formatTextBlock | private function formatTextBlock($text, $prefix = '', $prefixAllLines = false)
{
if (empty($text)) {
return $text;
}
$textLines = explode(PHP_EOL, $text);
// remove the trailing PHP_EOL (and add it back afterwards) to avoid formatting issues
$addTrailingNewline = false;
if ('' === $textLines[count($textLines) - 1]) {
array_pop($textLines);
$addTrailingNewline = true;
}
$newTextLines = array();
foreach ($textLines as $line) {
if ($prefixAllLines) {
$newTextLines[] = $prefix.$line;
} else {
if (isset($line[0]) && ' ' !== $line[0]) {
$newTextLines[] = $prefix.$line;
} else {
$newTextLines[] = str_repeat(' ', strlen($prefix)).$line;
}
}
}
return implode(PHP_EOL, $newTextLines).($addTrailingNewline ? PHP_EOL : '');
} | php | private function formatTextBlock($text, $prefix = '', $prefixAllLines = false)
{
if (empty($text)) {
return $text;
}
$textLines = explode(PHP_EOL, $text);
// remove the trailing PHP_EOL (and add it back afterwards) to avoid formatting issues
$addTrailingNewline = false;
if ('' === $textLines[count($textLines) - 1]) {
array_pop($textLines);
$addTrailingNewline = true;
}
$newTextLines = array();
foreach ($textLines as $line) {
if ($prefixAllLines) {
$newTextLines[] = $prefix.$line;
} else {
if (isset($line[0]) && ' ' !== $line[0]) {
$newTextLines[] = $prefix.$line;
} else {
$newTextLines[] = str_repeat(' ', strlen($prefix)).$line;
}
}
}
return implode(PHP_EOL, $newTextLines).($addTrailingNewline ? PHP_EOL : '');
} | [
"private",
"function",
"formatTextBlock",
"(",
"$",
"text",
",",
"$",
"prefix",
"=",
"''",
",",
"$",
"prefixAllLines",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"text",
")",
")",
"{",
"return",
"$",
"text",
";",
"}",
"$",
"textLines",
"... | Prepends the prefix to every line of the given string.
@param string $text
@param string $prefix
@param bool $prefixAllLines If false, prefix is only added to lines that don't start with white spaces
@return string | [
"Prepends",
"the",
"prefix",
"to",
"every",
"line",
"of",
"the",
"given",
"string",
"."
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L662-L691 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.filterVariablesUsedAsPlaceholders | private function filterVariablesUsedAsPlaceholders($string, array $variables)
{
if (empty($string)) {
return $variables;
}
// array_filter() is not used because ARRAY_FILTER_USE_KEY requires PHP 5.6
$filteredVariables = array();
foreach ($variables as $key => $value) {
if (false === strpos($string, '{'.$key.'}')) {
$filteredVariables[$key] = $value;
}
}
return $filteredVariables;
} | php | private function filterVariablesUsedAsPlaceholders($string, array $variables)
{
if (empty($string)) {
return $variables;
}
// array_filter() is not used because ARRAY_FILTER_USE_KEY requires PHP 5.6
$filteredVariables = array();
foreach ($variables as $key => $value) {
if (false === strpos($string, '{'.$key.'}')) {
$filteredVariables[$key] = $value;
}
}
return $filteredVariables;
} | [
"private",
"function",
"filterVariablesUsedAsPlaceholders",
"(",
"$",
"string",
",",
"array",
"$",
"variables",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"string",
")",
")",
"{",
"return",
"$",
"variables",
";",
"}",
"// array_filter() is not used because ARRAY_FILT... | It scans the given string for placeholders and removes from $variables
any element whose key matches the name of a placeholder.
@param string $string
@param array $variables
@return array | [
"It",
"scans",
"the",
"given",
"string",
"for",
"placeholders",
"and",
"removes",
"from",
"$variables",
"any",
"element",
"whose",
"key",
"matches",
"the",
"name",
"of",
"a",
"placeholder",
"."
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L721-L736 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.getInlineLevel | private function getInlineLevel(array $record)
{
if ($this->isTranslationLog($record)) {
return 0;
}
if ($this->isDoctrineLog($record) || $this->isAsseticLog($record)) {
return 1;
}
return 2;
} | php | private function getInlineLevel(array $record)
{
if ($this->isTranslationLog($record)) {
return 0;
}
if ($this->isDoctrineLog($record) || $this->isAsseticLog($record)) {
return 1;
}
return 2;
} | [
"private",
"function",
"getInlineLevel",
"(",
"array",
"$",
"record",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isTranslationLog",
"(",
"$",
"record",
")",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isDoctrineLog",
"(",
"$",
"re... | It returns the level at which YAML component inlines the values, which
determines how compact or readable the information is displayed.
@param array $record
@return int | [
"It",
"returns",
"the",
"level",
"at",
"which",
"YAML",
"component",
"inlines",
"the",
"values",
"which",
"determines",
"how",
"compact",
"or",
"readable",
"the",
"information",
"is",
"displayed",
"."
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L746-L757 |
EasyCorp/easy-log-handler | src/EasyLogFormatter.php | EasyLogFormatter.makePathRelative | private function makePathRelative($filePath)
{
$thisFilePath = __FILE__;
$thisFilePathParts = explode('/src/', $thisFilePath);
$projectRootDir = $thisFilePathParts[0].DIRECTORY_SEPARATOR;
return str_replace($projectRootDir, '', $filePath);
} | php | private function makePathRelative($filePath)
{
$thisFilePath = __FILE__;
$thisFilePathParts = explode('/src/', $thisFilePath);
$projectRootDir = $thisFilePathParts[0].DIRECTORY_SEPARATOR;
return str_replace($projectRootDir, '', $filePath);
} | [
"private",
"function",
"makePathRelative",
"(",
"$",
"filePath",
")",
"{",
"$",
"thisFilePath",
"=",
"__FILE__",
";",
"$",
"thisFilePathParts",
"=",
"explode",
"(",
"'/src/'",
",",
"$",
"thisFilePath",
")",
";",
"$",
"projectRootDir",
"=",
"$",
"thisFilePathPa... | @param string $filePath
@return mixed | [
"@param",
"string",
"$filePath"
] | train | https://github.com/EasyCorp/easy-log-handler/blob/5f95717248d20684f88cfb878d8bf3d78aadcbba/src/EasyLogFormatter.php#L792-L799 |
php-http/discovery | src/Strategy/CommonClassesStrategy.php | CommonClassesStrategy.getCandidates | public static function getCandidates($type)
{
if (Psr18Client::class === $type) {
$candidates = self::$classes[PSR18Client::class];
// HTTPlug 2.0 clients implements PSR18Client too.
foreach (self::$classes[HttpClient::class] as $c) {
if (is_subclass_of($c['class'], Psr18Client::class)) {
$candidates[] = $c;
}
}
return $candidates;
}
if (isset(self::$classes[$type])) {
return self::$classes[$type];
}
return [];
} | php | public static function getCandidates($type)
{
if (Psr18Client::class === $type) {
$candidates = self::$classes[PSR18Client::class];
// HTTPlug 2.0 clients implements PSR18Client too.
foreach (self::$classes[HttpClient::class] as $c) {
if (is_subclass_of($c['class'], Psr18Client::class)) {
$candidates[] = $c;
}
}
return $candidates;
}
if (isset(self::$classes[$type])) {
return self::$classes[$type];
}
return [];
} | [
"public",
"static",
"function",
"getCandidates",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"Psr18Client",
"::",
"class",
"===",
"$",
"type",
")",
"{",
"$",
"candidates",
"=",
"self",
"::",
"$",
"classes",
"[",
"PSR18Client",
"::",
"class",
"]",
";",
"// H... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/Strategy/CommonClassesStrategy.php#L95-L115 |
php-http/discovery | src/Psr17FactoryDiscovery.php | Psr17FactoryDiscovery.findRequestFactory | public static function findRequestFactory()
{
try {
$messageFactory = static::findOneByType(RequestFactoryInterface::class);
} catch (DiscoveryFailedException $e) {
throw self::createException('request factory', $e);
}
return static::instantiateClass($messageFactory);
} | php | public static function findRequestFactory()
{
try {
$messageFactory = static::findOneByType(RequestFactoryInterface::class);
} catch (DiscoveryFailedException $e) {
throw self::createException('request factory', $e);
}
return static::instantiateClass($messageFactory);
} | [
"public",
"static",
"function",
"findRequestFactory",
"(",
")",
"{",
"try",
"{",
"$",
"messageFactory",
"=",
"static",
"::",
"findOneByType",
"(",
"RequestFactoryInterface",
"::",
"class",
")",
";",
"}",
"catch",
"(",
"DiscoveryFailedException",
"$",
"e",
")",
... | @return RequestFactoryInterface
@throws Exception\NotFoundException | [
"@return",
"RequestFactoryInterface"
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/Psr17FactoryDiscovery.php#L34-L43 |
php-http/discovery | src/Psr17FactoryDiscovery.php | Psr17FactoryDiscovery.findResponseFactory | public static function findResponseFactory()
{
try {
$messageFactory = static::findOneByType(ResponseFactoryInterface::class);
} catch (DiscoveryFailedException $e) {
throw self::createException('response factory', $e);
}
return static::instantiateClass($messageFactory);
} | php | public static function findResponseFactory()
{
try {
$messageFactory = static::findOneByType(ResponseFactoryInterface::class);
} catch (DiscoveryFailedException $e) {
throw self::createException('response factory', $e);
}
return static::instantiateClass($messageFactory);
} | [
"public",
"static",
"function",
"findResponseFactory",
"(",
")",
"{",
"try",
"{",
"$",
"messageFactory",
"=",
"static",
"::",
"findOneByType",
"(",
"ResponseFactoryInterface",
"::",
"class",
")",
";",
"}",
"catch",
"(",
"DiscoveryFailedException",
"$",
"e",
")",... | @return ResponseFactoryInterface
@throws Exception\NotFoundException | [
"@return",
"ResponseFactoryInterface"
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/Psr17FactoryDiscovery.php#L50-L59 |
php-http/discovery | src/Psr17FactoryDiscovery.php | Psr17FactoryDiscovery.findServerRequestFactory | public static function findServerRequestFactory()
{
try {
$messageFactory = static::findOneByType(ServerRequestFactoryInterface::class);
} catch (DiscoveryFailedException $e) {
throw self::createException('server request factory', $e);
}
return static::instantiateClass($messageFactory);
} | php | public static function findServerRequestFactory()
{
try {
$messageFactory = static::findOneByType(ServerRequestFactoryInterface::class);
} catch (DiscoveryFailedException $e) {
throw self::createException('server request factory', $e);
}
return static::instantiateClass($messageFactory);
} | [
"public",
"static",
"function",
"findServerRequestFactory",
"(",
")",
"{",
"try",
"{",
"$",
"messageFactory",
"=",
"static",
"::",
"findOneByType",
"(",
"ServerRequestFactoryInterface",
"::",
"class",
")",
";",
"}",
"catch",
"(",
"DiscoveryFailedException",
"$",
"... | @return ServerRequestFactoryInterface
@throws Exception\NotFoundException | [
"@return",
"ServerRequestFactoryInterface"
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/Psr17FactoryDiscovery.php#L66-L75 |
php-http/discovery | src/Psr17FactoryDiscovery.php | Psr17FactoryDiscovery.findStreamFactory | public static function findStreamFactory()
{
try {
$messageFactory = static::findOneByType(StreamFactoryInterface::class);
} catch (DiscoveryFailedException $e) {
throw self::createException('stream factory', $e);
}
return static::instantiateClass($messageFactory);
} | php | public static function findStreamFactory()
{
try {
$messageFactory = static::findOneByType(StreamFactoryInterface::class);
} catch (DiscoveryFailedException $e) {
throw self::createException('stream factory', $e);
}
return static::instantiateClass($messageFactory);
} | [
"public",
"static",
"function",
"findStreamFactory",
"(",
")",
"{",
"try",
"{",
"$",
"messageFactory",
"=",
"static",
"::",
"findOneByType",
"(",
"StreamFactoryInterface",
"::",
"class",
")",
";",
"}",
"catch",
"(",
"DiscoveryFailedException",
"$",
"e",
")",
"... | @return StreamFactoryInterface
@throws Exception\NotFoundException | [
"@return",
"StreamFactoryInterface"
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/Psr17FactoryDiscovery.php#L82-L91 |
php-http/discovery | src/Psr17FactoryDiscovery.php | Psr17FactoryDiscovery.findUploadedFileFactory | public static function findUploadedFileFactory()
{
try {
$messageFactory = static::findOneByType(UploadedFileFactoryInterface::class);
} catch (DiscoveryFailedException $e) {
throw self::createException('uploaded file factory', $e);
}
return static::instantiateClass($messageFactory);
} | php | public static function findUploadedFileFactory()
{
try {
$messageFactory = static::findOneByType(UploadedFileFactoryInterface::class);
} catch (DiscoveryFailedException $e) {
throw self::createException('uploaded file factory', $e);
}
return static::instantiateClass($messageFactory);
} | [
"public",
"static",
"function",
"findUploadedFileFactory",
"(",
")",
"{",
"try",
"{",
"$",
"messageFactory",
"=",
"static",
"::",
"findOneByType",
"(",
"UploadedFileFactoryInterface",
"::",
"class",
")",
";",
"}",
"catch",
"(",
"DiscoveryFailedException",
"$",
"e"... | @return UploadedFileFactoryInterface
@throws Exception\NotFoundException | [
"@return",
"UploadedFileFactoryInterface"
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/Psr17FactoryDiscovery.php#L98-L107 |
php-http/discovery | src/Psr17FactoryDiscovery.php | Psr17FactoryDiscovery.findUrlFactory | public static function findUrlFactory()
{
try {
$messageFactory = static::findOneByType(UriFactoryInterface::class);
} catch (DiscoveryFailedException $e) {
throw self::createException('url factory', $e);
}
return static::instantiateClass($messageFactory);
} | php | public static function findUrlFactory()
{
try {
$messageFactory = static::findOneByType(UriFactoryInterface::class);
} catch (DiscoveryFailedException $e) {
throw self::createException('url factory', $e);
}
return static::instantiateClass($messageFactory);
} | [
"public",
"static",
"function",
"findUrlFactory",
"(",
")",
"{",
"try",
"{",
"$",
"messageFactory",
"=",
"static",
"::",
"findOneByType",
"(",
"UriFactoryInterface",
"::",
"class",
")",
";",
"}",
"catch",
"(",
"DiscoveryFailedException",
"$",
"e",
")",
"{",
... | @return UriFactoryInterface
@throws Exception\NotFoundException | [
"@return",
"UriFactoryInterface"
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/Psr17FactoryDiscovery.php#L114-L123 |
php-http/discovery | src/Psr18ClientDiscovery.php | Psr18ClientDiscovery.find | public static function find()
{
try {
$client = static::findOneByType(ClientInterface::class);
} catch (DiscoveryFailedException $e) {
throw new \Http\Discovery\Exception\NotFoundException(
'No PSR-18 clients found. Make sure to install a package providing "psr/http-client-implementation". Example: "php-http/guzzle6-adapter".',
0,
$e
);
}
return static::instantiateClass($client);
} | php | public static function find()
{
try {
$client = static::findOneByType(ClientInterface::class);
} catch (DiscoveryFailedException $e) {
throw new \Http\Discovery\Exception\NotFoundException(
'No PSR-18 clients found. Make sure to install a package providing "psr/http-client-implementation". Example: "php-http/guzzle6-adapter".',
0,
$e
);
}
return static::instantiateClass($client);
} | [
"public",
"static",
"function",
"find",
"(",
")",
"{",
"try",
"{",
"$",
"client",
"=",
"static",
"::",
"findOneByType",
"(",
"ClientInterface",
"::",
"class",
")",
";",
"}",
"catch",
"(",
"DiscoveryFailedException",
"$",
"e",
")",
"{",
"throw",
"new",
"\... | Finds a PSR-18 HTTP Client.
@return ClientInterface
@throws Exception\NotFoundException | [
"Finds",
"a",
"PSR",
"-",
"18",
"HTTP",
"Client",
"."
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/Psr18ClientDiscovery.php#L22-L35 |
php-http/discovery | src/Strategy/CommonPsr17ClassesStrategy.php | CommonPsr17ClassesStrategy.getCandidates | public static function getCandidates($type)
{
$candidates = [];
if (isset(self::$classes[$type])) {
foreach (self::$classes[$type] as $class) {
$candidates[] = ['class' => $class, 'condition' => [$class]];
}
}
return $candidates;
} | php | public static function getCandidates($type)
{
$candidates = [];
if (isset(self::$classes[$type])) {
foreach (self::$classes[$type] as $class) {
$candidates[] = ['class' => $class, 'condition' => [$class]];
}
}
return $candidates;
} | [
"public",
"static",
"function",
"getCandidates",
"(",
"$",
"type",
")",
"{",
"$",
"candidates",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"classes",
"[",
"$",
"type",
"]",
")",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"c... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/Strategy/CommonPsr17ClassesStrategy.php#L70-L80 |
php-http/discovery | src/ClassDiscovery.php | ClassDiscovery.findOneByType | protected static function findOneByType($type)
{
// Look in the cache
if (null !== ($class = self::getFromCache($type))) {
return $class;
}
$exceptions = [];
foreach (self::$strategies as $strategy) {
try {
$candidates = call_user_func($strategy.'::getCandidates', $type);
} catch (StrategyUnavailableException $e) {
$exceptions[] = $e;
continue;
}
foreach ($candidates as $candidate) {
if (isset($candidate['condition'])) {
if (!self::evaluateCondition($candidate['condition'])) {
continue;
}
}
// save the result for later use
self::storeInCache($type, $candidate);
return $candidate['class'];
}
$exceptions[] = new NoCandidateFoundException($strategy, $candidates);
}
throw DiscoveryFailedException::create($exceptions);
} | php | protected static function findOneByType($type)
{
// Look in the cache
if (null !== ($class = self::getFromCache($type))) {
return $class;
}
$exceptions = [];
foreach (self::$strategies as $strategy) {
try {
$candidates = call_user_func($strategy.'::getCandidates', $type);
} catch (StrategyUnavailableException $e) {
$exceptions[] = $e;
continue;
}
foreach ($candidates as $candidate) {
if (isset($candidate['condition'])) {
if (!self::evaluateCondition($candidate['condition'])) {
continue;
}
}
// save the result for later use
self::storeInCache($type, $candidate);
return $candidate['class'];
}
$exceptions[] = new NoCandidateFoundException($strategy, $candidates);
}
throw DiscoveryFailedException::create($exceptions);
} | [
"protected",
"static",
"function",
"findOneByType",
"(",
"$",
"type",
")",
"{",
"// Look in the cache",
"if",
"(",
"null",
"!==",
"(",
"$",
"class",
"=",
"self",
"::",
"getFromCache",
"(",
"$",
"type",
")",
")",
")",
"{",
"return",
"$",
"class",
";",
"... | Finds a class.
@param string $type
@return string|\Closure
@throws DiscoveryFailedException | [
"Finds",
"a",
"class",
"."
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/ClassDiscovery.php#L46-L80 |
php-http/discovery | src/ClassDiscovery.php | ClassDiscovery.getFromCache | private static function getFromCache($type)
{
if (!isset(self::$cache[$type])) {
return;
}
$candidate = self::$cache[$type];
if (isset($candidate['condition'])) {
if (!self::evaluateCondition($candidate['condition'])) {
return;
}
}
return $candidate['class'];
} | php | private static function getFromCache($type)
{
if (!isset(self::$cache[$type])) {
return;
}
$candidate = self::$cache[$type];
if (isset($candidate['condition'])) {
if (!self::evaluateCondition($candidate['condition'])) {
return;
}
}
return $candidate['class'];
} | [
"private",
"static",
"function",
"getFromCache",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"cache",
"[",
"$",
"type",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"candidate",
"=",
"self",
"::",
"$",
"cache",
"[... | Get a value from cache.
@param string $type
@return string|null | [
"Get",
"a",
"value",
"from",
"cache",
"."
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/ClassDiscovery.php#L89-L103 |
php-http/discovery | src/ClassDiscovery.php | ClassDiscovery.evaluateCondition | protected static function evaluateCondition($condition)
{
if (is_string($condition)) {
// Should be extended for functions, extensions???
return self::safeClassExists($condition);
}
if (is_callable($condition)) {
return (bool) $condition();
}
if (is_bool($condition)) {
return $condition;
}
if (is_array($condition)) {
foreach ($condition as $c) {
if (false === static::evaluateCondition($c)) {
// Immediately stop execution if the condition is false
return false;
}
}
return true;
}
return false;
} | php | protected static function evaluateCondition($condition)
{
if (is_string($condition)) {
// Should be extended for functions, extensions???
return self::safeClassExists($condition);
}
if (is_callable($condition)) {
return (bool) $condition();
}
if (is_bool($condition)) {
return $condition;
}
if (is_array($condition)) {
foreach ($condition as $c) {
if (false === static::evaluateCondition($c)) {
// Immediately stop execution if the condition is false
return false;
}
}
return true;
}
return false;
} | [
"protected",
"static",
"function",
"evaluateCondition",
"(",
"$",
"condition",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"condition",
")",
")",
"{",
"// Should be extended for functions, extensions???",
"return",
"self",
"::",
"safeClassExists",
"(",
"$",
"conditi... | Evaluates conditions to boolean.
@param mixed $condition
@return bool | [
"Evaluates",
"conditions",
"to",
"boolean",
"."
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/ClassDiscovery.php#L164-L188 |
php-http/discovery | src/UriFactoryDiscovery.php | UriFactoryDiscovery.find | public static function find()
{
try {
$uriFactory = static::findOneByType(UriFactory::class);
} catch (DiscoveryFailedException $e) {
throw new NotFoundException(
'No uri factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.',
0,
$e
);
}
return static::instantiateClass($uriFactory);
} | php | public static function find()
{
try {
$uriFactory = static::findOneByType(UriFactory::class);
} catch (DiscoveryFailedException $e) {
throw new NotFoundException(
'No uri factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.',
0,
$e
);
}
return static::instantiateClass($uriFactory);
} | [
"public",
"static",
"function",
"find",
"(",
")",
"{",
"try",
"{",
"$",
"uriFactory",
"=",
"static",
"::",
"findOneByType",
"(",
"UriFactory",
"::",
"class",
")",
";",
"}",
"catch",
"(",
"DiscoveryFailedException",
"$",
"e",
")",
"{",
"throw",
"new",
"No... | Finds a URI Factory.
@return UriFactory
@throws Exception\NotFoundException | [
"Finds",
"a",
"URI",
"Factory",
"."
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/UriFactoryDiscovery.php#L24-L37 |
php-http/discovery | src/Strategy/PuliBetaStrategy.php | PuliBetaStrategy.getPuliFactory | private static function getPuliFactory()
{
if (null === self::$puliFactory) {
if (!defined('PULI_FACTORY_CLASS')) {
throw new PuliUnavailableException('Puli Factory is not available');
}
$puliFactoryClass = PULI_FACTORY_CLASS;
if (!ClassDiscovery::safeClassExists($puliFactoryClass)) {
throw new PuliUnavailableException('Puli Factory class does not exist');
}
self::$puliFactory = new $puliFactoryClass();
}
return self::$puliFactory;
} | php | private static function getPuliFactory()
{
if (null === self::$puliFactory) {
if (!defined('PULI_FACTORY_CLASS')) {
throw new PuliUnavailableException('Puli Factory is not available');
}
$puliFactoryClass = PULI_FACTORY_CLASS;
if (!ClassDiscovery::safeClassExists($puliFactoryClass)) {
throw new PuliUnavailableException('Puli Factory class does not exist');
}
self::$puliFactory = new $puliFactoryClass();
}
return self::$puliFactory;
} | [
"private",
"static",
"function",
"getPuliFactory",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"self",
"::",
"$",
"puliFactory",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'PULI_FACTORY_CLASS'",
")",
")",
"{",
"throw",
"new",
"PuliUnavailableException",
"(",
... | @return GeneratedPuliFactory
@throws PuliUnavailableException | [
"@return",
"GeneratedPuliFactory"
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/Strategy/PuliBetaStrategy.php#L36-L53 |
php-http/discovery | src/Strategy/PuliBetaStrategy.php | PuliBetaStrategy.getPuliDiscovery | private static function getPuliDiscovery()
{
if (!isset(self::$puliDiscovery)) {
$factory = self::getPuliFactory();
$repository = $factory->createRepository();
self::$puliDiscovery = $factory->createDiscovery($repository);
}
return self::$puliDiscovery;
} | php | private static function getPuliDiscovery()
{
if (!isset(self::$puliDiscovery)) {
$factory = self::getPuliFactory();
$repository = $factory->createRepository();
self::$puliDiscovery = $factory->createDiscovery($repository);
}
return self::$puliDiscovery;
} | [
"private",
"static",
"function",
"getPuliDiscovery",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"puliDiscovery",
")",
")",
"{",
"$",
"factory",
"=",
"self",
"::",
"getPuliFactory",
"(",
")",
";",
"$",
"repository",
"=",
"$",
"facto... | Returns the Puli discovery layer.
@return Discovery
@throws PuliUnavailableException | [
"Returns",
"the",
"Puli",
"discovery",
"layer",
"."
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/Strategy/PuliBetaStrategy.php#L62-L72 |
php-http/discovery | src/Strategy/PuliBetaStrategy.php | PuliBetaStrategy.getCandidates | public static function getCandidates($type)
{
$returnData = [];
$bindings = self::getPuliDiscovery()->findBindings($type);
foreach ($bindings as $binding) {
$condition = true;
if ($binding->hasParameterValue('depends')) {
$condition = $binding->getParameterValue('depends');
}
$returnData[] = ['class' => $binding->getClassName(), 'condition' => $condition];
}
return $returnData;
} | php | public static function getCandidates($type)
{
$returnData = [];
$bindings = self::getPuliDiscovery()->findBindings($type);
foreach ($bindings as $binding) {
$condition = true;
if ($binding->hasParameterValue('depends')) {
$condition = $binding->getParameterValue('depends');
}
$returnData[] = ['class' => $binding->getClassName(), 'condition' => $condition];
}
return $returnData;
} | [
"public",
"static",
"function",
"getCandidates",
"(",
"$",
"type",
")",
"{",
"$",
"returnData",
"=",
"[",
"]",
";",
"$",
"bindings",
"=",
"self",
"::",
"getPuliDiscovery",
"(",
")",
"->",
"findBindings",
"(",
"$",
"type",
")",
";",
"foreach",
"(",
"$",... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/Strategy/PuliBetaStrategy.php#L77-L91 |
php-http/discovery | spec/Strategy/PuliSpec.php | PuliBetaStrategyStub.setPuliFactory | public static function setPuliFactory($puliFactory)
{
if (!is_callable([$puliFactory, 'createRepository']) || !is_callable([$puliFactory, 'createDiscovery'])) {
throw new \InvalidArgumentException('The Puli Factory must expose a repository and a discovery');
}
self::$puliFactory = $puliFactory;
self::$puliDiscovery = null;
} | php | public static function setPuliFactory($puliFactory)
{
if (!is_callable([$puliFactory, 'createRepository']) || !is_callable([$puliFactory, 'createDiscovery'])) {
throw new \InvalidArgumentException('The Puli Factory must expose a repository and a discovery');
}
self::$puliFactory = $puliFactory;
self::$puliDiscovery = null;
} | [
"public",
"static",
"function",
"setPuliFactory",
"(",
"$",
"puliFactory",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"[",
"$",
"puliFactory",
",",
"'createRepository'",
"]",
")",
"||",
"!",
"is_callable",
"(",
"[",
"$",
"puliFactory",
",",
"'createDiscov... | Sets the Puli factory.
@param object $puliFactory | [
"Sets",
"the",
"Puli",
"factory",
"."
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/spec/Strategy/PuliSpec.php#L92-L99 |
php-http/discovery | src/MessageFactoryDiscovery.php | MessageFactoryDiscovery.find | public static function find()
{
try {
$messageFactory = static::findOneByType(MessageFactory::class);
} catch (DiscoveryFailedException $e) {
throw new NotFoundException(
'No message factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.',
0,
$e
);
}
return static::instantiateClass($messageFactory);
} | php | public static function find()
{
try {
$messageFactory = static::findOneByType(MessageFactory::class);
} catch (DiscoveryFailedException $e) {
throw new NotFoundException(
'No message factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.',
0,
$e
);
}
return static::instantiateClass($messageFactory);
} | [
"public",
"static",
"function",
"find",
"(",
")",
"{",
"try",
"{",
"$",
"messageFactory",
"=",
"static",
"::",
"findOneByType",
"(",
"MessageFactory",
"::",
"class",
")",
";",
"}",
"catch",
"(",
"DiscoveryFailedException",
"$",
"e",
")",
"{",
"throw",
"new... | Finds a Message Factory.
@return MessageFactory
@throws Exception\NotFoundException | [
"Finds",
"a",
"Message",
"Factory",
"."
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/MessageFactoryDiscovery.php#L24-L37 |
php-http/discovery | src/HttpAsyncClientDiscovery.php | HttpAsyncClientDiscovery.find | public static function find()
{
try {
$asyncClient = static::findOneByType(HttpAsyncClient::class);
} catch (DiscoveryFailedException $e) {
throw new NotFoundException(
'No HTTPlug async clients found. Make sure to install a package providing "php-http/async-client-implementation". Example: "php-http/guzzle6-adapter".',
0,
$e
);
}
return static::instantiateClass($asyncClient);
} | php | public static function find()
{
try {
$asyncClient = static::findOneByType(HttpAsyncClient::class);
} catch (DiscoveryFailedException $e) {
throw new NotFoundException(
'No HTTPlug async clients found. Make sure to install a package providing "php-http/async-client-implementation". Example: "php-http/guzzle6-adapter".',
0,
$e
);
}
return static::instantiateClass($asyncClient);
} | [
"public",
"static",
"function",
"find",
"(",
")",
"{",
"try",
"{",
"$",
"asyncClient",
"=",
"static",
"::",
"findOneByType",
"(",
"HttpAsyncClient",
"::",
"class",
")",
";",
"}",
"catch",
"(",
"DiscoveryFailedException",
"$",
"e",
")",
"{",
"throw",
"new",... | Finds an HTTP Async Client.
@return HttpAsyncClient
@throws Exception\NotFoundException | [
"Finds",
"an",
"HTTP",
"Async",
"Client",
"."
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/HttpAsyncClientDiscovery.php#L22-L35 |
php-http/discovery | src/StreamFactoryDiscovery.php | StreamFactoryDiscovery.find | public static function find()
{
try {
$streamFactory = static::findOneByType(StreamFactory::class);
} catch (DiscoveryFailedException $e) {
throw new NotFoundException(
'No stream factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.',
0,
$e
);
}
return static::instantiateClass($streamFactory);
} | php | public static function find()
{
try {
$streamFactory = static::findOneByType(StreamFactory::class);
} catch (DiscoveryFailedException $e) {
throw new NotFoundException(
'No stream factories found. To use Guzzle, Diactoros or Slim Framework factories install php-http/message and the chosen message implementation.',
0,
$e
);
}
return static::instantiateClass($streamFactory);
} | [
"public",
"static",
"function",
"find",
"(",
")",
"{",
"try",
"{",
"$",
"streamFactory",
"=",
"static",
"::",
"findOneByType",
"(",
"StreamFactory",
"::",
"class",
")",
";",
"}",
"catch",
"(",
"DiscoveryFailedException",
"$",
"e",
")",
"{",
"throw",
"new",... | Finds a Stream Factory.
@return StreamFactory
@throws Exception\NotFoundException | [
"Finds",
"a",
"Stream",
"Factory",
"."
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/StreamFactoryDiscovery.php#L24-L37 |
php-http/discovery | src/HttpClientDiscovery.php | HttpClientDiscovery.find | public static function find()
{
try {
$client = static::findOneByType(HttpClient::class);
} catch (DiscoveryFailedException $e) {
throw new NotFoundException(
'No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation". Example: "php-http/guzzle6-adapter".',
0,
$e
);
}
return static::instantiateClass($client);
} | php | public static function find()
{
try {
$client = static::findOneByType(HttpClient::class);
} catch (DiscoveryFailedException $e) {
throw new NotFoundException(
'No HTTPlug clients found. Make sure to install a package providing "php-http/client-implementation". Example: "php-http/guzzle6-adapter".',
0,
$e
);
}
return static::instantiateClass($client);
} | [
"public",
"static",
"function",
"find",
"(",
")",
"{",
"try",
"{",
"$",
"client",
"=",
"static",
"::",
"findOneByType",
"(",
"HttpClient",
"::",
"class",
")",
";",
"}",
"catch",
"(",
"DiscoveryFailedException",
"$",
"e",
")",
"{",
"throw",
"new",
"NotFou... | Finds an HTTP Client.
@return HttpClient
@throws Exception\NotFoundException | [
"Finds",
"an",
"HTTP",
"Client",
"."
] | train | https://github.com/php-http/discovery/blob/684855f2c2e9d0a61868b8f8d6bd0295c8a4b651/src/HttpClientDiscovery.php#L22-L35 |
php-http/message | src/CookieJar.php | CookieJar.addCookie | public function addCookie(Cookie $cookie)
{
if (!$this->hasCookie($cookie)) {
$cookies = $this->getMatchingCookies($cookie);
foreach ($cookies as $matchingCookie) {
if ($cookie->getValue() !== $matchingCookie->getValue() || $cookie->getMaxAge() > $matchingCookie->getMaxAge()) {
$this->removeCookie($matchingCookie);
continue;
}
}
if ($cookie->hasValue()) {
$this->cookies->attach($cookie);
}
}
} | php | public function addCookie(Cookie $cookie)
{
if (!$this->hasCookie($cookie)) {
$cookies = $this->getMatchingCookies($cookie);
foreach ($cookies as $matchingCookie) {
if ($cookie->getValue() !== $matchingCookie->getValue() || $cookie->getMaxAge() > $matchingCookie->getMaxAge()) {
$this->removeCookie($matchingCookie);
continue;
}
}
if ($cookie->hasValue()) {
$this->cookies->attach($cookie);
}
}
} | [
"public",
"function",
"addCookie",
"(",
"Cookie",
"$",
"cookie",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasCookie",
"(",
"$",
"cookie",
")",
")",
"{",
"$",
"cookies",
"=",
"$",
"this",
"->",
"getMatchingCookies",
"(",
"$",
"cookie",
")",
";",
... | Adds a cookie.
@param Cookie $cookie | [
"Adds",
"a",
"cookie",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/CookieJar.php#L39-L56 |
php-http/message | src/CookieJar.php | CookieJar.getMatchingCookies | public function getMatchingCookies(Cookie $cookie)
{
$match = function ($matchCookie) use ($cookie) {
return $matchCookie->match($cookie);
};
return $this->findMatchingCookies($match);
} | php | public function getMatchingCookies(Cookie $cookie)
{
$match = function ($matchCookie) use ($cookie) {
return $matchCookie->match($cookie);
};
return $this->findMatchingCookies($match);
} | [
"public",
"function",
"getMatchingCookies",
"(",
"Cookie",
"$",
"cookie",
")",
"{",
"$",
"match",
"=",
"function",
"(",
"$",
"matchCookie",
")",
"use",
"(",
"$",
"cookie",
")",
"{",
"return",
"$",
"matchCookie",
"->",
"match",
"(",
"$",
"cookie",
")",
... | Returns all matching cookies.
@param Cookie $cookie
@return Cookie[] | [
"Returns",
"all",
"matching",
"cookies",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/CookieJar.php#L89-L96 |
php-http/message | src/CookieJar.php | CookieJar.findMatchingCookies | protected function findMatchingCookies(callable $match)
{
$cookies = [];
foreach ($this->cookies as $cookie) {
if ($match($cookie)) {
$cookies[] = $cookie;
}
}
return $cookies;
} | php | protected function findMatchingCookies(callable $match)
{
$cookies = [];
foreach ($this->cookies as $cookie) {
if ($match($cookie)) {
$cookies[] = $cookie;
}
}
return $cookies;
} | [
"protected",
"function",
"findMatchingCookies",
"(",
"callable",
"$",
"match",
")",
"{",
"$",
"cookies",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"cookies",
"as",
"$",
"cookie",
")",
"{",
"if",
"(",
"$",
"match",
"(",
"$",
"cookie",
")"... | Finds matching cookies based on a callable.
@param callable $match
@return Cookie[] | [
"Finds",
"matching",
"cookies",
"based",
"on",
"a",
"callable",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/CookieJar.php#L105-L116 |
php-http/message | src/CookieJar.php | CookieJar.removeMatchingCookies | public function removeMatchingCookies($name = null, $domain = null, $path = null)
{
$match = function ($cookie) use ($name, $domain, $path) {
$match = true;
if (isset($name)) {
$match = $match && ($cookie->getName() === $name);
}
if (isset($domain)) {
$match = $match && $cookie->matchDomain($domain);
}
if (isset($path)) {
$match = $match && $cookie->matchPath($path);
}
return $match;
};
$cookies = $this->findMatchingCookies($match);
$this->removeCookies($cookies);
} | php | public function removeMatchingCookies($name = null, $domain = null, $path = null)
{
$match = function ($cookie) use ($name, $domain, $path) {
$match = true;
if (isset($name)) {
$match = $match && ($cookie->getName() === $name);
}
if (isset($domain)) {
$match = $match && $cookie->matchDomain($domain);
}
if (isset($path)) {
$match = $match && $cookie->matchPath($path);
}
return $match;
};
$cookies = $this->findMatchingCookies($match);
$this->removeCookies($cookies);
} | [
"public",
"function",
"removeMatchingCookies",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"domain",
"=",
"null",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"match",
"=",
"function",
"(",
"$",
"cookie",
")",
"use",
"(",
"$",
"name",
",",
"$",
"doma... | Removes cookies which match the given parameters.
Null means that parameter should not be matched
@param string|null $name
@param string|null $domain
@param string|null $path | [
"Removes",
"cookies",
"which",
"match",
"the",
"given",
"parameters",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/CookieJar.php#L172-L195 |
php-http/message | src/Authentication/QueryParam.php | QueryParam.authenticate | public function authenticate(RequestInterface $request)
{
$uri = $request->getUri();
$query = $uri->getQuery();
$params = [];
parse_str($query, $params);
$params = array_merge($params, $this->params);
$query = http_build_query($params, null, '&');
$uri = $uri->withQuery($query);
return $request->withUri($uri);
} | php | public function authenticate(RequestInterface $request)
{
$uri = $request->getUri();
$query = $uri->getQuery();
$params = [];
parse_str($query, $params);
$params = array_merge($params, $this->params);
$query = http_build_query($params, null, '&');
$uri = $uri->withQuery($query);
return $request->withUri($uri);
} | [
"public",
"function",
"authenticate",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"uri",
"=",
"$",
"request",
"->",
"getUri",
"(",
")",
";",
"$",
"query",
"=",
"$",
"uri",
"->",
"getQuery",
"(",
")",
";",
"$",
"params",
"=",
"[",
"]",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Authentication/QueryParam.php#L34-L49 |
php-http/message | src/Authentication/BasicAuth.php | BasicAuth.authenticate | public function authenticate(RequestInterface $request)
{
$header = sprintf('Basic %s', base64_encode(sprintf('%s:%s', $this->username, $this->password)));
return $request->withHeader('Authorization', $header);
} | php | public function authenticate(RequestInterface $request)
{
$header = sprintf('Basic %s', base64_encode(sprintf('%s:%s', $this->username, $this->password)));
return $request->withHeader('Authorization', $header);
} | [
"public",
"function",
"authenticate",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"header",
"=",
"sprintf",
"(",
"'Basic %s'",
",",
"base64_encode",
"(",
"sprintf",
"(",
"'%s:%s'",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"pa... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Authentication/BasicAuth.php#L38-L43 |
php-http/message | src/RequestMatcher/RequestMatcher.php | RequestMatcher.matches | public function matches(RequestInterface $request)
{
if ($this->schemes && !in_array($request->getUri()->getScheme(), $this->schemes)) {
return false;
}
if ($this->methods && !in_array($request->getMethod(), $this->methods)) {
return false;
}
if (null !== $this->path && !preg_match('{'.$this->path.'}', rawurldecode($request->getUri()->getPath()))) {
return false;
}
if (null !== $this->host && !preg_match('{'.$this->host.'}i', $request->getUri()->getHost())) {
return false;
}
return true;
} | php | public function matches(RequestInterface $request)
{
if ($this->schemes && !in_array($request->getUri()->getScheme(), $this->schemes)) {
return false;
}
if ($this->methods && !in_array($request->getMethod(), $this->methods)) {
return false;
}
if (null !== $this->path && !preg_match('{'.$this->path.'}', rawurldecode($request->getUri()->getPath()))) {
return false;
}
if (null !== $this->host && !preg_match('{'.$this->host.'}i', $request->getUri()->getHost())) {
return false;
}
return true;
} | [
"public",
"function",
"matches",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"schemes",
"&&",
"!",
"in_array",
"(",
"$",
"request",
"->",
"getUri",
"(",
")",
"->",
"getScheme",
"(",
")",
",",
"$",
"this",
"->",
"s... | {@inheritdoc}
@api | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/RequestMatcher/RequestMatcher.php#L58-L77 |
php-http/message | src/Decorator/ResponseDecorator.php | ResponseDecorator.withStatus | public function withStatus($code, $reasonPhrase = '')
{
$new = clone $this;
$new->message = $this->message->withStatus($code, $reasonPhrase);
return $new;
} | php | public function withStatus($code, $reasonPhrase = '')
{
$new = clone $this;
$new->message = $this->message->withStatus($code, $reasonPhrase);
return $new;
} | [
"public",
"function",
"withStatus",
"(",
"$",
"code",
",",
"$",
"reasonPhrase",
"=",
"''",
")",
"{",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"$",
"new",
"->",
"message",
"=",
"$",
"this",
"->",
"message",
"->",
"withStatus",
"(",
"$",
"code",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Decorator/ResponseDecorator.php#L42-L48 |
php-http/message | src/Authentication/RequestConditional.php | RequestConditional.authenticate | public function authenticate(RequestInterface $request)
{
if ($this->requestMatcher->matches($request)) {
return $this->authentication->authenticate($request);
}
return $request;
} | php | public function authenticate(RequestInterface $request)
{
if ($this->requestMatcher->matches($request)) {
return $this->authentication->authenticate($request);
}
return $request;
} | [
"public",
"function",
"authenticate",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"requestMatcher",
"->",
"matches",
"(",
"$",
"request",
")",
")",
"{",
"return",
"$",
"this",
"->",
"authentication",
"->",
"authenticate",... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Authentication/RequestConditional.php#L39-L46 |
php-http/message | src/Cookie.php | Cookie.createWithoutValidation | public static function createWithoutValidation(
$name,
$value = null,
$maxAge = null,
$domain = null,
$path = null,
$secure = false,
$httpOnly = false,
\DateTime $expires = null
) {
$cookie = new self('name', null, null, $domain, $path, $secure, $httpOnly, $expires);
$cookie->name = $name;
$cookie->value = $value;
$cookie->maxAge = $maxAge;
return $cookie;
} | php | public static function createWithoutValidation(
$name,
$value = null,
$maxAge = null,
$domain = null,
$path = null,
$secure = false,
$httpOnly = false,
\DateTime $expires = null
) {
$cookie = new self('name', null, null, $domain, $path, $secure, $httpOnly, $expires);
$cookie->name = $name;
$cookie->value = $value;
$cookie->maxAge = $maxAge;
return $cookie;
} | [
"public",
"static",
"function",
"createWithoutValidation",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
",",
"$",
"maxAge",
"=",
"null",
",",
"$",
"domain",
"=",
"null",
",",
"$",
"path",
"=",
"null",
",",
"$",
"secure",
"=",
"false",
",",
"$",
... | Creates a new cookie without any attribute validation.
@param string $name
@param string|null $value
@param int $maxAge
@param string|null $domain
@param string|null $path
@param bool $secure
@param bool $httpOnly
@param \DateTime|null $expires Expires attribute is HTTP 1.0 only and should be avoided. | [
"Creates",
"a",
"new",
"cookie",
"without",
"any",
"attribute",
"validation",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Cookie.php#L104-L120 |
php-http/message | src/Cookie.php | Cookie.matchPath | public function matchPath($path)
{
return $this->path === $path || (0 === strpos($path, rtrim($this->path, '/').'/'));
} | php | public function matchPath($path)
{
return $this->path === $path || (0 === strpos($path, rtrim($this->path, '/').'/'));
} | [
"public",
"function",
"matchPath",
"(",
"$",
"path",
")",
"{",
"return",
"$",
"this",
"->",
"path",
"===",
"$",
"path",
"||",
"(",
"0",
"===",
"strpos",
"(",
"$",
"path",
",",
"rtrim",
"(",
"$",
"this",
"->",
"path",
",",
"'/'",
")",
".",
"'/'",
... | Checks whether this cookie is meant for this path.
@see http://tools.ietf.org/html/rfc6265#section-5.1.4
@param string $path
@return bool | [
"Checks",
"whether",
"this",
"cookie",
"is",
"meant",
"for",
"this",
"path",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Cookie.php#L344-L347 |
php-http/message | src/Cookie.php | Cookie.match | public function match(self $cookie)
{
return $this->name === $cookie->name && $this->domain === $cookie->domain and $this->path === $cookie->path;
} | php | public function match(self $cookie)
{
return $this->name === $cookie->name && $this->domain === $cookie->domain and $this->path === $cookie->path;
} | [
"public",
"function",
"match",
"(",
"self",
"$",
"cookie",
")",
"{",
"return",
"$",
"this",
"->",
"name",
"===",
"$",
"cookie",
"->",
"name",
"&&",
"$",
"this",
"->",
"domain",
"===",
"$",
"cookie",
"->",
"domain",
"and",
"$",
"this",
"->",
"path",
... | Checks if this cookie represents the same cookie as $cookie.
This does not compare the values, only name, domain and path.
@param Cookie $cookie
@return bool | [
"Checks",
"if",
"this",
"cookie",
"represents",
"the",
"same",
"cookie",
"as",
"$cookie",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Cookie.php#L408-L411 |
php-http/message | src/Cookie.php | Cookie.isValid | public function isValid()
{
try {
$this->validateName($this->name);
$this->validateValue($this->value);
$this->validateMaxAge($this->maxAge);
} catch (\InvalidArgumentException $e) {
return false;
}
return true;
} | php | public function isValid()
{
try {
$this->validateName($this->name);
$this->validateValue($this->value);
$this->validateMaxAge($this->maxAge);
} catch (\InvalidArgumentException $e) {
return false;
}
return true;
} | [
"public",
"function",
"isValid",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"validateName",
"(",
"$",
"this",
"->",
"name",
")",
";",
"$",
"this",
"->",
"validateValue",
"(",
"$",
"this",
"->",
"value",
")",
";",
"$",
"this",
"->",
"validateMaxAge... | Validates cookie attributes.
@return bool | [
"Validates",
"cookie",
"attributes",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Cookie.php#L418-L429 |
php-http/message | src/Cookie.php | Cookie.validateName | private function validateName($name)
{
if (strlen($name) < 1) {
throw new \InvalidArgumentException('The name cannot be empty');
}
// Name attribute is a token as per spec in RFC 2616
if (preg_match('/[\x00-\x20\x22\x28-\x29\x2C\x2F\x3A-\x40\x5B-\x5D\x7B\x7D\x7F]/', $name)) {
throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name));
}
} | php | private function validateName($name)
{
if (strlen($name) < 1) {
throw new \InvalidArgumentException('The name cannot be empty');
}
// Name attribute is a token as per spec in RFC 2616
if (preg_match('/[\x00-\x20\x22\x28-\x29\x2C\x2F\x3A-\x40\x5B-\x5D\x7B\x7D\x7F]/', $name)) {
throw new \InvalidArgumentException(sprintf('The cookie name "%s" contains invalid characters.', $name));
}
} | [
"private",
"function",
"validateName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"name",
")",
"<",
"1",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The name cannot be empty'",
")",
";",
"}",
"// Name attribute is a token... | Validates the name attribute.
@see http://tools.ietf.org/search/rfc2616#section-2.2
@param string $name
@throws \InvalidArgumentException If the name is empty or contains invalid characters. | [
"Validates",
"the",
"name",
"attribute",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Cookie.php#L440-L450 |
php-http/message | src/Cookie.php | Cookie.normalizePath | private function normalizePath($path)
{
$path = rtrim($path, '/');
if (empty($path) or '/' !== substr($path, 0, 1)) {
$path = '/';
}
return $path;
} | php | private function normalizePath($path)
{
$path = rtrim($path, '/');
if (empty($path) or '/' !== substr($path, 0, 1)) {
$path = '/';
}
return $path;
} | [
"private",
"function",
"normalizePath",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"path",
")",
"or",
"'/'",
"!==",
"substr",
"(",
"$",
"path",
",",
"0",
",",
"1"... | Processes path as per spec in RFC 6265.
@see http://tools.ietf.org/html/rfc6265#section-5.1.4
@see http://tools.ietf.org/html/rfc6265#section-5.2.4
@param string|null $path
@return string | [
"Processes",
"path",
"as",
"per",
"spec",
"in",
"RFC",
"6265",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Cookie.php#L516-L525 |
php-http/message | src/Decorator/RequestDecorator.php | RequestDecorator.withUri | public function withUri(UriInterface $uri, $preserveHost = false)
{
$new = clone $this;
$new->message = $this->message->withUri($uri, $preserveHost);
return $new;
} | php | public function withUri(UriInterface $uri, $preserveHost = false)
{
$new = clone $this;
$new->message = $this->message->withUri($uri, $preserveHost);
return $new;
} | [
"public",
"function",
"withUri",
"(",
"UriInterface",
"$",
"uri",
",",
"$",
"preserveHost",
"=",
"false",
")",
"{",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"$",
"new",
"->",
"message",
"=",
"$",
"this",
"->",
"message",
"->",
"withUri",
"(",
"$",... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Decorator/RequestDecorator.php#L81-L87 |
php-http/message | src/MessageFactory/SlimMessageFactory.php | SlimMessageFactory.createRequest | public function createRequest(
$method,
$uri,
array $headers = [],
$body = null,
$protocolVersion = '1.1'
) {
return (new Request(
$method,
$this->uriFactory->createUri($uri),
new Headers($headers),
[],
[],
$this->streamFactory->createStream($body),
[]
))->withProtocolVersion($protocolVersion);
} | php | public function createRequest(
$method,
$uri,
array $headers = [],
$body = null,
$protocolVersion = '1.1'
) {
return (new Request(
$method,
$this->uriFactory->createUri($uri),
new Headers($headers),
[],
[],
$this->streamFactory->createStream($body),
[]
))->withProtocolVersion($protocolVersion);
} | [
"public",
"function",
"createRequest",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"body",
"=",
"null",
",",
"$",
"protocolVersion",
"=",
"'1.1'",
")",
"{",
"return",
"(",
"new",
"Request",
"(",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/MessageFactory/SlimMessageFactory.php#L38-L54 |
php-http/message | src/MessageFactory/SlimMessageFactory.php | SlimMessageFactory.createResponse | public function createResponse(
$statusCode = 200,
$reasonPhrase = null,
array $headers = [],
$body = null,
$protocolVersion = '1.1'
) {
return (new Response(
$statusCode,
new Headers($headers),
$this->streamFactory->createStream($body)
))->withProtocolVersion($protocolVersion);
} | php | public function createResponse(
$statusCode = 200,
$reasonPhrase = null,
array $headers = [],
$body = null,
$protocolVersion = '1.1'
) {
return (new Response(
$statusCode,
new Headers($headers),
$this->streamFactory->createStream($body)
))->withProtocolVersion($protocolVersion);
} | [
"public",
"function",
"createResponse",
"(",
"$",
"statusCode",
"=",
"200",
",",
"$",
"reasonPhrase",
"=",
"null",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"body",
"=",
"null",
",",
"$",
"protocolVersion",
"=",
"'1.1'",
")",
"{",
"return"... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/MessageFactory/SlimMessageFactory.php#L59-L71 |
php-http/message | src/Builder/ResponseBuilder.php | ResponseBuilder.setHeadersFromArray | public function setHeadersFromArray(array $headers)
{
$status = array_shift($headers);
$this->setStatus($status);
foreach ($headers as $headerLine) {
$headerLine = trim($headerLine);
if ('' === $headerLine) {
continue;
}
$this->addHeader($headerLine);
}
return $this;
} | php | public function setHeadersFromArray(array $headers)
{
$status = array_shift($headers);
$this->setStatus($status);
foreach ($headers as $headerLine) {
$headerLine = trim($headerLine);
if ('' === $headerLine) {
continue;
}
$this->addHeader($headerLine);
}
return $this;
} | [
"public",
"function",
"setHeadersFromArray",
"(",
"array",
"$",
"headers",
")",
"{",
"$",
"status",
"=",
"array_shift",
"(",
"$",
"headers",
")",
";",
"$",
"this",
"->",
"setStatus",
"(",
"$",
"status",
")",
";",
"foreach",
"(",
"$",
"headers",
"as",
"... | Add headers represented by an array of header lines.
@param string[] $headers Response headers as array of header lines.
@return $this
@throws \UnexpectedValueException For invalid header values.
@throws \InvalidArgumentException For invalid status code arguments. | [
"Add",
"headers",
"represented",
"by",
"an",
"array",
"of",
"header",
"lines",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Builder/ResponseBuilder.php#L49-L64 |
php-http/message | src/Builder/ResponseBuilder.php | ResponseBuilder.setStatus | public function setStatus($statusLine)
{
$parts = explode(' ', $statusLine, 3);
if (count($parts) < 2 || 0 !== strpos(strtolower($parts[0]), 'http/')) {
throw new \InvalidArgumentException(
sprintf('"%s" is not a valid HTTP status line', $statusLine)
);
}
$reasonPhrase = count($parts) > 2 ? $parts[2] : '';
$this->response = $this->response
->withStatus((int) $parts[1], $reasonPhrase)
->withProtocolVersion(substr($parts[0], 5));
return $this;
} | php | public function setStatus($statusLine)
{
$parts = explode(' ', $statusLine, 3);
if (count($parts) < 2 || 0 !== strpos(strtolower($parts[0]), 'http/')) {
throw new \InvalidArgumentException(
sprintf('"%s" is not a valid HTTP status line', $statusLine)
);
}
$reasonPhrase = count($parts) > 2 ? $parts[2] : '';
$this->response = $this->response
->withStatus((int) $parts[1], $reasonPhrase)
->withProtocolVersion(substr($parts[0], 5));
return $this;
} | [
"public",
"function",
"setStatus",
"(",
"$",
"statusLine",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"' '",
",",
"$",
"statusLine",
",",
"3",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"<",
"2",
"||",
"0",
"!==",
"strpos",
"(",
"str... | Set response status from a status string.
@param string $statusLine Response status as a string.
@return $this
@throws \InvalidArgumentException For invalid status line. | [
"Set",
"response",
"status",
"from",
"a",
"status",
"string",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Builder/ResponseBuilder.php#L104-L119 |
php-http/message | src/Builder/ResponseBuilder.php | ResponseBuilder.addHeader | public function addHeader($headerLine)
{
$parts = explode(':', $headerLine, 2);
if (2 !== count($parts)) {
throw new \InvalidArgumentException(
sprintf('"%s" is not a valid HTTP header line', $headerLine)
);
}
$name = trim($parts[0]);
$value = trim($parts[1]);
if ($this->response->hasHeader($name)) {
$this->response = $this->response->withAddedHeader($name, $value);
} else {
$this->response = $this->response->withHeader($name, $value);
}
return $this;
} | php | public function addHeader($headerLine)
{
$parts = explode(':', $headerLine, 2);
if (2 !== count($parts)) {
throw new \InvalidArgumentException(
sprintf('"%s" is not a valid HTTP header line', $headerLine)
);
}
$name = trim($parts[0]);
$value = trim($parts[1]);
if ($this->response->hasHeader($name)) {
$this->response = $this->response->withAddedHeader($name, $value);
} else {
$this->response = $this->response->withHeader($name, $value);
}
return $this;
} | [
"public",
"function",
"addHeader",
"(",
"$",
"headerLine",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"':'",
",",
"$",
"headerLine",
",",
"2",
")",
";",
"if",
"(",
"2",
"!==",
"count",
"(",
"$",
"parts",
")",
")",
"{",
"throw",
"new",
"\\",
"In... | Add header represented by a string.
@param string $headerLine Response header as a string.
@return $this
@throws \InvalidArgumentException For invalid header names or values. | [
"Add",
"header",
"represented",
"by",
"a",
"string",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Builder/ResponseBuilder.php#L130-L147 |
php-http/message | src/CookieUtil.php | CookieUtil.parseDate | public static function parseDate($dateValue)
{
foreach (self::$dateFormats as $dateFormat) {
if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) {
return $date;
}
}
// attempt a fallback for unusual formatting
if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) {
return $date;
}
throw new UnexpectedValueException(sprintf(
'Unparseable cookie date string "%s"',
$dateValue
));
} | php | public static function parseDate($dateValue)
{
foreach (self::$dateFormats as $dateFormat) {
if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) {
return $date;
}
}
// attempt a fallback for unusual formatting
if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) {
return $date;
}
throw new UnexpectedValueException(sprintf(
'Unparseable cookie date string "%s"',
$dateValue
));
} | [
"public",
"static",
"function",
"parseDate",
"(",
"$",
"dateValue",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"dateFormats",
"as",
"$",
"dateFormat",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"date",
"=",
"\\",
"DateTime",
"::",
"createFromFormat",
"(... | @see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/BrowserKit/Cookie.php
@param string $dateValue
@return \DateTime
@throws UnexpectedValueException if we cannot parse the cookie date string. | [
"@see",
"https",
":",
"//",
"github",
".",
"com",
"/",
"symfony",
"/",
"symfony",
"/",
"blob",
"/",
"master",
"/",
"src",
"/",
"Symfony",
"/",
"Component",
"/",
"BrowserKit",
"/",
"Cookie",
".",
"php"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/CookieUtil.php#L35-L52 |
php-http/message | src/Authentication/Bearer.php | Bearer.authenticate | public function authenticate(RequestInterface $request)
{
$header = sprintf('Bearer %s', $this->token);
return $request->withHeader('Authorization', $header);
} | php | public function authenticate(RequestInterface $request)
{
$header = sprintf('Bearer %s', $this->token);
return $request->withHeader('Authorization', $header);
} | [
"public",
"function",
"authenticate",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"header",
"=",
"sprintf",
"(",
"'Bearer %s'",
",",
"$",
"this",
"->",
"token",
")",
";",
"return",
"$",
"request",
"->",
"withHeader",
"(",
"'Authorization'",
",",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Authentication/Bearer.php#L31-L36 |
php-http/message | src/Decorator/MessageDecorator.php | MessageDecorator.withHeader | public function withHeader($header, $value)
{
$new = clone $this;
$new->message = $this->message->withHeader($header, $value);
return $new;
} | php | public function withHeader($header, $value)
{
$new = clone $this;
$new->message = $this->message->withHeader($header, $value);
return $new;
} | [
"public",
"function",
"withHeader",
"(",
"$",
"header",
",",
"$",
"value",
")",
"{",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"$",
"new",
"->",
"message",
"=",
"$",
"this",
"->",
"message",
"->",
"withHeader",
"(",
"$",
"header",
",",
"$",
"valu... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Decorator/MessageDecorator.php#L85-L91 |
php-http/message | src/Decorator/MessageDecorator.php | MessageDecorator.withAddedHeader | public function withAddedHeader($header, $value)
{
$new = clone $this;
$new->message = $this->message->withAddedHeader($header, $value);
return $new;
} | php | public function withAddedHeader($header, $value)
{
$new = clone $this;
$new->message = $this->message->withAddedHeader($header, $value);
return $new;
} | [
"public",
"function",
"withAddedHeader",
"(",
"$",
"header",
",",
"$",
"value",
")",
"{",
"$",
"new",
"=",
"clone",
"$",
"this",
";",
"$",
"new",
"->",
"message",
"=",
"$",
"this",
"->",
"message",
"->",
"withAddedHeader",
"(",
"$",
"header",
",",
"$... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Decorator/MessageDecorator.php#L96-L102 |
php-http/message | src/Encoding/FilteredStream.php | FilteredStream.read | public function read($length)
{
if (strlen($this->buffer) >= $length) {
$read = substr($this->buffer, 0, $length);
$this->buffer = substr($this->buffer, $length);
return $read;
}
if ($this->stream->eof()) {
$buffer = $this->buffer;
$this->buffer = '';
return $buffer;
}
$read = $this->buffer;
$this->buffer = '';
$this->fill();
return $read.$this->read($length - strlen($read));
} | php | public function read($length)
{
if (strlen($this->buffer) >= $length) {
$read = substr($this->buffer, 0, $length);
$this->buffer = substr($this->buffer, $length);
return $read;
}
if ($this->stream->eof()) {
$buffer = $this->buffer;
$this->buffer = '';
return $buffer;
}
$read = $this->buffer;
$this->buffer = '';
$this->fill();
return $read.$this->read($length - strlen($read));
} | [
"public",
"function",
"read",
"(",
"$",
"length",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"buffer",
")",
">=",
"$",
"length",
")",
"{",
"$",
"read",
"=",
"substr",
"(",
"$",
"this",
"->",
"buffer",
",",
"0",
",",
"$",
"length",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Encoding/FilteredStream.php#L83-L104 |
php-http/message | src/Encoding/FilteredStream.php | FilteredStream.fill | protected function fill()
{
$readFilterCallback = $this->readFilterCallback;
$this->buffer .= $readFilterCallback($this->stream->read(self::BUFFER_SIZE));
if ($this->stream->eof()) {
$this->buffer .= $readFilterCallback();
}
} | php | protected function fill()
{
$readFilterCallback = $this->readFilterCallback;
$this->buffer .= $readFilterCallback($this->stream->read(self::BUFFER_SIZE));
if ($this->stream->eof()) {
$this->buffer .= $readFilterCallback();
}
} | [
"protected",
"function",
"fill",
"(",
")",
"{",
"$",
"readFilterCallback",
"=",
"$",
"this",
"->",
"readFilterCallback",
";",
"$",
"this",
"->",
"buffer",
".=",
"$",
"readFilterCallback",
"(",
"$",
"this",
"->",
"stream",
"->",
"read",
"(",
"self",
"::",
... | Buffer is filled by reading underlying stream.
Callback is reading once more even if the stream is ended.
This allow to get last data in the PHP buffer otherwise this
bug is present : https://bugs.php.net/bug.php?id=48725 | [
"Buffer",
"is",
"filled",
"by",
"reading",
"underlying",
"stream",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Encoding/FilteredStream.php#L121-L129 |
php-http/message | src/Encoding/FilteredStream.php | FilteredStream.getContents | public function getContents()
{
$buffer = '';
while (!$this->eof()) {
$buf = $this->read(self::BUFFER_SIZE);
// Using a loose equality here to match on '' and false.
if (null == $buf) {
break;
}
$buffer .= $buf;
}
return $buffer;
} | php | public function getContents()
{
$buffer = '';
while (!$this->eof()) {
$buf = $this->read(self::BUFFER_SIZE);
// Using a loose equality here to match on '' and false.
if (null == $buf) {
break;
}
$buffer .= $buf;
}
return $buffer;
} | [
"public",
"function",
"getContents",
"(",
")",
"{",
"$",
"buffer",
"=",
"''",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"eof",
"(",
")",
")",
"{",
"$",
"buf",
"=",
"$",
"this",
"->",
"read",
"(",
"self",
"::",
"BUFFER_SIZE",
")",
";",
"// Using ... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Encoding/FilteredStream.php#L134-L149 |
php-http/message | src/Encoding/FilteredStream.php | FilteredStream.seek | public function seek($offset, $whence = SEEK_SET)
{
@trigger_error('Filtered streams are not seekable. This method will start raising an exception in the next major version', E_USER_DEPRECATED);
$this->doSeek($offset, $whence);
} | php | public function seek($offset, $whence = SEEK_SET)
{
@trigger_error('Filtered streams are not seekable. This method will start raising an exception in the next major version', E_USER_DEPRECATED);
$this->doSeek($offset, $whence);
} | [
"public",
"function",
"seek",
"(",
"$",
"offset",
",",
"$",
"whence",
"=",
"SEEK_SET",
")",
"{",
"@",
"trigger_error",
"(",
"'Filtered streams are not seekable. This method will start raising an exception in the next major version'",
",",
"E_USER_DEPRECATED",
")",
";",
"$",... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Encoding/FilteredStream.php#L189-L193 |
php-http/message | src/Formatter/FullHttpMessageFormatter.php | FullHttpMessageFormatter.formatRequest | public function formatRequest(RequestInterface $request)
{
$message = sprintf(
"%s %s HTTP/%s\n",
$request->getMethod(),
$request->getRequestTarget(),
$request->getProtocolVersion()
);
foreach ($request->getHeaders() as $name => $values) {
$message .= $name.': '.implode(', ', $values)."\n";
}
return $this->addBody($request, $message);
} | php | public function formatRequest(RequestInterface $request)
{
$message = sprintf(
"%s %s HTTP/%s\n",
$request->getMethod(),
$request->getRequestTarget(),
$request->getProtocolVersion()
);
foreach ($request->getHeaders() as $name => $values) {
$message .= $name.': '.implode(', ', $values)."\n";
}
return $this->addBody($request, $message);
} | [
"public",
"function",
"formatRequest",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"\"%s %s HTTP/%s\\n\"",
",",
"$",
"request",
"->",
"getMethod",
"(",
")",
",",
"$",
"request",
"->",
"getRequestTarget",
"(",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Formatter/FullHttpMessageFormatter.php#L35-L49 |
php-http/message | src/Formatter/FullHttpMessageFormatter.php | FullHttpMessageFormatter.formatResponse | public function formatResponse(ResponseInterface $response)
{
$message = sprintf(
"HTTP/%s %s %s\n",
$response->getProtocolVersion(),
$response->getStatusCode(),
$response->getReasonPhrase()
);
foreach ($response->getHeaders() as $name => $values) {
$message .= $name.': '.implode(', ', $values)."\n";
}
return $this->addBody($response, $message);
} | php | public function formatResponse(ResponseInterface $response)
{
$message = sprintf(
"HTTP/%s %s %s\n",
$response->getProtocolVersion(),
$response->getStatusCode(),
$response->getReasonPhrase()
);
foreach ($response->getHeaders() as $name => $values) {
$message .= $name.': '.implode(', ', $values)."\n";
}
return $this->addBody($response, $message);
} | [
"public",
"function",
"formatResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"\"HTTP/%s %s %s\\n\"",
",",
"$",
"response",
"->",
"getProtocolVersion",
"(",
")",
",",
"$",
"response",
"->",
"getStatusCode",
"("... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Formatter/FullHttpMessageFormatter.php#L54-L68 |
php-http/message | src/Formatter/FullHttpMessageFormatter.php | FullHttpMessageFormatter.addBody | private function addBody(MessageInterface $request, $message)
{
$stream = $request->getBody();
if (!$stream->isSeekable() || 0 === $this->maxBodyLength) {
// Do not read the stream
return $message."\n";
}
if (null === $this->maxBodyLength) {
$message .= "\n".$stream->__toString();
} else {
$message .= "\n".mb_substr($stream->__toString(), 0, $this->maxBodyLength);
}
$stream->rewind();
return $message;
} | php | private function addBody(MessageInterface $request, $message)
{
$stream = $request->getBody();
if (!$stream->isSeekable() || 0 === $this->maxBodyLength) {
// Do not read the stream
return $message."\n";
}
if (null === $this->maxBodyLength) {
$message .= "\n".$stream->__toString();
} else {
$message .= "\n".mb_substr($stream->__toString(), 0, $this->maxBodyLength);
}
$stream->rewind();
return $message;
} | [
"private",
"function",
"addBody",
"(",
"MessageInterface",
"$",
"request",
",",
"$",
"message",
")",
"{",
"$",
"stream",
"=",
"$",
"request",
"->",
"getBody",
"(",
")",
";",
"if",
"(",
"!",
"$",
"stream",
"->",
"isSeekable",
"(",
")",
"||",
"0",
"===... | Add the message body if the stream is seekable.
@param MessageInterface $request
@param string $message
@return string | [
"Add",
"the",
"message",
"body",
"if",
"the",
"stream",
"is",
"seekable",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Formatter/FullHttpMessageFormatter.php#L78-L95 |
php-http/message | src/Encoding/Filter/Chunk.php | Chunk.filter | public function filter($in, $out, &$consumed, $closing)
{
while ($bucket = stream_bucket_make_writeable($in)) {
$lenbucket = stream_bucket_new($this->stream, dechex($bucket->datalen)."\r\n");
stream_bucket_append($out, $lenbucket);
$consumed += $bucket->datalen;
stream_bucket_append($out, $bucket);
$lenbucket = stream_bucket_new($this->stream, "\r\n");
stream_bucket_append($out, $lenbucket);
}
return PSFS_PASS_ON;
} | php | public function filter($in, $out, &$consumed, $closing)
{
while ($bucket = stream_bucket_make_writeable($in)) {
$lenbucket = stream_bucket_new($this->stream, dechex($bucket->datalen)."\r\n");
stream_bucket_append($out, $lenbucket);
$consumed += $bucket->datalen;
stream_bucket_append($out, $bucket);
$lenbucket = stream_bucket_new($this->stream, "\r\n");
stream_bucket_append($out, $lenbucket);
}
return PSFS_PASS_ON;
} | [
"public",
"function",
"filter",
"(",
"$",
"in",
",",
"$",
"out",
",",
"&",
"$",
"consumed",
",",
"$",
"closing",
")",
"{",
"while",
"(",
"$",
"bucket",
"=",
"stream_bucket_make_writeable",
"(",
"$",
"in",
")",
")",
"{",
"$",
"lenbucket",
"=",
"stream... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Encoding/Filter/Chunk.php#L15-L29 |
php-http/message | src/Authentication/AutoBasicAuth.php | AutoBasicAuth.authenticate | public function authenticate(RequestInterface $request)
{
$uri = $request->getUri();
$userInfo = $uri->getUserInfo();
if (!empty($userInfo)) {
if ($this->shouldRemoveUserInfo) {
$request = $request->withUri($uri->withUserInfo(''));
}
$request = $request->withHeader('Authorization', sprintf('Basic %s', base64_encode($userInfo)));
}
return $request;
} | php | public function authenticate(RequestInterface $request)
{
$uri = $request->getUri();
$userInfo = $uri->getUserInfo();
if (!empty($userInfo)) {
if ($this->shouldRemoveUserInfo) {
$request = $request->withUri($uri->withUserInfo(''));
}
$request = $request->withHeader('Authorization', sprintf('Basic %s', base64_encode($userInfo)));
}
return $request;
} | [
"public",
"function",
"authenticate",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"uri",
"=",
"$",
"request",
"->",
"getUri",
"(",
")",
";",
"$",
"userInfo",
"=",
"$",
"uri",
"->",
"getUserInfo",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Authentication/AutoBasicAuth.php#L33-L47 |
php-http/message | src/Stream/BufferedStream.php | BufferedStream.close | public function close()
{
if (null === $this->resource) {
throw new \RuntimeException('Cannot close on a detached stream');
}
$this->stream->close();
fclose($this->resource);
} | php | public function close()
{
if (null === $this->resource) {
throw new \RuntimeException('Cannot close on a detached stream');
}
$this->stream->close();
fclose($this->resource);
} | [
"public",
"function",
"close",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"resource",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Cannot close on a detached stream'",
")",
";",
"}",
"$",
"this",
"->",
"stream",
"->",
"close"... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Stream/BufferedStream.php#L71-L79 |
php-http/message | src/Stream/BufferedStream.php | BufferedStream.detach | public function detach()
{
if (null === $this->resource) {
return;
}
// Force reading the remaining data of the stream
$this->getContents();
$resource = $this->resource;
$this->stream->close();
$this->stream = null;
$this->resource = null;
return $resource;
} | php | public function detach()
{
if (null === $this->resource) {
return;
}
// Force reading the remaining data of the stream
$this->getContents();
$resource = $this->resource;
$this->stream->close();
$this->stream = null;
$this->resource = null;
return $resource;
} | [
"public",
"function",
"detach",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"resource",
")",
"{",
"return",
";",
"}",
"// Force reading the remaining data of the stream",
"$",
"this",
"->",
"getContents",
"(",
")",
";",
"$",
"resource",
"=",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Stream/BufferedStream.php#L84-L99 |
php-http/message | src/Stream/BufferedStream.php | BufferedStream.getSize | public function getSize()
{
if (null === $this->resource) {
return;
}
if (null === $this->size && $this->stream->eof()) {
return $this->written;
}
return $this->size;
} | php | public function getSize()
{
if (null === $this->resource) {
return;
}
if (null === $this->size && $this->stream->eof()) {
return $this->written;
}
return $this->size;
} | [
"public",
"function",
"getSize",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"resource",
")",
"{",
"return",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"size",
"&&",
"$",
"this",
"->",
"stream",
"->",
"eof",
"(",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Stream/BufferedStream.php#L104-L115 |
php-http/message | src/Stream/BufferedStream.php | BufferedStream.eof | public function eof()
{
if (null === $this->resource) {
throw new \RuntimeException('Cannot call eof on a detached stream');
}
// We are at the end only when both our resource and underlying stream are at eof
return $this->stream->eof() && (ftell($this->resource) === $this->written);
} | php | public function eof()
{
if (null === $this->resource) {
throw new \RuntimeException('Cannot call eof on a detached stream');
}
// We are at the end only when both our resource and underlying stream are at eof
return $this->stream->eof() && (ftell($this->resource) === $this->written);
} | [
"public",
"function",
"eof",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"resource",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Cannot call eof on a detached stream'",
")",
";",
"}",
"// We are at the end only when both our resource a... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Stream/BufferedStream.php#L132-L140 |
php-http/message | src/Stream/BufferedStream.php | BufferedStream.read | public function read($length)
{
if (null === $this->resource) {
throw new \RuntimeException('Cannot read on a detached stream');
}
$read = '';
// First read from the resource
if (ftell($this->resource) !== $this->written) {
$read = fread($this->resource, $length);
}
$bytesRead = strlen($read);
if ($bytesRead < $length) {
$streamRead = $this->stream->read($length - $bytesRead);
// Write on the underlying stream what we read
$this->written += fwrite($this->resource, $streamRead);
$read .= $streamRead;
}
return $read;
} | php | public function read($length)
{
if (null === $this->resource) {
throw new \RuntimeException('Cannot read on a detached stream');
}
$read = '';
// First read from the resource
if (ftell($this->resource) !== $this->written) {
$read = fread($this->resource, $length);
}
$bytesRead = strlen($read);
if ($bytesRead < $length) {
$streamRead = $this->stream->read($length - $bytesRead);
// Write on the underlying stream what we read
$this->written += fwrite($this->resource, $streamRead);
$read .= $streamRead;
}
return $read;
} | [
"public",
"function",
"read",
"(",
"$",
"length",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"resource",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Cannot read on a detached stream'",
")",
";",
"}",
"$",
"read",
"=",
"''",
";"... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Stream/BufferedStream.php#L201-L225 |
php-http/message | src/Stream/BufferedStream.php | BufferedStream.getContents | public function getContents()
{
if (null === $this->resource) {
throw new \RuntimeException('Cannot read on a detached stream');
}
$read = '';
while (!$this->eof()) {
$read .= $this->read(8192);
}
return $read;
} | php | public function getContents()
{
if (null === $this->resource) {
throw new \RuntimeException('Cannot read on a detached stream');
}
$read = '';
while (!$this->eof()) {
$read .= $this->read(8192);
}
return $read;
} | [
"public",
"function",
"getContents",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"resource",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Cannot read on a detached stream'",
")",
";",
"}",
"$",
"read",
"=",
"''",
";",
"while",... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Stream/BufferedStream.php#L230-L243 |
php-http/message | src/Authentication/Chain.php | Chain.authenticate | public function authenticate(RequestInterface $request)
{
foreach ($this->authenticationChain as $authentication) {
$request = $authentication->authenticate($request);
}
return $request;
} | php | public function authenticate(RequestInterface $request)
{
foreach ($this->authenticationChain as $authentication) {
$request = $authentication->authenticate($request);
}
return $request;
} | [
"public",
"function",
"authenticate",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"authenticationChain",
"as",
"$",
"authentication",
")",
"{",
"$",
"request",
"=",
"$",
"authentication",
"->",
"authenticate",
"(",
"$"... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Authentication/Chain.php#L39-L46 |
php-http/message | src/Authentication/Matching.php | Matching.authenticate | public function authenticate(RequestInterface $request)
{
if ($this->matcher->matches($request)) {
return $this->authentication->authenticate($request);
}
return $request;
} | php | public function authenticate(RequestInterface $request)
{
if ($this->matcher->matches($request)) {
return $this->authentication->authenticate($request);
}
return $request;
} | [
"public",
"function",
"authenticate",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"matcher",
"->",
"matches",
"(",
"$",
"request",
")",
")",
"{",
"return",
"$",
"this",
"->",
"authentication",
"->",
"authenticate",
"(",... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Authentication/Matching.php#L49-L56 |
php-http/message | src/Authentication/Matching.php | Matching.createUrlMatcher | public static function createUrlMatcher(Authentication $authentication, $url)
{
$matcher = function (RequestInterface $request) use ($url) {
return preg_match($url, $request->getRequestTarget());
};
return new static($authentication, $matcher);
} | php | public static function createUrlMatcher(Authentication $authentication, $url)
{
$matcher = function (RequestInterface $request) use ($url) {
return preg_match($url, $request->getRequestTarget());
};
return new static($authentication, $matcher);
} | [
"public",
"static",
"function",
"createUrlMatcher",
"(",
"Authentication",
"$",
"authentication",
",",
"$",
"url",
")",
"{",
"$",
"matcher",
"=",
"function",
"(",
"RequestInterface",
"$",
"request",
")",
"use",
"(",
"$",
"url",
")",
"{",
"return",
"preg_matc... | Creates a matching authentication for an URL.
@param Authentication $authentication
@param string $url
@return self | [
"Creates",
"a",
"matching",
"authentication",
"for",
"an",
"URL",
"."
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Authentication/Matching.php#L66-L73 |
php-http/message | src/Authentication/Wsse.php | Wsse.authenticate | public function authenticate(RequestInterface $request)
{
// TODO: generate better nonce?
$nonce = substr(md5(uniqid(uniqid().'_', true)), 0, 16);
$created = date('c');
$digest = base64_encode(sha1(base64_decode($nonce).$created.$this->password, true));
$wsse = sprintf(
'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"',
$this->username,
$digest,
$nonce,
$created
);
return $request
->withHeader('Authorization', 'WSSE profile="UsernameToken"')
->withHeader('X-WSSE', $wsse)
;
} | php | public function authenticate(RequestInterface $request)
{
// TODO: generate better nonce?
$nonce = substr(md5(uniqid(uniqid().'_', true)), 0, 16);
$created = date('c');
$digest = base64_encode(sha1(base64_decode($nonce).$created.$this->password, true));
$wsse = sprintf(
'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"',
$this->username,
$digest,
$nonce,
$created
);
return $request
->withHeader('Authorization', 'WSSE profile="UsernameToken"')
->withHeader('X-WSSE', $wsse)
;
} | [
"public",
"function",
"authenticate",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"// TODO: generate better nonce?",
"$",
"nonce",
"=",
"substr",
"(",
"md5",
"(",
"uniqid",
"(",
"uniqid",
"(",
")",
".",
"'_'",
",",
"true",
")",
")",
",",
"0",
",",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Authentication/Wsse.php#L38-L57 |
php-http/message | src/RequestMatcher/RegexRequestMatcher.php | RegexRequestMatcher.matches | public function matches(RequestInterface $request)
{
return (bool) preg_match($this->regex, (string) $request->getUri());
} | php | public function matches(RequestInterface $request)
{
return (bool) preg_match($this->regex, (string) $request->getUri());
} | [
"public",
"function",
"matches",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"return",
"(",
"bool",
")",
"preg_match",
"(",
"$",
"this",
"->",
"regex",
",",
"(",
"string",
")",
"$",
"request",
"->",
"getUri",
"(",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/RequestMatcher/RegexRequestMatcher.php#L37-L40 |
php-http/message | src/Formatter/CurlCommandFormatter.php | CurlCommandFormatter.formatRequest | public function formatRequest(RequestInterface $request)
{
$command = sprintf('curl %s', escapeshellarg((string) $request->getUri()->withFragment('')));
if ('1.0' === $request->getProtocolVersion()) {
$command .= ' --http1.0';
} elseif ('2.0' === $request->getProtocolVersion()) {
$command .= ' --http2';
}
$method = strtoupper($request->getMethod());
if ('HEAD' === $method) {
$command .= ' --head';
} elseif ('GET' !== $method) {
$command .= ' --request '.$method;
}
$command .= $this->getHeadersAsCommandOptions($request);
$body = $request->getBody();
if ($body->getSize() > 0) {
if ($body->isSeekable()) {
$data = $body->__toString();
$body->rewind();
if (preg_match('/[\x00-\x1F\x7F]/', $data)) {
$data = '[binary stream omitted]';
}
} else {
$data = '[non-seekable stream omitted]';
}
$escapedData = @escapeshellarg($data);
if (empty($escapedData)) {
$escapedData = 'We couldn\'t not escape the data properly';
}
$command .= sprintf(' --data %s', $escapedData);
}
return $command;
} | php | public function formatRequest(RequestInterface $request)
{
$command = sprintf('curl %s', escapeshellarg((string) $request->getUri()->withFragment('')));
if ('1.0' === $request->getProtocolVersion()) {
$command .= ' --http1.0';
} elseif ('2.0' === $request->getProtocolVersion()) {
$command .= ' --http2';
}
$method = strtoupper($request->getMethod());
if ('HEAD' === $method) {
$command .= ' --head';
} elseif ('GET' !== $method) {
$command .= ' --request '.$method;
}
$command .= $this->getHeadersAsCommandOptions($request);
$body = $request->getBody();
if ($body->getSize() > 0) {
if ($body->isSeekable()) {
$data = $body->__toString();
$body->rewind();
if (preg_match('/[\x00-\x1F\x7F]/', $data)) {
$data = '[binary stream omitted]';
}
} else {
$data = '[non-seekable stream omitted]';
}
$escapedData = @escapeshellarg($data);
if (empty($escapedData)) {
$escapedData = 'We couldn\'t not escape the data properly';
}
$command .= sprintf(' --data %s', $escapedData);
}
return $command;
} | [
"public",
"function",
"formatRequest",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"command",
"=",
"sprintf",
"(",
"'curl %s'",
",",
"escapeshellarg",
"(",
"(",
"string",
")",
"$",
"request",
"->",
"getUri",
"(",
")",
"->",
"withFragment",
"(",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Formatter/CurlCommandFormatter.php#L19-L57 |
php-http/message | src/Formatter/CurlCommandFormatter.php | CurlCommandFormatter.getHeadersAsCommandOptions | private function getHeadersAsCommandOptions(RequestInterface $request)
{
$command = '';
foreach ($request->getHeaders() as $name => $values) {
if ('host' === strtolower($name) && $values[0] === $request->getUri()->getHost()) {
continue;
}
if ('user-agent' === strtolower($name)) {
$command .= sprintf(' -A %s', escapeshellarg($values[0]));
continue;
}
$command .= sprintf(' -H %s', escapeshellarg($name.': '.$request->getHeaderLine($name)));
}
return $command;
} | php | private function getHeadersAsCommandOptions(RequestInterface $request)
{
$command = '';
foreach ($request->getHeaders() as $name => $values) {
if ('host' === strtolower($name) && $values[0] === $request->getUri()->getHost()) {
continue;
}
if ('user-agent' === strtolower($name)) {
$command .= sprintf(' -A %s', escapeshellarg($values[0]));
continue;
}
$command .= sprintf(' -H %s', escapeshellarg($name.': '.$request->getHeaderLine($name)));
}
return $command;
} | [
"private",
"function",
"getHeadersAsCommandOptions",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"command",
"=",
"''",
";",
"foreach",
"(",
"$",
"request",
"->",
"getHeaders",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"values",
")",
"{",
"if",
... | @param RequestInterface $request
@return string | [
"@param",
"RequestInterface",
"$request"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Formatter/CurlCommandFormatter.php#L72-L90 |
php-http/message | src/Formatter/SimpleFormatter.php | SimpleFormatter.formatRequest | public function formatRequest(RequestInterface $request)
{
return sprintf(
'%s %s %s',
$request->getMethod(),
$request->getUri()->__toString(),
$request->getProtocolVersion()
);
} | php | public function formatRequest(RequestInterface $request)
{
return sprintf(
'%s %s %s',
$request->getMethod(),
$request->getUri()->__toString(),
$request->getProtocolVersion()
);
} | [
"public",
"function",
"formatRequest",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"return",
"sprintf",
"(",
"'%s %s %s'",
",",
"$",
"request",
"->",
"getMethod",
"(",
")",
",",
"$",
"request",
"->",
"getUri",
"(",
")",
"->",
"__toString",
"(",
")",... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Formatter/SimpleFormatter.php#L20-L28 |
php-http/message | src/Formatter/SimpleFormatter.php | SimpleFormatter.formatResponse | public function formatResponse(ResponseInterface $response)
{
return sprintf(
'%s %s %s',
$response->getStatusCode(),
$response->getReasonPhrase(),
$response->getProtocolVersion()
);
} | php | public function formatResponse(ResponseInterface $response)
{
return sprintf(
'%s %s %s',
$response->getStatusCode(),
$response->getReasonPhrase(),
$response->getProtocolVersion()
);
} | [
"public",
"function",
"formatResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"return",
"sprintf",
"(",
"'%s %s %s'",
",",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
",",
"$",
"response",
"->",
"getReasonPhrase",
"(",
")",
",",
"$",
"re... | {@inheritdoc} | [
"{"
] | train | https://github.com/php-http/message/blob/31f25d63e9c84aa22f02c5d888e22fe23d0b65da/src/Formatter/SimpleFormatter.php#L33-L41 |
composer/xdebug-handler | src/Process.php | Process.addColorOption | public static function addColorOption(array $args, $colorOption)
{
if (!$colorOption
|| in_array($colorOption, $args)
|| !preg_match('/^--([a-z]+$)|(^--[a-z]+=)/', $colorOption, $matches)) {
return $args;
}
if (isset($matches[2])) {
// Handle --color(s)= options
if (false !== ($index = array_search($matches[2].'auto', $args))) {
$args[$index] = $colorOption;
return $args;
} elseif (preg_grep('/^'.$matches[2].'/', $args)) {
return $args;
}
} elseif (in_array('--no-'.$matches[1], $args)) {
return $args;
}
if (false !== ($index = array_search('--', $args))) {
// Position option before double-dash delimiter
array_splice($args, $index, 0, $colorOption);
} else {
$args[] = $colorOption;
}
return $args;
} | php | public static function addColorOption(array $args, $colorOption)
{
if (!$colorOption
|| in_array($colorOption, $args)
|| !preg_match('/^--([a-z]+$)|(^--[a-z]+=)/', $colorOption, $matches)) {
return $args;
}
if (isset($matches[2])) {
// Handle --color(s)= options
if (false !== ($index = array_search($matches[2].'auto', $args))) {
$args[$index] = $colorOption;
return $args;
} elseif (preg_grep('/^'.$matches[2].'/', $args)) {
return $args;
}
} elseif (in_array('--no-'.$matches[1], $args)) {
return $args;
}
if (false !== ($index = array_search('--', $args))) {
// Position option before double-dash delimiter
array_splice($args, $index, 0, $colorOption);
} else {
$args[] = $colorOption;
}
return $args;
} | [
"public",
"static",
"function",
"addColorOption",
"(",
"array",
"$",
"args",
",",
"$",
"colorOption",
")",
"{",
"if",
"(",
"!",
"$",
"colorOption",
"||",
"in_array",
"(",
"$",
"colorOption",
",",
"$",
"args",
")",
"||",
"!",
"preg_match",
"(",
"'/^--([a-... | Returns an array of parameters, including a color option if required
A color option is needed because child process output is piped.
@param array $args The script parameters
@param string $colorOption The long option to force color output
@return array | [
"Returns",
"an",
"array",
"of",
"parameters",
"including",
"a",
"color",
"option",
"if",
"required"
] | train | https://github.com/composer/xdebug-handler/blob/0af624bc9c20a3c9252793625bbe976af082d401/src/Process.php#L33-L61 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.