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
brick/std
src/ObjectStorage.php
ObjectStorage.get
public function get($object) { $hash = spl_object_hash($object); if (isset($this->data[$hash])) { return $this->data[$hash]; } return null; }
php
public function get($object) { $hash = spl_object_hash($object); if (isset($this->data[$hash])) { return $this->data[$hash]; } return null; }
[ "public", "function", "get", "(", "$", "object", ")", "{", "$", "hash", "=", "spl_object_hash", "(", "$", "object", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "hash", "]", ")", ")", "{", "return", "$", "this", "->", ...
Returns the data associated to the given object. If the given object is not in the storage, or has no associated data, NULL is returned. @param object $object The object. @return mixed The stored data.
[ "Returns", "the", "data", "associated", "to", "the", "given", "object", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/ObjectStorage.php#L54-L63
train
brick/std
src/ObjectStorage.php
ObjectStorage.set
public function set($object, $data = null) : void { $hash = spl_object_hash($object); $this->objects[$hash] = $object; $this->data[$hash] = $data; }
php
public function set($object, $data = null) : void { $hash = spl_object_hash($object); $this->objects[$hash] = $object; $this->data[$hash] = $data; }
[ "public", "function", "set", "(", "$", "object", ",", "$", "data", "=", "null", ")", ":", "void", "{", "$", "hash", "=", "spl_object_hash", "(", "$", "object", ")", ";", "$", "this", "->", "objects", "[", "$", "hash", "]", "=", "$", "object", ";"...
Stores an object with associated data. @param object $object The object. @param mixed $data The data to store. @return void
[ "Stores", "an", "object", "with", "associated", "data", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/ObjectStorage.php#L73-L79
train
brick/std
src/ObjectStorage.php
ObjectStorage.remove
public function remove($object) : void { $hash = spl_object_hash($object); unset($this->objects[$hash]); unset($this->data[$hash]); }
php
public function remove($object) : void { $hash = spl_object_hash($object); unset($this->objects[$hash]); unset($this->data[$hash]); }
[ "public", "function", "remove", "(", "$", "object", ")", ":", "void", "{", "$", "hash", "=", "spl_object_hash", "(", "$", "object", ")", ";", "unset", "(", "$", "this", "->", "objects", "[", "$", "hash", "]", ")", ";", "unset", "(", "$", "this", ...
Removes the given object from this storage, along with associated data. If this storage does not contain the given object, this method does nothing. @param object $object The object to remove. @return void
[ "Removes", "the", "given", "object", "from", "this", "storage", "along", "with", "associated", "data", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/ObjectStorage.php#L90-L96
train
brick/std
src/ObjectStorage.php
ObjectStorage.getIterator
public function getIterator() : \Traversable { foreach ($this->objects as $hash => $object) { yield $object => $this->data[$hash]; } }
php
public function getIterator() : \Traversable { foreach ($this->objects as $hash => $object) { yield $object => $this->data[$hash]; } }
[ "public", "function", "getIterator", "(", ")", ":", "\\", "Traversable", "{", "foreach", "(", "$", "this", "->", "objects", "as", "$", "hash", "=>", "$", "object", ")", "{", "yield", "$", "object", "=>", "$", "this", "->", "data", "[", "$", "hash", ...
Returns an iterator for this storage. This method is part of the IteratorAggregate interface. @return \Traversable
[ "Returns", "an", "iterator", "for", "this", "storage", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/ObjectStorage.php#L127-L132
train
civicrm/civicrm-cxn-rpc
src/RegistrationServer.php
RegistrationServer.call
public function call($reqData) { $respData = $this->createError('Unrecognized entity or action'); if ($reqData['entity'] == 'Cxn' && preg_match('/^[a-zA-Z]+$/', $reqData['action'])) { $func = 'on' . $reqData['entity'] . strtoupper($reqData['action']{0}) . substr($reqData['action'], 1); if (is_callable(array($this, $func))) { $respData = call_user_func(array($this, $func), $reqData['cxn'], $reqData['params']); } } return $respData; }
php
public function call($reqData) { $respData = $this->createError('Unrecognized entity or action'); if ($reqData['entity'] == 'Cxn' && preg_match('/^[a-zA-Z]+$/', $reqData['action'])) { $func = 'on' . $reqData['entity'] . strtoupper($reqData['action']{0}) . substr($reqData['action'], 1); if (is_callable(array($this, $func))) { $respData = call_user_func(array($this, $func), $reqData['cxn'], $reqData['params']); } } return $respData; }
[ "public", "function", "call", "(", "$", "reqData", ")", "{", "$", "respData", "=", "$", "this", "->", "createError", "(", "'Unrecognized entity or action'", ")", ";", "if", "(", "$", "reqData", "[", "'entity'", "]", "==", "'Cxn'", "&&", "preg_match", "(", ...
Delegate handling of hte registration message to a callback function. @param $reqData @return array|mixed
[ "Delegate", "handling", "of", "hte", "registration", "message", "to", "a", "callback", "function", "." ]
5a142bc4d24b7f8c830f59768b405ec74d582f22
https://github.com/civicrm/civicrm-cxn-rpc/blob/5a142bc4d24b7f8c830f59768b405ec74d582f22/src/RegistrationServer.php#L105-L116
train
civicrm/civicrm-cxn-rpc
src/RegistrationServer.php
RegistrationServer.onCxnRegister
public function onCxnRegister($cxn, $params) { $storedCxn = $this->cxnStore->getByCxnId($cxn['cxnId']); if (!$storedCxn || $storedCxn['secret'] == $cxn['secret']) { $this->log->notice('Register cxnId="{cxnId}" siteUrl={siteUrl}: OK', array( 'cxnId' => $cxn['cxnId'], 'siteUrl' => $cxn['siteUrl'], )); $this->cxnStore->add($cxn); return $this->createSuccess(array( 'cxn_id' => $cxn['cxnId'], )); } else { $this->log->warning('Register cxnId="{cxnId}" siteUrl="{siteUrl}": Secret does not match.', array( 'cxnId' => $cxn['cxnId'], 'siteUrl' => $cxn['siteUrl'], )); $this->createError('Secret does not match previous registration.'); } }
php
public function onCxnRegister($cxn, $params) { $storedCxn = $this->cxnStore->getByCxnId($cxn['cxnId']); if (!$storedCxn || $storedCxn['secret'] == $cxn['secret']) { $this->log->notice('Register cxnId="{cxnId}" siteUrl={siteUrl}: OK', array( 'cxnId' => $cxn['cxnId'], 'siteUrl' => $cxn['siteUrl'], )); $this->cxnStore->add($cxn); return $this->createSuccess(array( 'cxn_id' => $cxn['cxnId'], )); } else { $this->log->warning('Register cxnId="{cxnId}" siteUrl="{siteUrl}": Secret does not match.', array( 'cxnId' => $cxn['cxnId'], 'siteUrl' => $cxn['siteUrl'], )); $this->createError('Secret does not match previous registration.'); } }
[ "public", "function", "onCxnRegister", "(", "$", "cxn", ",", "$", "params", ")", "{", "$", "storedCxn", "=", "$", "this", "->", "cxnStore", "->", "getByCxnId", "(", "$", "cxn", "[", "'cxnId'", "]", ")", ";", "if", "(", "!", "$", "storedCxn", "||", ...
Callback for Cxn.register. @param array $cxn The CXN record submitted by the client. @param array $params Additional parameters from the client. @return array
[ "Callback", "for", "Cxn", ".", "register", "." ]
5a142bc4d24b7f8c830f59768b405ec74d582f22
https://github.com/civicrm/civicrm-cxn-rpc/blob/5a142bc4d24b7f8c830f59768b405ec74d582f22/src/RegistrationServer.php#L127-L147
train
civicrm/civicrm-cxn-rpc
src/RegistrationServer.php
RegistrationServer.onCxnUnregister
public function onCxnUnregister($cxn, $params) { $storedCxn = $this->cxnStore->getByCxnId($cxn['cxnId']); if (!$storedCxn) { $this->log->warning('Unregister cxnId="{cxnId} siteUrl="{siteUrl}"": Non-existent', array( 'cxnId' => $cxn['cxnId'], 'siteUrl' => $cxn['siteUrl'], )); return $this->createSuccess(array( 'cxn_id' => $cxn['cxnId'], )); } elseif ($storedCxn['secret'] == $cxn['secret']) { $this->log->notice('Unregister cxnId="{cxnId} siteUrl="{siteUrl}": OK"', array( 'cxnId' => $cxn['cxnId'], 'siteUrl' => $cxn['siteUrl'], )); $this->cxnStore->remove($cxn['cxnId']); return $this->createSuccess(array( 'cxn_id' => $cxn['cxnId'], )); } else { $this->log->warning('Unregister cxnId="{cxnId}" siteUrl="{siteUrl}": Secret does not match.', array( 'cxnId' => $cxn['cxnId'], 'siteUrl' => $cxn['siteUrl'], )); $this->createError('Incorrect cxnId or secret.'); } }
php
public function onCxnUnregister($cxn, $params) { $storedCxn = $this->cxnStore->getByCxnId($cxn['cxnId']); if (!$storedCxn) { $this->log->warning('Unregister cxnId="{cxnId} siteUrl="{siteUrl}"": Non-existent', array( 'cxnId' => $cxn['cxnId'], 'siteUrl' => $cxn['siteUrl'], )); return $this->createSuccess(array( 'cxn_id' => $cxn['cxnId'], )); } elseif ($storedCxn['secret'] == $cxn['secret']) { $this->log->notice('Unregister cxnId="{cxnId} siteUrl="{siteUrl}": OK"', array( 'cxnId' => $cxn['cxnId'], 'siteUrl' => $cxn['siteUrl'], )); $this->cxnStore->remove($cxn['cxnId']); return $this->createSuccess(array( 'cxn_id' => $cxn['cxnId'], )); } else { $this->log->warning('Unregister cxnId="{cxnId}" siteUrl="{siteUrl}": Secret does not match.', array( 'cxnId' => $cxn['cxnId'], 'siteUrl' => $cxn['siteUrl'], )); $this->createError('Incorrect cxnId or secret.'); } }
[ "public", "function", "onCxnUnregister", "(", "$", "cxn", ",", "$", "params", ")", "{", "$", "storedCxn", "=", "$", "this", "->", "cxnStore", "->", "getByCxnId", "(", "$", "cxn", "[", "'cxnId'", "]", ")", ";", "if", "(", "!", "$", "storedCxn", ")", ...
Callback for Cxn.unregister. @param array $cxn The CXN record submitted by the client. @param array $params Additional parameters from the client. @return array
[ "Callback", "for", "Cxn", ".", "unregister", "." ]
5a142bc4d24b7f8c830f59768b405ec74d582f22
https://github.com/civicrm/civicrm-cxn-rpc/blob/5a142bc4d24b7f8c830f59768b405ec74d582f22/src/RegistrationServer.php#L158-L186
train
harmonycms/sdk
HttpClient/Builder.php
Builder.addPlugin
public function addPlugin(Plugin $plugin): Builder { $this->plugins[] = $plugin; $this->httpClientModified = true; return $this; }
php
public function addPlugin(Plugin $plugin): Builder { $this->plugins[] = $plugin; $this->httpClientModified = true; return $this; }
[ "public", "function", "addPlugin", "(", "Plugin", "$", "plugin", ")", ":", "Builder", "{", "$", "this", "->", "plugins", "[", "]", "=", "$", "plugin", ";", "$", "this", "->", "httpClientModified", "=", "true", ";", "return", "$", "this", ";", "}" ]
Add a new plugin to the end of the plugin chain. @param Plugin $plugin @return Builder
[ "Add", "a", "new", "plugin", "to", "the", "end", "of", "the", "plugin", "chain", "." ]
108f9d7a05118a367efd28d1096258da9270cb6d
https://github.com/harmonycms/sdk/blob/108f9d7a05118a367efd28d1096258da9270cb6d/HttpClient/Builder.php#L101-L107
train
inphinit/framework
src/Inphinit/Routing/Route.php
Route.set
public static function set($method, $path, $action) { if (is_array($method)) { foreach ($method as $value) { self::set($value, $path, $action); } } else { if (is_string($action)) { $action = parent::$prefixNS . $action; } elseif ($action !== null && !$action instanceof \Closure) { return null; } $method = strtoupper(trim($method)); $path = parent::$prefixPath . $path; if (!isset(parent::$httpRoutes[$path])) { parent::$httpRoutes[$path] = array(); } parent::$httpRoutes[$path][$method] = $action; } }
php
public static function set($method, $path, $action) { if (is_array($method)) { foreach ($method as $value) { self::set($value, $path, $action); } } else { if (is_string($action)) { $action = parent::$prefixNS . $action; } elseif ($action !== null && !$action instanceof \Closure) { return null; } $method = strtoupper(trim($method)); $path = parent::$prefixPath . $path; if (!isset(parent::$httpRoutes[$path])) { parent::$httpRoutes[$path] = array(); } parent::$httpRoutes[$path][$method] = $action; } }
[ "public", "static", "function", "set", "(", "$", "method", ",", "$", "path", ",", "$", "action", ")", "{", "if", "(", "is_array", "(", "$", "method", ")", ")", "{", "foreach", "(", "$", "method", "as", "$", "value", ")", "{", "self", "::", "set",...
Register or remove a action from controller for a route @param string|array $method @param string $path @param string|\Closure $action @return void
[ "Register", "or", "remove", "a", "action", "from", "controller", "for", "a", "route" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/Routing/Route.php#L24-L47
train
inphinit/framework
src/Inphinit/Routing/Route.php
Route.get
public static function get() { if (self::$current !== null) { return self::$current; } $resp = 404; $args = array(); $routes = parent::$httpRoutes; $path = \UtilsPath(); $method = $_SERVER['REQUEST_METHOD']; //... if (isset($routes[$path])) { $verbs = $routes[$path]; } else { foreach ($routes as $route => $actions) { if (parent::find($route, $path, $args)) { $verbs = $actions; break; } } } if (isset($verbs[$method])) { $resp = $verbs[$method]; } elseif (isset($verbs['ANY'])) { $resp = $verbs['ANY']; } elseif (isset($verbs)) { $resp = 405; } if (is_numeric($resp)) { self::$current = $resp; } else { self::$current = array( 'callback' => $resp, 'args' => $args ); } $routes = null; return self::$current; }
php
public static function get() { if (self::$current !== null) { return self::$current; } $resp = 404; $args = array(); $routes = parent::$httpRoutes; $path = \UtilsPath(); $method = $_SERVER['REQUEST_METHOD']; //... if (isset($routes[$path])) { $verbs = $routes[$path]; } else { foreach ($routes as $route => $actions) { if (parent::find($route, $path, $args)) { $verbs = $actions; break; } } } if (isset($verbs[$method])) { $resp = $verbs[$method]; } elseif (isset($verbs['ANY'])) { $resp = $verbs['ANY']; } elseif (isset($verbs)) { $resp = 405; } if (is_numeric($resp)) { self::$current = $resp; } else { self::$current = array( 'callback' => $resp, 'args' => $args ); } $routes = null; return self::$current; }
[ "public", "static", "function", "get", "(", ")", "{", "if", "(", "self", "::", "$", "current", "!==", "null", ")", "{", "return", "self", "::", "$", "current", ";", "}", "$", "resp", "=", "404", ";", "$", "args", "=", "array", "(", ")", ";", "$...
Get action controller from current route @return array|bool
[ "Get", "action", "controller", "from", "current", "route" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/Routing/Route.php#L54-L99
train
brick/std
src/Internal/ErrorCatcher.php
ErrorCatcher.run
public static function run(callable $function) { set_error_handler(static function($severity, $message, $file, $line) { throw new \ErrorException($message, 0, $severity, $file, $line); }); try { $result = $function(); } finally { restore_error_handler(); } return $result; }
php
public static function run(callable $function) { set_error_handler(static function($severity, $message, $file, $line) { throw new \ErrorException($message, 0, $severity, $file, $line); }); try { $result = $function(); } finally { restore_error_handler(); } return $result; }
[ "public", "static", "function", "run", "(", "callable", "$", "function", ")", "{", "set_error_handler", "(", "static", "function", "(", "$", "severity", ",", "$", "message", ",", "$", "file", ",", "$", "line", ")", "{", "throw", "new", "\\", "ErrorExcept...
Runs the given function, catching PHP errors and throwing exceptions. @param callable $function The function to execute. @return mixed The return value of the function. @throws \ErrorException If a PHP error occurs.
[ "Runs", "the", "given", "function", "catching", "PHP", "errors", "and", "throwing", "exceptions", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/Internal/ErrorCatcher.php#L25-L38
train
tastphp/framework
src/Framework/Logger/LoggerService.php
LoggerService.emergency
public static function emergency($message, $context = [], $channel = 'tastphp.logger') { $logger = static::getLoggerByLevelAndChannel(Monolog::ALERT, $channel); $logger->addEmergency($message, $context); }
php
public static function emergency($message, $context = [], $channel = 'tastphp.logger') { $logger = static::getLoggerByLevelAndChannel(Monolog::ALERT, $channel); $logger->addEmergency($message, $context); }
[ "public", "static", "function", "emergency", "(", "$", "message", ",", "$", "context", "=", "[", "]", ",", "$", "channel", "=", "'tastphp.logger'", ")", "{", "$", "logger", "=", "static", "::", "getLoggerByLevelAndChannel", "(", "Monolog", "::", "ALERT", "...
system is unusable. @param $message @param $context @param string $channel
[ "system", "is", "unusable", "." ]
c706fb4cc2918f4c56bfb67616cb95a4c0db270e
https://github.com/tastphp/framework/blob/c706fb4cc2918f4c56bfb67616cb95a4c0db270e/src/Framework/Logger/LoggerService.php#L107-L111
train
inphinit/framework
src/Inphinit/Http/Response.php
Response.dispatch
public static function dispatch() { if (empty(self::$headers) === false) { self::$dispatchedHeaders = true; foreach (self::$headers as $value) { self::putHeader($value[0], $value[1], $value[2]); } } }
php
public static function dispatch() { if (empty(self::$headers) === false) { self::$dispatchedHeaders = true; foreach (self::$headers as $value) { self::putHeader($value[0], $value[1], $value[2]); } } }
[ "public", "static", "function", "dispatch", "(", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "headers", ")", "===", "false", ")", "{", "self", "::", "$", "dispatchedHeaders", "=", "true", ";", "foreach", "(", "self", "::", "$", "headers", "...
Define registered headers to response @return void
[ "Define", "registered", "headers", "to", "response" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/Http/Response.php#L25-L34
train
inphinit/framework
src/Inphinit/Http/Response.php
Response.status
public static function status($code = null, $trigger = true) { if (self::$httpCode === null) { self::$httpCode = \UtilsStatusCode(); } if ($code === null || self::$httpCode === $code) { return self::$httpCode; } elseif (headers_sent() || $code < 100 || $code > 599) { return false; } header('X-PHP-Response-Code: ' . $code, true, $code); $lastCode = self::$httpCode; self::$httpCode = $code; if ($trigger) { App::trigger('changestatus', array($code, null)); } return $lastCode; }
php
public static function status($code = null, $trigger = true) { if (self::$httpCode === null) { self::$httpCode = \UtilsStatusCode(); } if ($code === null || self::$httpCode === $code) { return self::$httpCode; } elseif (headers_sent() || $code < 100 || $code > 599) { return false; } header('X-PHP-Response-Code: ' . $code, true, $code); $lastCode = self::$httpCode; self::$httpCode = $code; if ($trigger) { App::trigger('changestatus', array($code, null)); } return $lastCode; }
[ "public", "static", "function", "status", "(", "$", "code", "=", "null", ",", "$", "trigger", "=", "true", ")", "{", "if", "(", "self", "::", "$", "httpCode", "===", "null", ")", "{", "self", "::", "$", "httpCode", "=", "\\", "UtilsStatusCode", "(", ...
Get or set status code and return last status code @param int $code @param bool $trigger @return int|bool
[ "Get", "or", "set", "status", "code", "and", "return", "last", "status", "code" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/Http/Response.php#L53-L75
train
inphinit/framework
src/Inphinit/Http/Response.php
Response.removeHeader
public static function removeHeader($name) { self::$headers = array_filter(self::$headers, function ($header) use ($name) { return strcasecmp($header[0], $name) !== 0; }); }
php
public static function removeHeader($name) { self::$headers = array_filter(self::$headers, function ($header) use ($name) { return strcasecmp($header[0], $name) !== 0; }); }
[ "public", "static", "function", "removeHeader", "(", "$", "name", ")", "{", "self", "::", "$", "headers", "=", "array_filter", "(", "self", "::", "$", "headers", ",", "function", "(", "$", "header", ")", "use", "(", "$", "name", ")", "{", "return", "...
Remove registered header @param string $name @return void
[ "Remove", "registered", "header" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/Http/Response.php#L102-L107
train
inphinit/framework
src/Inphinit/Http/Response.php
Response.download
public static function download($name = null, $contentLength = 0) { if ($name) { $name = '; filename="' . strtr($name, '"', '-') . '"'; } else { $name = ''; } self::putHeader('Content-Transfer-Encoding', 'Binary'); self::putHeader('Content-Disposition', 'attachment' . $name); if ($contentLength > 0) { self::putHeader('Content-Length', $contentLength); } }
php
public static function download($name = null, $contentLength = 0) { if ($name) { $name = '; filename="' . strtr($name, '"', '-') . '"'; } else { $name = ''; } self::putHeader('Content-Transfer-Encoding', 'Binary'); self::putHeader('Content-Disposition', 'attachment' . $name); if ($contentLength > 0) { self::putHeader('Content-Length', $contentLength); } }
[ "public", "static", "function", "download", "(", "$", "name", "=", "null", ",", "$", "contentLength", "=", "0", ")", "{", "if", "(", "$", "name", ")", "{", "$", "name", "=", "'; filename=\"'", ".", "strtr", "(", "$", "name", ",", "'\"'", ",", "'-'"...
Force download current page @param string $name @param int $contentLength @return void
[ "Force", "download", "current", "page" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/Http/Response.php#L139-L153
train
cafe-latte/framework
src/Core/ModelView.php
ModelView.addViewData
public function addViewData($key, $value) { if ($key) { $this->modelVar[$key] = $value; } else { $this->modelVar = $value; } return $this; }
php
public function addViewData($key, $value) { if ($key) { $this->modelVar[$key] = $value; } else { $this->modelVar = $value; } return $this; }
[ "public", "function", "addViewData", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "$", "key", ")", "{", "$", "this", "->", "modelVar", "[", "$", "key", "]", "=", "$", "value", ";", "}", "else", "{", "$", "this", "->", "modelVar", "=...
to add view data @param $key @param $value @return $this
[ "to", "add", "view", "data" ]
2a2a88ad09b05ec1d03f3fc6fefb280d171fa2da
https://github.com/cafe-latte/framework/blob/2a2a88ad09b05ec1d03f3fc6fefb280d171fa2da/src/Core/ModelView.php#L37-L46
train
inphinit/framework
src/Experimental/Shell.php
Shell.inputObserver
public function inputObserver($callback, $exitCicle = null) { if (self::isCli() === false || is_callable($callback) === false) { return false; } $this->io = $callback; $this->ec = $exitCicle ? $exitCicle : $this->ec; if ($this->started) { return true; } $this->started = true; $this->fireInputObserver(); return true; }
php
public function inputObserver($callback, $exitCicle = null) { if (self::isCli() === false || is_callable($callback) === false) { return false; } $this->io = $callback; $this->ec = $exitCicle ? $exitCicle : $this->ec; if ($this->started) { return true; } $this->started = true; $this->fireInputObserver(); return true; }
[ "public", "function", "inputObserver", "(", "$", "callback", ",", "$", "exitCicle", "=", "null", ")", "{", "if", "(", "self", "::", "isCli", "(", ")", "===", "false", "||", "is_callable", "(", "$", "callback", ")", "===", "false", ")", "{", "return", ...
Add callback event to input @param callable $callback @param string $exitCicle @return bool
[ "Add", "callback", "event", "to", "input" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Experimental/Shell.php#L97-L114
train
inphinit/framework
src/Experimental/Shell.php
Shell.fireInputObserver
protected function fireInputObserver() { $response = rtrim(self::input(), PHP_EOL); if (strcasecmp($response, $this->ec) === 0) { return null; } $callback = $this->io; $callback($response); usleep(100); $this->fireInputObserver(); }
php
protected function fireInputObserver() { $response = rtrim(self::input(), PHP_EOL); if (strcasecmp($response, $this->ec) === 0) { return null; } $callback = $this->io; $callback($response); usleep(100); $this->fireInputObserver(); }
[ "protected", "function", "fireInputObserver", "(", ")", "{", "$", "response", "=", "rtrim", "(", "self", "::", "input", "(", ")", ",", "PHP_EOL", ")", ";", "if", "(", "strcasecmp", "(", "$", "response", ",", "$", "this", "->", "ec", ")", "===", "0", ...
Trigger observer input @return void
[ "Trigger", "observer", "input" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Experimental/Shell.php#L121-L136
train
cafe-latte/framework
src/Core/Router.php
Router.get
public function get(string $pattern, callable $callback) { if ($this->requestMethod === "GET") { $this->mapRoute($pattern, $callback); } }
php
public function get(string $pattern, callable $callback) { if ($this->requestMethod === "GET") { $this->mapRoute($pattern, $callback); } }
[ "public", "function", "get", "(", "string", "$", "pattern", ",", "callable", "$", "callback", ")", "{", "if", "(", "$", "this", "->", "requestMethod", "===", "\"GET\"", ")", "{", "$", "this", "->", "mapRoute", "(", "$", "pattern", ",", "$", "callback",...
allow to access via the get request @param string $pattern @param callable $callback
[ "allow", "to", "access", "via", "the", "get", "request" ]
2a2a88ad09b05ec1d03f3fc6fefb280d171fa2da
https://github.com/cafe-latte/framework/blob/2a2a88ad09b05ec1d03f3fc6fefb280d171fa2da/src/Core/Router.php#L52-L57
train
cafe-latte/framework
src/Core/Router.php
Router.post
public function post(string $pattern, callable $callback) { if ($this->requestMethod === "POST") { $this->mapRoute($pattern, $callback); } }
php
public function post(string $pattern, callable $callback) { if ($this->requestMethod === "POST") { $this->mapRoute($pattern, $callback); } }
[ "public", "function", "post", "(", "string", "$", "pattern", ",", "callable", "$", "callback", ")", "{", "if", "(", "$", "this", "->", "requestMethod", "===", "\"POST\"", ")", "{", "$", "this", "->", "mapRoute", "(", "$", "pattern", ",", "$", "callback...
allow to access via the post request @param string $pattern @param callable $callback
[ "allow", "to", "access", "via", "the", "post", "request" ]
2a2a88ad09b05ec1d03f3fc6fefb280d171fa2da
https://github.com/cafe-latte/framework/blob/2a2a88ad09b05ec1d03f3fc6fefb280d171fa2da/src/Core/Router.php#L65-L70
train
cafe-latte/framework
src/Core/Router.php
Router.getPattern
private static function getPattern(string $pattern) { $keywords = preg_split("/\\//", $pattern); $i = '0'; $word = ""; foreach ($keywords as $keyword) { $i++; if (preg_match("/:/i", $keyword)) { $word .= "([a-zA-Z0-9-._]+)"; } else { $word .= $keyword; } if (count($keywords) != $i) { $word .= "/"; } } return $word; }
php
private static function getPattern(string $pattern) { $keywords = preg_split("/\\//", $pattern); $i = '0'; $word = ""; foreach ($keywords as $keyword) { $i++; if (preg_match("/:/i", $keyword)) { $word .= "([a-zA-Z0-9-._]+)"; } else { $word .= $keyword; } if (count($keywords) != $i) { $word .= "/"; } } return $word; }
[ "private", "static", "function", "getPattern", "(", "string", "$", "pattern", ")", "{", "$", "keywords", "=", "preg_split", "(", "\"/\\\\//\"", ",", "$", "pattern", ")", ";", "$", "i", "=", "'0'", ";", "$", "word", "=", "\"\"", ";", "foreach", "(", "...
input patten re change @param string $pattern @return string
[ "input", "patten", "re", "change" ]
2a2a88ad09b05ec1d03f3fc6fefb280d171fa2da
https://github.com/cafe-latte/framework/blob/2a2a88ad09b05ec1d03f3fc6fefb280d171fa2da/src/Core/Router.php#L118-L136
train
alchemy-fr/embed-bundle
src/Component/Embed/Embed.php
Embed.normalizeConfig
private function normalizeConfig(array $embedConfig) { $config = $embedConfig; // apply deprecated configuration keys if exists: if (array_key_exists('video_player', $embedConfig)) { $config['video']['player'] = $embedConfig['video_player']; } if (array_key_exists('video_autoplay', $embedConfig)) { $config['video']['autoplay'] = $embedConfig['video_autoplay']; } if (array_key_exists('video_available_speeds', $embedConfig)) { $config['video']['available-speeds'] = $embedConfig['video_available_speeds']; } if (array_key_exists('audio_player', $embedConfig)) { $config['audio']['player'] = $embedConfig['audio_player']; } if (array_key_exists('audio_autoplay', $embedConfig)) { $config['audio']['autoplay'] = $embedConfig['audio_autoplay']; } if (array_key_exists('audio_available_speeds', $embedConfig)) { $config['audio']['available-speeds'] = $embedConfig['audio_available_speeds']; } if (array_key_exists('enable_pdfjs', $embedConfig['document'])) { $config['document']['enable-pdfjs'] = $embedConfig['document']['enable_pdfjs']; } return $config; }
php
private function normalizeConfig(array $embedConfig) { $config = $embedConfig; // apply deprecated configuration keys if exists: if (array_key_exists('video_player', $embedConfig)) { $config['video']['player'] = $embedConfig['video_player']; } if (array_key_exists('video_autoplay', $embedConfig)) { $config['video']['autoplay'] = $embedConfig['video_autoplay']; } if (array_key_exists('video_available_speeds', $embedConfig)) { $config['video']['available-speeds'] = $embedConfig['video_available_speeds']; } if (array_key_exists('audio_player', $embedConfig)) { $config['audio']['player'] = $embedConfig['audio_player']; } if (array_key_exists('audio_autoplay', $embedConfig)) { $config['audio']['autoplay'] = $embedConfig['audio_autoplay']; } if (array_key_exists('audio_available_speeds', $embedConfig)) { $config['audio']['available-speeds'] = $embedConfig['audio_available_speeds']; } if (array_key_exists('enable_pdfjs', $embedConfig['document'])) { $config['document']['enable-pdfjs'] = $embedConfig['document']['enable_pdfjs']; } return $config; }
[ "private", "function", "normalizeConfig", "(", "array", "$", "embedConfig", ")", "{", "$", "config", "=", "$", "embedConfig", ";", "// apply deprecated configuration keys if exists:", "if", "(", "array_key_exists", "(", "'video_player'", ",", "$", "embedConfig", ")", ...
apply deprecated configuration keys @param array $embedConfig @return array
[ "apply", "deprecated", "configuration", "keys" ]
fc3df52f0258afadf885120166442165c6845a97
https://github.com/alchemy-fr/embed-bundle/blob/fc3df52f0258afadf885120166442165c6845a97/src/Component/Embed/Embed.php#L56-L85
train
KodiCMS/laravel-assets
src/Traits/Groups.php
Groups.group
public function group($group, $handle = null, $content = null) { $this->groups[$group][$handle] = $content; return $this; }
php
public function group($group, $handle = null, $content = null) { $this->groups[$group][$handle] = $content; return $this; }
[ "public", "function", "group", "(", "$", "group", ",", "$", "handle", "=", "null", ",", "$", "content", "=", "null", ")", "{", "$", "this", "->", "groups", "[", "$", "group", "]", "[", "$", "handle", "]", "=", "$", "content", ";", "return", "$", ...
Group wrapper. @param string $group Group name @param string $handle Asset name @param string $content Asset content @return $this
[ "Group", "wrapper", "." ]
734b1f77f19bd4d5cbbad64d6cfc69c1a7482db0
https://github.com/KodiCMS/laravel-assets/blob/734b1f77f19bd4d5cbbad64d6cfc69c1a7482db0/src/Traits/Groups.php#L21-L26
train
KodiCMS/laravel-assets
src/Traits/Groups.php
Groups.removeGroup
public function removeGroup($group = null, $handle = null) { if (is_null($group)) { return $this->groups = []; } if (is_null($handle)) { unset($this->groups[$group]); return; } unset($this->groups[$group][$handle]); }
php
public function removeGroup($group = null, $handle = null) { if (is_null($group)) { return $this->groups = []; } if (is_null($handle)) { unset($this->groups[$group]); return; } unset($this->groups[$group][$handle]); }
[ "public", "function", "removeGroup", "(", "$", "group", "=", "null", ",", "$", "handle", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "group", ")", ")", "{", "return", "$", "this", "->", "groups", "=", "[", "]", ";", "}", "if", "(", "...
Remove a group asset, all of a groups assets, or all group assets. @param string $group Group name @param string $handle Asset name @return mixed Empty array or void
[ "Remove", "a", "group", "asset", "all", "of", "a", "groups", "assets", "or", "all", "group", "assets", "." ]
734b1f77f19bd4d5cbbad64d6cfc69c1a7482db0
https://github.com/KodiCMS/laravel-assets/blob/734b1f77f19bd4d5cbbad64d6cfc69c1a7482db0/src/Traits/Groups.php#L49-L62
train
KodiCMS/laravel-assets
src/Traits/Groups.php
Groups.renderGroup
public function renderGroup($group) { if (!isset($this->groups[$group])) { return PHP_EOL; } foreach ($this->groups[$group] as $handle => $data) { $assets[] = $this->getGroup($group, $handle); } return implode(PHP_EOL, $assets); }
php
public function renderGroup($group) { if (!isset($this->groups[$group])) { return PHP_EOL; } foreach ($this->groups[$group] as $handle => $data) { $assets[] = $this->getGroup($group, $handle); } return implode(PHP_EOL, $assets); }
[ "public", "function", "renderGroup", "(", "$", "group", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "groups", "[", "$", "group", "]", ")", ")", "{", "return", "PHP_EOL", ";", "}", "foreach", "(", "$", "this", "->", "groups", "[", "...
Get all of a groups assets, sorted by dependencies. @param string $group Group name @return string Assets content
[ "Get", "all", "of", "a", "groups", "assets", "sorted", "by", "dependencies", "." ]
734b1f77f19bd4d5cbbad64d6cfc69c1a7482db0
https://github.com/KodiCMS/laravel-assets/blob/734b1f77f19bd4d5cbbad64d6cfc69c1a7482db0/src/Traits/Groups.php#L71-L82
train
agilov/yii2-seo-behavior
components/SeoBehavior.php
SeoBehavior.saveSeoContent
public function saveSeoContent() { $model = $this->getSeoContentModel(); if (!$model->is_global) { $model->title = $this->owner->{$this->titleAttribute}; $model->keywords = $this->owner->{$this->keywordsAttribute}; $model->description = $this->owner->{$this->descriptionAttribute}; $model->save(); } }
php
public function saveSeoContent() { $model = $this->getSeoContentModel(); if (!$model->is_global) { $model->title = $this->owner->{$this->titleAttribute}; $model->keywords = $this->owner->{$this->keywordsAttribute}; $model->description = $this->owner->{$this->descriptionAttribute}; $model->save(); } }
[ "public", "function", "saveSeoContent", "(", ")", "{", "$", "model", "=", "$", "this", "->", "getSeoContentModel", "(", ")", ";", "if", "(", "!", "$", "model", "->", "is_global", ")", "{", "$", "model", "->", "title", "=", "$", "this", "->", "owner",...
Saving seo content
[ "Saving", "seo", "content" ]
b4ad117a19ac2400c15eda54bf514c9a2cbf0a14
https://github.com/agilov/yii2-seo-behavior/blob/b4ad117a19ac2400c15eda54bf514c9a2cbf0a14/components/SeoBehavior.php#L148-L156
train
agilov/yii2-seo-behavior
components/SeoBehavior.php
SeoBehavior.deleteSeoContent
public function deleteSeoContent() { $model = $this->getSeoContentModel(); if ($model && !$model->getIsNewRecord() && !$model->is_global) { $model->delete(); } }
php
public function deleteSeoContent() { $model = $this->getSeoContentModel(); if ($model && !$model->getIsNewRecord() && !$model->is_global) { $model->delete(); } }
[ "public", "function", "deleteSeoContent", "(", ")", "{", "$", "model", "=", "$", "this", "->", "getSeoContentModel", "(", ")", ";", "if", "(", "$", "model", "&&", "!", "$", "model", "->", "getIsNewRecord", "(", ")", "&&", "!", "$", "model", "->", "is...
Deleting seo content @throws \Exception
[ "Deleting", "seo", "content" ]
b4ad117a19ac2400c15eda54bf514c9a2cbf0a14
https://github.com/agilov/yii2-seo-behavior/blob/b4ad117a19ac2400c15eda54bf514c9a2cbf0a14/components/SeoBehavior.php#L163-L168
train
inphinit/framework
src/Inphinit/Routing/Router.php
Router.find
protected static function find($route, $path, array &$matches) { $re = Regex::parse($route); if ($re !== false && preg_match('#^' . $re . '$#', $path, $matches)) { array_shift($matches); return true; } return false; }
php
protected static function find($route, $path, array &$matches) { $re = Regex::parse($route); if ($re !== false && preg_match('#^' . $re . '$#', $path, $matches)) { array_shift($matches); return true; } return false; }
[ "protected", "static", "function", "find", "(", "$", "route", ",", "$", "path", ",", "array", "&", "$", "matches", ")", "{", "$", "re", "=", "Regex", "::", "parse", "(", "$", "route", ")", ";", "if", "(", "$", "re", "!==", "false", "&&", "preg_ma...
Get params from routes using regex @param string $route @param string $path @param array $matches @return bool
[ "Get", "params", "from", "routes", "using", "regex" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/Routing/Router.php#L45-L55
train
inphinit/framework
src/Experimental/Routing/Quick.php
Quick.verbs
private static function verbs(array $methods) { $list = array(); $reMatch = '#^(any|get|post|patch|put|head|delete|options|trace|connect)([A-Z0-9]\w+)$#'; foreach ($methods as $value) { $verb = array(); if (preg_match($reMatch, $value, $verb)) { if (strcasecmp('index', $verb[2]) === 0) { $verb[2] = ''; } else { $verb[2] = strtolower(preg_replace('#([a-z])([A-Z])#', '$1-$2', $verb[2])); } $list[] = array(strtoupper($verb[1]), $verb[2], $value); } } return $list; }
php
private static function verbs(array $methods) { $list = array(); $reMatch = '#^(any|get|post|patch|put|head|delete|options|trace|connect)([A-Z0-9]\w+)$#'; foreach ($methods as $value) { $verb = array(); if (preg_match($reMatch, $value, $verb)) { if (strcasecmp('index', $verb[2]) === 0) { $verb[2] = ''; } else { $verb[2] = strtolower(preg_replace('#([a-z])([A-Z])#', '$1-$2', $verb[2])); } $list[] = array(strtoupper($verb[1]), $verb[2], $value); } } return $list; }
[ "private", "static", "function", "verbs", "(", "array", "$", "methods", ")", "{", "$", "list", "=", "array", "(", ")", ";", "$", "reMatch", "=", "'#^(any|get|post|patch|put|head|delete|options|trace|connect)([A-Z0-9]\\w+)$#'", ";", "foreach", "(", "$", "methods", ...
Extract valid methods @param array $methods Methods of \Controller class @return array
[ "Extract", "valid", "methods" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Experimental/Routing/Quick.php#L90-L110
train
inphinit/framework
src/Experimental/Routing/Quick.php
Quick.prepare
public function prepare() { if ($this->ready) { return null; } $this->ready = true; $format = $this->format; $controller = $this->controller; foreach ($this->classMethods as $value) { if ($format === self::BOTH || $format === self::SLASH) { $route = '/' . (empty($value[1]) ? '' : ($value[1] . '/')); Route::set($value[0], $route, $controller . ':' . $value[2]); } if ($format === self::BOTH || $format === self::NOSLASH) { $route = empty($value[1]) ? '' : ('/' . $value[1]); Route::set($value[0], $route, $controller . ':' . $value[2]); } } $controller = $classMethods = null; }
php
public function prepare() { if ($this->ready) { return null; } $this->ready = true; $format = $this->format; $controller = $this->controller; foreach ($this->classMethods as $value) { if ($format === self::BOTH || $format === self::SLASH) { $route = '/' . (empty($value[1]) ? '' : ($value[1] . '/')); Route::set($value[0], $route, $controller . ':' . $value[2]); } if ($format === self::BOTH || $format === self::NOSLASH) { $route = empty($value[1]) ? '' : ('/' . $value[1]); Route::set($value[0], $route, $controller . ':' . $value[2]); } } $controller = $classMethods = null; }
[ "public", "function", "prepare", "(", ")", "{", "if", "(", "$", "this", "->", "ready", ")", "{", "return", "null", ";", "}", "$", "this", "->", "ready", "=", "true", ";", "$", "format", "=", "$", "this", "->", "format", ";", "$", "controller", "=...
Create routes by configurations @throws \Inphinit\Experimental\Exception @return void
[ "Create", "routes", "by", "configurations" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Experimental/Routing/Quick.php#L141-L167
train
civicrm/civicrm-cxn-rpc
src/AesHelper.php
AesHelper.authenticateThenDecrypt
public static function authenticateThenDecrypt($secret, $body, $signature) { $keys = self::deriveAesKeys($secret); $localHmac = hash_hmac('sha256', $body, $keys['auth']); if (!self::hash_compare($signature, $localHmac)) { throw new InvalidMessageException("Incorrect hash"); } list ($jsonEnvelope, $jsonEncrypted) = explode(Constants::PROTOCOL_DELIM, $body, 2); if (strlen($jsonEnvelope) > Constants::MAX_ENVELOPE_BYTES) { throw new InvalidMessageException("Oversized envelope"); } $envelope = json_decode($jsonEnvelope, TRUE); if (!$envelope) { throw new InvalidMessageException("Malformed envelope"); } if (!is_numeric($envelope['ttl']) || Time::getTime() > $envelope['ttl']) { throw new InvalidMessageException("Invalid TTL"); } if (!is_string($envelope['iv']) || strlen($envelope['iv']) !== Constants::AES_BYTES * 2 || !preg_match('/^[a-f0-9]+$/', $envelope['iv'])) { // AES_BYTES (32) ==> bin2hex ==> 2 hex digits (4-bit) per byte (8-bit) throw new InvalidMessageException("Malformed initialization vector"); } $jsonPlaintext = UserError::adapt('Civi\Cxn\Rpc\Exception\InvalidMessageException', function () use ($jsonEncrypted, $envelope, $keys) { $cipher = new \Crypt_AES(CRYPT_AES_MODE_CBC); $cipher->setKeyLength(Constants::AES_BYTES); $cipher->setKey($keys['enc']); $cipher->setIV(BinHex::hex2bin($envelope['iv'])); return $cipher->decrypt($jsonEncrypted); }); return $jsonPlaintext; }
php
public static function authenticateThenDecrypt($secret, $body, $signature) { $keys = self::deriveAesKeys($secret); $localHmac = hash_hmac('sha256', $body, $keys['auth']); if (!self::hash_compare($signature, $localHmac)) { throw new InvalidMessageException("Incorrect hash"); } list ($jsonEnvelope, $jsonEncrypted) = explode(Constants::PROTOCOL_DELIM, $body, 2); if (strlen($jsonEnvelope) > Constants::MAX_ENVELOPE_BYTES) { throw new InvalidMessageException("Oversized envelope"); } $envelope = json_decode($jsonEnvelope, TRUE); if (!$envelope) { throw new InvalidMessageException("Malformed envelope"); } if (!is_numeric($envelope['ttl']) || Time::getTime() > $envelope['ttl']) { throw new InvalidMessageException("Invalid TTL"); } if (!is_string($envelope['iv']) || strlen($envelope['iv']) !== Constants::AES_BYTES * 2 || !preg_match('/^[a-f0-9]+$/', $envelope['iv'])) { // AES_BYTES (32) ==> bin2hex ==> 2 hex digits (4-bit) per byte (8-bit) throw new InvalidMessageException("Malformed initialization vector"); } $jsonPlaintext = UserError::adapt('Civi\Cxn\Rpc\Exception\InvalidMessageException', function () use ($jsonEncrypted, $envelope, $keys) { $cipher = new \Crypt_AES(CRYPT_AES_MODE_CBC); $cipher->setKeyLength(Constants::AES_BYTES); $cipher->setKey($keys['enc']); $cipher->setIV(BinHex::hex2bin($envelope['iv'])); return $cipher->decrypt($jsonEncrypted); }); return $jsonPlaintext; }
[ "public", "static", "function", "authenticateThenDecrypt", "(", "$", "secret", ",", "$", "body", ",", "$", "signature", ")", "{", "$", "keys", "=", "self", "::", "deriveAesKeys", "(", "$", "secret", ")", ";", "$", "localHmac", "=", "hash_hmac", "(", "'sh...
Validate the signature and date of the message, then decrypt it. @param string $secret @param string $body @param string $signature @return string Plain text. @throws InvalidMessageException
[ "Validate", "the", "signature", "and", "date", "of", "the", "message", "then", "decrypt", "it", "." ]
5a142bc4d24b7f8c830f59768b405ec74d582f22
https://github.com/civicrm/civicrm-cxn-rpc/blob/5a142bc4d24b7f8c830f59768b405ec74d582f22/src/AesHelper.php#L91-L126
train
civicrm/civicrm-cxn-rpc
src/AesHelper.php
AesHelper.hash_compare
private static function hash_compare($a, $b) { if (!is_string($a) || !is_string($b)) { return FALSE; } $len = strlen($a); if ($len !== strlen($b)) { return FALSE; } $status = 0; for ($i = 0; $i < $len; $i++) { $status |= ord($a[$i]) ^ ord($b[$i]); } return $status === 0; }
php
private static function hash_compare($a, $b) { if (!is_string($a) || !is_string($b)) { return FALSE; } $len = strlen($a); if ($len !== strlen($b)) { return FALSE; } $status = 0; for ($i = 0; $i < $len; $i++) { $status |= ord($a[$i]) ^ ord($b[$i]); } return $status === 0; }
[ "private", "static", "function", "hash_compare", "(", "$", "a", ",", "$", "b", ")", "{", "if", "(", "!", "is_string", "(", "$", "a", ")", "||", "!", "is_string", "(", "$", "b", ")", ")", "{", "return", "FALSE", ";", "}", "$", "len", "=", "strle...
Comparison function which resists timing attacks. @param string $a @param string $b @return bool
[ "Comparison", "function", "which", "resists", "timing", "attacks", "." ]
5a142bc4d24b7f8c830f59768b405ec74d582f22
https://github.com/civicrm/civicrm-cxn-rpc/blob/5a142bc4d24b7f8c830f59768b405ec74d582f22/src/AesHelper.php#L135-L150
train
inphinit/framework
src/Inphinit/File.php
File.exists
public static function exists($path) { if (file_exists($path) === false) { return false; } $path = preg_replace('#^file:/+([a-z]:/|/)#i', '$1', $path); $pinfo = pathinfo($path); $rpath = strtr(realpath($path), '\\', '/'); if ($pinfo['dirname'] !== '.') { $path = Uri::canonpath($pinfo['dirname']) . '/' . $pinfo['basename']; } $pinfo = null; return $rpath === $path || substr($rpath, strlen($rpath) - strlen($path)) === $path; }
php
public static function exists($path) { if (file_exists($path) === false) { return false; } $path = preg_replace('#^file:/+([a-z]:/|/)#i', '$1', $path); $pinfo = pathinfo($path); $rpath = strtr(realpath($path), '\\', '/'); if ($pinfo['dirname'] !== '.') { $path = Uri::canonpath($pinfo['dirname']) . '/' . $pinfo['basename']; } $pinfo = null; return $rpath === $path || substr($rpath, strlen($rpath) - strlen($path)) === $path; }
[ "public", "static", "function", "exists", "(", "$", "path", ")", "{", "if", "(", "file_exists", "(", "$", "path", ")", "===", "false", ")", "{", "return", "false", ";", "}", "$", "path", "=", "preg_replace", "(", "'#^file:/+([a-z]:/|/)#i'", ",", "'$1'", ...
Check if file exists using case-sensitive, For help developers who using Windows OS and using unix-like for production @param string $path @return bool
[ "Check", "if", "file", "exists", "using", "case", "-", "sensitive", "For", "help", "developers", "who", "using", "Windows", "OS", "and", "using", "unix", "-", "like", "for", "production" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/File.php#L23-L41
train
inphinit/framework
src/Inphinit/File.php
File.mime
public static function mime($path) { $mime = false; if (is_readable($path)) { if (function_exists('finfo_open')) { $buffer = file_get_contents($path, false, null, -1, 5012); $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_buffer($finfo, $buffer); finfo_close($finfo); $buffer = null; } elseif (function_exists('mime_content_type')) { $mime = mime_content_type($path); } } if ($mime !== false && strpos($mime, 'application/') === 0) { $size = filesize($path); $mime = $size >= 0 && $size < 2 ? 'text/plain' : $mime; } return $mime; }
php
public static function mime($path) { $mime = false; if (is_readable($path)) { if (function_exists('finfo_open')) { $buffer = file_get_contents($path, false, null, -1, 5012); $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_buffer($finfo, $buffer); finfo_close($finfo); $buffer = null; } elseif (function_exists('mime_content_type')) { $mime = mime_content_type($path); } } if ($mime !== false && strpos($mime, 'application/') === 0) { $size = filesize($path); $mime = $size >= 0 && $size < 2 ? 'text/plain' : $mime; } return $mime; }
[ "public", "static", "function", "mime", "(", "$", "path", ")", "{", "$", "mime", "=", "false", ";", "if", "(", "is_readable", "(", "$", "path", ")", ")", "{", "if", "(", "function_exists", "(", "'finfo_open'", ")", ")", "{", "$", "buffer", "=", "fi...
Get mimetype from file, return `false` if file is invalid @param string $path @return string|bool
[ "Get", "mimetype", "from", "file", "return", "false", "if", "file", "is", "invalid" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/File.php#L109-L133
train
inphinit/framework
src/Inphinit/File.php
File.output
public static function output($path, $length = 102400, $delay = 0) { if (is_readable($path) === false) { return false; } $buffer = ob_get_level() !== 0; $handle = fopen($path, 'rb'); $length = is_int($length) && $length > 0 ? $length : 102400; while (false === feof($handle)) { echo fread($handle, $length); if ($delay > 0) { usleep($delay); } if ($buffer) { ob_flush(); } flush(); } }
php
public static function output($path, $length = 102400, $delay = 0) { if (is_readable($path) === false) { return false; } $buffer = ob_get_level() !== 0; $handle = fopen($path, 'rb'); $length = is_int($length) && $length > 0 ? $length : 102400; while (false === feof($handle)) { echo fread($handle, $length); if ($delay > 0) { usleep($delay); } if ($buffer) { ob_flush(); } flush(); } }
[ "public", "static", "function", "output", "(", "$", "path", ",", "$", "length", "=", "102400", ",", "$", "delay", "=", "0", ")", "{", "if", "(", "is_readable", "(", "$", "path", ")", "===", "false", ")", "{", "return", "false", ";", "}", "$", "bu...
Show file in output, if use ob_start is auto used ob_flush. You can set delay for cycles @param string $path @param int $length @param int $delay @return void|bool
[ "Show", "file", "in", "output", "if", "use", "ob_start", "is", "auto", "used", "ob_flush", ".", "You", "can", "set", "delay", "for", "cycles" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/File.php#L143-L168
train
civicrm/civicrm-cxn-rpc
src/Message.php
Message.send
public function send() { list ($headers, $blob, $code) = $this->toHttp(); header('Content-Type: ' . Constants::MIME_TYPE); header("X-PHP-Response-Code: $code", TRUE, $code); foreach ($headers as $n => $v) { header("$n: $v"); } echo $blob; }
php
public function send() { list ($headers, $blob, $code) = $this->toHttp(); header('Content-Type: ' . Constants::MIME_TYPE); header("X-PHP-Response-Code: $code", TRUE, $code); foreach ($headers as $n => $v) { header("$n: $v"); } echo $blob; }
[ "public", "function", "send", "(", ")", "{", "list", "(", "$", "headers", ",", "$", "blob", ",", "$", "code", ")", "=", "$", "this", "->", "toHttp", "(", ")", ";", "header", "(", "'Content-Type: '", ".", "Constants", "::", "MIME_TYPE", ")", ";", "h...
Send this message immediately.
[ "Send", "this", "message", "immediately", "." ]
5a142bc4d24b7f8c830f59768b405ec74d582f22
https://github.com/civicrm/civicrm-cxn-rpc/blob/5a142bc4d24b7f8c830f59768b405ec74d582f22/src/Message.php#L92-L100
train
civicrm/civicrm-cxn-rpc
src/Message.php
Message.toSymfonyResponse
public function toSymfonyResponse() { $headers = array_merge( array('Content-Type' => Constants::MIME_TYPE), $this->getHeaders() ); return new \Symfony\Component\HttpFoundation\Response( $this->encode(), $this->code, $headers ); }
php
public function toSymfonyResponse() { $headers = array_merge( array('Content-Type' => Constants::MIME_TYPE), $this->getHeaders() ); return new \Symfony\Component\HttpFoundation\Response( $this->encode(), $this->code, $headers ); }
[ "public", "function", "toSymfonyResponse", "(", ")", "{", "$", "headers", "=", "array_merge", "(", "array", "(", "'Content-Type'", "=>", "Constants", "::", "MIME_TYPE", ")", ",", "$", "this", "->", "getHeaders", "(", ")", ")", ";", "return", "new", "\\", ...
Convert this message a Symfony "Response" object. @return \Symfony\Component\HttpFoundation\Response
[ "Convert", "this", "message", "a", "Symfony", "Response", "object", "." ]
5a142bc4d24b7f8c830f59768b405ec74d582f22
https://github.com/civicrm/civicrm-cxn-rpc/blob/5a142bc4d24b7f8c830f59768b405ec74d582f22/src/Message.php#L107-L117
train
mathielen/import-engine
src/Mathielen/ImportEngine/Storage/Parser/JmsMetadataParser.php
JmsMetadataParser.doParse
protected function doParse($className, $visited = array(), array $groups = array()) { $meta = $this->factory->getMetadataForClass($className); if (null === $meta) { throw new \InvalidArgumentException(sprintf('No metadata found for class %s', $className)); } $exclusionStrategies = array(); if ($groups) { $exclusionStrategies[] = new GroupsExclusionStrategy($groups); } $params = array(); // iterate over property metadata foreach ($meta->propertyMetadata as $item) { if (!is_null($item->type)) { $name = $this->namingStrategy->translateName($item); $dataType = $this->processDataType($item); // apply exclusion strategies foreach ($exclusionStrategies as $strategy) { if (true === $strategy->shouldSkipProperty($item, SerializationContext::create())) { continue 2; } } $params[$name] = array( 'dataType' => $dataType['normalized'], 'required' => false, 'readonly' => $item->readOnly, 'sinceVersion' => $item->sinceVersion, 'untilVersion' => $item->untilVersion, ); if (!is_null($dataType['class'])) { $params[$name]['class'] = $dataType['class']; } // if class already parsed, continue, to avoid infinite recursion if (in_array($dataType['class'], $visited)) { continue; } // check for nested classes with JMS metadata if ($dataType['class'] && null !== $this->factory->getMetadataForClass($dataType['class'])) { $visited[] = $dataType['class']; $params[$name]['children'] = $this->doParse($dataType['class'], $visited, $groups); } } } return $params; }
php
protected function doParse($className, $visited = array(), array $groups = array()) { $meta = $this->factory->getMetadataForClass($className); if (null === $meta) { throw new \InvalidArgumentException(sprintf('No metadata found for class %s', $className)); } $exclusionStrategies = array(); if ($groups) { $exclusionStrategies[] = new GroupsExclusionStrategy($groups); } $params = array(); // iterate over property metadata foreach ($meta->propertyMetadata as $item) { if (!is_null($item->type)) { $name = $this->namingStrategy->translateName($item); $dataType = $this->processDataType($item); // apply exclusion strategies foreach ($exclusionStrategies as $strategy) { if (true === $strategy->shouldSkipProperty($item, SerializationContext::create())) { continue 2; } } $params[$name] = array( 'dataType' => $dataType['normalized'], 'required' => false, 'readonly' => $item->readOnly, 'sinceVersion' => $item->sinceVersion, 'untilVersion' => $item->untilVersion, ); if (!is_null($dataType['class'])) { $params[$name]['class'] = $dataType['class']; } // if class already parsed, continue, to avoid infinite recursion if (in_array($dataType['class'], $visited)) { continue; } // check for nested classes with JMS metadata if ($dataType['class'] && null !== $this->factory->getMetadataForClass($dataType['class'])) { $visited[] = $dataType['class']; $params[$name]['children'] = $this->doParse($dataType['class'], $visited, $groups); } } } return $params; }
[ "protected", "function", "doParse", "(", "$", "className", ",", "$", "visited", "=", "array", "(", ")", ",", "array", "$", "groups", "=", "array", "(", ")", ")", "{", "$", "meta", "=", "$", "this", "->", "factory", "->", "getMetadataForClass", "(", "...
Recursively parse all metadata for a class. @param string $className Class to get all metadata for @param array $visited Classes we've already visited to prevent infinite recursion. @param array $groups Serialization groups to include. @return array metadata for given class @throws \InvalidArgumentException
[ "Recursively", "parse", "all", "metadata", "for", "a", "class", "." ]
a1d0b4b517f062751e35e45a54c635edd5737376
https://github.com/mathielen/import-engine/blob/a1d0b4b517f062751e35e45a54c635edd5737376/src/Mathielen/ImportEngine/Storage/Parser/JmsMetadataParser.php#L59-L114
train
inphinit/framework
src/Inphinit/Http/Request.php
Request.header
public static function header($name = null) { if (self::$reqHeaders === null) { self::generate(); } if (is_string($name)) { $name = strtolower($name); return isset(self::$reqHeadersLower[$name]) ? self::$reqHeadersLower[$name] : false; } return self::$reqHeaders; }
php
public static function header($name = null) { if (self::$reqHeaders === null) { self::generate(); } if (is_string($name)) { $name = strtolower($name); return isset(self::$reqHeadersLower[$name]) ? self::$reqHeadersLower[$name] : false; } return self::$reqHeaders; }
[ "public", "static", "function", "header", "(", "$", "name", "=", "null", ")", "{", "if", "(", "self", "::", "$", "reqHeaders", "===", "null", ")", "{", "self", "::", "generate", "(", ")", ";", "}", "if", "(", "is_string", "(", "$", "name", ")", "...
Get HTTP headers from current request @param string $name @return string|array|bool
[ "Get", "HTTP", "headers", "from", "current", "request" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/Http/Request.php#L56-L68
train
inphinit/framework
src/Inphinit/Http/Request.php
Request.raw
public static function raw($binary = true) { if (is_readable('php://input')) { return false; } $mode = $binary ? 'rb' : 'r'; if (PHP_VERSION_ID >= 50600) { return fopen('php://input', $mode); } $tmp = Storage::temp(); return copy('php://input', $tmp) ? fopen($tmp, $mode) : false; }
php
public static function raw($binary = true) { if (is_readable('php://input')) { return false; } $mode = $binary ? 'rb' : 'r'; if (PHP_VERSION_ID >= 50600) { return fopen('php://input', $mode); } $tmp = Storage::temp(); return copy('php://input', $tmp) ? fopen($tmp, $mode) : false; }
[ "public", "static", "function", "raw", "(", "$", "binary", "=", "true", ")", "{", "if", "(", "is_readable", "(", "'php://input'", ")", ")", "{", "return", "false", ";", "}", "$", "mode", "=", "$", "binary", "?", "'rb'", ":", "'r'", ";", "if", "(", ...
Get a value input handler @param bool $binary @return resource|bool
[ "Get", "a", "value", "input", "handler" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/Http/Request.php#L165-L180
train
agilov/yii2-seo-behavior
components/SeoContentHelper.php
SeoContentHelper.behavior
protected static function behavior(Component $model) { foreach ($model->getBehaviors() as $b) { if ($b instanceof SeoBehavior) { return $b; } } throw new InvalidConfigException('Model ' . $model->className() . ' must have SeoBehavior'); }
php
protected static function behavior(Component $model) { foreach ($model->getBehaviors() as $b) { if ($b instanceof SeoBehavior) { return $b; } } throw new InvalidConfigException('Model ' . $model->className() . ' must have SeoBehavior'); }
[ "protected", "static", "function", "behavior", "(", "Component", "$", "model", ")", "{", "foreach", "(", "$", "model", "->", "getBehaviors", "(", ")", "as", "$", "b", ")", "{", "if", "(", "$", "b", "instanceof", "SeoBehavior", ")", "{", "return", "$", ...
Getting behavior object from given model @param Component $model @return SeoBehavior @throws InvalidConfigException if model don't have our SeoBehavior
[ "Getting", "behavior", "object", "from", "given", "model" ]
b4ad117a19ac2400c15eda54bf514c9a2cbf0a14
https://github.com/agilov/yii2-seo-behavior/blob/b4ad117a19ac2400c15eda54bf514c9a2cbf0a14/components/SeoContentHelper.php#L17-L26
train
agilov/yii2-seo-behavior
components/SeoContentHelper.php
SeoContentHelper.registerSeoMetaTag
protected static function registerSeoMetaTag(Component $model, string $modelSeoAttributeName, string $metaTagKey) { $value = $model->{$modelSeoAttributeName}; if ($value) Yii::$app->view->registerMetaTag(['name' => $metaTagKey, 'content' => $value], $metaTagKey); }
php
protected static function registerSeoMetaTag(Component $model, string $modelSeoAttributeName, string $metaTagKey) { $value = $model->{$modelSeoAttributeName}; if ($value) Yii::$app->view->registerMetaTag(['name' => $metaTagKey, 'content' => $value], $metaTagKey); }
[ "protected", "static", "function", "registerSeoMetaTag", "(", "Component", "$", "model", ",", "string", "$", "modelSeoAttributeName", ",", "string", "$", "metaTagKey", ")", "{", "$", "value", "=", "$", "model", "->", "{", "$", "modelSeoAttributeName", "}", ";"...
Register seo meta tag @param Component $model @param string $modelSeoAttributeName @param string $metaTagKey @since x.x.x
[ "Register", "seo", "meta", "tag" ]
b4ad117a19ac2400c15eda54bf514c9a2cbf0a14
https://github.com/agilov/yii2-seo-behavior/blob/b4ad117a19ac2400c15eda54bf514c9a2cbf0a14/components/SeoContentHelper.php#L36-L41
train
agilov/yii2-seo-behavior
components/SeoContentHelper.php
SeoContentHelper.registerAllSeoMeta
public static function registerAllSeoMeta(Component $model) { self::registerMetaTitle($model); self::registerMetaKeywords($model); self::registerMetaDescription($model); }
php
public static function registerAllSeoMeta(Component $model) { self::registerMetaTitle($model); self::registerMetaKeywords($model); self::registerMetaDescription($model); }
[ "public", "static", "function", "registerAllSeoMeta", "(", "Component", "$", "model", ")", "{", "self", "::", "registerMetaTitle", "(", "$", "model", ")", ";", "self", "::", "registerMetaKeywords", "(", "$", "model", ")", ";", "self", "::", "registerMetaDescri...
Register seo metadata. You can register part of it using methods below right in view code. @param Component $model @since x.x.x
[ "Register", "seo", "metadata", ".", "You", "can", "register", "part", "of", "it", "using", "methods", "below", "right", "in", "view", "code", "." ]
b4ad117a19ac2400c15eda54bf514c9a2cbf0a14
https://github.com/agilov/yii2-seo-behavior/blob/b4ad117a19ac2400c15eda54bf514c9a2cbf0a14/components/SeoContentHelper.php#L60-L65
train
agilov/yii2-seo-behavior
components/SeoContentHelper.php
SeoContentHelper.setTitle
public static function setTitle(Component $model) { $title = $model->{self::behavior($model)->titleAttribute}; if ($title) Yii::$app->view->title = $title; }
php
public static function setTitle(Component $model) { $title = $model->{self::behavior($model)->titleAttribute}; if ($title) Yii::$app->view->title = $title; }
[ "public", "static", "function", "setTitle", "(", "Component", "$", "model", ")", "{", "$", "title", "=", "$", "model", "->", "{", "self", "::", "behavior", "(", "$", "model", ")", "->", "titleAttribute", "}", ";", "if", "(", "$", "title", ")", "Yii",...
Sets page title. If your layout @param Component $model
[ "Sets", "page", "title", ".", "If", "your", "layout" ]
b4ad117a19ac2400c15eda54bf514c9a2cbf0a14
https://github.com/agilov/yii2-seo-behavior/blob/b4ad117a19ac2400c15eda54bf514c9a2cbf0a14/components/SeoContentHelper.php#L72-L77
train
agilov/yii2-seo-behavior
components/SeoContentHelper.php
SeoContentHelper.registerMetaTitle
public static function registerMetaTitle(Component $model) { $modelSeoAttributeName = self::behavior($model)->titleAttribute; self::registerSeoMetaTag($model, $modelSeoAttributeName, 'title'); }
php
public static function registerMetaTitle(Component $model) { $modelSeoAttributeName = self::behavior($model)->titleAttribute; self::registerSeoMetaTag($model, $modelSeoAttributeName, 'title'); }
[ "public", "static", "function", "registerMetaTitle", "(", "Component", "$", "model", ")", "{", "$", "modelSeoAttributeName", "=", "self", "::", "behavior", "(", "$", "model", ")", "->", "titleAttribute", ";", "self", "::", "registerSeoMetaTag", "(", "$", "mode...
Register meta title @param Component $model
[ "Register", "meta", "title" ]
b4ad117a19ac2400c15eda54bf514c9a2cbf0a14
https://github.com/agilov/yii2-seo-behavior/blob/b4ad117a19ac2400c15eda54bf514c9a2cbf0a14/components/SeoContentHelper.php#L84-L88
train
agilov/yii2-seo-behavior
components/SeoContentHelper.php
SeoContentHelper.registerMetaKeywords
public static function registerMetaKeywords(Component $model) { $modelSeoAttributeName = self::behavior($model)->keywordsAttribute; self::registerSeoMetaTag($model, $modelSeoAttributeName, 'keywords'); }
php
public static function registerMetaKeywords(Component $model) { $modelSeoAttributeName = self::behavior($model)->keywordsAttribute; self::registerSeoMetaTag($model, $modelSeoAttributeName, 'keywords'); }
[ "public", "static", "function", "registerMetaKeywords", "(", "Component", "$", "model", ")", "{", "$", "modelSeoAttributeName", "=", "self", "::", "behavior", "(", "$", "model", ")", "->", "keywordsAttribute", ";", "self", "::", "registerSeoMetaTag", "(", "$", ...
Register meta keywords @param Component $model
[ "Register", "meta", "keywords" ]
b4ad117a19ac2400c15eda54bf514c9a2cbf0a14
https://github.com/agilov/yii2-seo-behavior/blob/b4ad117a19ac2400c15eda54bf514c9a2cbf0a14/components/SeoContentHelper.php#L95-L99
train
agilov/yii2-seo-behavior
components/SeoContentHelper.php
SeoContentHelper.registerMetaDescription
public static function registerMetaDescription(Component $model) { $modelSeoAttributeName = self::behavior($model)->descriptionAttribute; self::registerSeoMetaTag($model, $modelSeoAttributeName, 'description'); }
php
public static function registerMetaDescription(Component $model) { $modelSeoAttributeName = self::behavior($model)->descriptionAttribute; self::registerSeoMetaTag($model, $modelSeoAttributeName, 'description'); }
[ "public", "static", "function", "registerMetaDescription", "(", "Component", "$", "model", ")", "{", "$", "modelSeoAttributeName", "=", "self", "::", "behavior", "(", "$", "model", ")", "->", "descriptionAttribute", ";", "self", "::", "registerSeoMetaTag", "(", ...
Register meta description @param Component $model
[ "Register", "meta", "description" ]
b4ad117a19ac2400c15eda54bf514c9a2cbf0a14
https://github.com/agilov/yii2-seo-behavior/blob/b4ad117a19ac2400c15eda54bf514c9a2cbf0a14/components/SeoContentHelper.php#L106-L110
train
brick/std
src/Io/FileStream.php
FileStream.gets
public function gets(?int $maxLength = null) : string { if ($this->closed) { throw new IoException('The stream is closed.'); } try { $data = ErrorCatcher::run(function() use ($maxLength) { if ($maxLength === null) { return fgets($this->handle); } else { return fgets($this->handle, $maxLength + 1); } }); } catch (\ErrorException $e) { throw new IoException($e->getMessage(), 0, $e); } if ($data === false) { return ''; } return $data; }
php
public function gets(?int $maxLength = null) : string { if ($this->closed) { throw new IoException('The stream is closed.'); } try { $data = ErrorCatcher::run(function() use ($maxLength) { if ($maxLength === null) { return fgets($this->handle); } else { return fgets($this->handle, $maxLength + 1); } }); } catch (\ErrorException $e) { throw new IoException($e->getMessage(), 0, $e); } if ($data === false) { return ''; } return $data; }
[ "public", "function", "gets", "(", "?", "int", "$", "maxLength", "=", "null", ")", ":", "string", "{", "if", "(", "$", "this", "->", "closed", ")", "{", "throw", "new", "IoException", "(", "'The stream is closed.'", ")", ";", "}", "try", "{", "$", "d...
Reads a line from the stream. @param int|null $maxLength The max length in bytes to read. If no max length is specified, it will keep reading from the stream until it reaches the end of the line or EOF. @return string The data, or an empty string if there is no more data to read. @throws IoException If an error occurs.
[ "Reads", "a", "line", "from", "the", "stream", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/Io/FileStream.php#L96-L119
train
brick/std
src/Io/FileStream.php
FileStream.lock
public function lock(bool $exclusive) : void { if ($this->closed) { throw new IoException('The stream is closed.'); } try { $result = ErrorCatcher::run(function() use ($exclusive) { return flock($this->handle, $exclusive ? LOCK_EX : LOCK_SH); }); } catch (\ErrorException $e) { throw new IoException($e->getMessage(), 0, $e); } if ($result === false) { throw new IoException('Failed to obtain a lock.'); } }
php
public function lock(bool $exclusive) : void { if ($this->closed) { throw new IoException('The stream is closed.'); } try { $result = ErrorCatcher::run(function() use ($exclusive) { return flock($this->handle, $exclusive ? LOCK_EX : LOCK_SH); }); } catch (\ErrorException $e) { throw new IoException($e->getMessage(), 0, $e); } if ($result === false) { throw new IoException('Failed to obtain a lock.'); } }
[ "public", "function", "lock", "(", "bool", "$", "exclusive", ")", ":", "void", "{", "if", "(", "$", "this", "->", "closed", ")", "{", "throw", "new", "IoException", "(", "'The stream is closed.'", ")", ";", "}", "try", "{", "$", "result", "=", "ErrorCa...
Obtains an advisory lock. @param bool $exclusive @return void @throws IoException If an error occurs.
[ "Obtains", "an", "advisory", "lock", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/Io/FileStream.php#L188-L205
train
brick/std
src/Io/FileStream.php
FileStream.unlock
public function unlock() : void { if ($this->closed) { throw new IoException('The stream is closed.'); } try { $result = ErrorCatcher::run(function() { return flock($this->handle, LOCK_UN); }); } catch (\ErrorException $e) { throw new IoException($e->getMessage(), 0, $e); } if ($result === false) { throw new IoException('Failed to release the lock.'); } }
php
public function unlock() : void { if ($this->closed) { throw new IoException('The stream is closed.'); } try { $result = ErrorCatcher::run(function() { return flock($this->handle, LOCK_UN); }); } catch (\ErrorException $e) { throw new IoException($e->getMessage(), 0, $e); } if ($result === false) { throw new IoException('Failed to release the lock.'); } }
[ "public", "function", "unlock", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "closed", ")", "{", "throw", "new", "IoException", "(", "'The stream is closed.'", ")", ";", "}", "try", "{", "$", "result", "=", "ErrorCatcher", "::", "run", "("...
Releases an advisory lock. @return void @throws IoException
[ "Releases", "an", "advisory", "lock", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/Io/FileStream.php#L214-L231
train
Riimu/Kit-UrlParser
src/Uri.php
Uri.withScheme
public function withScheme($scheme) { $scheme = strtolower($scheme); $pattern = new UriPattern(); if (strlen($scheme) === 0 || $pattern->matchScheme($scheme)) { return $this->with('scheme', $scheme); } throw new \InvalidArgumentException("Invalid scheme '$scheme'"); }
php
public function withScheme($scheme) { $scheme = strtolower($scheme); $pattern = new UriPattern(); if (strlen($scheme) === 0 || $pattern->matchScheme($scheme)) { return $this->with('scheme', $scheme); } throw new \InvalidArgumentException("Invalid scheme '$scheme'"); }
[ "public", "function", "withScheme", "(", "$", "scheme", ")", "{", "$", "scheme", "=", "strtolower", "(", "$", "scheme", ")", ";", "$", "pattern", "=", "new", "UriPattern", "(", ")", ";", "if", "(", "strlen", "(", "$", "scheme", ")", "===", "0", "||...
Returns a URI instance with the specified scheme. This method allows all different kinds of schemes. Note, however, that the different components are only validated based on the generic URI syntax. No additional validation is performed based on the scheme. An empty string can be used to remove the scheme. Note that the provided scheme will be normalized to lowercase. @param string $scheme The scheme to use with the new instance @return static A new instance with the specified scheme @throws \InvalidArgumentException If the scheme is invalid
[ "Returns", "a", "URI", "instance", "with", "the", "specified", "scheme", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/Uri.php#L196-L206
train
Riimu/Kit-UrlParser
src/Uri.php
Uri.withUserInfo
public function withUserInfo($user, $password = null) { $username = rawurlencode($user); if (strlen($username) > 0) { return $this->with('userInfo', $this->constructString([ '%s%s' => $username, '%s:%s' => rawurlencode($password), ])); } return $this->with('userInfo', ''); }
php
public function withUserInfo($user, $password = null) { $username = rawurlencode($user); if (strlen($username) > 0) { return $this->with('userInfo', $this->constructString([ '%s%s' => $username, '%s:%s' => rawurlencode($password), ])); } return $this->with('userInfo', ''); }
[ "public", "function", "withUserInfo", "(", "$", "user", ",", "$", "password", "=", "null", ")", "{", "$", "username", "=", "rawurlencode", "(", "$", "user", ")", ";", "if", "(", "strlen", "(", "$", "username", ")", ">", "0", ")", "{", "return", "$"...
Returns a URI instance with the specified user information. Note that the password is optional, but unless an username is provided, the password will be ignored. Note that this method assumes that neither the username nor the password contains encoded characters. Thus, all encoded characters will be double encoded, if present. An empty username can be used to remove the user information. @param string $user The username to use for the authority component @param string|null $password The password associated with the user @return static A new instance with the specified user information
[ "Returns", "a", "URI", "instance", "with", "the", "specified", "user", "information", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/Uri.php#L221-L233
train
Riimu/Kit-UrlParser
src/Uri.php
Uri.withHost
public function withHost($host) { $pattern = new UriPattern(); if ($pattern->matchHost($host)) { return $this->with('host', $this->normalize(strtolower($host))); } throw new \InvalidArgumentException("Invalid host '$host'"); }
php
public function withHost($host) { $pattern = new UriPattern(); if ($pattern->matchHost($host)) { return $this->with('host', $this->normalize(strtolower($host))); } throw new \InvalidArgumentException("Invalid host '$host'"); }
[ "public", "function", "withHost", "(", "$", "host", ")", "{", "$", "pattern", "=", "new", "UriPattern", "(", ")", ";", "if", "(", "$", "pattern", "->", "matchHost", "(", "$", "host", ")", ")", "{", "return", "$", "this", "->", "with", "(", "'host'"...
Returns a URI instance with the specified host. An empty host can be used to remove the host. Note that since host names are treated in a case insensitive manner, the host will be normalized to lowercase. This method does not support international domain names and hosts with non ascii characters are considered invalid. @param string $host The hostname to use with the new instance @return static A new instance with the specified host @throws \InvalidArgumentException If the hostname is invalid
[ "Returns", "a", "URI", "instance", "with", "the", "specified", "host", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/Uri.php#L247-L256
train
Riimu/Kit-UrlParser
src/Uri.php
Uri.withPort
public function withPort($port) { if ($port !== null) { $port = (int) $port; if (max(0, min(65535, $port)) !== $port) { throw new \InvalidArgumentException("Invalid port number '$port'"); } } return $this->with('port', $port); }
php
public function withPort($port) { if ($port !== null) { $port = (int) $port; if (max(0, min(65535, $port)) !== $port) { throw new \InvalidArgumentException("Invalid port number '$port'"); } } return $this->with('port', $port); }
[ "public", "function", "withPort", "(", "$", "port", ")", "{", "if", "(", "$", "port", "!==", "null", ")", "{", "$", "port", "=", "(", "int", ")", "$", "port", ";", "if", "(", "max", "(", "0", ",", "min", "(", "65535", ",", "$", "port", ")", ...
Returns a URI instance with the specified port. A null value can be used to remove the port number. Note that if an invalid port number is provided (a number less than 0 or more than 65535), an exception will be thrown. @param int|null $port The port to use with the new instance @return static A new instance with the specified port @throws \InvalidArgumentException If the port is invalid
[ "Returns", "a", "URI", "instance", "with", "the", "specified", "port", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/Uri.php#L269-L280
train
Riimu/Kit-UrlParser
src/Uri.php
Uri.with
private function with($variable, $value) { if ($value === $this->$variable) { return $this; } $uri = clone $this; $uri->$variable = $value; return $uri; }
php
private function with($variable, $value) { if ($value === $this->$variable) { return $this; } $uri = clone $this; $uri->$variable = $value; return $uri; }
[ "private", "function", "with", "(", "$", "variable", ",", "$", "value", ")", "{", "if", "(", "$", "value", "===", "$", "this", "->", "$", "variable", ")", "{", "return", "$", "this", ";", "}", "$", "uri", "=", "clone", "$", "this", ";", "$", "u...
Returns an Uri instance with the given value. @param string $variable Name of the variable to change @param mixed $value New value for the variable @return static A new or the same instance depending on if the value changed
[ "Returns", "an", "Uri", "instance", "with", "the", "given", "value", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/Uri.php#L335-L345
train
Riimu/Kit-UrlParser
src/Uri.php
Uri.encode
private function encode($string, $extra = '') { $pattern = sprintf( '/[^0-9a-zA-Z%s]|%%(?![0-9A-F]{2})/', preg_quote("%-._~!$&'()*+,;=" . $extra, '/') ); return preg_replace_callback($pattern, function ($match) { return sprintf('%%%02X', ord($match[0])); }, $this->normalize($string)); }
php
private function encode($string, $extra = '') { $pattern = sprintf( '/[^0-9a-zA-Z%s]|%%(?![0-9A-F]{2})/', preg_quote("%-._~!$&'()*+,;=" . $extra, '/') ); return preg_replace_callback($pattern, function ($match) { return sprintf('%%%02X', ord($match[0])); }, $this->normalize($string)); }
[ "private", "function", "encode", "(", "$", "string", ",", "$", "extra", "=", "''", ")", "{", "$", "pattern", "=", "sprintf", "(", "'/[^0-9a-zA-Z%s]|%%(?![0-9A-F]{2})/'", ",", "preg_quote", "(", "\"%-._~!$&'()*+,;=\"", ".", "$", "extra", ",", "'/'", ")", ")",...
Percent encodes the value without double encoding. @param string $string The value to encode @param string $extra Additional allowed characters in the value @return string The encoded string
[ "Percent", "encodes", "the", "value", "without", "double", "encoding", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/Uri.php#L353-L363
train
Riimu/Kit-UrlParser
src/Uri.php
Uri.constructString
private function constructString(array $components) { $formats = array_keys($components); $values = array_values($components); $keys = array_keys(array_filter($values, 'strlen')); return array_reduce($keys, function ($string, $key) use ($formats, $values) { return sprintf($formats[$key], $string, $values[$key]); }, ''); }
php
private function constructString(array $components) { $formats = array_keys($components); $values = array_values($components); $keys = array_keys(array_filter($values, 'strlen')); return array_reduce($keys, function ($string, $key) use ($formats, $values) { return sprintf($formats[$key], $string, $values[$key]); }, ''); }
[ "private", "function", "constructString", "(", "array", "$", "components", ")", "{", "$", "formats", "=", "array_keys", "(", "$", "components", ")", ";", "$", "values", "=", "array_values", "(", "$", "components", ")", ";", "$", "keys", "=", "array_keys", ...
Constructs the string from the non empty parts with specific formats. @param array $components Associative array of formats and values @return string The constructed string
[ "Constructs", "the", "string", "from", "the", "non", "empty", "parts", "with", "specific", "formats", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/Uri.php#L407-L416
train
Riimu/Kit-UrlParser
src/Uri.php
Uri.getNormalizedUriPath
private function getNormalizedUriPath() { $path = $this->getPath(); if ($this->getAuthority() === '') { return preg_replace('#^/+#', '/', $path); } elseif ($path === '' || $path[0] === '/') { return $path; } return '/' . $path; }
php
private function getNormalizedUriPath() { $path = $this->getPath(); if ($this->getAuthority() === '') { return preg_replace('#^/+#', '/', $path); } elseif ($path === '' || $path[0] === '/') { return $path; } return '/' . $path; }
[ "private", "function", "getNormalizedUriPath", "(", ")", "{", "$", "path", "=", "$", "this", "->", "getPath", "(", ")", ";", "if", "(", "$", "this", "->", "getAuthority", "(", ")", "===", "''", ")", "{", "return", "preg_replace", "(", "'#^/+#'", ",", ...
Returns the path normalized for the string representation. @return string The normalized path for the string representation
[ "Returns", "the", "path", "normalized", "for", "the", "string", "representation", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/Uri.php#L422-L433
train
tastphp/framework
src/Framework/Cache/RedisCacheService.php
RedisCacheService.hGet
public function hGet($hashKey, $key) { $value = $this->redis->hGet($hashKey, $key); if ($value) { $value = gzinflate($value); } $jsonData = json_decode($value, true); return ($jsonData === NULL) ? $value : $jsonData; }
php
public function hGet($hashKey, $key) { $value = $this->redis->hGet($hashKey, $key); if ($value) { $value = gzinflate($value); } $jsonData = json_decode($value, true); return ($jsonData === NULL) ? $value : $jsonData; }
[ "public", "function", "hGet", "(", "$", "hashKey", ",", "$", "key", ")", "{", "$", "value", "=", "$", "this", "->", "redis", "->", "hGet", "(", "$", "hashKey", ",", "$", "key", ")", ";", "if", "(", "$", "value", ")", "{", "$", "value", "=", "...
get hash cache @param hashKey @param key @return string|array|false
[ "get", "hash", "cache" ]
c706fb4cc2918f4c56bfb67616cb95a4c0db270e
https://github.com/tastphp/framework/blob/c706fb4cc2918f4c56bfb67616cb95a4c0db270e/src/Framework/Cache/RedisCacheService.php#L66-L75
train
tastphp/framework
src/Framework/Cache/RedisCacheService.php
RedisCacheService.hSet
public function hSet($hashKey, $key, $data, $expireTime = 3600) { $data = (is_object($data) || is_array($data)) ? json_encode($data) : $data; $data = gzdeflate($data, 0); if (strlen($data) > 4096) { $data = gzdeflate($data, 6); } $status = $this->redis->hSet($hashKey, $key, $data); $this->redis->expire($hashKey, $expireTime); return $status; }
php
public function hSet($hashKey, $key, $data, $expireTime = 3600) { $data = (is_object($data) || is_array($data)) ? json_encode($data) : $data; $data = gzdeflate($data, 0); if (strlen($data) > 4096) { $data = gzdeflate($data, 6); } $status = $this->redis->hSet($hashKey, $key, $data); $this->redis->expire($hashKey, $expireTime); return $status; }
[ "public", "function", "hSet", "(", "$", "hashKey", ",", "$", "key", ",", "$", "data", ",", "$", "expireTime", "=", "3600", ")", "{", "$", "data", "=", "(", "is_object", "(", "$", "data", ")", "||", "is_array", "(", "$", "data", ")", ")", "?", "...
set hash cache @param hashKey @param key @param data @param expireTime (int) @return int
[ "set", "hash", "cache" ]
c706fb4cc2918f4c56bfb67616cb95a4c0db270e
https://github.com/tastphp/framework/blob/c706fb4cc2918f4c56bfb67616cb95a4c0db270e/src/Framework/Cache/RedisCacheService.php#L86-L101
train
inphinit/framework
src/Experimental/Http/Negotiation.php
Negotiation.header
public function header($header, $level = self::HIGH) { $header = strtolower($header); if (empty($this->headers[$header])) { return false; } return self::qFactor($this->headers[$header], $level); }
php
public function header($header, $level = self::HIGH) { $header = strtolower($header); if (empty($this->headers[$header])) { return false; } return self::qFactor($this->headers[$header], $level); }
[ "public", "function", "header", "(", "$", "header", ",", "$", "level", "=", "self", "::", "HIGH", ")", "{", "$", "header", "=", "strtolower", "(", "$", "header", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "headers", "[", "$", "header", ...
Parse any header like `TE` header or headers with `Accepet-` prefix @param string $header @param int $level @throws \Inphinit\Experimental\Exception @return array|bool
[ "Parse", "any", "header", "like", "TE", "header", "or", "headers", "with", "Accepet", "-", "prefix" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Experimental/Http/Negotiation.php#L162-L171
train
inphinit/framework
src/Experimental/Http/Negotiation.php
Negotiation.qFactor
public static function qFactor($value, $level = self::HIGH) { $multivalues = explode(',', $value); $headers = array(); foreach ($multivalues as $hvalues) { if (substr_count($hvalues, ';') > 1) { throw new Exception('Header contains a value with multiple semicolons: "' . $value . '"', 2); } $current = explode(';', $hvalues, 2); if (empty($current[1])) { $qvalue = 1.0; } else { $qvalue = self::parseQValue($current[1]); } $headers[ trim($current[0]) ] = $qvalue; } $multivalues = null; if ($level === self::ALL) { return array_keys($headers); } if ($level === self::LOW) { asort($headers, SORT_NUMERIC); } else { arsort($headers, SORT_NUMERIC); } return $headers; }
php
public static function qFactor($value, $level = self::HIGH) { $multivalues = explode(',', $value); $headers = array(); foreach ($multivalues as $hvalues) { if (substr_count($hvalues, ';') > 1) { throw new Exception('Header contains a value with multiple semicolons: "' . $value . '"', 2); } $current = explode(';', $hvalues, 2); if (empty($current[1])) { $qvalue = 1.0; } else { $qvalue = self::parseQValue($current[1]); } $headers[ trim($current[0]) ] = $qvalue; } $multivalues = null; if ($level === self::ALL) { return array_keys($headers); } if ($level === self::LOW) { asort($headers, SORT_NUMERIC); } else { arsort($headers, SORT_NUMERIC); } return $headers; }
[ "public", "static", "function", "qFactor", "(", "$", "value", ",", "$", "level", "=", "self", "::", "HIGH", ")", "{", "$", "multivalues", "=", "explode", "(", "','", ",", "$", "value", ")", ";", "$", "headers", "=", "array", "(", ")", ";", "foreach...
Parse and sort a custom value with q-factor @param string $value @param int $level @throws \Inphinit\Experimental\Exception @return array
[ "Parse", "and", "sort", "a", "custom", "value", "with", "q", "-", "factor" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Experimental/Http/Negotiation.php#L181-L215
train
romainbessugesmeusy/php-sql-query
lib/RBM/SqlQuery/Select.php
Select.joinCondition
public function joinCondition() { if (!isset($this->_joinCondition)) { $this->_joinCondition = Factory::filter($this); } return $this->_joinCondition; }
php
public function joinCondition() { if (!isset($this->_joinCondition)) { $this->_joinCondition = Factory::filter($this); } return $this->_joinCondition; }
[ "public", "function", "joinCondition", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_joinCondition", ")", ")", "{", "$", "this", "->", "_joinCondition", "=", "Factory", "::", "filter", "(", "$", "this", ")", ";", "}", "return", "$...
The filter used for the ON clause of a JOIN @return Filter
[ "The", "filter", "used", "for", "the", "ON", "clause", "of", "a", "JOIN" ]
9c94bc38b1031b0358d9f3a4bc35cbe076d4581b
https://github.com/romainbessugesmeusy/php-sql-query/blob/9c94bc38b1031b0358d9f3a4bc35cbe076d4581b/lib/RBM/SqlQuery/Select.php#L192-L198
train
inphinit/framework
src/Experimental/File.php
File.portion
public static function portion($path, $init = 0, $end = 1024, $lines = false) { self::fullpath($path); if ($lines !== true) { return file_get_contents($path, false, null, $init, $end); } $i = 1; $output = ''; $handle = fopen($path, 'rb'); while (false === feof($handle) && $i <= $end) { $data = fgets($handle); if ($i >= $init) { $output .= $data; } ++$i; } fclose($handle); return $output; }
php
public static function portion($path, $init = 0, $end = 1024, $lines = false) { self::fullpath($path); if ($lines !== true) { return file_get_contents($path, false, null, $init, $end); } $i = 1; $output = ''; $handle = fopen($path, 'rb'); while (false === feof($handle) && $i <= $end) { $data = fgets($handle); if ($i >= $init) { $output .= $data; } ++$i; } fclose($handle); return $output; }
[ "public", "static", "function", "portion", "(", "$", "path", ",", "$", "init", "=", "0", ",", "$", "end", "=", "1024", ",", "$", "lines", "=", "false", ")", "{", "self", "::", "fullpath", "(", "$", "path", ")", ";", "if", "(", "$", "lines", "!=...
Read a script excerpt @param string $path @param int $init @param int $end @param bool $lines @throws \Inphinit\Experimental\Exception @return string
[ "Read", "a", "script", "excerpt" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Experimental/File.php#L24-L50
train
inphinit/framework
src/Experimental/File.php
File.isBinary
public static function isBinary($path) { self::fullpath($path); $size = filesize($path); if ($size >= 0 && $size < 2) { return false; } $finfo = finfo_open(FILEINFO_MIME_ENCODING); $encode = finfo_buffer($finfo, file_get_contents($path, false, null, 0, 5012)); finfo_close($finfo); return strcasecmp($encode, 'binary') === 0; }
php
public static function isBinary($path) { self::fullpath($path); $size = filesize($path); if ($size >= 0 && $size < 2) { return false; } $finfo = finfo_open(FILEINFO_MIME_ENCODING); $encode = finfo_buffer($finfo, file_get_contents($path, false, null, 0, 5012)); finfo_close($finfo); return strcasecmp($encode, 'binary') === 0; }
[ "public", "static", "function", "isBinary", "(", "$", "path", ")", "{", "self", "::", "fullpath", "(", "$", "path", ")", ";", "$", "size", "=", "filesize", "(", "$", "path", ")", ";", "if", "(", "$", "size", ">=", "0", "&&", "$", "size", "<", "...
Determines whether the file is binary @param string $path @throws \Inphinit\Experimental\Exception @return bool
[ "Determines", "whether", "the", "file", "is", "binary" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Experimental/File.php#L59-L74
train
inphinit/framework
src/Experimental/File.php
File.size
public static function size($path) { $path = ltrim(self::fullpath($path), '/'); $ch = curl_init('file://' . $path); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); $headers = curl_exec($ch); curl_close($ch); $ch = null; if (preg_match('#content-length:(\s+?|)(\d+)#i', $headers, $matches)) { return $matches[2]; } return false; }
php
public static function size($path) { $path = ltrim(self::fullpath($path), '/'); $ch = curl_init('file://' . $path); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); $headers = curl_exec($ch); curl_close($ch); $ch = null; if (preg_match('#content-length:(\s+?|)(\d+)#i', $headers, $matches)) { return $matches[2]; } return false; }
[ "public", "static", "function", "size", "(", "$", "path", ")", "{", "$", "path", "=", "ltrim", "(", "self", "::", "fullpath", "(", "$", "path", ")", ",", "'/'", ")", ";", "$", "ch", "=", "curl_init", "(", "'file://'", ".", "$", "path", ")", ";", ...
Get file size, support for read files with more of 2GB in 32bit. Return `false` if file is not found @param string $path @throws \Inphinit\Experimental\Exception @return string|bool
[ "Get", "file", "size", "support", "for", "read", "files", "with", "more", "of", "2GB", "in", "32bit", ".", "Return", "false", "if", "file", "is", "not", "found" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Experimental/File.php#L84-L104
train
inphinit/framework
src/Experimental/Dom/Selector.php
Selector.get
public function get($selector, \DOMNode $context = null, $registerNodeNS = true) { return $this->exec('query', $selector, $context, $registerNodeNS); }
php
public function get($selector, \DOMNode $context = null, $registerNodeNS = true) { return $this->exec('query', $selector, $context, $registerNodeNS); }
[ "public", "function", "get", "(", "$", "selector", ",", "\\", "DOMNode", "$", "context", "=", "null", ",", "$", "registerNodeNS", "=", "true", ")", "{", "return", "$", "this", "->", "exec", "(", "'query'", ",", "$", "selector", ",", "$", "context", "...
Returns a \DOMNodeList containing all nodes matching the given CSS selector @param string $selector @param \DOMNode $context @param bool $registerNodeNS @return \DOMNodeList
[ "Returns", "a", "\\", "DOMNodeList", "containing", "all", "nodes", "matching", "the", "given", "CSS", "selector" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Experimental/Dom/Selector.php#L70-L73
train
Calendart/CalendArt
src/AbstractEvent.php
AbstractEvent.isRunning
public function isRunning(Datetime $current = null) { $current = $current ?: new Datetime; return $this->hasStarted($current) && !$this->hasEnded($current); }
php
public function isRunning(Datetime $current = null) { $current = $current ?: new Datetime; return $this->hasStarted($current) && !$this->hasEnded($current); }
[ "public", "function", "isRunning", "(", "Datetime", "$", "current", "=", "null", ")", "{", "$", "current", "=", "$", "current", "?", ":", "new", "Datetime", ";", "return", "$", "this", "->", "hasStarted", "(", "$", "current", ")", "&&", "!", "$", "th...
Checks if this event is currently running @return Boolean
[ "Checks", "if", "this", "event", "is", "currently", "running" ]
46a6642c49b1dee345f6bbe86a6318d73615e954
https://github.com/Calendart/CalendArt/blob/46a6642c49b1dee345f6bbe86a6318d73615e954/src/AbstractEvent.php#L167-L172
train
Calendart/CalendArt
src/AbstractEvent.php
AbstractEvent.detach
public function detach() { $this->calendar->getEvents()->removeEvent($this); $this->calendar = null; return $this; }
php
public function detach() { $this->calendar->getEvents()->removeEvent($this); $this->calendar = null; return $this; }
[ "public", "function", "detach", "(", ")", "{", "$", "this", "->", "calendar", "->", "getEvents", "(", ")", "->", "removeEvent", "(", "$", "this", ")", ";", "$", "this", "->", "calendar", "=", "null", ";", "return", "$", "this", ";", "}" ]
Detach this event from the associated Calendar @return $this
[ "Detach", "this", "event", "from", "the", "associated", "Calendar" ]
46a6642c49b1dee345f6bbe86a6318d73615e954
https://github.com/Calendart/CalendArt/blob/46a6642c49b1dee345f6bbe86a6318d73615e954/src/AbstractEvent.php#L185-L191
train
civicrm/civicrm-cxn-rpc
src/DefaultCertificateValidator.php
DefaultCertificateValidator.validateCert
public function validateCert($certPem) { if ($this->getCaCert()) { self::validate($certPem, $this->getCaCert(), $this->getCrl(), $this->getCrlDistCert()); } }
php
public function validateCert($certPem) { if ($this->getCaCert()) { self::validate($certPem, $this->getCaCert(), $this->getCrl(), $this->getCrlDistCert()); } }
[ "public", "function", "validateCert", "(", "$", "certPem", ")", "{", "if", "(", "$", "this", "->", "getCaCert", "(", ")", ")", "{", "self", "::", "validate", "(", "$", "certPem", ",", "$", "this", "->", "getCaCert", "(", ")", ",", "$", "this", "->"...
Determine whether an X.509 certificate is currently valid. @param string $certPem PEM-encoded certificate. @throws InvalidCertException Invalid certificates are reported as exceptions.
[ "Determine", "whether", "an", "X", ".", "509", "certificate", "is", "currently", "valid", "." ]
5a142bc4d24b7f8c830f59768b405ec74d582f22
https://github.com/civicrm/civicrm-cxn-rpc/blob/5a142bc4d24b7f8c830f59768b405ec74d582f22/src/DefaultCertificateValidator.php#L100-L104
train
civicrm/civicrm-cxn-rpc
src/DefaultCertificateValidator.php
DefaultCertificateValidator.getCrlUrl
public function getCrlUrl() { if ($this->crlUrl === self::AUTOLOAD) { $this->crlUrl = NULL; // Default if we can't find something else. $caCertObj = X509Util::loadCACert($this->getCaCert()); // There can be multiple DPs, but in practice CiviRootCA only has one. $crlDPs = $caCertObj->getExtension('id-ce-cRLDistributionPoints'); if (is_array($crlDPs)) { foreach ($crlDPs as $crlDP) { foreach ($crlDP['distributionPoint']['fullName'] as $fullName) { if (isset($fullName['uniformResourceIdentifier'])) { $this->crlUrl = $fullName['uniformResourceIdentifier']; break 2; } } } } } return $this->crlUrl; }
php
public function getCrlUrl() { if ($this->crlUrl === self::AUTOLOAD) { $this->crlUrl = NULL; // Default if we can't find something else. $caCertObj = X509Util::loadCACert($this->getCaCert()); // There can be multiple DPs, but in practice CiviRootCA only has one. $crlDPs = $caCertObj->getExtension('id-ce-cRLDistributionPoints'); if (is_array($crlDPs)) { foreach ($crlDPs as $crlDP) { foreach ($crlDP['distributionPoint']['fullName'] as $fullName) { if (isset($fullName['uniformResourceIdentifier'])) { $this->crlUrl = $fullName['uniformResourceIdentifier']; break 2; } } } } } return $this->crlUrl; }
[ "public", "function", "getCrlUrl", "(", ")", "{", "if", "(", "$", "this", "->", "crlUrl", "===", "self", "::", "AUTOLOAD", ")", "{", "$", "this", "->", "crlUrl", "=", "NULL", ";", "// Default if we can't find something else.", "$", "caCertObj", "=", "X509Uti...
Determine the CRL URL which corresponds to this CA.
[ "Determine", "the", "CRL", "URL", "which", "corresponds", "to", "this", "CA", "." ]
5a142bc4d24b7f8c830f59768b405ec74d582f22
https://github.com/civicrm/civicrm-cxn-rpc/blob/5a142bc4d24b7f8c830f59768b405ec74d582f22/src/DefaultCertificateValidator.php#L181-L199
train
Riimu/Kit-UrlParser
src/UriPattern.php
UriPattern.matchUri
public function matchUri($uri, & $matches = []) { if ($this->matchAbsoluteUri($uri, $matches)) { return true; } return $this->matchRelativeUri($uri, $matches); }
php
public function matchUri($uri, & $matches = []) { if ($this->matchAbsoluteUri($uri, $matches)) { return true; } return $this->matchRelativeUri($uri, $matches); }
[ "public", "function", "matchUri", "(", "$", "uri", ",", "&", "$", "matches", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "matchAbsoluteUri", "(", "$", "uri", ",", "$", "matches", ")", ")", "{", "return", "true", ";", "}", "return", "$"...
Matches the string against URI or relative-ref ABNF. @param string $uri The string to match @param array $matches Provides the matched sub sections from the match @return bool True if the URI matches, false if not
[ "Matches", "the", "string", "against", "URI", "or", "relative", "-", "ref", "ABNF", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/UriPattern.php#L61-L68
train
Riimu/Kit-UrlParser
src/UriPattern.php
UriPattern.match
private function match($pattern, $subject, & $matches) { $matches = []; $subject = (string) $subject; if ($this->allowNonAscii || preg_match('/^[\\x00-\\x7F]*$/', $subject)) { if (preg_match($pattern, $subject, $match)) { $matches = $this->getNamedPatterns($match); return true; } } return false; }
php
private function match($pattern, $subject, & $matches) { $matches = []; $subject = (string) $subject; if ($this->allowNonAscii || preg_match('/^[\\x00-\\x7F]*$/', $subject)) { if (preg_match($pattern, $subject, $match)) { $matches = $this->getNamedPatterns($match); return true; } } return false; }
[ "private", "function", "match", "(", "$", "pattern", ",", "$", "subject", ",", "&", "$", "matches", ")", "{", "$", "matches", "=", "[", "]", ";", "$", "subject", "=", "(", "string", ")", "$", "subject", ";", "if", "(", "$", "this", "->", "allowNo...
Matches the subject against the pattern and provides the literal sub patterns. @param string $pattern The pattern to use for matching @param string $subject The subject to match @param array $matches The provided list of literal sub patterns @return bool True if the pattern matches, false if not
[ "Matches", "the", "subject", "against", "the", "pattern", "and", "provides", "the", "literal", "sub", "patterns", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/UriPattern.php#L121-L135
train
Riimu/Kit-UrlParser
src/UriPattern.php
UriPattern.getNamedPatterns
private function getNamedPatterns($matches) { foreach ($matches as $key => $value) { if (!is_string($key) || strlen($value) < 1) { unset($matches[$key]); } } return $matches; }
php
private function getNamedPatterns($matches) { foreach ($matches as $key => $value) { if (!is_string($key) || strlen($value) < 1) { unset($matches[$key]); } } return $matches; }
[ "private", "function", "getNamedPatterns", "(", "$", "matches", ")", "{", "foreach", "(", "$", "matches", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", "||", "strlen", "(", "$", "value", ")", "<"...
Returns nonempty named sub patterns from the match set. @param array $matches Sub pattern matches @return array<string,string> Nonempty named sub pattern matches
[ "Returns", "nonempty", "named", "sub", "patterns", "from", "the", "match", "set", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/UriPattern.php#L142-L151
train
Riimu/Kit-UrlParser
src/UriPattern.php
UriPattern.buildPatterns
private static function buildPatterns() { $alpha = 'A-Za-z'; $digit = '0-9'; $hex = $digit . 'A-Fa-f'; $unreserved = "$alpha$digit\\-._~"; $delimiters = "!$&'()*+,;="; $utf8 = '\\x80-\\xFF'; $octet = "(?:[$digit]|[1-9][$digit]|1[$digit]{2}|2[0-4]$digit|25[0-5])"; $ipv4address = "(?>$octet\\.$octet\\.$octet\\.$octet)"; $encoded = "%[$hex]{2}"; $h16 = "[$hex]{1,4}"; $ls32 = "(?:$h16:$h16|$ipv4address)"; $data = "[$unreserved$delimiters:@$utf8]++|$encoded"; // Defining the scheme $scheme = "(?'scheme'(?>[$alpha][$alpha$digit+\\-.]*+))"; // Defining the authority $ipv6address = "(?'IPv6address'" . "(?:(?:$h16:){6}$ls32)|" . "(?:::(?:$h16:){5}$ls32)|" . "(?:(?:$h16)?::(?:$h16:){4}$ls32)|" . "(?:(?:(?:$h16:){0,1}$h16)?::(?:$h16:){3}$ls32)|" . "(?:(?:(?:$h16:){0,2}$h16)?::(?:$h16:){2}$ls32)|" . "(?:(?:(?:$h16:){0,3}$h16)?::$h16:$ls32)|" . "(?:(?:(?:$h16:){0,4}$h16)?::$ls32)|" . "(?:(?:(?:$h16:){0,5}$h16)?::$h16)|" . "(?:(?:(?:$h16:){0,6}$h16)?::))"; $regularName = "(?'reg_name'(?>(?:[$unreserved$delimiters$utf8]++|$encoded)*))"; $ipvFuture = "(?'IPvFuture'v[$hex]++\\.[$unreserved$delimiters:]++)"; $ipLiteral = "(?'IP_literal'\\[(?>$ipv6address|$ipvFuture)\\])"; $port = "(?'port'(?>[$digit]*+))"; $host = "(?'host'$ipLiteral|(?'IPv4address'$ipv4address)|$regularName)"; $userInfo = "(?'userinfo'(?>(?:[$unreserved$delimiters:$utf8]++|$encoded)*))"; $authority = "(?'authority'(?:$userInfo@)?$host(?::$port)?)"; // Defining the path $segment = "(?>(?:$data)*)"; $segmentNotEmpty = "(?>(?:$data)+)"; $segmentNoScheme = "(?>([$unreserved$delimiters@$utf8]++|$encoded)+)"; $pathAbsoluteEmpty = "(?'path_abempty'(?:/$segment)*)"; $pathAbsolute = "(?'path_absolute'/(?:$segmentNotEmpty(?:/$segment)*)?)"; $pathNoScheme = "(?'path_noscheme'$segmentNoScheme(?:/$segment)*)"; $pathRootless = "(?'path_rootless'$segmentNotEmpty(?:/$segment)*)"; $pathEmpty = "(?'path_empty')"; // Defining other parts $query = "(?'query'(?>(?:$data|[/?])*))"; $fragment = "(?'fragment'(?>(?:$data|[/?])*))"; $absolutePath = "(?'hier_part'//$authority$pathAbsoluteEmpty|$pathAbsolute|$pathRootless|$pathEmpty)"; $relativePath = "(?'relative_part'//$authority$pathAbsoluteEmpty|$pathAbsolute|$pathNoScheme|$pathEmpty)"; self::$absoluteUri = "#^$scheme:$absolutePath(?:\\?$query)?(?:\\#$fragment)?$#"; self::$relativeUri = "#^$relativePath(?:\\?$query)?(?:\\#$fragment)?$#"; self::$scheme = "#^$scheme$#"; self::$host = "#^$host$#"; }
php
private static function buildPatterns() { $alpha = 'A-Za-z'; $digit = '0-9'; $hex = $digit . 'A-Fa-f'; $unreserved = "$alpha$digit\\-._~"; $delimiters = "!$&'()*+,;="; $utf8 = '\\x80-\\xFF'; $octet = "(?:[$digit]|[1-9][$digit]|1[$digit]{2}|2[0-4]$digit|25[0-5])"; $ipv4address = "(?>$octet\\.$octet\\.$octet\\.$octet)"; $encoded = "%[$hex]{2}"; $h16 = "[$hex]{1,4}"; $ls32 = "(?:$h16:$h16|$ipv4address)"; $data = "[$unreserved$delimiters:@$utf8]++|$encoded"; // Defining the scheme $scheme = "(?'scheme'(?>[$alpha][$alpha$digit+\\-.]*+))"; // Defining the authority $ipv6address = "(?'IPv6address'" . "(?:(?:$h16:){6}$ls32)|" . "(?:::(?:$h16:){5}$ls32)|" . "(?:(?:$h16)?::(?:$h16:){4}$ls32)|" . "(?:(?:(?:$h16:){0,1}$h16)?::(?:$h16:){3}$ls32)|" . "(?:(?:(?:$h16:){0,2}$h16)?::(?:$h16:){2}$ls32)|" . "(?:(?:(?:$h16:){0,3}$h16)?::$h16:$ls32)|" . "(?:(?:(?:$h16:){0,4}$h16)?::$ls32)|" . "(?:(?:(?:$h16:){0,5}$h16)?::$h16)|" . "(?:(?:(?:$h16:){0,6}$h16)?::))"; $regularName = "(?'reg_name'(?>(?:[$unreserved$delimiters$utf8]++|$encoded)*))"; $ipvFuture = "(?'IPvFuture'v[$hex]++\\.[$unreserved$delimiters:]++)"; $ipLiteral = "(?'IP_literal'\\[(?>$ipv6address|$ipvFuture)\\])"; $port = "(?'port'(?>[$digit]*+))"; $host = "(?'host'$ipLiteral|(?'IPv4address'$ipv4address)|$regularName)"; $userInfo = "(?'userinfo'(?>(?:[$unreserved$delimiters:$utf8]++|$encoded)*))"; $authority = "(?'authority'(?:$userInfo@)?$host(?::$port)?)"; // Defining the path $segment = "(?>(?:$data)*)"; $segmentNotEmpty = "(?>(?:$data)+)"; $segmentNoScheme = "(?>([$unreserved$delimiters@$utf8]++|$encoded)+)"; $pathAbsoluteEmpty = "(?'path_abempty'(?:/$segment)*)"; $pathAbsolute = "(?'path_absolute'/(?:$segmentNotEmpty(?:/$segment)*)?)"; $pathNoScheme = "(?'path_noscheme'$segmentNoScheme(?:/$segment)*)"; $pathRootless = "(?'path_rootless'$segmentNotEmpty(?:/$segment)*)"; $pathEmpty = "(?'path_empty')"; // Defining other parts $query = "(?'query'(?>(?:$data|[/?])*))"; $fragment = "(?'fragment'(?>(?:$data|[/?])*))"; $absolutePath = "(?'hier_part'//$authority$pathAbsoluteEmpty|$pathAbsolute|$pathRootless|$pathEmpty)"; $relativePath = "(?'relative_part'//$authority$pathAbsoluteEmpty|$pathAbsolute|$pathNoScheme|$pathEmpty)"; self::$absoluteUri = "#^$scheme:$absolutePath(?:\\?$query)?(?:\\#$fragment)?$#"; self::$relativeUri = "#^$relativePath(?:\\?$query)?(?:\\#$fragment)?$#"; self::$scheme = "#^$scheme$#"; self::$host = "#^$host$#"; }
[ "private", "static", "function", "buildPatterns", "(", ")", "{", "$", "alpha", "=", "'A-Za-z'", ";", "$", "digit", "=", "'0-9'", ";", "$", "hex", "=", "$", "digit", ".", "'A-Fa-f'", ";", "$", "unreserved", "=", "\"$alpha$digit\\\\-._~\"", ";", "$", "deli...
Builds the PCRE patterns according to the ABNF definitions.
[ "Builds", "the", "PCRE", "patterns", "according", "to", "the", "ABNF", "definitions", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/UriPattern.php#L156-L221
train
brick/std
src/Io/FileSystem.php
FileSystem.createDirectories
public static function createDirectories(string $path, int $mode = 0777) : void { $exception = null; try { $success = ErrorCatcher::run(static function() use ($path, $mode) { return mkdir($path, $mode, true); }); if ($success === true) { return; } } catch (\ErrorException $e) { $exception = $e; } if (self::isDirectory($path)) { return; } throw new IoException('Error creating directories ' . $path, 0, $exception); }
php
public static function createDirectories(string $path, int $mode = 0777) : void { $exception = null; try { $success = ErrorCatcher::run(static function() use ($path, $mode) { return mkdir($path, $mode, true); }); if ($success === true) { return; } } catch (\ErrorException $e) { $exception = $e; } if (self::isDirectory($path)) { return; } throw new IoException('Error creating directories ' . $path, 0, $exception); }
[ "public", "static", "function", "createDirectories", "(", "string", "$", "path", ",", "int", "$", "mode", "=", "0777", ")", ":", "void", "{", "$", "exception", "=", "null", ";", "try", "{", "$", "success", "=", "ErrorCatcher", "::", "run", "(", "static...
Creates a directory by creating all nonexistent parent directories first. Unlike the `createDirectory` method, an exception is not thrown if the directory could not be created because it already exists. @param string $path The directory path. @param int $mode The access mode. The mode is 0777 by default, which means the widest possible access. @return void @throws IoException If an error occurs.
[ "Creates", "a", "directory", "by", "creating", "all", "nonexistent", "parent", "directories", "first", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/Io/FileSystem.php#L153-L174
train
brick/std
src/Io/FileSystem.php
FileSystem.isFile
public static function isFile(string $path) : bool { try { return ErrorCatcher::run(static function() use ($path) { return is_file($path); }); } catch (\ErrorException $e) { throw new IoException('Error checking if ' . $path . ' is a file', 0, $e); } }
php
public static function isFile(string $path) : bool { try { return ErrorCatcher::run(static function() use ($path) { return is_file($path); }); } catch (\ErrorException $e) { throw new IoException('Error checking if ' . $path . ' is a file', 0, $e); } }
[ "public", "static", "function", "isFile", "(", "string", "$", "path", ")", ":", "bool", "{", "try", "{", "return", "ErrorCatcher", "::", "run", "(", "static", "function", "(", ")", "use", "(", "$", "path", ")", "{", "return", "is_file", "(", "$", "pa...
Checks whether the path points to a regular file. @param string $path The file path path. @return bool @throws IoException If an error occurs.
[ "Checks", "whether", "the", "path", "points", "to", "a", "regular", "file", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/Io/FileSystem.php#L205-L214
train
brick/std
src/Io/FileSystem.php
FileSystem.isDirectory
public static function isDirectory(string $path) : bool { try { return ErrorCatcher::run(static function() use ($path) { return is_dir($path); }); } catch (\ErrorException $e) { throw new IoException('Error checking if ' . $path . ' is a directory', 0, $e); } }
php
public static function isDirectory(string $path) : bool { try { return ErrorCatcher::run(static function() use ($path) { return is_dir($path); }); } catch (\ErrorException $e) { throw new IoException('Error checking if ' . $path . ' is a directory', 0, $e); } }
[ "public", "static", "function", "isDirectory", "(", "string", "$", "path", ")", ":", "bool", "{", "try", "{", "return", "ErrorCatcher", "::", "run", "(", "static", "function", "(", ")", "use", "(", "$", "path", ")", "{", "return", "is_dir", "(", "$", ...
Checks whether the path points to a directory. @param string $path The file path. @return bool @throws IoException If an error occurs.
[ "Checks", "whether", "the", "path", "points", "to", "a", "directory", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/Io/FileSystem.php#L225-L234
train
brick/std
src/Io/FileSystem.php
FileSystem.isSymbolicLink
public static function isSymbolicLink(string $path) : bool { try { return ErrorCatcher::run(static function() use ($path) { return is_link($path); }); } catch (\ErrorException $e) { throw new IoException('Error checking if ' . $path . ' is a symbolic link', 0, $e); } }
php
public static function isSymbolicLink(string $path) : bool { try { return ErrorCatcher::run(static function() use ($path) { return is_link($path); }); } catch (\ErrorException $e) { throw new IoException('Error checking if ' . $path . ' is a symbolic link', 0, $e); } }
[ "public", "static", "function", "isSymbolicLink", "(", "string", "$", "path", ")", ":", "bool", "{", "try", "{", "return", "ErrorCatcher", "::", "run", "(", "static", "function", "(", ")", "use", "(", "$", "path", ")", "{", "return", "is_link", "(", "$...
Checks whether the path points to a symbolic link. @param string $path The file path. @return bool @throws IoException If an error occurs.
[ "Checks", "whether", "the", "path", "points", "to", "a", "symbolic", "link", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/Io/FileSystem.php#L245-L254
train
brick/std
src/Io/FileSystem.php
FileSystem.createSymbolicLink
public static function createSymbolicLink(string $link, string $target) : void { $exception = null; try { $success = ErrorCatcher::run(static function() use ($link, $target) { return symlink($target, $link); }); if ($success === true) { return; } } catch (\ErrorException $e) { $exception = $e; } throw new IoException('Error creating symbolic link ' . $link . ' to ' . $target, 0, $exception); }
php
public static function createSymbolicLink(string $link, string $target) : void { $exception = null; try { $success = ErrorCatcher::run(static function() use ($link, $target) { return symlink($target, $link); }); if ($success === true) { return; } } catch (\ErrorException $e) { $exception = $e; } throw new IoException('Error creating symbolic link ' . $link . ' to ' . $target, 0, $exception); }
[ "public", "static", "function", "createSymbolicLink", "(", "string", "$", "link", ",", "string", "$", "target", ")", ":", "void", "{", "$", "exception", "=", "null", ";", "try", "{", "$", "success", "=", "ErrorCatcher", "::", "run", "(", "static", "funct...
Creates a symbolic link to a target. @param string $link The path of the symbolic link to create. @param string $target The target of the symbolic link. @return void @throws IoException If an error occurs.
[ "Creates", "a", "symbolic", "link", "to", "a", "target", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/Io/FileSystem.php#L266-L283
train
brick/std
src/Io/FileSystem.php
FileSystem.readSymbolicLink
public static function readSymbolicLink(string $path) : string { $exception = null; try { $result = ErrorCatcher::run(static function() use ($path) { return readlink($path); }); if ($result !== false) { return $result; } } catch (\ErrorException $e) { $exception = $e; } throw new IoException('Error reading symbolic link ' . $path, 0, $exception); }
php
public static function readSymbolicLink(string $path) : string { $exception = null; try { $result = ErrorCatcher::run(static function() use ($path) { return readlink($path); }); if ($result !== false) { return $result; } } catch (\ErrorException $e) { $exception = $e; } throw new IoException('Error reading symbolic link ' . $path, 0, $exception); }
[ "public", "static", "function", "readSymbolicLink", "(", "string", "$", "path", ")", ":", "string", "{", "$", "exception", "=", "null", ";", "try", "{", "$", "result", "=", "ErrorCatcher", "::", "run", "(", "static", "function", "(", ")", "use", "(", "...
Returns the target of a symbolic link. @param string $path The symbolic link path. @return string The contents of the symbolic link path. @throws IoException If an error occurs.
[ "Returns", "the", "target", "of", "a", "symbolic", "link", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/Io/FileSystem.php#L323-L340
train
brick/std
src/Io/FileSystem.php
FileSystem.getRealPath
public static function getRealPath(string $path) : string { $exception = null; try { $result = ErrorCatcher::run(static function() use ($path) { return realpath($path); }); if ($result !== false) { return $result; } } catch (\ErrorException $e) { $exception = $e; } throw new IoException('Error getting real path of ' . $path . ', check that the path exists', 0, $exception); }
php
public static function getRealPath(string $path) : string { $exception = null; try { $result = ErrorCatcher::run(static function() use ($path) { return realpath($path); }); if ($result !== false) { return $result; } } catch (\ErrorException $e) { $exception = $e; } throw new IoException('Error getting real path of ' . $path . ', check that the path exists', 0, $exception); }
[ "public", "static", "function", "getRealPath", "(", "string", "$", "path", ")", ":", "string", "{", "$", "exception", "=", "null", ";", "try", "{", "$", "result", "=", "ErrorCatcher", "::", "run", "(", "static", "function", "(", ")", "use", "(", "$", ...
Returns the canonicalized absolute pathname. @param string $path The path. @return string The canonicalized absolute pathname. @throws IoException If an error occurs.
[ "Returns", "the", "canonicalized", "absolute", "pathname", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/Io/FileSystem.php#L351-L368
train
brick/std
src/Io/FileSystem.php
FileSystem.write
public static function write(string $path, $data, bool $append = false, bool $lock = false) : int { $flags = 0; if ($append) { $flags |= FILE_APPEND; } if ($lock) { $flags |= LOCK_EX; } $exception = null; try { $result = ErrorCatcher::run(static function() use ($path, $data, $flags) { return file_put_contents($path, $data, $flags); }); if ($result !== false) { return $result; } } catch (\ErrorException $e) { $exception = $e; } throw new IoException('Error writing to ' . $path, 0, $exception); }
php
public static function write(string $path, $data, bool $append = false, bool $lock = false) : int { $flags = 0; if ($append) { $flags |= FILE_APPEND; } if ($lock) { $flags |= LOCK_EX; } $exception = null; try { $result = ErrorCatcher::run(static function() use ($path, $data, $flags) { return file_put_contents($path, $data, $flags); }); if ($result !== false) { return $result; } } catch (\ErrorException $e) { $exception = $e; } throw new IoException('Error writing to ' . $path, 0, $exception); }
[ "public", "static", "function", "write", "(", "string", "$", "path", ",", "$", "data", ",", "bool", "$", "append", "=", "false", ",", "bool", "$", "lock", "=", "false", ")", ":", "int", "{", "$", "flags", "=", "0", ";", "if", "(", "$", "append", ...
Writes data to a file. If the file already exists, it will be overwritten, unless `$append` is set to `true`. @param string $path The path to the file. @param string|resource $data The data to write, as a string or a stream resource. @param bool $append Whether to append if the file already exists. Defaults to false (overwrite). @param bool $lock Whether to acquire an exclusive lock on the file. Defaults to false. @return int The number of bytes written. @throws IoException If an error occurs.
[ "Writes", "data", "to", "a", "file", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/Io/FileSystem.php#L384-L410
train
brick/std
src/Io/FileSystem.php
FileSystem.read
public static function read(string $path, int $offset = 0, int $maxLength = null) : string { $exception = null; try { $result = ErrorCatcher::run(static function() use ($path, $offset, $maxLength) { if ($maxLength === null) { return file_get_contents($path, false, null, $offset); } return file_get_contents($path, false, null, $offset, $maxLength); }); if ($result !== false) { return $result; } } catch (\ErrorException $e) { $exception = $e; } throw new IoException('Error reading from ' . $path, 0, $exception); }
php
public static function read(string $path, int $offset = 0, int $maxLength = null) : string { $exception = null; try { $result = ErrorCatcher::run(static function() use ($path, $offset, $maxLength) { if ($maxLength === null) { return file_get_contents($path, false, null, $offset); } return file_get_contents($path, false, null, $offset, $maxLength); }); if ($result !== false) { return $result; } } catch (\ErrorException $e) { $exception = $e; } throw new IoException('Error reading from ' . $path, 0, $exception); }
[ "public", "static", "function", "read", "(", "string", "$", "path", ",", "int", "$", "offset", "=", "0", ",", "int", "$", "maxLength", "=", "null", ")", ":", "string", "{", "$", "exception", "=", "null", ";", "try", "{", "$", "result", "=", "ErrorC...
Reads data from a file. Always be careful when reading a file in memory, as it may exceed the memory limit. @param string $path The path to the file. @param int $offset The offset where the reading starts on the original stream. Negative offsets count from the end of the stream. @param int|null $maxLength Maximum length of data read. The default is to read until end of file is reached. @return string The file contents. @throws IoException If an error occurs.
[ "Reads", "data", "from", "a", "file", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/Io/FileSystem.php#L426-L447
train
brick/std
src/Curl/Curl.php
Curl.getInfo
public function getInfo(int $opt = null) { if ($opt === null) { return curl_getinfo($this->curl); } return curl_getinfo($this->curl, $opt); }
php
public function getInfo(int $opt = null) { if ($opt === null) { return curl_getinfo($this->curl); } return curl_getinfo($this->curl, $opt); }
[ "public", "function", "getInfo", "(", "int", "$", "opt", "=", "null", ")", "{", "if", "(", "$", "opt", "===", "null", ")", "{", "return", "curl_getinfo", "(", "$", "this", "->", "curl", ")", ";", "}", "return", "curl_getinfo", "(", "$", "this", "->...
Returns information about the last transfer. If opt is given, its value is returned. If opt is not recognized, false is returned. Otherwise, an associative array of values is returned. @param int $opt One of the CURLINFO_* constants. @return mixed
[ "Returns", "information", "about", "the", "last", "transfer", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/Curl/Curl.php#L76-L83
train
Riimu/Kit-UrlParser
src/UriParser.php
UriParser.parse
public function parse($uri) { if (!$this->isValidString($uri)) { return null; } $pattern = new UriPattern(); $pattern->allowNonAscii($this->mode !== self::MODE_RFC3986); if ($pattern->matchUri($uri, $match)) { try { return $this->buildUri($match); } catch (\InvalidArgumentException $exception) { return null; } } return null; }
php
public function parse($uri) { if (!$this->isValidString($uri)) { return null; } $pattern = new UriPattern(); $pattern->allowNonAscii($this->mode !== self::MODE_RFC3986); if ($pattern->matchUri($uri, $match)) { try { return $this->buildUri($match); } catch (\InvalidArgumentException $exception) { return null; } } return null; }
[ "public", "function", "parse", "(", "$", "uri", ")", "{", "if", "(", "!", "$", "this", "->", "isValidString", "(", "$", "uri", ")", ")", "{", "return", "null", ";", "}", "$", "pattern", "=", "new", "UriPattern", "(", ")", ";", "$", "pattern", "->...
Parses the URL using the generic URI syntax. This method returns the `Uri` instance constructed from the components parsed from the URL. The URL is parsed using either the absolute URI pattern or the relative URI pattern based on which one matches the provided string. If the URL cannot be parsed as a valid URI, null is returned instead. @param string $uri The URL to parse @return Uri|null The parsed URL or null if the URL is invalid
[ "Parses", "the", "URL", "using", "the", "generic", "URI", "syntax", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/UriParser.php#L102-L120
train
Riimu/Kit-UrlParser
src/UriParser.php
UriParser.isValidString
private function isValidString($uri) { if (preg_match('/^[\\x00-\\x7F]*$/', $uri)) { return true; } elseif ($this->mode === self::MODE_RFC3986) { return false; } // Validate UTF-8 via regular expression to avoid mbstring dependency $pattern = '/^(?> [\x00-\x7F]+ # ASCII | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] # excluding over longs | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 )*$/x'; return (bool) preg_match($pattern, $uri); }
php
private function isValidString($uri) { if (preg_match('/^[\\x00-\\x7F]*$/', $uri)) { return true; } elseif ($this->mode === self::MODE_RFC3986) { return false; } // Validate UTF-8 via regular expression to avoid mbstring dependency $pattern = '/^(?> [\x00-\x7F]+ # ASCII | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] # excluding over longs | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 )*$/x'; return (bool) preg_match($pattern, $uri); }
[ "private", "function", "isValidString", "(", "$", "uri", ")", "{", "if", "(", "preg_match", "(", "'/^[\\\\x00-\\\\x7F]*$/'", ",", "$", "uri", ")", ")", "{", "return", "true", ";", "}", "elseif", "(", "$", "this", "->", "mode", "===", "self", "::", "MOD...
Tells if the URI string is valid for the current parser mode. @param string $uri The URI to validate @return bool True if the string is valid, false if not
[ "Tells", "if", "the", "URI", "string", "is", "valid", "for", "the", "current", "parser", "mode", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/UriParser.php#L127-L149
train
Riimu/Kit-UrlParser
src/UriParser.php
UriParser.buildUri
private function buildUri(array $components) { $uri = new Uri(); if (isset($components['reg_name'])) { $components['host'] = $this->decodeHost($components['host']); } foreach (array_intersect_key(self::$setters, $components) as $key => $method) { $uri = call_user_func([$uri, $method], $components[$key]); } if (isset($components['userinfo'])) { list($username, $password) = preg_split('/:|$/', $components['userinfo'], 2); $uri = $uri->withUserInfo(rawurldecode($username), rawurldecode($password)); } return $uri; }
php
private function buildUri(array $components) { $uri = new Uri(); if (isset($components['reg_name'])) { $components['host'] = $this->decodeHost($components['host']); } foreach (array_intersect_key(self::$setters, $components) as $key => $method) { $uri = call_user_func([$uri, $method], $components[$key]); } if (isset($components['userinfo'])) { list($username, $password) = preg_split('/:|$/', $components['userinfo'], 2); $uri = $uri->withUserInfo(rawurldecode($username), rawurldecode($password)); } return $uri; }
[ "private", "function", "buildUri", "(", "array", "$", "components", ")", "{", "$", "uri", "=", "new", "Uri", "(", ")", ";", "if", "(", "isset", "(", "$", "components", "[", "'reg_name'", "]", ")", ")", "{", "$", "components", "[", "'host'", "]", "=...
Builds the Uri instance from the parsed components. @param array<string, string> $components Components parsed from the URI @return Uri The constructed URI representation
[ "Builds", "the", "Uri", "instance", "from", "the", "parsed", "components", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/UriParser.php#L156-L174
train
Riimu/Kit-UrlParser
src/UriParser.php
UriParser.decodeHost
private function decodeHost($hostname) { if (preg_match('/^[\\x00-\\x7F]*$/', $hostname)) { return $hostname; } elseif ($this->mode !== self::MODE_IDNA2003) { throw new \InvalidArgumentException("Invalid hostname '$hostname'"); } $hostname = idn_to_ascii($hostname); if ($hostname === false) { throw new \InvalidArgumentException("Invalid hostname '$hostname'"); } return $hostname; }
php
private function decodeHost($hostname) { if (preg_match('/^[\\x00-\\x7F]*$/', $hostname)) { return $hostname; } elseif ($this->mode !== self::MODE_IDNA2003) { throw new \InvalidArgumentException("Invalid hostname '$hostname'"); } $hostname = idn_to_ascii($hostname); if ($hostname === false) { throw new \InvalidArgumentException("Invalid hostname '$hostname'"); } return $hostname; }
[ "private", "function", "decodeHost", "(", "$", "hostname", ")", "{", "if", "(", "preg_match", "(", "'/^[\\\\x00-\\\\x7F]*$/'", ",", "$", "hostname", ")", ")", "{", "return", "$", "hostname", ";", "}", "elseif", "(", "$", "this", "->", "mode", "!==", "sel...
Decodes the hostname component according to parser mode. @param string $hostname The parsed hostname @return string The decoded hostname @throws \InvalidArgumentException If the hostname is not valid
[ "Decodes", "the", "hostname", "component", "according", "to", "parser", "mode", "." ]
6fdc2dd57915425720a874ee697911c6b144808c
https://github.com/Riimu/Kit-UrlParser/blob/6fdc2dd57915425720a874ee697911c6b144808c/src/UriParser.php#L182-L197
train
inphinit/framework
src/Inphinit/App.php
App.env
public static function env($key, $value = null) { if (is_string($value) || is_bool($value) || is_numeric($value)) { self::$configs[$key] = $value; } elseif ($value === null && isset(self::$configs[$key])) { return self::$configs[$key]; } }
php
public static function env($key, $value = null) { if (is_string($value) || is_bool($value) || is_numeric($value)) { self::$configs[$key] = $value; } elseif ($value === null && isset(self::$configs[$key])) { return self::$configs[$key]; } }
[ "public", "static", "function", "env", "(", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", "||", "is_bool", "(", "$", "value", ")", "||", "is_numeric", "(", "$", "value", ")", ")", "{", "self...
Set or get environment value @param string $key @param string|bool|int|float $value @return string|bool|int|float|void
[ "Set", "or", "get", "environment", "value" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/App.php#L32-L39
train
inphinit/framework
src/Inphinit/App.php
App.config
public static function config($path) { $data = \UtilsSandboxLoader('application/Config/' . strtr($path, '.', '/') . '.php'); foreach ($data as $key => $value) { self::env($key, $value); } $data = null; }
php
public static function config($path) { $data = \UtilsSandboxLoader('application/Config/' . strtr($path, '.', '/') . '.php'); foreach ($data as $key => $value) { self::env($key, $value); } $data = null; }
[ "public", "static", "function", "config", "(", "$", "path", ")", "{", "$", "data", "=", "\\", "UtilsSandboxLoader", "(", "'application/Config/'", ".", "strtr", "(", "$", "path", ",", "'.'", ",", "'/'", ")", ".", "'.php'", ")", ";", "foreach", "(", "$",...
Set environment variables by config files @param string $path @return void
[ "Set", "environment", "variables", "by", "config", "files" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/App.php#L47-L56
train
inphinit/framework
src/Inphinit/App.php
App.trigger
public static function trigger($name, array $args = array()) { if ($name === 'error') { self::$state = 5; } if (empty(self::$events[$name])) { return null; } $listen = self::$events[$name]; usort($listen, function ($a, $b) { return $b[1] >= $a[1]; }); foreach ($listen as $callback) { call_user_func_array($callback[0], $args); } $listen = null; }
php
public static function trigger($name, array $args = array()) { if ($name === 'error') { self::$state = 5; } if (empty(self::$events[$name])) { return null; } $listen = self::$events[$name]; usort($listen, function ($a, $b) { return $b[1] >= $a[1]; }); foreach ($listen as $callback) { call_user_func_array($callback[0], $args); } $listen = null; }
[ "public", "static", "function", "trigger", "(", "$", "name", ",", "array", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "$", "name", "===", "'error'", ")", "{", "self", "::", "$", "state", "=", "5", ";", "}", "if", "(", "empty", "(...
Trigger registered event @param string $name @param array $args @return void
[ "Trigger", "registered", "event" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/App.php#L65-L86
train
inphinit/framework
src/Inphinit/App.php
App.off
public static function off($name, $callback = null) { if (empty(self::$events[$name])) { return null; } elseif ($callback === null) { self::$events[$name] = array(); return null; } $evts = self::$events[$name]; foreach ($evts as $key => $value) { if ($value[0] === $callback) { unset($evts[$key]); } } self::$events[$name] = $evts; $evts = null; }
php
public static function off($name, $callback = null) { if (empty(self::$events[$name])) { return null; } elseif ($callback === null) { self::$events[$name] = array(); return null; } $evts = self::$events[$name]; foreach ($evts as $key => $value) { if ($value[0] === $callback) { unset($evts[$key]); } } self::$events[$name] = $evts; $evts = null; }
[ "public", "static", "function", "off", "(", "$", "name", ",", "$", "callback", "=", "null", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "events", "[", "$", "name", "]", ")", ")", "{", "return", "null", ";", "}", "elseif", "(", "$", "c...
Unregister 1 or all events @param string $name @param callable $callback @return void
[ "Unregister", "1", "or", "all", "events" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/App.php#L133-L152
train
inphinit/framework
src/Inphinit/App.php
App.stop
public static function stop($code, $msg = null) { Response::status($code, false) && self::trigger('changestatus', array($code, $msg)); if (self::$state < 4) { self::$state = 4; self::trigger('finish'); } exit; }
php
public static function stop($code, $msg = null) { Response::status($code, false) && self::trigger('changestatus', array($code, $msg)); if (self::$state < 4) { self::$state = 4; self::trigger('finish'); } exit; }
[ "public", "static", "function", "stop", "(", "$", "code", ",", "$", "msg", "=", "null", ")", "{", "Response", "::", "status", "(", "$", "code", ",", "false", ")", "&&", "self", "::", "trigger", "(", "'changestatus'", ",", "array", "(", "$", "code", ...
Stop application, send HTTP status @param int $code @param string $msg @return void
[ "Stop", "application", "send", "HTTP", "status" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/App.php#L161-L171
train
inphinit/framework
src/Inphinit/App.php
App.exec
public static function exec() { if (self::$state > 0) { return null; } self::$state = 1; self::trigger('init'); if (self::env('maintenance')) { self::$state = 4; self::stop(503); } self::trigger('changestatus', array(\UtilsStatusCode(), null)); $resp = Route::get(); if (is_integer($resp)) { self::$state = 5; self::stop($resp, 'Invalid route'); } $callback = $resp['callback']; if (!$callback instanceof \Closure) { $parsed = explode(':', $callback, 2); $callback = '\\Controller\\' . strtr($parsed[0], '.', '\\'); $callback = array(new $callback, $parsed[1]); } $output = call_user_func_array($callback, $resp['args']); if (class_exists('\\Inphinit\\Http\\Response', false)) { Response::dispatch(); } if (class_exists('\\Inphinit\\Viewing\\View', false)) { View::dispatch(); } if (self::$state < 2) { self::$state = 2; } self::trigger('ready'); if ($output || is_numeric($output)) { echo $output; } if (self::$state < 3) { self::$state = 3; } self::trigger('finish'); if (self::$state < 4) { self::$state = 4; } }
php
public static function exec() { if (self::$state > 0) { return null; } self::$state = 1; self::trigger('init'); if (self::env('maintenance')) { self::$state = 4; self::stop(503); } self::trigger('changestatus', array(\UtilsStatusCode(), null)); $resp = Route::get(); if (is_integer($resp)) { self::$state = 5; self::stop($resp, 'Invalid route'); } $callback = $resp['callback']; if (!$callback instanceof \Closure) { $parsed = explode(':', $callback, 2); $callback = '\\Controller\\' . strtr($parsed[0], '.', '\\'); $callback = array(new $callback, $parsed[1]); } $output = call_user_func_array($callback, $resp['args']); if (class_exists('\\Inphinit\\Http\\Response', false)) { Response::dispatch(); } if (class_exists('\\Inphinit\\Viewing\\View', false)) { View::dispatch(); } if (self::$state < 2) { self::$state = 2; } self::trigger('ready'); if ($output || is_numeric($output)) { echo $output; } if (self::$state < 3) { self::$state = 3; } self::trigger('finish'); if (self::$state < 4) { self::$state = 4; } }
[ "public", "static", "function", "exec", "(", ")", "{", "if", "(", "self", "::", "$", "state", ">", "0", ")", "{", "return", "null", ";", "}", "self", "::", "$", "state", "=", "1", ";", "self", "::", "trigger", "(", "'init'", ")", ";", "if", "("...
Start application using routes @return void
[ "Start", "application", "using", "routes" ]
81eddb711e0225116a1ced91ed65e71437b7288c
https://github.com/inphinit/framework/blob/81eddb711e0225116a1ced91ed65e71437b7288c/src/Inphinit/App.php#L178-L240
train
brick/std
src/FixedArray.php
FixedArray.swap
public function swap(int $index1, int $index2) : void { if ($index1 !== $index2) { $value = $this[$index1]; $this[$index1] = $this[$index2]; $this[$index2] = $value; } }
php
public function swap(int $index1, int $index2) : void { if ($index1 !== $index2) { $value = $this[$index1]; $this[$index1] = $this[$index2]; $this[$index2] = $value; } }
[ "public", "function", "swap", "(", "int", "$", "index1", ",", "int", "$", "index2", ")", ":", "void", "{", "if", "(", "$", "index1", "!==", "$", "index2", ")", "{", "$", "value", "=", "$", "this", "[", "$", "index1", "]", ";", "$", "this", "[",...
Swaps two entries in this FixedArray. @param int $index1 The index of the first entry. @param int $index2 The index of the second entry. @return void
[ "Swaps", "two", "entries", "in", "this", "FixedArray", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/FixedArray.php#L171-L178
train
brick/std
src/FixedArray.php
FixedArray.shiftUp
public function shiftUp(int $index) : void { if ($index + 1 === $this->count()) { return; } $this->swap($index, $index + 1); }
php
public function shiftUp(int $index) : void { if ($index + 1 === $this->count()) { return; } $this->swap($index, $index + 1); }
[ "public", "function", "shiftUp", "(", "int", "$", "index", ")", ":", "void", "{", "if", "(", "$", "index", "+", "1", "===", "$", "this", "->", "count", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "swap", "(", "$", "index", ",", ...
Shifts an entry to the next index. This will effectively swap this entry with the next entry. If this entry is the last one in the array, this method will do nothing. @param int $index @return void
[ "Shifts", "an", "entry", "to", "the", "next", "index", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/FixedArray.php#L190-L197
train
brick/std
src/FixedArray.php
FixedArray.shiftTo
public function shiftTo(int $index, int $newIndex) : void { while ($index > $newIndex) { $this->shiftDown($index); $index--; } while ($index < $newIndex) { $this->shiftUp($index); $index++; } }
php
public function shiftTo(int $index, int $newIndex) : void { while ($index > $newIndex) { $this->shiftDown($index); $index--; } while ($index < $newIndex) { $this->shiftUp($index); $index++; } }
[ "public", "function", "shiftTo", "(", "int", "$", "index", ",", "int", "$", "newIndex", ")", ":", "void", "{", "while", "(", "$", "index", ">", "$", "newIndex", ")", "{", "$", "this", "->", "shiftDown", "(", "$", "index", ")", ";", "$", "index", ...
Shifts an entry to an arbitrary index, shifting all the entries between those indexes. @param int $index The index of the entry. @param int $newIndex The index to shift the entry to. @return void
[ "Shifts", "an", "entry", "to", "an", "arbitrary", "index", "shifting", "all", "the", "entries", "between", "those", "indexes", "." ]
d19162fcefcce457eeaa27904c797f76f9f49007
https://github.com/brick/std/blob/d19162fcefcce457eeaa27904c797f76f9f49007/src/FixedArray.php#L226-L236
train
rdohms/DMS
src/DMS/Bundle/TwigExtensionBundle/Twig/Text/PadStringExtension.php
PadStringExtension.padStringFilter
public function padStringFilter($value, $padCharacter, $maxLength, $padType = 'STR_PAD_RIGHT') { if ($this->isNullOrEmptyString($padCharacter)) { throw new \InvalidArgumentException('Pad String Filter cannot accept a null value or empty string as its first argument'); } if ( ! is_int($maxLength)) { throw new \InvalidArgumentException('Pad String Filter expects its second argument to be an integer'); } $diff = (function_exists('mb_strlen'))? strlen($value) - mb_strlen($value) : 0; $padType = constant($padType); return str_pad($value, $maxLength + $diff, $padCharacter, $padType); }
php
public function padStringFilter($value, $padCharacter, $maxLength, $padType = 'STR_PAD_RIGHT') { if ($this->isNullOrEmptyString($padCharacter)) { throw new \InvalidArgumentException('Pad String Filter cannot accept a null value or empty string as its first argument'); } if ( ! is_int($maxLength)) { throw new \InvalidArgumentException('Pad String Filter expects its second argument to be an integer'); } $diff = (function_exists('mb_strlen'))? strlen($value) - mb_strlen($value) : 0; $padType = constant($padType); return str_pad($value, $maxLength + $diff, $padCharacter, $padType); }
[ "public", "function", "padStringFilter", "(", "$", "value", ",", "$", "padCharacter", ",", "$", "maxLength", ",", "$", "padType", "=", "'STR_PAD_RIGHT'", ")", "{", "if", "(", "$", "this", "->", "isNullOrEmptyString", "(", "$", "padCharacter", ")", ")", "{"...
Pads string on right or left with given padCharacter until string reaches maxLength @param string $value @param string $padCharacter @param int $maxLength @param string $padType @return string @throws \InvalidArgumentException
[ "Pads", "string", "on", "right", "or", "left", "with", "given", "padCharacter", "until", "string", "reaches", "maxLength" ]
3fab902ac2db2a31876101280cdfe7611146a243
https://github.com/rdohms/DMS/blob/3fab902ac2db2a31876101280cdfe7611146a243/src/DMS/Bundle/TwigExtensionBundle/Twig/Text/PadStringExtension.php#L43-L55
train