repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
matomo-org/device-detector | Parser/Client/Browser.php | Browser.isMobileOnlyBrowser | public static function isMobileOnlyBrowser($browser)
{
return in_array($browser, self::$mobileOnlyBrowsers) || (in_array($browser, self::$availableBrowsers) && in_array(array_search($browser, self::$availableBrowsers), self::$mobileOnlyBrowsers));
} | php | public static function isMobileOnlyBrowser($browser)
{
return in_array($browser, self::$mobileOnlyBrowsers) || (in_array($browser, self::$availableBrowsers) && in_array(array_search($browser, self::$availableBrowsers), self::$mobileOnlyBrowsers));
} | [
"public",
"static",
"function",
"isMobileOnlyBrowser",
"(",
"$",
"browser",
")",
"{",
"return",
"in_array",
"(",
"$",
"browser",
",",
"self",
"::",
"$",
"mobileOnlyBrowsers",
")",
"||",
"(",
"in_array",
"(",
"$",
"browser",
",",
"self",
"::",
"$",
"availab... | Returns if the given browser is mobile only
@param string $browser Label or name of browser
@return bool | [
"Returns",
"if",
"the",
"given",
"browser",
"is",
"mobile",
"only"
] | 61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b | https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/Parser/Client/Browser.php#L269-L272 | train |
matomo-org/device-detector | Parser/Client/ClientParserAbstract.php | ClientParserAbstract.parse | public function parse()
{
$result = null;
if ($this->preMatchOverall()) {
foreach ($this->getRegexes() as $regex) {
$matches = $this->matchUserAgent($regex['regex']);
if ($matches) {
$result = array(
'type' ... | php | public function parse()
{
$result = null;
if ($this->preMatchOverall()) {
foreach ($this->getRegexes() as $regex) {
$matches = $this->matchUserAgent($regex['regex']);
if ($matches) {
$result = array(
'type' ... | [
"public",
"function",
"parse",
"(",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"preMatchOverall",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRegexes",
"(",
")",
"as",
"$",
"regex",
")",
"{",
"$",
"mat... | Parses the current UA and checks whether it contains any client information
@see $fixtureFile for file with list of detected clients
Step 1: Build a big regex containing all regexes and match UA against it
-> If no matches found: return
-> Otherwise:
Step 2: Walk through the list of regexes in feed_readers.yml and tr... | [
"Parses",
"the",
"current",
"UA",
"and",
"checks",
"whether",
"it",
"contains",
"any",
"client",
"information"
] | 61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b | https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/Parser/Client/ClientParserAbstract.php#L30-L50 | train |
matomo-org/device-detector | Parser/Client/ClientParserAbstract.php | ClientParserAbstract.getAvailableClients | public static function getAvailableClients()
{
$instance = new static();
$regexes = $instance->getRegexes();
$names = array();
foreach ($regexes as $regex) {
if ($regex['name'] != '$1') {
$names[] = $regex['name'];
}
}
natcases... | php | public static function getAvailableClients()
{
$instance = new static();
$regexes = $instance->getRegexes();
$names = array();
foreach ($regexes as $regex) {
if ($regex['name'] != '$1') {
$names[] = $regex['name'];
}
}
natcases... | [
"public",
"static",
"function",
"getAvailableClients",
"(",
")",
"{",
"$",
"instance",
"=",
"new",
"static",
"(",
")",
";",
"$",
"regexes",
"=",
"$",
"instance",
"->",
"getRegexes",
"(",
")",
";",
"$",
"names",
"=",
"array",
"(",
")",
";",
"foreach",
... | Returns all names defined in the regexes
Attention: This method might not return all names of detected clients
@return array | [
"Returns",
"all",
"names",
"defined",
"in",
"the",
"regexes"
] | 61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b | https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/Parser/Client/ClientParserAbstract.php#L59-L73 | train |
matomo-org/device-detector | Parser/Bot.php | Bot.parse | public function parse()
{
$result = null;
if ($this->preMatchOverall()) {
if ($this->discardDetails) {
$result = true;
} else {
foreach ($this->getRegexes() as $regex) {
$matches = $this->matchUserAgent($regex['regex']);
... | php | public function parse()
{
$result = null;
if ($this->preMatchOverall()) {
if ($this->discardDetails) {
$result = true;
} else {
foreach ($this->getRegexes() as $regex) {
$matches = $this->matchUserAgent($regex['regex']);
... | [
"public",
"function",
"parse",
"(",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"preMatchOverall",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"discardDetails",
")",
"{",
"$",
"result",
"=",
"true",
";",
"}",
"e... | Parses the current UA and checks whether it contains bot information
@see bots.yml for list of detected bots
Step 1: Build a big regex containing all regexes and match UA against it
-> If no matches found: return
-> Otherwise:
Step 2: Walk through the list of regexes in bots.yml and try to match every one
-> Return t... | [
"Parses",
"the",
"current",
"UA",
"and",
"checks",
"whether",
"it",
"contains",
"bot",
"information"
] | 61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b | https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/Parser/Bot.php#L49-L69 | train |
matomo-org/device-detector | Parser/OperatingSystem.php | OperatingSystem.getOsFamily | public static function getOsFamily($osLabel)
{
foreach (self::$osFamilies as $family => $labels) {
if (in_array($osLabel, $labels)) {
return $family;
}
}
return false;
} | php | public static function getOsFamily($osLabel)
{
foreach (self::$osFamilies as $family => $labels) {
if (in_array($osLabel, $labels)) {
return $family;
}
}
return false;
} | [
"public",
"static",
"function",
"getOsFamily",
"(",
"$",
"osLabel",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"osFamilies",
"as",
"$",
"family",
"=>",
"$",
"labels",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"osLabel",
",",
"$",
"labels",
")",
")... | Returns the operating system family for the given operating system
@param $osLabel
@return bool|string If false, "Unknown" | [
"Returns",
"the",
"operating",
"system",
"family",
"for",
"the",
"given",
"operating",
"system"
] | 61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b | https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/Parser/OperatingSystem.php#L223-L231 | train |
matomo-org/device-detector | Parser/OperatingSystem.php | OperatingSystem.getNameFromId | public static function getNameFromId($os, $ver = false)
{
if (array_key_exists($os, self::$operatingSystems)) {
$osFullName = self::$operatingSystems[$os];
return trim($osFullName . " " . $ver);
}
return false;
} | php | public static function getNameFromId($os, $ver = false)
{
if (array_key_exists($os, self::$operatingSystems)) {
$osFullName = self::$operatingSystems[$os];
return trim($osFullName . " " . $ver);
}
return false;
} | [
"public",
"static",
"function",
"getNameFromId",
"(",
"$",
"os",
",",
"$",
"ver",
"=",
"false",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"os",
",",
"self",
"::",
"$",
"operatingSystems",
")",
")",
"{",
"$",
"osFullName",
"=",
"self",
"::",
... | Returns the full name for the given short name
@param $os
@param bool $ver
@return bool|string | [
"Returns",
"the",
"full",
"name",
"for",
"the",
"given",
"short",
"name"
] | 61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b | https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/Parser/OperatingSystem.php#L241-L248 | train |
matomo-org/device-detector | Parser/ParserAbstract.php | ParserAbstract.setVersionTruncation | public static function setVersionTruncation($type)
{
if (in_array($type, array(self::VERSION_TRUNCATION_BUILD,
self::VERSION_TRUNCATION_NONE,
self::VERSION_TRUNCATION_MAJOR,
self::VERSION_TRUNCATION_MINOR,
... | php | public static function setVersionTruncation($type)
{
if (in_array($type, array(self::VERSION_TRUNCATION_BUILD,
self::VERSION_TRUNCATION_NONE,
self::VERSION_TRUNCATION_MAJOR,
self::VERSION_TRUNCATION_MINOR,
... | [
"public",
"static",
"function",
"setVersionTruncation",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"array",
"(",
"self",
"::",
"VERSION_TRUNCATION_BUILD",
",",
"self",
"::",
"VERSION_TRUNCATION_NONE",
",",
"self",
"::",
"VERSION_... | Set how DeviceDetector should return versions
@param int|null $type Any of the VERSION_TRUNCATION_* constants | [
"Set",
"how",
"DeviceDetector",
"should",
"return",
"versions"
] | 61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b | https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/Parser/ParserAbstract.php#L111-L120 | train |
matomo-org/device-detector | Parser/ParserAbstract.php | ParserAbstract.matchUserAgent | protected function matchUserAgent($regex)
{
// only match if useragent begins with given regex or there is no letter before it
$regex = '/(?:^|[^A-Z0-9\-_]|[^A-Z0-9\-]_|sprd-)(?:' . str_replace('/', '\/', $regex) . ')/i';
if (preg_match($regex, $this->userAgent, $matches)) {
ret... | php | protected function matchUserAgent($regex)
{
// only match if useragent begins with given regex or there is no letter before it
$regex = '/(?:^|[^A-Z0-9\-_]|[^A-Z0-9\-]_|sprd-)(?:' . str_replace('/', '\/', $regex) . ')/i';
if (preg_match($regex, $this->userAgent, $matches)) {
ret... | [
"protected",
"function",
"matchUserAgent",
"(",
"$",
"regex",
")",
"{",
"// only match if useragent begins with given regex or there is no letter before it",
"$",
"regex",
"=",
"'/(?:^|[^A-Z0-9\\-_]|[^A-Z0-9\\-]_|sprd-)(?:'",
".",
"str_replace",
"(",
"'/'",
",",
"'\\/'",
",",
... | Matches the useragent against the given regex
@param $regex
@return array|bool | [
"Matches",
"the",
"useragent",
"against",
"the",
"given",
"regex"
] | 61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b | https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/Parser/ParserAbstract.php#L177-L187 | train |
matomo-org/device-detector | Parser/ParserAbstract.php | ParserAbstract.preMatchOverall | protected function preMatchOverall()
{
$regexes = $this->getRegexes();
static $overAllMatch;
$cacheKey = $this->parserName.DeviceDetector::VERSION.'-all';
$cacheKey = preg_replace('/([^a-z0-9_-]+)/i', '', $cacheKey);
if (empty($overAllMatch)) {
$overAllMatch = ... | php | protected function preMatchOverall()
{
$regexes = $this->getRegexes();
static $overAllMatch;
$cacheKey = $this->parserName.DeviceDetector::VERSION.'-all';
$cacheKey = preg_replace('/([^a-z0-9_-]+)/i', '', $cacheKey);
if (empty($overAllMatch)) {
$overAllMatch = ... | [
"protected",
"function",
"preMatchOverall",
"(",
")",
"{",
"$",
"regexes",
"=",
"$",
"this",
"->",
"getRegexes",
"(",
")",
";",
"static",
"$",
"overAllMatch",
";",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"parserName",
".",
"DeviceDetector",
"::",
"VERSION... | Tests the useragent against a combination of all regexes
All regexes returned by getRegexes() will be reversed and concated with '|'
Afterwards the big regex will be tested against the user agent
Method can be used to speed up detections by making a big check before doing checks for every single regex
@return bool | [
"Tests",
"the",
"useragent",
"against",
"a",
"combination",
"of",
"all",
"regexes"
] | 61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b | https://github.com/matomo-org/device-detector/blob/61f93df202f3ffa1b5f2ff6d8620944e3f18ae4b/Parser/ParserAbstract.php#L241-L267 | train |
spatie/laravel-query-builder | src/QueryBuilder.php | QueryBuilder.for | public static function for($baseQuery, ?Request $request = null): self
{
if (is_string($baseQuery)) {
$baseQuery = ($baseQuery)::query();
}
return new static($baseQuery, $request ?? request());
} | php | public static function for($baseQuery, ?Request $request = null): self
{
if (is_string($baseQuery)) {
$baseQuery = ($baseQuery)::query();
}
return new static($baseQuery, $request ?? request());
} | [
"public",
"static",
"function",
"for",
"(",
"$",
"baseQuery",
",",
"?",
"Request",
"$",
"request",
"=",
"null",
")",
":",
"self",
"{",
"if",
"(",
"is_string",
"(",
"$",
"baseQuery",
")",
")",
"{",
"$",
"baseQuery",
"=",
"(",
"$",
"baseQuery",
")",
... | Create a new QueryBuilder for a request and model.
@param string|\Illuminate\Database\Query\Builder $baseQuery Model class or base query builder
@param \Illuminate\Http\Request $request
@return \Spatie\QueryBuilder\QueryBuilder | [
"Create",
"a",
"new",
"QueryBuilder",
"for",
"a",
"request",
"and",
"model",
"."
] | 68bc39e816fbdf75d6691960ae3c30479e1f5de5 | https://github.com/spatie/laravel-query-builder/blob/68bc39e816fbdf75d6691960ae3c30479e1f5de5/src/QueryBuilder.php#L42-L49 | train |
php-pm/php-pm | src/Bridges/BootstrapTrait.php | BootstrapTrait.bootstrapApplicationEnvironment | private function bootstrapApplicationEnvironment($appBootstrap, $appenv, $debug)
{
$appBootstrap = $this->normalizeBootstrapClass($appBootstrap);
$this->middleware = new $appBootstrap;
if ($this->middleware instanceof ApplicationEnvironmentAwareInterface) {
$this->middleware->in... | php | private function bootstrapApplicationEnvironment($appBootstrap, $appenv, $debug)
{
$appBootstrap = $this->normalizeBootstrapClass($appBootstrap);
$this->middleware = new $appBootstrap;
if ($this->middleware instanceof ApplicationEnvironmentAwareInterface) {
$this->middleware->in... | [
"private",
"function",
"bootstrapApplicationEnvironment",
"(",
"$",
"appBootstrap",
",",
"$",
"appenv",
",",
"$",
"debug",
")",
"{",
"$",
"appBootstrap",
"=",
"$",
"this",
"->",
"normalizeBootstrapClass",
"(",
"$",
"appBootstrap",
")",
";",
"$",
"this",
"->",
... | Bootstrap application environment
@param string|null $appBootstrap The environment your application will use to bootstrap (if any)
@param string $appenv
@param boolean $debug If debug is enabled | [
"Bootstrap",
"application",
"environment"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/Bridges/BootstrapTrait.php#L18-L26 | train |
php-pm/php-pm | src/SlavePool.php | SlavePool.add | public function add(Slave $slave)
{
$port = $slave->getPort();
if (isset($this->slaves[$port])) {
throw new \Exception("Slave port $port already occupied.");
}
if ($slave->getPort() !== $port) {
throw new \Exception("Slave mis-assigned.");
}
... | php | public function add(Slave $slave)
{
$port = $slave->getPort();
if (isset($this->slaves[$port])) {
throw new \Exception("Slave port $port already occupied.");
}
if ($slave->getPort() !== $port) {
throw new \Exception("Slave mis-assigned.");
}
... | [
"public",
"function",
"add",
"(",
"Slave",
"$",
"slave",
")",
"{",
"$",
"port",
"=",
"$",
"slave",
"->",
"getPort",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"slaves",
"[",
"$",
"port",
"]",
")",
")",
"{",
"throw",
"new",
"\\",... | Add slave to pool
Slave is in CREATED state
@param Slave $slave
@return void | [
"Add",
"slave",
"to",
"pool"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/SlavePool.php#L24-L37 | train |
php-pm/php-pm | src/SlavePool.php | SlavePool.remove | public function remove(Slave $slave)
{
$port = $slave->getPort();
// validate existence
$this->getByPort($port);
// remove
unset($this->slaves[$port]);
} | php | public function remove(Slave $slave)
{
$port = $slave->getPort();
// validate existence
$this->getByPort($port);
// remove
unset($this->slaves[$port]);
} | [
"public",
"function",
"remove",
"(",
"Slave",
"$",
"slave",
")",
"{",
"$",
"port",
"=",
"$",
"slave",
"->",
"getPort",
"(",
")",
";",
"// validate existence",
"$",
"this",
"->",
"getByPort",
"(",
"$",
"port",
")",
";",
"// remove",
"unset",
"(",
"$",
... | Remove from pool
@param Slave $slave
@return void | [
"Remove",
"from",
"pool"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/SlavePool.php#L46-L55 | train |
php-pm/php-pm | src/SlavePool.php | SlavePool.getByPort | public function getByPort($port)
{
if (!isset($this->slaves[$port])) {
throw new \Exception("Slave port $port empty.");
}
return $this->slaves[$port];
} | php | public function getByPort($port)
{
if (!isset($this->slaves[$port])) {
throw new \Exception("Slave port $port empty.");
}
return $this->slaves[$port];
} | [
"public",
"function",
"getByPort",
"(",
"$",
"port",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"slaves",
"[",
"$",
"port",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Slave port $port empty.\"",
")",
";",
"}",
"ret... | Get slave by port
@param int $port
@return Slave | [
"Get",
"slave",
"by",
"port"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/SlavePool.php#L63-L70 | train |
php-pm/php-pm | src/SlavePool.php | SlavePool.getByConnection | public function getByConnection(ConnectionInterface $connection)
{
$hash = spl_object_hash($connection);
foreach ($this->slaves as $slave) {
if ($slave->getConnection() && $hash === spl_object_hash($slave->getConnection())) {
return $slave;
}
}
... | php | public function getByConnection(ConnectionInterface $connection)
{
$hash = spl_object_hash($connection);
foreach ($this->slaves as $slave) {
if ($slave->getConnection() && $hash === spl_object_hash($slave->getConnection())) {
return $slave;
}
}
... | [
"public",
"function",
"getByConnection",
"(",
"ConnectionInterface",
"$",
"connection",
")",
"{",
"$",
"hash",
"=",
"spl_object_hash",
"(",
"$",
"connection",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"slaves",
"as",
"$",
"slave",
")",
"{",
"if",
"(",
... | Get slave slaves by connection
@param ConnectionInterface $connection
@return mixed
@throws \Exception | [
"Get",
"slave",
"slaves",
"by",
"connection"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/SlavePool.php#L80-L91 | train |
php-pm/php-pm | src/SlavePool.php | SlavePool.getByStatus | public function getByStatus($status)
{
return array_filter($this->slaves, function ($slave) use ($status) {
return $status === Slave::ANY || $status === $slave->getStatus();
});
} | php | public function getByStatus($status)
{
return array_filter($this->slaves, function ($slave) use ($status) {
return $status === Slave::ANY || $status === $slave->getStatus();
});
} | [
"public",
"function",
"getByStatus",
"(",
"$",
"status",
")",
"{",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"slaves",
",",
"function",
"(",
"$",
"slave",
")",
"use",
"(",
"$",
"status",
")",
"{",
"return",
"$",
"status",
"===",
"Slave",
"::",
... | Get multiple slaves by status | [
"Get",
"multiple",
"slaves",
"by",
"status"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/SlavePool.php#L96-L101 | train |
php-pm/php-pm | src/SlavePool.php | SlavePool.getStatusSummary | public function getStatusSummary()
{
$map = [
'total' => Slave::ANY,
'ready' => Slave::READY,
'busy' => Slave::BUSY,
'created' => Slave::CREATED,
'registered' => Slave::REGISTERED,
'closed' => Slave::CLOSED
];
return ar... | php | public function getStatusSummary()
{
$map = [
'total' => Slave::ANY,
'ready' => Slave::READY,
'busy' => Slave::BUSY,
'created' => Slave::CREATED,
'registered' => Slave::REGISTERED,
'closed' => Slave::CLOSED
];
return ar... | [
"public",
"function",
"getStatusSummary",
"(",
")",
"{",
"$",
"map",
"=",
"[",
"'total'",
"=>",
"Slave",
"::",
"ANY",
",",
"'ready'",
"=>",
"Slave",
"::",
"READY",
",",
"'busy'",
"=>",
"Slave",
"::",
"BUSY",
",",
"'created'",
"=>",
"Slave",
"::",
"CREA... | Return a human-readable summary of the slaves in the pool.
@return array | [
"Return",
"a",
"human",
"-",
"readable",
"summary",
"of",
"the",
"slaves",
"in",
"the",
"pool",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/SlavePool.php#L108-L122 | train |
php-pm/php-pm | src/Slave.php | Slave.register | public function register($pid, ConnectionInterface $connection)
{
if ($this->status !== self::CREATED) {
throw new \LogicException('Cannot register a slave that is not in created state');
}
$this->pid = $pid;
$this->connection = $connection;
$this->status = self... | php | public function register($pid, ConnectionInterface $connection)
{
if ($this->status !== self::CREATED) {
throw new \LogicException('Cannot register a slave that is not in created state');
}
$this->pid = $pid;
$this->connection = $connection;
$this->status = self... | [
"public",
"function",
"register",
"(",
"$",
"pid",
",",
"ConnectionInterface",
"$",
"connection",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"status",
"!==",
"self",
"::",
"CREATED",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Cannot register a sla... | Register a slave after it's process started
@param int $pid
@param ConnectionInterface $connection
@return void | [
"Register",
"a",
"slave",
"after",
"it",
"s",
"process",
"started"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/Slave.php#L122-L132 | train |
php-pm/php-pm | src/Slave.php | Slave.ready | public function ready()
{
if ($this->status !== self::REGISTERED) {
throw new \LogicException('Cannot ready a slave that is not in registered state');
}
$this->status = self::READY;
} | php | public function ready()
{
if ($this->status !== self::REGISTERED) {
throw new \LogicException('Cannot ready a slave that is not in registered state');
}
$this->status = self::READY;
} | [
"public",
"function",
"ready",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"status",
"!==",
"self",
"::",
"REGISTERED",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Cannot ready a slave that is not in registered state'",
")",
";",
"}",
"$",
"this"... | Ready a slave after bootstrap completed
@return void | [
"Ready",
"a",
"slave",
"after",
"bootstrap",
"completed"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/Slave.php#L139-L146 | train |
php-pm/php-pm | src/Slave.php | Slave.occupy | public function occupy()
{
if ($this->status !== self::READY) {
throw new \LogicException('Cannot occupy a slave that is not in ready state');
}
$this->status = self::BUSY;
} | php | public function occupy()
{
if ($this->status !== self::READY) {
throw new \LogicException('Cannot occupy a slave that is not in ready state');
}
$this->status = self::BUSY;
} | [
"public",
"function",
"occupy",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"status",
"!==",
"self",
"::",
"READY",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Cannot occupy a slave that is not in ready state'",
")",
";",
"}",
"$",
"this",
"->"... | Occupies a slave for request handling
@return void | [
"Occupies",
"a",
"slave",
"for",
"request",
"handling"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/Slave.php#L153-L160 | train |
php-pm/php-pm | src/Slave.php | Slave.release | public function release()
{
if ($this->status !== self::BUSY) {
throw new \LogicException('Cannot release a slave that is not in busy state');
}
$this->status = self::READY;
$this->handledRequests++;
} | php | public function release()
{
if ($this->status !== self::BUSY) {
throw new \LogicException('Cannot release a slave that is not in busy state');
}
$this->status = self::READY;
$this->handledRequests++;
} | [
"public",
"function",
"release",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"status",
"!==",
"self",
"::",
"BUSY",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Cannot release a slave that is not in busy state'",
")",
";",
"}",
"$",
"this",
"->"... | Releases a slave from request handling
@return void | [
"Releases",
"a",
"slave",
"from",
"request",
"handling"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/Slave.php#L167-L175 | train |
php-pm/php-pm | src/RequestHandler.php | RequestHandler.handle | public function handle(ConnectionInterface $incoming)
{
$this->incoming = $incoming;
$this->incoming->on('data', [$this, 'handleData']);
$this->incoming->on('close', function () {
$this->connectionOpen = false;
});
$this->start = microtime(true);
$this->... | php | public function handle(ConnectionInterface $incoming)
{
$this->incoming = $incoming;
$this->incoming->on('data', [$this, 'handleData']);
$this->incoming->on('close', function () {
$this->connectionOpen = false;
});
$this->start = microtime(true);
$this->... | [
"public",
"function",
"handle",
"(",
"ConnectionInterface",
"$",
"incoming",
")",
"{",
"$",
"this",
"->",
"incoming",
"=",
"$",
"incoming",
";",
"$",
"this",
"->",
"incoming",
"->",
"on",
"(",
"'data'",
",",
"[",
"$",
"this",
",",
"'handleData'",
"]",
... | Handle incoming client connection
@param ConnectionInterface $incoming | [
"Handle",
"incoming",
"client",
"connection"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/RequestHandler.php#L97-L113 | train |
php-pm/php-pm | src/RequestHandler.php | RequestHandler.handleData | public function handleData($data)
{
$this->incomingBuffer .= $data;
if ($this->connection && $this->isHeaderEnd($this->incomingBuffer)) {
$remoteAddress = (string) $this->incoming->getRemoteAddress();
$headersToReplace = [
'X-PHP-PM-Remote-IP' => trim(parse_u... | php | public function handleData($data)
{
$this->incomingBuffer .= $data;
if ($this->connection && $this->isHeaderEnd($this->incomingBuffer)) {
$remoteAddress = (string) $this->incoming->getRemoteAddress();
$headersToReplace = [
'X-PHP-PM-Remote-IP' => trim(parse_u... | [
"public",
"function",
"handleData",
"(",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"incomingBuffer",
".=",
"$",
"data",
";",
"if",
"(",
"$",
"this",
"->",
"connection",
"&&",
"$",
"this",
"->",
"isHeaderEnd",
"(",
"$",
"this",
"->",
"incomingBuffer",
"... | Buffer incoming data until slave connection is available
and headers have been received
@param string $data | [
"Buffer",
"incoming",
"data",
"until",
"slave",
"connection",
"is",
"available",
"and",
"headers",
"have",
"been",
"received"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/RequestHandler.php#L121-L138 | train |
php-pm/php-pm | src/RequestHandler.php | RequestHandler.getNextSlave | public function getNextSlave()
{
// client went away while waiting for worker
if (!$this->connectionOpen) {
return;
}
$available = $this->slaves->getByStatus(Slave::READY);
if (count($available)) {
// pick first slave
$slave = array_shift(... | php | public function getNextSlave()
{
// client went away while waiting for worker
if (!$this->connectionOpen) {
return;
}
$available = $this->slaves->getByStatus(Slave::READY);
if (count($available)) {
// pick first slave
$slave = array_shift(... | [
"public",
"function",
"getNextSlave",
"(",
")",
"{",
"// client went away while waiting for worker",
"if",
"(",
"!",
"$",
"this",
"->",
"connectionOpen",
")",
"{",
"return",
";",
"}",
"$",
"available",
"=",
"$",
"this",
"->",
"slaves",
"->",
"getByStatus",
"("... | Get next free slave from pool
Asynchronously keep trying until slave becomes available | [
"Get",
"next",
"free",
"slave",
"from",
"pool",
"Asynchronously",
"keep",
"trying",
"until",
"slave",
"becomes",
"available"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/RequestHandler.php#L144-L171 | train |
php-pm/php-pm | src/RequestHandler.php | RequestHandler.tryOccupySlave | public function tryOccupySlave(Slave $slave)
{
if ($slave->isExpired()) {
$slave->close();
$this->output->writeln(sprintf('Restart worker #%d because it reached its TTL', $slave->getPort()));
$slave->getConnection()->close();
return false;
}
$... | php | public function tryOccupySlave(Slave $slave)
{
if ($slave->isExpired()) {
$slave->close();
$this->output->writeln(sprintf('Restart worker #%d because it reached its TTL', $slave->getPort()));
$slave->getConnection()->close();
return false;
}
$... | [
"public",
"function",
"tryOccupySlave",
"(",
"Slave",
"$",
"slave",
")",
"{",
"if",
"(",
"$",
"slave",
"->",
"isExpired",
"(",
")",
")",
"{",
"$",
"slave",
"->",
"close",
"(",
")",
";",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"sprintf",
... | Slave available handler
@param Slave $slave available slave instance
@return bool Slave is available | [
"Slave",
"available",
"handler"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/RequestHandler.php#L195-L224 | train |
php-pm/php-pm | src/RequestHandler.php | RequestHandler.slaveConnected | public function slaveConnected(ConnectionInterface $connection)
{
$this->connection = $connection;
$this->verboseTimer(function ($took) {
return sprintf('<info>Took abnormal %.3f seconds for connecting to worker %d</info>', $took, $this->slave->getPort());
});
// call h... | php | public function slaveConnected(ConnectionInterface $connection)
{
$this->connection = $connection;
$this->verboseTimer(function ($took) {
return sprintf('<info>Took abnormal %.3f seconds for connecting to worker %d</info>', $took, $this->slave->getPort());
});
// call h... | [
"public",
"function",
"slaveConnected",
"(",
"ConnectionInterface",
"$",
"connection",
")",
"{",
"$",
"this",
"->",
"connection",
"=",
"$",
"connection",
";",
"$",
"this",
"->",
"verboseTimer",
"(",
"function",
"(",
"$",
"took",
")",
"{",
"return",
"sprintf"... | Handle successful slave connection
@param ConnectionInterface $connection Slave connection | [
"Handle",
"successful",
"slave",
"connection"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/RequestHandler.php#L231-L255 | train |
php-pm/php-pm | src/RequestHandler.php | RequestHandler.maxExecutionTimeExceeded | public function maxExecutionTimeExceeded()
{
// client went away while waiting for worker
if (!$this->connectionOpen) {
return false;
}
$this->incoming->write($this->createErrorResponse('504 Gateway Timeout', 'Maximum execution time exceeded'));
$this->lastOutgoi... | php | public function maxExecutionTimeExceeded()
{
// client went away while waiting for worker
if (!$this->connectionOpen) {
return false;
}
$this->incoming->write($this->createErrorResponse('504 Gateway Timeout', 'Maximum execution time exceeded'));
$this->lastOutgoi... | [
"public",
"function",
"maxExecutionTimeExceeded",
"(",
")",
"{",
"// client went away while waiting for worker",
"if",
"(",
"!",
"$",
"this",
"->",
"connectionOpen",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"incoming",
"->",
"write",
"(",
"$",
... | Stop the worker if the max execution time has been exceeded and return 504 | [
"Stop",
"the",
"worker",
"if",
"the",
"max",
"execution",
"time",
"has",
"been",
"exceeded",
"and",
"return",
"504"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/RequestHandler.php#L260-L274 | train |
php-pm/php-pm | src/RequestHandler.php | RequestHandler.slaveClosed | public function slaveClosed()
{
$this->verboseTimer(function ($took) {
return sprintf('<info>Worker %d took abnormal %.3f seconds for handling a connection</info>', $this->slave->getPort(), $took);
});
// Return a "502 Bad Gateway" response if the response was empty
if (... | php | public function slaveClosed()
{
$this->verboseTimer(function ($took) {
return sprintf('<info>Worker %d took abnormal %.3f seconds for handling a connection</info>', $this->slave->getPort(), $took);
});
// Return a "502 Bad Gateway" response if the response was empty
if (... | [
"public",
"function",
"slaveClosed",
"(",
")",
"{",
"$",
"this",
"->",
"verboseTimer",
"(",
"function",
"(",
"$",
"took",
")",
"{",
"return",
"sprintf",
"(",
"'<info>Worker %d took abnormal %.3f seconds for handling a connection</info>'",
",",
"$",
"this",
"->",
"sl... | Handle slave disconnected
Typically called after slave has finished handling request | [
"Handle",
"slave",
"disconnected"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/RequestHandler.php#L281-L326 | train |
php-pm/php-pm | src/RequestHandler.php | RequestHandler.slaveConnectFailed | public function slaveConnectFailed(\Exception $e)
{
$this->slave->release();
$this->verboseTimer(function ($took) use ($e) {
return sprintf(
'<error>Connection to worker %d failed. Try #%d, took %.3fs ' .
'(timeout %ds). Error message: [%d] %s</error>',
... | php | public function slaveConnectFailed(\Exception $e)
{
$this->slave->release();
$this->verboseTimer(function ($took) use ($e) {
return sprintf(
'<error>Connection to worker %d failed. Try #%d, took %.3fs ' .
'(timeout %ds). Error message: [%d] %s</error>',
... | [
"public",
"function",
"slaveConnectFailed",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"slave",
"->",
"release",
"(",
")",
";",
"$",
"this",
"->",
"verboseTimer",
"(",
"function",
"(",
"$",
"took",
")",
"use",
"(",
"$",
"e",
")",
... | Handle failed slave connection
Connection may fail because of timeouts or crashed or dying worker.
Since the worker may only very busy or dying it's put back into the
available worker list. If it is really dying it will be removed from the
worker list by the connection:close event.
@param \Exception $e slave connecti... | [
"Handle",
"failed",
"slave",
"connection"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/RequestHandler.php#L338-L362 | train |
php-pm/php-pm | src/RequestHandler.php | RequestHandler.verboseTimer | protected function verboseTimer($callback, $always = false)
{
$took = microtime(true) - $this->start;
if (($always || $took > 1) && $this->output->isVeryVerbose()) {
$message = $callback($took);
$this->output->writeln($message);
}
$this->start = microtime(true... | php | protected function verboseTimer($callback, $always = false)
{
$took = microtime(true) - $this->start;
if (($always || $took > 1) && $this->output->isVeryVerbose()) {
$message = $callback($took);
$this->output->writeln($message);
}
$this->start = microtime(true... | [
"protected",
"function",
"verboseTimer",
"(",
"$",
"callback",
",",
"$",
"always",
"=",
"false",
")",
"{",
"$",
"took",
"=",
"microtime",
"(",
"true",
")",
"-",
"$",
"this",
"->",
"start",
";",
"if",
"(",
"(",
"$",
"always",
"||",
"$",
"took",
">",... | Section timer. Measure execution time hand output if verbose mode.
@param callable $callback
@param bool $always Invoke callback regardless of execution time | [
"Section",
"timer",
".",
"Measure",
"execution",
"time",
"hand",
"output",
"if",
"verbose",
"mode",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/RequestHandler.php#L370-L378 | train |
php-pm/php-pm | src/RequestHandler.php | RequestHandler.replaceHeader | protected function replaceHeader($header, $headersToReplace)
{
$result = $header;
foreach ($headersToReplace as $key => $value) {
if (false !== $headerPosition = stripos($result, $key . ':')) {
// check how long the header is
$length = strpos(substr($head... | php | protected function replaceHeader($header, $headersToReplace)
{
$result = $header;
foreach ($headersToReplace as $key => $value) {
if (false !== $headerPosition = stripos($result, $key . ':')) {
// check how long the header is
$length = strpos(substr($head... | [
"protected",
"function",
"replaceHeader",
"(",
"$",
"header",
",",
"$",
"headersToReplace",
")",
"{",
"$",
"result",
"=",
"$",
"header",
";",
"foreach",
"(",
"$",
"headersToReplace",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"false",
"... | Replaces or injects header
@param string $header
@param string[] $headersToReplace
@return string | [
"Replaces",
"or",
"injects",
"header"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/RequestHandler.php#L400-L417 | train |
php-pm/php-pm | src/ProcessSlave.php | ProcessSlave.prepareShutdown | public function prepareShutdown()
{
if ($this->inShutdown) {
return false;
}
if ($this->errorLogger && $logs = $this->errorLogger->cleanLogs()) {
$messages = array_map(
function ($item) {
//array($level, $message, $context);
... | php | public function prepareShutdown()
{
if ($this->inShutdown) {
return false;
}
if ($this->errorLogger && $logs = $this->errorLogger->cleanLogs()) {
$messages = array_map(
function ($item) {
//array($level, $message, $context);
... | [
"public",
"function",
"prepareShutdown",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"inShutdown",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"errorLogger",
"&&",
"$",
"logs",
"=",
"$",
"this",
"->",
"errorLogger",
"->",
"c... | Shuts down the event loop. This basically exits the process.
@return boolean | [
"Shuts",
"down",
"the",
"event",
"loop",
".",
"This",
"basically",
"exits",
"the",
"process",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessSlave.php#L153-L205 | train |
php-pm/php-pm | src/ProcessSlave.php | ProcessSlave.bootstrap | protected function bootstrap($appBootstrap, $appenv, $debug)
{
if ($bridge = $this->getBridge()) {
$bridge->bootstrap($appBootstrap, $appenv, $debug);
$this->sendMessage($this->controller, 'ready');
}
} | php | protected function bootstrap($appBootstrap, $appenv, $debug)
{
if ($bridge = $this->getBridge()) {
$bridge->bootstrap($appBootstrap, $appenv, $debug);
$this->sendMessage($this->controller, 'ready');
}
} | [
"protected",
"function",
"bootstrap",
"(",
"$",
"appBootstrap",
",",
"$",
"appenv",
",",
"$",
"debug",
")",
"{",
"if",
"(",
"$",
"bridge",
"=",
"$",
"this",
"->",
"getBridge",
"(",
")",
")",
"{",
"$",
"bridge",
"->",
"bootstrap",
"(",
"$",
"appBootst... | Bootstraps the actual application.
@param string $appBootstrap
@param string $appenv
@param boolean $debug
@throws \Exception | [
"Bootstraps",
"the",
"actual",
"application",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessSlave.php#L252-L258 | train |
php-pm/php-pm | src/ProcessSlave.php | ProcessSlave.sendCurrentFiles | protected function sendCurrentFiles()
{
if (!$this->isDebug()) {
return;
}
$files = array_merge($this->watchedFiles, get_included_files());
$flipped = array_flip($files);
//speedy way checking if two arrays are different.
if (!$this->lastSentFiles || arr... | php | protected function sendCurrentFiles()
{
if (!$this->isDebug()) {
return;
}
$files = array_merge($this->watchedFiles, get_included_files());
$flipped = array_flip($files);
//speedy way checking if two arrays are different.
if (!$this->lastSentFiles || arr... | [
"protected",
"function",
"sendCurrentFiles",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isDebug",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"files",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"watchedFiles",
",",
"get_included_files",
"(",
... | Sends to the master a snapshot of current known php files, so it can track those files and restart
slaves if necessary. | [
"Sends",
"to",
"the",
"master",
"a",
"snapshot",
"of",
"current",
"known",
"php",
"files",
"so",
"it",
"can",
"track",
"those",
"files",
"and",
"restart",
"slaves",
"if",
"necessary",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessSlave.php#L277-L293 | train |
php-pm/php-pm | src/ProcessSlave.php | ProcessSlave.doConnect | private function doConnect()
{
$connector = new UnixConnector($this->loop);
$unixSocket = $this->getControllerSocketPath(false);
$connector->connect($unixSocket)->done(
function ($controller) {
$this->controller = $controller;
$this->loop->addSig... | php | private function doConnect()
{
$connector = new UnixConnector($this->loop);
$unixSocket = $this->getControllerSocketPath(false);
$connector->connect($unixSocket)->done(
function ($controller) {
$this->controller = $controller;
$this->loop->addSig... | [
"private",
"function",
"doConnect",
"(",
")",
"{",
"$",
"connector",
"=",
"new",
"UnixConnector",
"(",
"$",
"this",
"->",
"loop",
")",
";",
"$",
"unixSocket",
"=",
"$",
"this",
"->",
"getControllerSocketPath",
"(",
"false",
")",
";",
"$",
"connector",
"-... | Attempt a connection to the unix socket.
@throws \RuntimeException | [
"Attempt",
"a",
"connection",
"to",
"the",
"unix",
"socket",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessSlave.php#L300-L327 | train |
php-pm/php-pm | src/ProcessSlave.php | ProcessSlave.run | public function run()
{
$this->loop = Factory::create();
$this->errorLogger = BufferingLogger::create();
ErrorHandler::register(new ErrorHandler($this->errorLogger));
$this->tryConnect();
$this->loop->run();
} | php | public function run()
{
$this->loop = Factory::create();
$this->errorLogger = BufferingLogger::create();
ErrorHandler::register(new ErrorHandler($this->errorLogger));
$this->tryConnect();
$this->loop->run();
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"this",
"->",
"loop",
"=",
"Factory",
"::",
"create",
"(",
")",
";",
"$",
"this",
"->",
"errorLogger",
"=",
"BufferingLogger",
"::",
"create",
"(",
")",
";",
"ErrorHandler",
"::",
"register",
"(",
"new",... | Connects to ProcessManager, master process. | [
"Connects",
"to",
"ProcessManager",
"master",
"process",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessSlave.php#L348-L357 | train |
php-pm/php-pm | src/ProcessSlave.php | ProcessSlave.handleRequest | protected function handleRequest(ServerRequestInterface $request)
{
if ($this->getStaticDirectory()) {
$staticResponse = $this->serveStatic($request);
if ($staticResponse instanceof ResponseInterface) {
return $staticResponse;
}
}
if ($bri... | php | protected function handleRequest(ServerRequestInterface $request)
{
if ($this->getStaticDirectory()) {
$staticResponse = $this->serveStatic($request);
if ($staticResponse instanceof ResponseInterface) {
return $staticResponse;
}
}
if ($bri... | [
"protected",
"function",
"handleRequest",
"(",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getStaticDirectory",
"(",
")",
")",
"{",
"$",
"staticResponse",
"=",
"$",
"this",
"->",
"serveStatic",
"(",
"$",
"request",
")",... | Handle a redirected request from master.
@param ServerRequestInterface $request
@return ResponseInterface | [
"Handle",
"a",
"redirected",
"request",
"from",
"master",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessSlave.php#L422-L461 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.shutdown | public function shutdown($graceful = true)
{
if ($this->status === self::STATE_SHUTDOWN) {
return;
}
$this->output->writeln("<info>Server is shutting down.</info>");
$this->status = self::STATE_SHUTDOWN;
$remainingSlaves = count($this->slaves->getByStatus(Slave:... | php | public function shutdown($graceful = true)
{
if ($this->status === self::STATE_SHUTDOWN) {
return;
}
$this->output->writeln("<info>Server is shutting down.</info>");
$this->status = self::STATE_SHUTDOWN;
$remainingSlaves = count($this->slaves->getByStatus(Slave:... | [
"public",
"function",
"shutdown",
"(",
"$",
"graceful",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"status",
"===",
"self",
"::",
"STATE_SHUTDOWN",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"\"<info>Serv... | Handles termination signals, so we can gracefully stop all servers.
@param bool $graceful If true, will wait for busy workers to finish. | [
"Handles",
"termination",
"signals",
"so",
"we",
"can",
"gracefully",
"stop",
"all",
"servers",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L250-L284 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.quit | private function quit()
{
$this->output->writeln('Stopping the process manager.');
// this method is also called during startup when something crashed, so
// make sure we don't operate on nulls.
if ($this->controller) {
@$this->controller->close();
}
if (... | php | private function quit()
{
$this->output->writeln('Stopping the process manager.');
// this method is also called during startup when something crashed, so
// make sure we don't operate on nulls.
if ($this->controller) {
@$this->controller->close();
}
if (... | [
"private",
"function",
"quit",
"(",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"'Stopping the process manager.'",
")",
";",
"// this method is also called during startup when something crashed, so",
"// make sure we don't operate on nulls.",
"if",
"(",
"$",
... | To be called after all workers have been terminated and the event loop is no longer in use. | [
"To",
"be",
"called",
"after",
"all",
"workers",
"have",
"been",
"terminated",
"and",
"the",
"event",
"loop",
"is",
"no",
"longer",
"in",
"use",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L289-L308 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.run | public function run()
{
Debug::enable();
// make whatever is necessary to disable all stuff that could buffer output
ini_set('zlib.output_compression', 0);
ini_set('output_buffering', 0);
ini_set('implicit_flush', 1);
ob_implicit_flush(1);
$this->loop = Fact... | php | public function run()
{
Debug::enable();
// make whatever is necessary to disable all stuff that could buffer output
ini_set('zlib.output_compression', 0);
ini_set('output_buffering', 0);
ini_set('implicit_flush', 1);
ob_implicit_flush(1);
$this->loop = Fact... | [
"public",
"function",
"run",
"(",
")",
"{",
"Debug",
"::",
"enable",
"(",
")",
";",
"// make whatever is necessary to disable all stuff that could buffer output",
"ini_set",
"(",
"'zlib.output_compression'",
",",
"0",
")",
";",
"ini_set",
"(",
"'output_buffering'",
",",... | Starts the main loop. Blocks. | [
"Starts",
"the",
"main",
"loop",
".",
"Blocks",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L485-L522 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.onSlaveConnection | public function onSlaveConnection(ConnectionInterface $connection)
{
$this->bindProcessMessage($connection);
$connection->on('close', function () use ($connection) {
$this->onSlaveClosed($connection);
});
} | php | public function onSlaveConnection(ConnectionInterface $connection)
{
$this->bindProcessMessage($connection);
$connection->on('close', function () use ($connection) {
$this->onSlaveClosed($connection);
});
} | [
"public",
"function",
"onSlaveConnection",
"(",
"ConnectionInterface",
"$",
"connection",
")",
"{",
"$",
"this",
"->",
"bindProcessMessage",
"(",
"$",
"connection",
")",
";",
"$",
"connection",
"->",
"on",
"(",
"'close'",
",",
"function",
"(",
")",
"use",
"(... | Handles data communication from slave -> master
@param ConnectionInterface $connection | [
"Handles",
"data",
"communication",
"from",
"slave",
"-",
">",
"master"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L556-L562 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.onSlaveClosed | public function onSlaveClosed(ConnectionInterface $connection)
{
if ($this->status === self::STATE_SHUTDOWN) {
return;
}
try {
$slave = $this->slaves->getByConnection($connection);
} catch (\Exception $e) {
// this connection is not registered, so... | php | public function onSlaveClosed(ConnectionInterface $connection)
{
if ($this->status === self::STATE_SHUTDOWN) {
return;
}
try {
$slave = $this->slaves->getByConnection($connection);
} catch (\Exception $e) {
// this connection is not registered, so... | [
"public",
"function",
"onSlaveClosed",
"(",
"ConnectionInterface",
"$",
"connection",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"status",
"===",
"self",
"::",
"STATE_SHUTDOWN",
")",
"{",
"return",
";",
"}",
"try",
"{",
"$",
"slave",
"=",
"$",
"this",
"->",... | Handle slave closed
@param ConnectionInterface $connection
@return void | [
"Handle",
"slave",
"closed"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L570-L615 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.commandStatus | protected function commandStatus(array $data, ConnectionInterface $conn)
{
// remove nasty info about worker's bootstrap fail
$conn->removeAllListeners('close');
if ($this->output->isVeryVerbose()) {
$conn->on('close', function () {
$this->output->writeln('Status ... | php | protected function commandStatus(array $data, ConnectionInterface $conn)
{
// remove nasty info about worker's bootstrap fail
$conn->removeAllListeners('close');
if ($this->output->isVeryVerbose()) {
$conn->on('close', function () {
$this->output->writeln('Status ... | [
"protected",
"function",
"commandStatus",
"(",
"array",
"$",
"data",
",",
"ConnectionInterface",
"$",
"conn",
")",
"{",
"// remove nasty info about worker's bootstrap fail",
"$",
"conn",
"->",
"removeAllListeners",
"(",
"'close'",
")",
";",
"if",
"(",
"$",
"this",
... | A slave sent a `status` command.
@param array $data
@param ConnectionInterface $conn | [
"A",
"slave",
"sent",
"a",
"status",
"command",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L623-L663 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.commandStop | protected function commandStop(array $data, ConnectionInterface $conn)
{
if ($this->output->isVeryVerbose()) {
$conn->on('close', function () {
$this->output->writeln('Stop command requested');
});
}
$conn->end(json_encode([]));
$this->shutdo... | php | protected function commandStop(array $data, ConnectionInterface $conn)
{
if ($this->output->isVeryVerbose()) {
$conn->on('close', function () {
$this->output->writeln('Stop command requested');
});
}
$conn->end(json_encode([]));
$this->shutdo... | [
"protected",
"function",
"commandStop",
"(",
"array",
"$",
"data",
",",
"ConnectionInterface",
"$",
"conn",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"output",
"->",
"isVeryVerbose",
"(",
")",
")",
"{",
"$",
"conn",
"->",
"on",
"(",
"'close'",
",",
"func... | A slave sent a `stop` command.
@param array $data
@param ConnectionInterface $conn | [
"A",
"slave",
"sent",
"a",
"stop",
"command",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L671-L682 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.commandReload | protected function commandReload(array $data, ConnectionInterface $conn)
{
// remove nasty info about worker's bootstrap fail
$conn->removeAllListeners('close');
if ($this->output->isVeryVerbose()) {
$conn->on('close', function () {
$this->output->writeln('Reload... | php | protected function commandReload(array $data, ConnectionInterface $conn)
{
// remove nasty info about worker's bootstrap fail
$conn->removeAllListeners('close');
if ($this->output->isVeryVerbose()) {
$conn->on('close', function () {
$this->output->writeln('Reload... | [
"protected",
"function",
"commandReload",
"(",
"array",
"$",
"data",
",",
"ConnectionInterface",
"$",
"conn",
")",
"{",
"// remove nasty info about worker's bootstrap fail",
"$",
"conn",
"->",
"removeAllListeners",
"(",
"'close'",
")",
";",
"if",
"(",
"$",
"this",
... | A slave sent a `reload` command.
@param array $data
@param ConnectionInterface $conn | [
"A",
"slave",
"sent",
"a",
"reload",
"command",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L690-L704 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.commandRegister | protected function commandRegister(array $data, ConnectionInterface $conn)
{
$pid = (int)$data['pid'];
$port = (int)$data['port'];
try {
$slave = $this->slaves->getByPort($port);
$slave->register($pid, $conn);
} catch (\Exception $e) {
$this->outp... | php | protected function commandRegister(array $data, ConnectionInterface $conn)
{
$pid = (int)$data['pid'];
$port = (int)$data['port'];
try {
$slave = $this->slaves->getByPort($port);
$slave->register($pid, $conn);
} catch (\Exception $e) {
$this->outp... | [
"protected",
"function",
"commandRegister",
"(",
"array",
"$",
"data",
",",
"ConnectionInterface",
"$",
"conn",
")",
"{",
"$",
"pid",
"=",
"(",
"int",
")",
"$",
"data",
"[",
"'pid'",
"]",
";",
"$",
"port",
"=",
"(",
"int",
")",
"$",
"data",
"[",
"'... | A slave sent a `register` command.
@param array $data
@param ConnectionInterface $conn | [
"A",
"slave",
"sent",
"a",
"register",
"command",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L712-L734 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.commandReady | protected function commandReady(array $data, ConnectionInterface $conn)
{
try {
$slave = $this->slaves->getByConnection($conn);
} catch (\Exception $e) {
$this->output->writeln(
'<error>A ready command was sent by a worker with no connection. This was unexpect... | php | protected function commandReady(array $data, ConnectionInterface $conn)
{
try {
$slave = $this->slaves->getByConnection($conn);
} catch (\Exception $e) {
$this->output->writeln(
'<error>A ready command was sent by a worker with no connection. This was unexpect... | [
"protected",
"function",
"commandReady",
"(",
"array",
"$",
"data",
",",
"ConnectionInterface",
"$",
"conn",
")",
"{",
"try",
"{",
"$",
"slave",
"=",
"$",
"this",
"->",
"slaves",
"->",
"getByConnection",
"(",
"$",
"conn",
")",
";",
"}",
"catch",
"(",
"... | A slave sent a `ready` commands which basically says that the slave bootstrapped successfully the
application and is ready to accept connections.
@param array $data
@param ConnectionInterface $conn | [
"A",
"slave",
"sent",
"a",
"ready",
"commands",
"which",
"basically",
"says",
"that",
"the",
"slave",
"bootstrapped",
"successfully",
"the",
"application",
"and",
"is",
"ready",
"to",
"accept",
"connections",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L743-L779 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.commandFiles | protected function commandFiles(array $data, ConnectionInterface $conn)
{
try {
$slave = $this->slaves->getByConnection($conn);
$start = microtime(true);
clearstatcache();
$newFilesCount = 0;
$knownFiles = array_keys($this->filesLastMTime);
... | php | protected function commandFiles(array $data, ConnectionInterface $conn)
{
try {
$slave = $this->slaves->getByConnection($conn);
$start = microtime(true);
clearstatcache();
$newFilesCount = 0;
$knownFiles = array_keys($this->filesLastMTime);
... | [
"protected",
"function",
"commandFiles",
"(",
"array",
"$",
"data",
",",
"ConnectionInterface",
"$",
"conn",
")",
"{",
"try",
"{",
"$",
"slave",
"=",
"$",
"this",
"->",
"slaves",
"->",
"getByConnection",
"(",
"$",
"conn",
")",
";",
"$",
"start",
"=",
"... | Register client files for change tracking
@param array $data
@param ConnectionInterface $conn | [
"Register",
"client",
"files",
"for",
"change",
"tracking"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L800-L834 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.commandStats | protected function commandStats(array $data, ConnectionInterface $conn)
{
try {
$slave = $this->slaves->getByConnection($conn);
$slave->setUsedMemory($data['memory_usage']);
if ($this->output->isVeryVerbose()) {
$this->output->writeln(
... | php | protected function commandStats(array $data, ConnectionInterface $conn)
{
try {
$slave = $this->slaves->getByConnection($conn);
$slave->setUsedMemory($data['memory_usage']);
if ($this->output->isVeryVerbose()) {
$this->output->writeln(
... | [
"protected",
"function",
"commandStats",
"(",
"array",
"$",
"data",
",",
"ConnectionInterface",
"$",
"conn",
")",
"{",
"try",
"{",
"$",
"slave",
"=",
"$",
"this",
"->",
"slaves",
"->",
"getByConnection",
"(",
"$",
"conn",
")",
";",
"$",
"slave",
"->",
... | Receive stats from the worker such as current memory use
@param array $data
@param ConnectionInterface $conn | [
"Receive",
"stats",
"from",
"the",
"worker",
"such",
"as",
"current",
"memory",
"use"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L842-L859 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.bootstrapFailed | protected function bootstrapFailed($port)
{
if ($this->isDebug()) {
$this->output->writeln('');
if ($this->status !== self::STATE_EMERGENCY) {
$this->status = self::STATE_EMERGENCY;
$this->output->writeln(
sprintf(
... | php | protected function bootstrapFailed($port)
{
if ($this->isDebug()) {
$this->output->writeln('');
if ($this->status !== self::STATE_EMERGENCY) {
$this->status = self::STATE_EMERGENCY;
$this->output->writeln(
sprintf(
... | [
"protected",
"function",
"bootstrapFailed",
"(",
"$",
"port",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDebug",
"(",
")",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"''",
")",
";",
"if",
"(",
"$",
"this",
"->",
"status",
"!==",
... | Handles failed application bootstraps.
@param int $port | [
"Handles",
"failed",
"application",
"bootstraps",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L866-L900 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.checkChangedFiles | protected function checkChangedFiles($restartSlaves = true)
{
if ($this->inChangesDetectionCycle) {
return false;
}
$start = microtime(true);
$hasChanged = false;
$this->inChangesDetectionCycle = true;
clearstatcache();
foreach ($this->filesLas... | php | protected function checkChangedFiles($restartSlaves = true)
{
if ($this->inChangesDetectionCycle) {
return false;
}
$start = microtime(true);
$hasChanged = false;
$this->inChangesDetectionCycle = true;
clearstatcache();
foreach ($this->filesLas... | [
"protected",
"function",
"checkChangedFiles",
"(",
"$",
"restartSlaves",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"inChangesDetectionCycle",
")",
"{",
"return",
"false",
";",
"}",
"$",
"start",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"h... | Checks if tracked files have changed. If so, restart all slaves.
This approach uses simple filemtime to check against modifications. It is using this technique because
all other file watching stuff have either big dependencies or do not work under all platforms without
installing a pecl extension. Also this way is int... | [
"Checks",
"if",
"tracked",
"files",
"have",
"changed",
".",
"If",
"so",
"restart",
"all",
"slaves",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L913-L971 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.createSlaves | public function createSlaves()
{
for ($i = 1; $i <= $this->slaveCount; $i++) {
$this->newSlaveInstance(self::CONTROLLER_PORT + $i);
}
} | php | public function createSlaves()
{
for ($i = 1; $i <= $this->slaveCount; $i++) {
$this->newSlaveInstance(self::CONTROLLER_PORT + $i);
}
} | [
"public",
"function",
"createSlaves",
"(",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"this",
"->",
"slaveCount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"this",
"->",
"newSlaveInstance",
"(",
"self",
"::",
"CONTROLLER_PORT",
"... | Populate slave pool
@return void | [
"Populate",
"slave",
"pool"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L978-L983 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.closeSlave | protected function closeSlave($slave)
{
$slave->close();
$this->slaves->remove($slave);
if (!empty($slave->getConnection())) {
/** @var ConnectionInterface */
$connection = $slave->getConnection();
$connection->removeAllListeners('close');
$co... | php | protected function closeSlave($slave)
{
$slave->close();
$this->slaves->remove($slave);
if (!empty($slave->getConnection())) {
/** @var ConnectionInterface */
$connection = $slave->getConnection();
$connection->removeAllListeners('close');
$co... | [
"protected",
"function",
"closeSlave",
"(",
"$",
"slave",
")",
"{",
"$",
"slave",
"->",
"close",
"(",
")",
";",
"$",
"this",
"->",
"slaves",
"->",
"remove",
"(",
"$",
"slave",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"slave",
"->",
"getConnecti... | Close a slave
@param Slave $slave
@return void | [
"Close",
"a",
"slave"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L992-L1003 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.reloadSlaves | public function reloadSlaves($graceful = true)
{
$this->output->writeln('<info>Reloading all workers gracefully</info>');
$this->closeSlaves($graceful, function ($slave) {
/** @var $slave Slave */
if ($this->output->isVeryVerbose()) {
$this->output->writeln(... | php | public function reloadSlaves($graceful = true)
{
$this->output->writeln('<info>Reloading all workers gracefully</info>');
$this->closeSlaves($graceful, function ($slave) {
/** @var $slave Slave */
if ($this->output->isVeryVerbose()) {
$this->output->writeln(... | [
"public",
"function",
"reloadSlaves",
"(",
"$",
"graceful",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"'<info>Reloading all workers gracefully</info>'",
")",
";",
"$",
"this",
"->",
"closeSlaves",
"(",
"$",
"graceful",
",",
"fun... | Reload slaves in-place, allowing busy workers to finish what they are doing. | [
"Reload",
"slaves",
"in",
"-",
"place",
"allowing",
"busy",
"workers",
"to",
"finish",
"what",
"they",
"are",
"doing",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L1008-L1026 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.closeSlaves | public function closeSlaves($graceful = false, $onSlaveClosed = null)
{
if (!$onSlaveClosed) {
// create a default no-op if callable is undefined
$onSlaveClosed = function ($slave) {
};
}
/*
* NB: we don't lock slave reload with a semaphore, sinc... | php | public function closeSlaves($graceful = false, $onSlaveClosed = null)
{
if (!$onSlaveClosed) {
// create a default no-op if callable is undefined
$onSlaveClosed = function ($slave) {
};
}
/*
* NB: we don't lock slave reload with a semaphore, sinc... | [
"public",
"function",
"closeSlaves",
"(",
"$",
"graceful",
"=",
"false",
",",
"$",
"onSlaveClosed",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"onSlaveClosed",
")",
"{",
"// create a default no-op if callable is undefined",
"$",
"onSlaveClosed",
"=",
"function",
... | Closes all slaves and fires a user-defined callback for each slave that is closed.
If $graceful is false, slaves are closed unconditionally, regardless of their current status.
If $graceful is true, workers that are busy are put into a locked state, and will be closed after serving the
current request. If a reload-ti... | [
"Closes",
"all",
"slaves",
"and",
"fires",
"a",
"user",
"-",
"defined",
"callback",
"for",
"each",
"slave",
"that",
"is",
"closed",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L1040-L1116 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.restartSlaves | public function restartSlaves()
{
if ($this->inRestart) {
return;
}
$this->inRestart = true;
$this->closeSlaves();
$this->createSlaves();
$this->inRestart = false;
} | php | public function restartSlaves()
{
if ($this->inRestart) {
return;
}
$this->inRestart = true;
$this->closeSlaves();
$this->createSlaves();
$this->inRestart = false;
} | [
"public",
"function",
"restartSlaves",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"inRestart",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"inRestart",
"=",
"true",
";",
"$",
"this",
"->",
"closeSlaves",
"(",
")",
";",
"$",
"this",
"->",
"cr... | Restart all slaves. Necessary when watched files have changed. | [
"Restart",
"all",
"slaves",
".",
"Necessary",
"when",
"watched",
"files",
"have",
"changed",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L1121-L1133 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.allSlavesReady | protected function allSlavesReady()
{
if ($this->status === self::STATE_STARTING || $this->status === self::STATE_EMERGENCY) {
$readySlaves = $this->slaves->getByStatus(Slave::READY);
$busySlaves = $this->slaves->getByStatus(Slave::BUSY);
return count($readySlaves) + coun... | php | protected function allSlavesReady()
{
if ($this->status === self::STATE_STARTING || $this->status === self::STATE_EMERGENCY) {
$readySlaves = $this->slaves->getByStatus(Slave::READY);
$busySlaves = $this->slaves->getByStatus(Slave::BUSY);
return count($readySlaves) + coun... | [
"protected",
"function",
"allSlavesReady",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"status",
"===",
"self",
"::",
"STATE_STARTING",
"||",
"$",
"this",
"->",
"status",
"===",
"self",
"::",
"STATE_EMERGENCY",
")",
"{",
"$",
"readySlaves",
"=",
"$",
"t... | Check if all slaves have become available | [
"Check",
"if",
"all",
"slaves",
"have",
"become",
"available"
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L1138-L1147 | train |
php-pm/php-pm | src/ProcessManager.php | ProcessManager.newSlaveInstance | protected function newSlaveInstance($port)
{
if ($this->status === self::STATE_SHUTDOWN) {
// during shutdown phase all connections are closed and as result new
// instances are created - which is forbidden during this phase
return;
}
if ($this->output->i... | php | protected function newSlaveInstance($port)
{
if ($this->status === self::STATE_SHUTDOWN) {
// during shutdown phase all connections are closed and as result new
// instances are created - which is forbidden during this phase
return;
}
if ($this->output->i... | [
"protected",
"function",
"newSlaveInstance",
"(",
"$",
"port",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"status",
"===",
"self",
"::",
"STATE_SHUTDOWN",
")",
"{",
"// during shutdown phase all connections are closed and as result new",
"// instances are created - which is fo... | Creates a new ProcessSlave instance.
@param int $port | [
"Creates",
"a",
"new",
"ProcessSlave",
"instance",
"."
] | 4db650a94b51a26ce80dbec82e419ee913333431 | https://github.com/php-pm/php-pm/blob/4db650a94b51a26ce80dbec82e419ee913333431/src/ProcessManager.php#L1154-L1251 | train |
api-platform/core | src/Bridge/Doctrine/MongoDbOdm/PropertyHelperTrait.php | PropertyHelperTrait.addLookupsForNestedProperty | protected function addLookupsForNestedProperty(string $property, Builder $aggregationBuilder, string $resourceClass): array
{
$propertyParts = $this->splitPropertyParts($property, $resourceClass);
$alias = '';
foreach ($propertyParts['associations'] as $association) {
$classMeta... | php | protected function addLookupsForNestedProperty(string $property, Builder $aggregationBuilder, string $resourceClass): array
{
$propertyParts = $this->splitPropertyParts($property, $resourceClass);
$alias = '';
foreach ($propertyParts['associations'] as $association) {
$classMeta... | [
"protected",
"function",
"addLookupsForNestedProperty",
"(",
"string",
"$",
"property",
",",
"Builder",
"$",
"aggregationBuilder",
",",
"string",
"$",
"resourceClass",
")",
":",
"array",
"{",
"$",
"propertyParts",
"=",
"$",
"this",
"->",
"splitPropertyParts",
"(",... | Adds the necessary lookups for a nested property.
@throws InvalidArgumentException If property is not nested
@throws MappingException
@return array An array where the first element is the $alias of the lookup,
the second element is the $field name
the third element is the $associations array | [
"Adds",
"the",
"necessary",
"lookups",
"for",
"a",
"nested",
"property",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/MongoDbOdm/PropertyHelperTrait.php#L51-L106 | train |
api-platform/core | src/Serializer/Filter/PropertyFilter.php | PropertyFilter.formatWhitelist | private function formatWhitelist(array $whitelist): array
{
if (array_values($whitelist) === $whitelist) {
return $whitelist;
}
foreach ($whitelist as $name => $value) {
if (null === $value) {
unset($whitelist[$name]);
$whitelist[] = $n... | php | private function formatWhitelist(array $whitelist): array
{
if (array_values($whitelist) === $whitelist) {
return $whitelist;
}
foreach ($whitelist as $name => $value) {
if (null === $value) {
unset($whitelist[$name]);
$whitelist[] = $n... | [
"private",
"function",
"formatWhitelist",
"(",
"array",
"$",
"whitelist",
")",
":",
"array",
"{",
"if",
"(",
"array_values",
"(",
"$",
"whitelist",
")",
"===",
"$",
"whitelist",
")",
"{",
"return",
"$",
"whitelist",
";",
"}",
"foreach",
"(",
"$",
"whitel... | Generate an array of whitelist properties to match the format that properties
will have in the request.
@param array $whitelist the whitelist to format
@return array An array containing the whitelist ready to match request parameters | [
"Generate",
"an",
"array",
"of",
"whitelist",
"properties",
"to",
"match",
"the",
"format",
"that",
"properties",
"will",
"have",
"in",
"the",
"request",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Serializer/Filter/PropertyFilter.php#L110-L123 | train |
api-platform/core | src/Bridge/Elasticsearch/Serializer/ItemNormalizer.php | ItemNormalizer.populateIdentifier | private function populateIdentifier(array $data, string $class): array
{
$identifier = $this->identifierExtractor->getIdentifierFromResourceClass($class);
$identifier = null === $this->nameConverter ? $identifier : $this->nameConverter->normalize($identifier, $class, self::FORMAT);
if (!iss... | php | private function populateIdentifier(array $data, string $class): array
{
$identifier = $this->identifierExtractor->getIdentifierFromResourceClass($class);
$identifier = null === $this->nameConverter ? $identifier : $this->nameConverter->normalize($identifier, $class, self::FORMAT);
if (!iss... | [
"private",
"function",
"populateIdentifier",
"(",
"array",
"$",
"data",
",",
"string",
"$",
"class",
")",
":",
"array",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"identifierExtractor",
"->",
"getIdentifierFromResourceClass",
"(",
"$",
"class",
")",
";",
... | Populates the resource identifier with the document identifier if not present in the original JSON document. | [
"Populates",
"the",
"resource",
"identifier",
"with",
"the",
"document",
"identifier",
"if",
"not",
"present",
"in",
"the",
"original",
"JSON",
"document",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Elasticsearch/Serializer/ItemNormalizer.php#L87-L97 | train |
api-platform/core | src/Serializer/AbstractCollectionNormalizer.php | AbstractCollectionNormalizer.getPaginationConfig | protected function getPaginationConfig($object, array $context = []): array
{
$currentPage = $lastPage = $itemsPerPage = $pageTotalItems = $totalItems = null;
$paginated = $paginator = false;
if ($object instanceof PartialPaginatorInterface) {
$paginated = $paginator = true;
... | php | protected function getPaginationConfig($object, array $context = []): array
{
$currentPage = $lastPage = $itemsPerPage = $pageTotalItems = $totalItems = null;
$paginated = $paginator = false;
if ($object instanceof PartialPaginatorInterface) {
$paginated = $paginator = true;
... | [
"protected",
"function",
"getPaginationConfig",
"(",
"$",
"object",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"currentPage",
"=",
"$",
"lastPage",
"=",
"$",
"itemsPerPage",
"=",
"$",
"pageTotalItems",
"=",
"$",
"totalItems",... | Gets the pagination configuration.
@param iterable $object | [
"Gets",
"the",
"pagination",
"configuration",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Serializer/AbstractCollectionNormalizer.php#L117-L138 | train |
api-platform/core | features/bootstrap/SwaggerContext.php | SwaggerContext.getProperties | private function getProperties(string $className, int $specVersion = 2): stdClass
{
return $this->getClassInfo($className, $specVersion)->{'properties'} ?? new \stdClass();
} | php | private function getProperties(string $className, int $specVersion = 2): stdClass
{
return $this->getClassInfo($className, $specVersion)->{'properties'} ?? new \stdClass();
} | [
"private",
"function",
"getProperties",
"(",
"string",
"$",
"className",
",",
"int",
"$",
"specVersion",
"=",
"2",
")",
":",
"stdClass",
"{",
"return",
"$",
"this",
"->",
"getClassInfo",
"(",
"$",
"className",
",",
"$",
"specVersion",
")",
"->",
"{",
"'p... | Gets all operations of a given class. | [
"Gets",
"all",
"operations",
"of",
"a",
"given",
"class",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/features/bootstrap/SwaggerContext.php#L166-L169 | train |
api-platform/core | features/bootstrap/SwaggerContext.php | SwaggerContext.getLastJsonResponse | private function getLastJsonResponse(): stdClass
{
if (null === ($decoded = json_decode($this->restContext->getMink()->getSession()->getDriver()->getContent()))) {
throw new \RuntimeException('JSON response seems to be invalid');
}
return $decoded;
} | php | private function getLastJsonResponse(): stdClass
{
if (null === ($decoded = json_decode($this->restContext->getMink()->getSession()->getDriver()->getContent()))) {
throw new \RuntimeException('JSON response seems to be invalid');
}
return $decoded;
} | [
"private",
"function",
"getLastJsonResponse",
"(",
")",
":",
"stdClass",
"{",
"if",
"(",
"null",
"===",
"(",
"$",
"decoded",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"restContext",
"->",
"getMink",
"(",
")",
"->",
"getSession",
"(",
")",
"->",
"getDri... | Gets the last JSON response.
@throws \RuntimeException | [
"Gets",
"the",
"last",
"JSON",
"response",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/features/bootstrap/SwaggerContext.php#L193-L200 | train |
api-platform/core | src/Bridge/Elasticsearch/Metadata/Document/DocumentMetadata.php | DocumentMetadata.withIndex | public function withIndex(string $index): self
{
$metadata = clone $this;
$metadata->index = $index;
return $metadata;
} | php | public function withIndex(string $index): self
{
$metadata = clone $this;
$metadata->index = $index;
return $metadata;
} | [
"public",
"function",
"withIndex",
"(",
"string",
"$",
"index",
")",
":",
"self",
"{",
"$",
"metadata",
"=",
"clone",
"$",
"this",
";",
"$",
"metadata",
"->",
"index",
"=",
"$",
"index",
";",
"return",
"$",
"metadata",
";",
"}"
] | Gets a new instance with the given index. | [
"Gets",
"a",
"new",
"instance",
"with",
"the",
"given",
"index",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Elasticsearch/Metadata/Document/DocumentMetadata.php#L41-L47 | train |
api-platform/core | src/Bridge/Elasticsearch/Metadata/Document/DocumentMetadata.php | DocumentMetadata.withType | public function withType(string $type): self
{
$metadata = clone $this;
$metadata->type = $type;
return $metadata;
} | php | public function withType(string $type): self
{
$metadata = clone $this;
$metadata->type = $type;
return $metadata;
} | [
"public",
"function",
"withType",
"(",
"string",
"$",
"type",
")",
":",
"self",
"{",
"$",
"metadata",
"=",
"clone",
"$",
"this",
";",
"$",
"metadata",
"->",
"type",
"=",
"$",
"type",
";",
"return",
"$",
"metadata",
";",
"}"
] | Gets a new instance with the given type. | [
"Gets",
"a",
"new",
"instance",
"with",
"the",
"given",
"type",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Elasticsearch/Metadata/Document/DocumentMetadata.php#L60-L66 | train |
api-platform/core | src/EventListener/ReadListener.php | ReadListener.onKernelRequest | public function onKernelRequest(GetResponseEvent $event): void
{
$request = $event->getRequest();
if (
!($attributes = RequestAttributesExtractor::extractAttributes($request))
|| !$attributes['receive']
) {
return;
}
if (null === $filters ... | php | public function onKernelRequest(GetResponseEvent $event): void
{
$request = $event->getRequest();
if (
!($attributes = RequestAttributesExtractor::extractAttributes($request))
|| !$attributes['receive']
) {
return;
}
if (null === $filters ... | [
"public",
"function",
"onKernelRequest",
"(",
"GetResponseEvent",
"$",
"event",
")",
":",
"void",
"{",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"attributes",
"=",
"RequestAttributesExtractor",
"::",
"e... | Calls the data provider and sets the data attribute.
@throws NotFoundHttpException | [
"Calls",
"the",
"data",
"provider",
"and",
"sets",
"the",
"data",
"attribute",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/EventListener/ReadListener.php#L54-L110 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Filter/RangeFilter.php | RangeFilter.addWhere | protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, $alias, $field, $operator, $value)
{
$valueParameter = $queryNameGenerator->generateParameterName($field);
switch ($operator) {
case self::PARAMETER_BETWEEN:
$rangeVa... | php | protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, $alias, $field, $operator, $value)
{
$valueParameter = $queryNameGenerator->generateParameterName($field);
switch ($operator) {
case self::PARAMETER_BETWEEN:
$rangeVa... | [
"protected",
"function",
"addWhere",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"QueryNameGeneratorInterface",
"$",
"queryNameGenerator",
",",
"$",
"alias",
",",
"$",
"field",
",",
"$",
"operator",
",",
"$",
"value",
")",
"{",
"$",
"valueParameter",
"=",
"... | Adds the where clause according to the operator.
@param string $alias
@param string $field
@param string $operator
@param string $value | [
"Adds",
"the",
"where",
"clause",
"according",
"to",
"the",
"operator",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Filter/RangeFilter.php#L75-L139 | train |
api-platform/core | src/Bridge/Symfony/Bundle/Action/SwaggerUiAction.php | SwaggerUiAction.getContext | private function getContext(Request $request, Documentation $documentation): array
{
$context = [
'title' => $this->title,
'description' => $this->description,
'formats' => $this->formats,
'showWebby' => $this->showWebby,
'swaggerUiEnabled' => $thi... | php | private function getContext(Request $request, Documentation $documentation): array
{
$context = [
'title' => $this->title,
'description' => $this->description,
'formats' => $this->formats,
'showWebby' => $this->showWebby,
'swaggerUiEnabled' => $thi... | [
"private",
"function",
"getContext",
"(",
"Request",
"$",
"request",
",",
"Documentation",
"$",
"documentation",
")",
":",
"array",
"{",
"$",
"context",
"=",
"[",
"'title'",
"=>",
"$",
"this",
"->",
"title",
",",
"'description'",
"=>",
"$",
"this",
"->",
... | Gets the base Twig context. | [
"Gets",
"the",
"base",
"Twig",
"context",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Symfony/Bundle/Action/SwaggerUiAction.php#L116-L168 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/QueryChecker.php | QueryChecker.hasRootEntityWithForeignKeyIdentifier | public static function hasRootEntityWithForeignKeyIdentifier(QueryBuilder $queryBuilder, ManagerRegistry $managerRegistry): bool
{
foreach ($queryBuilder->getRootEntities() as $rootEntity) {
/** @var ClassMetadata $rootMetadata */
$rootMetadata = $managerRegistry
->ge... | php | public static function hasRootEntityWithForeignKeyIdentifier(QueryBuilder $queryBuilder, ManagerRegistry $managerRegistry): bool
{
foreach ($queryBuilder->getRootEntities() as $rootEntity) {
/** @var ClassMetadata $rootMetadata */
$rootMetadata = $managerRegistry
->ge... | [
"public",
"static",
"function",
"hasRootEntityWithForeignKeyIdentifier",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"ManagerRegistry",
"$",
"managerRegistry",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"queryBuilder",
"->",
"getRootEntities",
"(",
")",
"as",
"$... | Determines whether the QueryBuilder has any root entity with foreign key identifier. | [
"Determines",
"whether",
"the",
"QueryBuilder",
"has",
"any",
"root",
"entity",
"with",
"foreign",
"key",
"identifier",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/QueryChecker.php#L46-L60 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/QueryChecker.php | QueryChecker.hasRootEntityWithCompositeIdentifier | public static function hasRootEntityWithCompositeIdentifier(QueryBuilder $queryBuilder, ManagerRegistry $managerRegistry): bool
{
foreach ($queryBuilder->getRootEntities() as $rootEntity) {
/** @var ClassMetadata $rootMetadata */
$rootMetadata = $managerRegistry
->get... | php | public static function hasRootEntityWithCompositeIdentifier(QueryBuilder $queryBuilder, ManagerRegistry $managerRegistry): bool
{
foreach ($queryBuilder->getRootEntities() as $rootEntity) {
/** @var ClassMetadata $rootMetadata */
$rootMetadata = $managerRegistry
->get... | [
"public",
"static",
"function",
"hasRootEntityWithCompositeIdentifier",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"ManagerRegistry",
"$",
"managerRegistry",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"queryBuilder",
"->",
"getRootEntities",
"(",
")",
"as",
"$"... | Determines whether the QueryBuilder has any composite identifier. | [
"Determines",
"whether",
"the",
"QueryBuilder",
"has",
"any",
"composite",
"identifier",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/QueryChecker.php#L65-L79 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/QueryChecker.php | QueryChecker.hasLeftJoin | public static function hasLeftJoin(QueryBuilder $queryBuilder): bool
{
foreach ($queryBuilder->getDQLPart('join') as $joins) {
foreach ($joins as $join) {
if (Join::LEFT_JOIN === $join->getJoinType()) {
return true;
}
}
}
... | php | public static function hasLeftJoin(QueryBuilder $queryBuilder): bool
{
foreach ($queryBuilder->getDQLPart('join') as $joins) {
foreach ($joins as $join) {
if (Join::LEFT_JOIN === $join->getJoinType()) {
return true;
}
}
}
... | [
"public",
"static",
"function",
"hasLeftJoin",
"(",
"QueryBuilder",
"$",
"queryBuilder",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"queryBuilder",
"->",
"getDQLPart",
"(",
"'join'",
")",
"as",
"$",
"joins",
")",
"{",
"foreach",
"(",
"$",
"joins",
"as",
... | Determines whether the QueryBuilder already has a left join. | [
"Determines",
"whether",
"the",
"QueryBuilder",
"already",
"has",
"a",
"left",
"join",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/QueryChecker.php#L168-L179 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/QueryChecker.php | QueryChecker.hasJoinedToManyAssociation | public static function hasJoinedToManyAssociation(QueryBuilder $queryBuilder, ManagerRegistry $managerRegistry): bool
{
if (
0 === \count($queryBuilder->getDQLPart('join'))
) {
return false;
}
$joinAliases = array_diff($queryBuilder->getAllAliases(), $queryBu... | php | public static function hasJoinedToManyAssociation(QueryBuilder $queryBuilder, ManagerRegistry $managerRegistry): bool
{
if (
0 === \count($queryBuilder->getDQLPart('join'))
) {
return false;
}
$joinAliases = array_diff($queryBuilder->getAllAliases(), $queryBu... | [
"public",
"static",
"function",
"hasJoinedToManyAssociation",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"ManagerRegistry",
"$",
"managerRegistry",
")",
":",
"bool",
"{",
"if",
"(",
"0",
"===",
"\\",
"count",
"(",
"$",
"queryBuilder",
"->",
"getDQLPart",
"("... | Determines whether the QueryBuilder has a joined to-many association. | [
"Determines",
"whether",
"the",
"QueryBuilder",
"has",
"a",
"joined",
"to",
"-",
"many",
"association",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/QueryChecker.php#L184-L206 | train |
api-platform/core | src/Util/ErrorFormatGuesser.php | ErrorFormatGuesser.guessErrorFormat | public static function guessErrorFormat(Request $request, array $errorFormats): array
{
$requestFormat = $request->getRequestFormat('');
if ('' !== $requestFormat && isset($errorFormats[$requestFormat])) {
return ['key' => $requestFormat, 'value' => $errorFormats[$requestFormat]];
... | php | public static function guessErrorFormat(Request $request, array $errorFormats): array
{
$requestFormat = $request->getRequestFormat('');
if ('' !== $requestFormat && isset($errorFormats[$requestFormat])) {
return ['key' => $requestFormat, 'value' => $errorFormats[$requestFormat]];
... | [
"public",
"static",
"function",
"guessErrorFormat",
"(",
"Request",
"$",
"request",
",",
"array",
"$",
"errorFormats",
")",
":",
"array",
"{",
"$",
"requestFormat",
"=",
"$",
"request",
"->",
"getRequestFormat",
"(",
"''",
")",
";",
"if",
"(",
"''",
"!==",... | Get the error format and its associated MIME type. | [
"Get",
"the",
"error",
"format",
"and",
"its",
"associated",
"MIME",
"type",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Util/ErrorFormatGuesser.php#L32-L54 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Extension/EagerLoadingExtension.php | EagerLoadingExtension.getNormalizationContext | private function getNormalizationContext(string $resourceClass, string $contextType, array $options): array
{
if (null !== $this->requestStack && null !== $this->serializerContextBuilder && null !== $request = $this->requestStack->getCurrentRequest()) {
return $this->serializerContextBuilder->cr... | php | private function getNormalizationContext(string $resourceClass, string $contextType, array $options): array
{
if (null !== $this->requestStack && null !== $this->serializerContextBuilder && null !== $request = $this->requestStack->getCurrentRequest()) {
return $this->serializerContextBuilder->cr... | [
"private",
"function",
"getNormalizationContext",
"(",
"string",
"$",
"resourceClass",
",",
"string",
"$",
"contextType",
",",
"array",
"$",
"options",
")",
":",
"array",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"requestStack",
"&&",
"null",
"!==",
... | Gets the serializer context.
@param string $contextType normalization_context or denormalization_context
@param array $options represents the operation name so that groups are the one of the specific operation | [
"Gets",
"the",
"serializer",
"context",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Extension/EagerLoadingExtension.php#L283-L299 | train |
api-platform/core | src/EventListener/SerializeListener.php | SerializeListener.onKernelView | public function onKernelView(GetResponseForControllerResultEvent $event): void
{
$controllerResult = $event->getControllerResult();
$request = $event->getRequest();
if ($controllerResult instanceof Response || !(($attributes = RequestAttributesExtractor::extractAttributes($request))['respon... | php | public function onKernelView(GetResponseForControllerResultEvent $event): void
{
$controllerResult = $event->getControllerResult();
$request = $event->getRequest();
if ($controllerResult instanceof Response || !(($attributes = RequestAttributesExtractor::extractAttributes($request))['respon... | [
"public",
"function",
"onKernelView",
"(",
"GetResponseForControllerResultEvent",
"$",
"event",
")",
":",
"void",
"{",
"$",
"controllerResult",
"=",
"$",
"event",
"->",
"getControllerResult",
"(",
")",
";",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
... | Serializes the data to the requested format. | [
"Serializes",
"the",
"data",
"to",
"the",
"requested",
"format",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/EventListener/SerializeListener.php#L47-L93 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Extension/FilterEagerLoadingExtension.php | FilterEagerLoadingExtension.getQueryBuilderWithNewAliases | private function getQueryBuilderWithNewAliases(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $originAlias = 'o', string $replacement = 'o_2'): QueryBuilder
{
$queryBuilderClone = clone $queryBuilder;
$joinParts = $queryBuilder->getDQLPart('join');
$wher... | php | private function getQueryBuilderWithNewAliases(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $originAlias = 'o', string $replacement = 'o_2'): QueryBuilder
{
$queryBuilderClone = clone $queryBuilder;
$joinParts = $queryBuilder->getDQLPart('join');
$wher... | [
"private",
"function",
"getQueryBuilderWithNewAliases",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"QueryNameGeneratorInterface",
"$",
"queryNameGenerator",
",",
"string",
"$",
"originAlias",
"=",
"'o'",
",",
"string",
"$",
"replacement",
"=",
"'o_2'",
")",
":",
... | Returns a clone of the given query builder where everything gets re-aliased.
@param string $originAlias the base alias
@param string $replacement the replacement for the base alias, will change the from alias | [
"Returns",
"a",
"clone",
"of",
"the",
"given",
"query",
"builder",
"where",
"everything",
"gets",
"re",
"-",
"aliased",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Extension/FilterEagerLoadingExtension.php#L111-L161 | train |
api-platform/core | src/Bridge/Symfony/Routing/OperationMethodResolver.php | OperationMethodResolver.getOperationRoute | private function getOperationRoute(string $resourceClass, string $operationName, string $operationType): Route
{
$routeName = $this->getRouteName($this->resourceMetadataFactory->create($resourceClass), $operationName, $operationType);
if (null !== $routeName) {
return $this->getRoute($ro... | php | private function getOperationRoute(string $resourceClass, string $operationName, string $operationType): Route
{
$routeName = $this->getRouteName($this->resourceMetadataFactory->create($resourceClass), $operationName, $operationType);
if (null !== $routeName) {
return $this->getRoute($ro... | [
"private",
"function",
"getOperationRoute",
"(",
"string",
"$",
"resourceClass",
",",
"string",
"$",
"operationName",
",",
"string",
"$",
"operationType",
")",
":",
"Route",
"{",
"$",
"routeName",
"=",
"$",
"this",
"->",
"getRouteName",
"(",
"$",
"this",
"->... | Gets the route related to the given operation.
@throws RuntimeException | [
"Gets",
"the",
"route",
"related",
"to",
"the",
"given",
"operation",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Symfony/Routing/OperationMethodResolver.php#L101-L120 | train |
api-platform/core | src/Bridge/Symfony/Routing/OperationMethodResolver.php | OperationMethodResolver.getRouteName | private function getRouteName(ResourceMetadata $resourceMetadata, string $operationName, string $operationType): ?string
{
if (OperationType::ITEM === $operationType) {
return $resourceMetadata->getItemOperationAttribute($operationName, 'route_name');
}
return $resourceMetadata-... | php | private function getRouteName(ResourceMetadata $resourceMetadata, string $operationName, string $operationType): ?string
{
if (OperationType::ITEM === $operationType) {
return $resourceMetadata->getItemOperationAttribute($operationName, 'route_name');
}
return $resourceMetadata-... | [
"private",
"function",
"getRouteName",
"(",
"ResourceMetadata",
"$",
"resourceMetadata",
",",
"string",
"$",
"operationName",
",",
"string",
"$",
"operationType",
")",
":",
"?",
"string",
"{",
"if",
"(",
"OperationType",
"::",
"ITEM",
"===",
"$",
"operationType"... | Gets the route name or null if not defined. | [
"Gets",
"the",
"route",
"name",
"or",
"null",
"if",
"not",
"defined",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Symfony/Routing/OperationMethodResolver.php#L125-L132 | train |
api-platform/core | src/Bridge/Symfony/Routing/OperationMethodResolver.php | OperationMethodResolver.getRoute | private function getRoute(string $routeName): Route
{
foreach ($this->router->getRouteCollection() as $name => $route) {
if ($routeName === $name) {
return $route;
}
}
throw new RuntimeException(sprintf('The route "%s" does not exist.', $routeName));
... | php | private function getRoute(string $routeName): Route
{
foreach ($this->router->getRouteCollection() as $name => $route) {
if ($routeName === $name) {
return $route;
}
}
throw new RuntimeException(sprintf('The route "%s" does not exist.', $routeName));
... | [
"private",
"function",
"getRoute",
"(",
"string",
"$",
"routeName",
")",
":",
"Route",
"{",
"foreach",
"(",
"$",
"this",
"->",
"router",
"->",
"getRouteCollection",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"route",
")",
"{",
"if",
"(",
"$",
"routeName",... | Gets the route with the given name.
@throws RuntimeException | [
"Gets",
"the",
"route",
"with",
"the",
"given",
"name",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Symfony/Routing/OperationMethodResolver.php#L139-L148 | train |
api-platform/core | src/Metadata/Extractor/XmlExtractor.php | XmlExtractor.getOperations | private function getOperations(\SimpleXMLElement $resource, string $operationType): ?array
{
$graphql = 'operation' === $operationType;
if (!$graphql && $legacyOperations = $this->getAttributes($resource, $operationType)) {
@trigger_error(
sprintf('Configuring "%1$s" tags... | php | private function getOperations(\SimpleXMLElement $resource, string $operationType): ?array
{
$graphql = 'operation' === $operationType;
if (!$graphql && $legacyOperations = $this->getAttributes($resource, $operationType)) {
@trigger_error(
sprintf('Configuring "%1$s" tags... | [
"private",
"function",
"getOperations",
"(",
"\\",
"SimpleXMLElement",
"$",
"resource",
",",
"string",
"$",
"operationType",
")",
":",
"?",
"array",
"{",
"$",
"graphql",
"=",
"'operation'",
"===",
"$",
"operationType",
";",
"if",
"(",
"!",
"$",
"graphql",
... | Returns the array containing configured operations. Returns NULL if there is no operation configuration. | [
"Returns",
"the",
"array",
"containing",
"configured",
"operations",
".",
"Returns",
"NULL",
"if",
"there",
"is",
"no",
"operation",
"configuration",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Metadata/Extractor/XmlExtractor.php#L62-L80 | train |
api-platform/core | src/Metadata/Extractor/XmlExtractor.php | XmlExtractor.getAttributes | private function getAttributes(\SimpleXMLElement $resource, string $elementName, bool $topLevel = false): array
{
$attributes = [];
foreach ($resource->{$elementName} as $attribute) {
$value = isset($attribute->attribute[0]) ? $this->getAttributes($attribute, 'attribute') : XmlUtils::php... | php | private function getAttributes(\SimpleXMLElement $resource, string $elementName, bool $topLevel = false): array
{
$attributes = [];
foreach ($resource->{$elementName} as $attribute) {
$value = isset($attribute->attribute[0]) ? $this->getAttributes($attribute, 'attribute') : XmlUtils::php... | [
"private",
"function",
"getAttributes",
"(",
"\\",
"SimpleXMLElement",
"$",
"resource",
",",
"string",
"$",
"elementName",
",",
"bool",
"$",
"topLevel",
"=",
"false",
")",
":",
"array",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"re... | Recursively transforms an attribute structure into an associative array. | [
"Recursively",
"transforms",
"an",
"attribute",
"structure",
"into",
"an",
"associative",
"array",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Metadata/Extractor/XmlExtractor.php#L85-L102 | train |
api-platform/core | src/Metadata/Extractor/XmlExtractor.php | XmlExtractor.getProperties | private function getProperties(\SimpleXMLElement $resource): array
{
$properties = [];
foreach ($resource->property as $property) {
$properties[(string) $property['name']] = [
'description' => $this->phpize($property, 'description', 'string'),
'readable' =... | php | private function getProperties(\SimpleXMLElement $resource): array
{
$properties = [];
foreach ($resource->property as $property) {
$properties[(string) $property['name']] = [
'description' => $this->phpize($property, 'description', 'string'),
'readable' =... | [
"private",
"function",
"getProperties",
"(",
"\\",
"SimpleXMLElement",
"$",
"resource",
")",
":",
"array",
"{",
"$",
"properties",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"resource",
"->",
"property",
"as",
"$",
"property",
")",
"{",
"$",
"properties",
... | Gets metadata of a property. | [
"Gets",
"metadata",
"of",
"a",
"property",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Metadata/Extractor/XmlExtractor.php#L107-L130 | train |
api-platform/core | src/Metadata/Extractor/XmlExtractor.php | XmlExtractor.phpize | private function phpize(\SimpleXMLElement $array, string $key, string $type)
{
if (!isset($array[$key])) {
return null;
}
switch ($type) {
case 'string':
return (string) $array[$key];
case 'integer':
return (int) $array[$ke... | php | private function phpize(\SimpleXMLElement $array, string $key, string $type)
{
if (!isset($array[$key])) {
return null;
}
switch ($type) {
case 'string':
return (string) $array[$key];
case 'integer':
return (int) $array[$ke... | [
"private",
"function",
"phpize",
"(",
"\\",
"SimpleXMLElement",
"$",
"array",
",",
"string",
"$",
"key",
",",
"string",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"null",
";",
... | Transforms an XML attribute's value in a PHP value.
@return string|int|bool|null | [
"Transforms",
"an",
"XML",
"attribute",
"s",
"value",
"in",
"a",
"PHP",
"value",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Metadata/Extractor/XmlExtractor.php#L137-L153 | train |
api-platform/core | src/EventListener/DeserializeListener.php | DeserializeListener.onKernelRequest | public function onKernelRequest(GetResponseEvent $event): void
{
$request = $event->getRequest();
$method = $request->getMethod();
if (
'DELETE' === $method
|| $request->isMethodSafe(false)
|| !($attributes = RequestAttributesExtractor::extractAttributes(... | php | public function onKernelRequest(GetResponseEvent $event): void
{
$request = $event->getRequest();
$method = $request->getMethod();
if (
'DELETE' === $method
|| $request->isMethodSafe(false)
|| !($attributes = RequestAttributesExtractor::extractAttributes(... | [
"public",
"function",
"onKernelRequest",
"(",
"GetResponseEvent",
"$",
"event",
")",
":",
"void",
"{",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"$",
"method",
"=",
"$",
"request",
"->",
"getMethod",
"(",
")",
";",
"if",
"("... | Deserializes the data sent in the requested format. | [
"Deserializes",
"the",
"data",
"sent",
"in",
"the",
"requested",
"format",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/EventListener/DeserializeListener.php#L62-L103 | train |
api-platform/core | src/EventListener/DeserializeListener.php | DeserializeListener.getFormat | private function getFormat(Request $request): string
{
/**
* @var string|null
*/
$contentType = $request->headers->get('CONTENT_TYPE');
if (null === $contentType) {
throw new NotAcceptableHttpException('The "Content-Type" header must exist.');
}
... | php | private function getFormat(Request $request): string
{
/**
* @var string|null
*/
$contentType = $request->headers->get('CONTENT_TYPE');
if (null === $contentType) {
throw new NotAcceptableHttpException('The "Content-Type" header must exist.');
}
... | [
"private",
"function",
"getFormat",
"(",
"Request",
"$",
"request",
")",
":",
"string",
"{",
"/**\n * @var string|null\n */",
"$",
"contentType",
"=",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"'CONTENT_TYPE'",
")",
";",
"if",
"(",
"null... | Extracts the format from the Content-Type header and check that it is supported.
@throws NotAcceptableHttpException | [
"Extracts",
"the",
"format",
"from",
"the",
"Content",
"-",
"Type",
"header",
"and",
"check",
"that",
"it",
"is",
"supported",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/EventListener/DeserializeListener.php#L110-L137 | train |
api-platform/core | src/Util/ClassInfoTrait.php | ClassInfoTrait.getRealClassName | private function getRealClassName(string $className): string
{
// __CG__: Doctrine Common Marker for Proxy (ODM < 2.0 and ORM < 3.0)
// __PM__: Ocramius Proxy Manager (ODM >= 2.0)
if ((false === $positionCg = strrpos($className, '\\__CG__\\')) &&
(false === $positionPm = strrpos(... | php | private function getRealClassName(string $className): string
{
// __CG__: Doctrine Common Marker for Proxy (ODM < 2.0 and ORM < 3.0)
// __PM__: Ocramius Proxy Manager (ODM >= 2.0)
if ((false === $positionCg = strrpos($className, '\\__CG__\\')) &&
(false === $positionPm = strrpos(... | [
"private",
"function",
"getRealClassName",
"(",
"string",
"$",
"className",
")",
":",
"string",
"{",
"// __CG__: Doctrine Common Marker for Proxy (ODM < 2.0 and ORM < 3.0)",
"// __PM__: Ocramius Proxy Manager (ODM >= 2.0)",
"if",
"(",
"(",
"false",
"===",
"$",
"positionCg",
"... | Get the real class name of a class name that could be a proxy. | [
"Get",
"the",
"real",
"class",
"name",
"of",
"a",
"class",
"name",
"that",
"could",
"be",
"a",
"proxy",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Util/ClassInfoTrait.php#L38-L58 | train |
api-platform/core | src/DataProvider/OperationDataProviderTrait.php | OperationDataProviderTrait.getItemData | private function getItemData($identifiers, array $attributes, array $context)
{
return $this->itemDataProvider->getItem($attributes['resource_class'], $identifiers, $attributes['item_operation_name'], $context);
} | php | private function getItemData($identifiers, array $attributes, array $context)
{
return $this->itemDataProvider->getItem($attributes['resource_class'], $identifiers, $attributes['item_operation_name'], $context);
} | [
"private",
"function",
"getItemData",
"(",
"$",
"identifiers",
",",
"array",
"$",
"attributes",
",",
"array",
"$",
"context",
")",
"{",
"return",
"$",
"this",
"->",
"itemDataProvider",
"->",
"getItem",
"(",
"$",
"attributes",
"[",
"'resource_class'",
"]",
",... | Gets data for an item operation.
@return object|null | [
"Gets",
"data",
"for",
"an",
"item",
"operation",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/DataProvider/OperationDataProviderTrait.php#L60-L63 | train |
api-platform/core | src/DataProvider/OperationDataProviderTrait.php | OperationDataProviderTrait.getSubresourceData | private function getSubresourceData($identifiers, array $attributes, array $context)
{
if (null === $this->subresourceDataProvider) {
throw new RuntimeException('Subresources not supported');
}
return $this->subresourceDataProvider->getSubresource($attributes['resource_class'], ... | php | private function getSubresourceData($identifiers, array $attributes, array $context)
{
if (null === $this->subresourceDataProvider) {
throw new RuntimeException('Subresources not supported');
}
return $this->subresourceDataProvider->getSubresource($attributes['resource_class'], ... | [
"private",
"function",
"getSubresourceData",
"(",
"$",
"identifiers",
",",
"array",
"$",
"attributes",
",",
"array",
"$",
"context",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"subresourceDataProvider",
")",
"{",
"throw",
"new",
"RuntimeException",... | Gets data for a nested operation.
@throws RuntimeException
@return array|object|null | [
"Gets",
"data",
"for",
"a",
"nested",
"operation",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/DataProvider/OperationDataProviderTrait.php#L72-L79 | train |
api-platform/core | src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php | ApiPlatformExtension.registerSwaggerConfiguration | private function registerSwaggerConfiguration(ContainerBuilder $container, array $config, XmlFileLoader $loader): void
{
if (!$config['enable_swagger']) {
return;
}
$loader->load('swagger.xml');
if ($config['enable_swagger_ui'] || $config['enable_re_doc']) {
... | php | private function registerSwaggerConfiguration(ContainerBuilder $container, array $config, XmlFileLoader $loader): void
{
if (!$config['enable_swagger']) {
return;
}
$loader->load('swagger.xml');
if ($config['enable_swagger_ui'] || $config['enable_re_doc']) {
... | [
"private",
"function",
"registerSwaggerConfiguration",
"(",
"ContainerBuilder",
"$",
"container",
",",
"array",
"$",
"config",
",",
"XmlFileLoader",
"$",
"loader",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"config",
"[",
"'enable_swagger'",
"]",
")",
"{",
... | Registers the Swagger, ReDoc and Swagger UI configuration. | [
"Registers",
"the",
"Swagger",
"ReDoc",
"and",
"Swagger",
"UI",
"configuration",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php#L296-L312 | train |
api-platform/core | src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php | ApiPlatformExtension.getFormats | private function getFormats(array $configFormats): array
{
$formats = [];
foreach ($configFormats as $format => $value) {
foreach ($value['mime_types'] as $mimeType) {
$formats[$format][] = $mimeType;
}
}
return $formats;
} | php | private function getFormats(array $configFormats): array
{
$formats = [];
foreach ($configFormats as $format => $value) {
foreach ($value['mime_types'] as $mimeType) {
$formats[$format][] = $mimeType;
}
}
return $formats;
} | [
"private",
"function",
"getFormats",
"(",
"array",
"$",
"configFormats",
")",
":",
"array",
"{",
"$",
"formats",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"configFormats",
"as",
"$",
"format",
"=>",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"value",
... | Normalizes the format from config to the one accepted by Symfony HttpFoundation. | [
"Normalizes",
"the",
"format",
"from",
"config",
"to",
"the",
"one",
"accepted",
"by",
"Symfony",
"HttpFoundation",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php#L488-L498 | train |
api-platform/core | src/JsonLd/Serializer/JsonLdContextTrait.php | JsonLdContextTrait.addJsonLdContext | private function addJsonLdContext(ContextBuilderInterface $contextBuilder, string $resourceClass, array &$context, array $data = []): array
{
if (isset($context['jsonld_has_context'])) {
return $data;
}
$context['jsonld_has_context'] = true;
if (isset($context['jsonld_e... | php | private function addJsonLdContext(ContextBuilderInterface $contextBuilder, string $resourceClass, array &$context, array $data = []): array
{
if (isset($context['jsonld_has_context'])) {
return $data;
}
$context['jsonld_has_context'] = true;
if (isset($context['jsonld_e... | [
"private",
"function",
"addJsonLdContext",
"(",
"ContextBuilderInterface",
"$",
"contextBuilder",
",",
"string",
"$",
"resourceClass",
",",
"array",
"&",
"$",
"context",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
":",
"array",
"{",
"if",
"(",
"isset",
... | Updates the given JSON-LD document to add its @context key. | [
"Updates",
"the",
"given",
"JSON",
"-",
"LD",
"document",
"to",
"add",
"its"
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/JsonLd/Serializer/JsonLdContextTrait.php#L31-L48 | train |
api-platform/core | src/EventListener/AddFormatListener.php | AddFormatListener.addRequestFormats | private function addRequestFormats(Request $request, array $formats): void
{
foreach ($formats as $format => $mimeTypes) {
$request->setFormat($format, (array) $mimeTypes);
}
} | php | private function addRequestFormats(Request $request, array $formats): void
{
foreach ($formats as $format => $mimeTypes) {
$request->setFormat($format, (array) $mimeTypes);
}
} | [
"private",
"function",
"addRequestFormats",
"(",
"Request",
"$",
"request",
",",
"array",
"$",
"formats",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"formats",
"as",
"$",
"format",
"=>",
"$",
"mimeTypes",
")",
"{",
"$",
"request",
"->",
"setFormat",
"("... | Adds the supported formats to the request.
This is necessary for {@see Request::getMimeType} and {@see Request::getMimeTypes} to work. | [
"Adds",
"the",
"supported",
"formats",
"to",
"the",
"request",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/EventListener/AddFormatListener.php#L125-L130 | train |
api-platform/core | src/EventListener/AddFormatListener.php | AddFormatListener.getNotAcceptableHttpException | private function getNotAcceptableHttpException(string $accept, array $mimeTypes = null): NotAcceptableHttpException
{
if (null === $mimeTypes) {
$mimeTypes = array_keys($this->mimeTypes);
}
return new NotAcceptableHttpException(sprintf(
'Requested format "%s" is not ... | php | private function getNotAcceptableHttpException(string $accept, array $mimeTypes = null): NotAcceptableHttpException
{
if (null === $mimeTypes) {
$mimeTypes = array_keys($this->mimeTypes);
}
return new NotAcceptableHttpException(sprintf(
'Requested format "%s" is not ... | [
"private",
"function",
"getNotAcceptableHttpException",
"(",
"string",
"$",
"accept",
",",
"array",
"$",
"mimeTypes",
"=",
"null",
")",
":",
"NotAcceptableHttpException",
"{",
"if",
"(",
"null",
"===",
"$",
"mimeTypes",
")",
"{",
"$",
"mimeTypes",
"=",
"array_... | Retrieves an instance of NotAcceptableHttpException.
@param string[]|null $mimeTypes | [
"Retrieves",
"an",
"instance",
"of",
"NotAcceptableHttpException",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/EventListener/AddFormatListener.php#L154-L165 | train |
api-platform/core | src/Util/Reflection.php | Reflection.getProperty | public function getProperty(string $methodName): ?string
{
$pattern = implode('|', array_merge(self::ACCESSOR_PREFIXES, self::MUTATOR_PREFIXES));
if (preg_match('/^('.$pattern.')(.+)$/i', $methodName, $matches)) {
return $matches[2];
}
return null;
} | php | public function getProperty(string $methodName): ?string
{
$pattern = implode('|', array_merge(self::ACCESSOR_PREFIXES, self::MUTATOR_PREFIXES));
if (preg_match('/^('.$pattern.')(.+)$/i', $methodName, $matches)) {
return $matches[2];
}
return null;
} | [
"public",
"function",
"getProperty",
"(",
"string",
"$",
"methodName",
")",
":",
"?",
"string",
"{",
"$",
"pattern",
"=",
"implode",
"(",
"'|'",
",",
"array_merge",
"(",
"self",
"::",
"ACCESSOR_PREFIXES",
",",
"self",
"::",
"MUTATOR_PREFIXES",
")",
")",
";... | Gets the property name associated with an accessor method. | [
"Gets",
"the",
"property",
"name",
"associated",
"with",
"an",
"accessor",
"method",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Util/Reflection.php#L31-L40 | train |
api-platform/core | src/DataProvider/Pagination.php | Pagination.getOffset | public function getOffset(string $resourceClass = null, string $operationName = null, array $context = []): int
{
$graphql = $context['graphql'] ?? false;
$limit = $this->getLimit($resourceClass, $operationName, $context);
if ($graphql && null !== ($after = $this->getParameterFromContext($... | php | public function getOffset(string $resourceClass = null, string $operationName = null, array $context = []): int
{
$graphql = $context['graphql'] ?? false;
$limit = $this->getLimit($resourceClass, $operationName, $context);
if ($graphql && null !== ($after = $this->getParameterFromContext($... | [
"public",
"function",
"getOffset",
"(",
"string",
"$",
"resourceClass",
"=",
"null",
",",
"string",
"$",
"operationName",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
":",
"int",
"{",
"$",
"graphql",
"=",
"$",
"context",
"[",
"'graphq... | Gets the current offset. | [
"Gets",
"the",
"current",
"offset",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/DataProvider/Pagination.php#L71-L90 | train |
api-platform/core | src/DataProvider/Pagination.php | Pagination.getLimit | public function getLimit(string $resourceClass = null, string $operationName = null, array $context = []): int
{
$graphql = $context['graphql'] ?? false;
$limit = $this->options['items_per_page'];
$clientLimit = $this->options['client_items_per_page'];
if (null !== $resourceClass) ... | php | public function getLimit(string $resourceClass = null, string $operationName = null, array $context = []): int
{
$graphql = $context['graphql'] ?? false;
$limit = $this->options['items_per_page'];
$clientLimit = $this->options['client_items_per_page'];
if (null !== $resourceClass) ... | [
"public",
"function",
"getLimit",
"(",
"string",
"$",
"resourceClass",
"=",
"null",
",",
"string",
"$",
"operationName",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
":",
"int",
"{",
"$",
"graphql",
"=",
"$",
"context",
"[",
"'graphql... | Gets the current limit.
@throws InvalidArgumentException | [
"Gets",
"the",
"current",
"limit",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/DataProvider/Pagination.php#L97-L142 | train |
api-platform/core | src/DataProvider/Pagination.php | Pagination.getPagination | public function getPagination(string $resourceClass = null, string $operationName = null, array $context = []): array
{
$page = $this->getPage($context);
$limit = $this->getLimit($resourceClass, $operationName, $context);
if (0 === $limit && 1 < $page) {
throw new InvalidArgumen... | php | public function getPagination(string $resourceClass = null, string $operationName = null, array $context = []): array
{
$page = $this->getPage($context);
$limit = $this->getLimit($resourceClass, $operationName, $context);
if (0 === $limit && 1 < $page) {
throw new InvalidArgumen... | [
"public",
"function",
"getPagination",
"(",
"string",
"$",
"resourceClass",
"=",
"null",
",",
"string",
"$",
"operationName",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"getPag... | Gets info about the pagination.
Returns an array with the following info as values:
- the page {@see Pagination::getPage()}
- the offset {@see Pagination::getOffset()}
- the limit {@see Pagination::getLimit()}
@throws InvalidArgumentException | [
"Gets",
"info",
"about",
"the",
"pagination",
"."
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/DataProvider/Pagination.php#L154-L164 | train |
api-platform/core | src/DataProvider/Pagination.php | Pagination.isEnabled | public function isEnabled(string $resourceClass = null, string $operationName = null, array $context = []): bool
{
return $this->getEnabled($context, $resourceClass, $operationName);
} | php | public function isEnabled(string $resourceClass = null, string $operationName = null, array $context = []): bool
{
return $this->getEnabled($context, $resourceClass, $operationName);
} | [
"public",
"function",
"isEnabled",
"(",
"string",
"$",
"resourceClass",
"=",
"null",
",",
"string",
"$",
"operationName",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"getEnabled",
"(",
"... | Is the pagination enabled? | [
"Is",
"the",
"pagination",
"enabled?"
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/DataProvider/Pagination.php#L169-L172 | train |
api-platform/core | src/DataProvider/Pagination.php | Pagination.isPartialEnabled | public function isPartialEnabled(string $resourceClass = null, string $operationName = null, array $context = []): bool
{
return $this->getEnabled($context, $resourceClass, $operationName, true);
} | php | public function isPartialEnabled(string $resourceClass = null, string $operationName = null, array $context = []): bool
{
return $this->getEnabled($context, $resourceClass, $operationName, true);
} | [
"public",
"function",
"isPartialEnabled",
"(",
"string",
"$",
"resourceClass",
"=",
"null",
",",
"string",
"$",
"operationName",
"=",
"null",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"getEnabled",
"... | Is the partial pagination enabled? | [
"Is",
"the",
"partial",
"pagination",
"enabled?"
] | 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/DataProvider/Pagination.php#L177-L180 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.