repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
yoanm/symfony-jsonrpc-http-server
src/Resolver/MethodResolver.php
MethodResolver.resolve
public function resolve(string $methodName) : ?JsonRpcMethodInterface { return $this->locator->has($methodName) ? $this->locator->get($methodName) : null ; }
php
public function resolve(string $methodName) : ?JsonRpcMethodInterface { return $this->locator->has($methodName) ? $this->locator->get($methodName) : null ; }
[ "public", "function", "resolve", "(", "string", "$", "methodName", ")", ":", "?", "JsonRpcMethodInterface", "{", "return", "$", "this", "->", "locator", "->", "has", "(", "$", "methodName", ")", "?", "$", "this", "->", "locator", "->", "get", "(", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/yoanm/symfony-jsonrpc-http-server/blob/e6a9df43aa1e944966a790140546b9aeb98b6a53/src/Resolver/MethodResolver.php#L24-L30
kaliop-uk/kueueingbundle
Service/MessageConsumer/ConsoleCommand.php
ConsoleCommand.validateCommand
protected function validateCommand($consoleCommand, $arguments = array(), $options = array()) { if ($this->application !== null) { if (!in_array($consoleCommand, array_keys($this->application->all()))) { throw new \InvalidArgumentException("Command '$consoleCommand' is not registered in the symfony console"); } } }
php
protected function validateCommand($consoleCommand, $arguments = array(), $options = array()) { if ($this->application !== null) { if (!in_array($consoleCommand, array_keys($this->application->all()))) { throw new \InvalidArgumentException("Command '$consoleCommand' is not registered in the symfony console"); } } }
[ "protected", "function", "validateCommand", "(", "$", "consoleCommand", ",", "$", "arguments", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "application", "!==", "null", ")", "{", "if", ...
Does some preliminary checks before attempting to run command, throws if command is blatantly non-runnable. (split as a separate method to better accommodate subclasses) @param string $consoleCommand @param array $arguments @param array $options @throws \InvalidArgumentException
[ "Does", "some", "preliminary", "checks", "before", "attempting", "to", "run", "command", "throws", "if", "command", "is", "blatantly", "non", "-", "runnable", ".", "(", "split", "as", "a", "separate", "method", "to", "better", "accommodate", "subclasses", ")" ...
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/MessageConsumer/ConsoleCommand.php#L90-L97
kaliop-uk/kueueingbundle
Service/MessageConsumer/ConsoleCommand.php
ConsoleCommand.runCommand
protected function runCommand($consoleCommand, $arguments = array(), $options = array()) { $command = $this->consoleCommand; $command .= $this->buildCommandString($consoleCommand, $arguments, $options); $label = trim(ConsumerCommand::getLabel()); if ($label != '') { $label = " '$label'"; } if ($this->logger) { $this->logger->debug("Console command will be executed from MessageConsumer{$label}: " . $command); } $process = new Process($command); $retCode = $process->run(); $results = array($retCode, $process->getOutput(), $process->getErrorOutput()); if ($retCode != 0 && $this->logger) { $this->logger->error( "Console command executed from MessageConsumer{$label} failed. Retcode: $retCode, Error message: '" . trim($results[2]) . "'", array()); } return $results; }
php
protected function runCommand($consoleCommand, $arguments = array(), $options = array()) { $command = $this->consoleCommand; $command .= $this->buildCommandString($consoleCommand, $arguments, $options); $label = trim(ConsumerCommand::getLabel()); if ($label != '') { $label = " '$label'"; } if ($this->logger) { $this->logger->debug("Console command will be executed from MessageConsumer{$label}: " . $command); } $process = new Process($command); $retCode = $process->run(); $results = array($retCode, $process->getOutput(), $process->getErrorOutput()); if ($retCode != 0 && $this->logger) { $this->logger->error( "Console command executed from MessageConsumer{$label} failed. Retcode: $retCode, Error message: '" . trim($results[2]) . "'", array()); } return $results; }
[ "protected", "function", "runCommand", "(", "$", "consoleCommand", ",", "$", "arguments", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "command", "=", "$", "this", "->", "consoleCommand", ";", "$", "command", ".="...
Runs an sf command as a separate php process - this way we insure the worker is stable (no memleaks or crashes) @param string $consoleCommand @param array $arguments @param array $options @return array (positional) retcode, stdout, stderr @throws ??? @todo add support for ttl when executing commands @todo add a verbose mode: echo to stdout or a log file the results of execution
[ "Runs", "an", "sf", "command", "as", "a", "separate", "php", "process", "-", "this", "way", "we", "insure", "the", "worker", "is", "stable", "(", "no", "memleaks", "or", "crashes", ")" ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/MessageConsumer/ConsoleCommand.php#L111-L138
MW-Peachy/Peachy
Includes/User.php
User.create
public function create( $password = null, $email = null, $mailpassword = false, $reason = null, $realname = null, $language = null, $domain = null ) { global $pgNotag, $pgTag; pecho( "Creating user account " . $this->username . "...\n\n", PECHO_NOTICE ); try{ $this->preEditChecks( "Create" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } $token = $this->wiki->apiQuery( array( 'action' => 'createaccount', 'name' => $this->username ), true ); $token = $token['createaccount']['token']; $apiArray = array( 'action' => 'createaccount', 'token' => $token, 'name' => $this->username ); if( !$password == null ) $apiArray['password'] = $password; if( !$email == null ) $apiArray['email'] = $email; if( !$realname == null ) $apiArray['realname'] = $realname; if( !$domain == null ) $apiArray['domain'] = $domain; if( !$reason == null ) { if( !$pgNotag ) $reason .= $pgTag; $apiArray['reason'] = $reason; } if( !$language == null ) $apiArray['language'] = $language; if( $this->exists() ) { pecho( "Error: User account already exists.\n\n", PECHO_ERROR ); return false; } if( $password == null && !$mailpassword ) { pecho( "Error: neither a password or the mailpassword have been set.\n\n", PECHO_ERROR ); return false; } if( $mailpassword ) { if( $email == null ) { pecho( "Error: Email not specified.\n\n", PECHO_ERROR ); return false; } else $apiArray['mailpassword'] = 'yes'; } else { if( is_null( $password ) ) { pecho( "Error: No password specified.\n\n", PECHO_ERROR ); return false; } } $result = $this->wiki->apiQuery( $apiArray, true ); $this->__construct( $this->wiki, $this->username ); if( isset( $result['createaccount']['result'] ) ) { if( $result['createaccount']['result'] == 'success' ) { return true; } else { pecho( "Create error...\n\n" . print_r( $result['createaccount'], true ), PECHO_FATAL ); return false; } } else { pecho( "Create error...\n\n" . print_r( $result['createaccount'], true ), PECHO_FATAL ); return false; } }
php
public function create( $password = null, $email = null, $mailpassword = false, $reason = null, $realname = null, $language = null, $domain = null ) { global $pgNotag, $pgTag; pecho( "Creating user account " . $this->username . "...\n\n", PECHO_NOTICE ); try{ $this->preEditChecks( "Create" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } $token = $this->wiki->apiQuery( array( 'action' => 'createaccount', 'name' => $this->username ), true ); $token = $token['createaccount']['token']; $apiArray = array( 'action' => 'createaccount', 'token' => $token, 'name' => $this->username ); if( !$password == null ) $apiArray['password'] = $password; if( !$email == null ) $apiArray['email'] = $email; if( !$realname == null ) $apiArray['realname'] = $realname; if( !$domain == null ) $apiArray['domain'] = $domain; if( !$reason == null ) { if( !$pgNotag ) $reason .= $pgTag; $apiArray['reason'] = $reason; } if( !$language == null ) $apiArray['language'] = $language; if( $this->exists() ) { pecho( "Error: User account already exists.\n\n", PECHO_ERROR ); return false; } if( $password == null && !$mailpassword ) { pecho( "Error: neither a password or the mailpassword have been set.\n\n", PECHO_ERROR ); return false; } if( $mailpassword ) { if( $email == null ) { pecho( "Error: Email not specified.\n\n", PECHO_ERROR ); return false; } else $apiArray['mailpassword'] = 'yes'; } else { if( is_null( $password ) ) { pecho( "Error: No password specified.\n\n", PECHO_ERROR ); return false; } } $result = $this->wiki->apiQuery( $apiArray, true ); $this->__construct( $this->wiki, $this->username ); if( isset( $result['createaccount']['result'] ) ) { if( $result['createaccount']['result'] == 'success' ) { return true; } else { pecho( "Create error...\n\n" . print_r( $result['createaccount'], true ), PECHO_FATAL ); return false; } } else { pecho( "Create error...\n\n" . print_r( $result['createaccount'], true ), PECHO_FATAL ); return false; } }
[ "public", "function", "create", "(", "$", "password", "=", "null", ",", "$", "email", "=", "null", ",", "$", "mailpassword", "=", "false", ",", "$", "reason", "=", "null", ",", "$", "realname", "=", "null", ",", "$", "language", "=", "null", ",", "...
Creates the account with the specified parameters @access public @param string $password Password (ignored if mailpassword is set). Default null. @param string $email Email address of user (optional). Default null. @param bool $mailpassword If set to true, a random password will be emailed to the user. Default false. @param string $reason Optional reason for creating the account to be put in the logs. Default null. @param string $realname Real name of user (optional). Default null. @param bool $tboverride Override the title blacklist. Requires the tboverride right. Default false. @param string $language Language code to set as default for the user (optional, defaults to content language). Default null. @param string $domain Domain for external authentication (optional). Default null. @return bool True on success, false otherwise
[ "Creates", "the", "account", "with", "the", "specified", "parameters" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L214-L285
MW-Peachy/Peachy
Includes/User.php
User.is_blocked
public function is_blocked( $force = false ) { if( !$force && $this->blocked !== null ) { return $this->blocked; } pecho( "Checking if {$this->username} is blocked...\n\n", PECHO_NORMAL ); $this->__construct( $this->wiki, $this->username ); return $this->blocked; }
php
public function is_blocked( $force = false ) { if( !$force && $this->blocked !== null ) { return $this->blocked; } pecho( "Checking if {$this->username} is blocked...\n\n", PECHO_NORMAL ); $this->__construct( $this->wiki, $this->username ); return $this->blocked; }
[ "public", "function", "is_blocked", "(", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "force", "&&", "$", "this", "->", "blocked", "!==", "null", ")", "{", "return", "$", "this", "->", "blocked", ";", "}", "pecho", "(", "\"Checking if {...
Returns whether or not the user is blocked @access public @param bool $force Whether or not to use the locally stored cache. Default false. @return bool
[ "Returns", "whether", "or", "not", "the", "user", "is", "blocked" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L294-L305
MW-Peachy/Peachy
Includes/User.php
User.block
public function block( $reason = null, $expiry = 'indefinite', $params = array(), $watch = false, $range = null ) { global $pgNotag, $pgTag; $token = $this->wiki->get_tokens(); $target = $this->username; if( !in_array( 'block', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to block users.\n\n", PECHO_FATAL ); return false; } if( !$this->exists() && !$this->is_ip() ) { pecho( "User does not exist.\n\n", PECHO_FATAL ); return false; } if( $range !== null ) { // intval() returns 0 or 1 on failure $range = intval( $range ); if( !$this->is_ip() ) { pecho( "Can only combine a range with an IP address, not a username.\n\n", PECHO_WARN ); } if( $range !== null && ( $range < 2 || $range > 32 ) ) { pecho( "Range must be an integer between 2 and 32 inclusive (more restrictive limits may also apply).\n\n", PECHO_WARN ); } $target .= '/' . $range; } if( !array_key_exists( 'block', $token ) ) return false; $apiArr = array( 'action' => 'block', 'user' => $target, 'token' => $token['block'], 'expiry' => $expiry, 'reblock' => 'yes', 'allowusertalk' => 'yes' ); if( !is_null( $reason ) ) { if( !$pgNotag ) $reason .= $pgTag; $apiArr['reason'] = $reason; } foreach( $params as $param ){ switch( $param ){ case 'anononly': $apiArr['anononly'] = 'yes'; break; case 'nocreate': $apiArr['nocreate'] = 'yes'; break; case 'autoblock': $apiArr['autoblock'] = 'yes'; break; case 'noemail': $apiArr['noemail'] = 'yes'; break; case 'hidename': $apiArr['hidename'] = 'yes'; break; case 'noallowusertalk': unset( $apiArr['allowusertalk'] ); break; } } if( $watch ) $apiArr['watchuser'] = 'yes'; Hooks::runHook( 'StartBlock', array( &$apiArr ) ); pecho( "Blocking $target...\n\n", PECHO_NOTICE ); try{ $this->preEditChecks( "Block" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } $result = $this->wiki->apiQuery( $apiArr, true ); if( isset( $result['block'] ) ) { if( !isset( $result['error'] ) ) { $this->__construct( $this->wiki, $this->username ); return true; } else { pecho( "Block error...\n\n" . print_r( $result['block'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Block error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
php
public function block( $reason = null, $expiry = 'indefinite', $params = array(), $watch = false, $range = null ) { global $pgNotag, $pgTag; $token = $this->wiki->get_tokens(); $target = $this->username; if( !in_array( 'block', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to block users.\n\n", PECHO_FATAL ); return false; } if( !$this->exists() && !$this->is_ip() ) { pecho( "User does not exist.\n\n", PECHO_FATAL ); return false; } if( $range !== null ) { // intval() returns 0 or 1 on failure $range = intval( $range ); if( !$this->is_ip() ) { pecho( "Can only combine a range with an IP address, not a username.\n\n", PECHO_WARN ); } if( $range !== null && ( $range < 2 || $range > 32 ) ) { pecho( "Range must be an integer between 2 and 32 inclusive (more restrictive limits may also apply).\n\n", PECHO_WARN ); } $target .= '/' . $range; } if( !array_key_exists( 'block', $token ) ) return false; $apiArr = array( 'action' => 'block', 'user' => $target, 'token' => $token['block'], 'expiry' => $expiry, 'reblock' => 'yes', 'allowusertalk' => 'yes' ); if( !is_null( $reason ) ) { if( !$pgNotag ) $reason .= $pgTag; $apiArr['reason'] = $reason; } foreach( $params as $param ){ switch( $param ){ case 'anononly': $apiArr['anononly'] = 'yes'; break; case 'nocreate': $apiArr['nocreate'] = 'yes'; break; case 'autoblock': $apiArr['autoblock'] = 'yes'; break; case 'noemail': $apiArr['noemail'] = 'yes'; break; case 'hidename': $apiArr['hidename'] = 'yes'; break; case 'noallowusertalk': unset( $apiArr['allowusertalk'] ); break; } } if( $watch ) $apiArr['watchuser'] = 'yes'; Hooks::runHook( 'StartBlock', array( &$apiArr ) ); pecho( "Blocking $target...\n\n", PECHO_NOTICE ); try{ $this->preEditChecks( "Block" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } $result = $this->wiki->apiQuery( $apiArr, true ); if( isset( $result['block'] ) ) { if( !isset( $result['error'] ) ) { $this->__construct( $this->wiki, $this->username ); return true; } else { pecho( "Block error...\n\n" . print_r( $result['block'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Block error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
[ "public", "function", "block", "(", "$", "reason", "=", "null", ",", "$", "expiry", "=", "'indefinite'", ",", "$", "params", "=", "array", "(", ")", ",", "$", "watch", "=", "false", ",", "$", "range", "=", "null", ")", "{", "global", "$", "pgNotag"...
Blocks the user @access public @param string $reason Reason for blocking. Default null @param string $expiry Expiry. Can be a date, {@link http://www.gnu.org/software/tar/manual/html_node/Date-input-formats.html GNU formatted date}, indefinite, or anything else that MediaWiki accepts. Default indefinite. @param array $params Parameters to set. Options are anononly, nocreate, autoblock, noemail, hidename, noallowusertalk. Defdault array(). @param bool $watch Watch the user/IP's user and talk pages. Default false. @param int $range The number of CIDR prefix bits to use for a rangeblock. Default null. @return bool
[ "Blocks", "the", "user" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L338-L433
MW-Peachy/Peachy
Includes/User.php
User.unblock
public function unblock( $reason = null, $id = null ) { global $pgNotag, $pgTag; if( !in_array( 'block', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to unblock users", PECHO_FATAL ); return false; } $token = $this->wiki->get_tokens(); if( !array_key_exists( 'block', $token ) ) return false; $apiArr = array( 'action' => 'unblock', 'user' => $this->username, 'token' => $token['unblock'], ); if( !is_null( $id ) ) { $apiArr['id'] = $id; unset( $apiArr['user'] ); } if( !is_null( $reason ) ) { if( !$pgNotag ) $reason .= $pgTag; $apiArr['reason'] = $reason; } Hooks::runHook( 'StartUnblock', array( &$apiArr ) ); pecho( "Unblocking {$this->username}...\n\n", PECHO_NOTICE ); try{ $this->preEditChecks( "Unblock" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } $result = $this->wiki->apiQuery( $apiArr, true ); if( isset( $result['unblock'] ) ) { if( isset( $result['unblock']['user'] ) ) { $this->__construct( $this->wiki, $this->username ); return true; } else { pecho( "Unblock error...\n\n" . print_r( $result['unblock'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Unblock error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
php
public function unblock( $reason = null, $id = null ) { global $pgNotag, $pgTag; if( !in_array( 'block', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to unblock users", PECHO_FATAL ); return false; } $token = $this->wiki->get_tokens(); if( !array_key_exists( 'block', $token ) ) return false; $apiArr = array( 'action' => 'unblock', 'user' => $this->username, 'token' => $token['unblock'], ); if( !is_null( $id ) ) { $apiArr['id'] = $id; unset( $apiArr['user'] ); } if( !is_null( $reason ) ) { if( !$pgNotag ) $reason .= $pgTag; $apiArr['reason'] = $reason; } Hooks::runHook( 'StartUnblock', array( &$apiArr ) ); pecho( "Unblocking {$this->username}...\n\n", PECHO_NOTICE ); try{ $this->preEditChecks( "Unblock" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } $result = $this->wiki->apiQuery( $apiArr, true ); if( isset( $result['unblock'] ) ) { if( isset( $result['unblock']['user'] ) ) { $this->__construct( $this->wiki, $this->username ); return true; } else { pecho( "Unblock error...\n\n" . print_r( $result['unblock'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Unblock error...\n\n" . print_r( $result, true ), PECHO_FATAL ); return false; } }
[ "public", "function", "unblock", "(", "$", "reason", "=", "null", ",", "$", "id", "=", "null", ")", "{", "global", "$", "pgNotag", ",", "$", "pgTag", ";", "if", "(", "!", "in_array", "(", "'block'", ",", "$", "this", "->", "wiki", "->", "get_userri...
Unblocks the user, or a block ID @access public @param string $reason Reason for unblocking. Default null @param int $id Block ID to unblock. Default null @return bool
[ "Unblocks", "the", "user", "or", "a", "block", "ID" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L443-L494
MW-Peachy/Peachy
Includes/User.php
User.get_editcount
public function get_editcount( $force = false, &$database = null, $liveonly = false ) { global $pgUseLabs; //First check if $database exists, because that returns a more accurate count if( !is_null( $database ) && $database instanceOf mysqli ) { pecho( "Getting edit count for {$this->username} using the Database class...\n\n", PECHO_NORMAL ); if( !$liveonly && $result = mysqli_query( $database, "SELECT COUNT(*) AS count FROM " . ( $pgUseLabs ? "archive_userindex" : "archive" ) . " WHERE `ar_user_text` = '{$this->username}';" ) ) { $res = mysqli_fetch_assoc( $result ); $del_count = $res['count']; mysqli_free_result( $result ); unset( $res ); } else $del_count = 0; if( $result = mysqli_query( $database, "SELECT COUNT(*) AS count FROM " . ( $pgUseLabs ? "revision_userindex" : "revision" ) . " WHERE `rev_user_text` = '{$this->username}';" ) ) { $res = mysqli_fetch_assoc( $result ); $live_count = $res['count']; mysqli_free_result( $result ); unset( $res ); } else $live_count = 0; $this->editcount = $del_count + $live_count; } else { if( $force ) { $this->__construct( $this->wiki, $this->username ); } } return $this->editcount; }
php
public function get_editcount( $force = false, &$database = null, $liveonly = false ) { global $pgUseLabs; //First check if $database exists, because that returns a more accurate count if( !is_null( $database ) && $database instanceOf mysqli ) { pecho( "Getting edit count for {$this->username} using the Database class...\n\n", PECHO_NORMAL ); if( !$liveonly && $result = mysqli_query( $database, "SELECT COUNT(*) AS count FROM " . ( $pgUseLabs ? "archive_userindex" : "archive" ) . " WHERE `ar_user_text` = '{$this->username}';" ) ) { $res = mysqli_fetch_assoc( $result ); $del_count = $res['count']; mysqli_free_result( $result ); unset( $res ); } else $del_count = 0; if( $result = mysqli_query( $database, "SELECT COUNT(*) AS count FROM " . ( $pgUseLabs ? "revision_userindex" : "revision" ) . " WHERE `rev_user_text` = '{$this->username}';" ) ) { $res = mysqli_fetch_assoc( $result ); $live_count = $res['count']; mysqli_free_result( $result ); unset( $res ); } else $live_count = 0; $this->editcount = $del_count + $live_count; } else { if( $force ) { $this->__construct( $this->wiki, $this->username ); } } return $this->editcount; }
[ "public", "function", "get_editcount", "(", "$", "force", "=", "false", ",", "&", "$", "database", "=", "null", ",", "$", "liveonly", "=", "false", ")", "{", "global", "$", "pgUseLabs", ";", "//First check if $database exists, because that returns a more accurate co...
Returns the editcount of the user @access public @param bool $force Whether or not to use the locally stored cache. Default false. @param Database &$database Use an instance of the mysqli class to get a more accurate count @param bool $liveonly Whether or not to only get the live edit count. Only works with $database. Default false. @return int Edit count
[ "Returns", "the", "editcount", "of", "the", "user" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L505-L533
MW-Peachy/Peachy
Includes/User.php
User.get_contribs
public function get_contribs( $mostrecentfirst = true, $limit = null ) { if( !$this->exists ) return array(); $ucArray = array( '_code' => 'uc', 'ucuser' => $this->username, 'action' => 'query', 'list' => 'usercontribs', '_limit' => $limit, ); if( $mostrecentfirst ) { $ucArray['ucdir'] = "older"; } else { $ucArray['ucdir'] = "newer"; } $result = $this->wiki->listHandler( $ucArray ); pecho( "Getting list of contributions by {$this->username}...\n\n", PECHO_NORMAL ); return $result; }
php
public function get_contribs( $mostrecentfirst = true, $limit = null ) { if( !$this->exists ) return array(); $ucArray = array( '_code' => 'uc', 'ucuser' => $this->username, 'action' => 'query', 'list' => 'usercontribs', '_limit' => $limit, ); if( $mostrecentfirst ) { $ucArray['ucdir'] = "older"; } else { $ucArray['ucdir'] = "newer"; } $result = $this->wiki->listHandler( $ucArray ); pecho( "Getting list of contributions by {$this->username}...\n\n", PECHO_NORMAL ); return $result; }
[ "public", "function", "get_contribs", "(", "$", "mostrecentfirst", "=", "true", ",", "$", "limit", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "exists", ")", "return", "array", "(", ")", ";", "$", "ucArray", "=", "array", "(", "'_code'"...
Returns a list of all user contributions @access public @param bool $mostrecentfirst Set to true to get the most recent edits first. Default true. @param bool $limit Only get this many edits. Default null. @return array Array, first level indexed, second level associative with keys user, pageid, revid, ns, title, timestamp, size and comment (edit summary).
[ "Returns", "a", "list", "of", "all", "user", "contributions" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L543-L565
MW-Peachy/Peachy
Includes/User.php
User.get_usergroups
public function get_usergroups( $force = false ) { if( $force ) { $uiRes = $this->wiki->apiQuery( array( 'action' => 'query', 'list' => 'users', 'ususers' => $this->username, 'usprop' => 'groups' ) ); $this->groups = $uiRes['query']['users'][0]['groups']; } return $this->groups; }
php
public function get_usergroups( $force = false ) { if( $force ) { $uiRes = $this->wiki->apiQuery( array( 'action' => 'query', 'list' => 'users', 'ususers' => $this->username, 'usprop' => 'groups' ) ); $this->groups = $uiRes['query']['users'][0]['groups']; } return $this->groups; }
[ "public", "function", "get_usergroups", "(", "$", "force", "=", "false", ")", "{", "if", "(", "$", "force", ")", "{", "$", "uiRes", "=", "$", "this", "->", "wiki", "->", "apiQuery", "(", "array", "(", "'action'", "=>", "'query'", ",", "'list'", "=>",...
Returns the usergroups, NULL if user is IP. @access public @param bool force Force use of the API. Default false; @return array
[ "Returns", "the", "usergroups", "NULL", "if", "user", "is", "IP", "." ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L584-L599
MW-Peachy/Peachy
Includes/User.php
User.email
public function email( $text = null, $subject = "Wikipedia Email", $ccme = false ) { global $pgNotag; if( !$this->has_email() ) { pecho( "Cannot email {$this->username}, user has email disabled", PECHO_FATAL ); return false; } $tokens = $this->wiki->get_tokens(); if( !$pgNotag ) $text .= "\n\nPowered by Peachy " . PEACHYVERSION; $editarray = array( 'action' => 'emailuser', 'target' => $this->username, 'token' => $tokens['email'], 'subject' => $subject, 'text' => $text ); if( $ccme ) $editarray['ccme'] = 'yes'; Hooks::runHook( 'StartEmail', array( &$editarray ) ); pecho( "Emailing {$this->username}...\n\n", PECHO_NOTICE ); try{ $this->preEditChecks( "Email" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } $result = $this->wiki->apiQuery( $editarray, true ); if( isset( $result['error'] ) ) { throw new EmailError( $result['error']['code'], $result['error']['info'] ); } elseif( isset( $result['emailuser'] ) ) { if( $result['emailuser']['result'] == "Success" ) { $this->__construct( $this->wiki, $this->username ); return true; } else { pecho( "Email error...\n\n" . print_r( $result['emailuser'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Email error...\n\n" . print_r( $result['edit'], true ) . "\n\n", PECHO_FATAL ); return false; } }
php
public function email( $text = null, $subject = "Wikipedia Email", $ccme = false ) { global $pgNotag; if( !$this->has_email() ) { pecho( "Cannot email {$this->username}, user has email disabled", PECHO_FATAL ); return false; } $tokens = $this->wiki->get_tokens(); if( !$pgNotag ) $text .= "\n\nPowered by Peachy " . PEACHYVERSION; $editarray = array( 'action' => 'emailuser', 'target' => $this->username, 'token' => $tokens['email'], 'subject' => $subject, 'text' => $text ); if( $ccme ) $editarray['ccme'] = 'yes'; Hooks::runHook( 'StartEmail', array( &$editarray ) ); pecho( "Emailing {$this->username}...\n\n", PECHO_NOTICE ); try{ $this->preEditChecks( "Email" ); } catch( EditError $e ){ pecho( "Error: $e\n\n", PECHO_FATAL ); return false; } $result = $this->wiki->apiQuery( $editarray, true ); if( isset( $result['error'] ) ) { throw new EmailError( $result['error']['code'], $result['error']['info'] ); } elseif( isset( $result['emailuser'] ) ) { if( $result['emailuser']['result'] == "Success" ) { $this->__construct( $this->wiki, $this->username ); return true; } else { pecho( "Email error...\n\n" . print_r( $result['emailuser'], true ) . "\n\n", PECHO_FATAL ); return false; } } else { pecho( "Email error...\n\n" . print_r( $result['edit'], true ) . "\n\n", PECHO_FATAL ); return false; } }
[ "public", "function", "email", "(", "$", "text", "=", "null", ",", "$", "subject", "=", "\"Wikipedia Email\"", ",", "$", "ccme", "=", "false", ")", "{", "global", "$", "pgNotag", ";", "if", "(", "!", "$", "this", "->", "has_email", "(", ")", ")", "...
Send an email to another wiki user @access public @param string $text Text to send @param string $subject Subject of email. Default 'Wikipedia Email' @param bool $ccme Whether or not to send a copy of the email to "myself". Default false. @throws EmailError @return bool True on success, false otherwise.
[ "Send", "an", "email", "to", "another", "wiki", "user" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L641-L687
MW-Peachy/Peachy
Includes/User.php
User.deletedcontribs
public function deletedcontribs( $content = false, $start = null, $end = null, $dir = 'older', $prop = array( 'revid', 'user', 'parsedcomment', 'minor', 'len', 'content', 'token' ) ) { if( !in_array( 'deletedhistory', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to view deleted revisions", PECHO_FATAL ); return false; } if( $content ) $prop[] = 'content'; $drArray = array( '_code' => 'dr', 'list' => 'deletedrevs', 'druser' => $this->username, 'drprop' => implode( '|', $prop ), 'drdir' => $dir ); if( !is_null( $start ) ) $drArray['drstart'] = $start; if( !is_null( $end ) ) $drArray['drend'] = $end; Hooks::runHook( 'StartDelrevs', array( &$drArray ) ); pecho( "Getting deleted revisions by {$this->username}...\n\n", PECHO_NORMAL ); return $this->wiki->listHandler( $drArray ); }
php
public function deletedcontribs( $content = false, $start = null, $end = null, $dir = 'older', $prop = array( 'revid', 'user', 'parsedcomment', 'minor', 'len', 'content', 'token' ) ) { if( !in_array( 'deletedhistory', $this->wiki->get_userrights() ) ) { pecho( "User is not allowed to view deleted revisions", PECHO_FATAL ); return false; } if( $content ) $prop[] = 'content'; $drArray = array( '_code' => 'dr', 'list' => 'deletedrevs', 'druser' => $this->username, 'drprop' => implode( '|', $prop ), 'drdir' => $dir ); if( !is_null( $start ) ) $drArray['drstart'] = $start; if( !is_null( $end ) ) $drArray['drend'] = $end; Hooks::runHook( 'StartDelrevs', array( &$drArray ) ); pecho( "Getting deleted revisions by {$this->username}...\n\n", PECHO_NORMAL ); return $this->wiki->listHandler( $drArray ); }
[ "public", "function", "deletedcontribs", "(", "$", "content", "=", "false", ",", "$", "start", "=", "null", ",", "$", "end", "=", "null", ",", "$", "dir", "=", "'older'", ",", "$", "prop", "=", "array", "(", "'revid'", ",", "'user'", ",", "'parsedcom...
List all deleted contributions. The logged in user must have the 'deletedhistory' right @access public @param bool $content Whether or not to return content of each contribution. Default false @param string $start Timestamp to start at. Default null. @param string $end Timestamp to end at. Default null. @param string $dir Direction to list. Default 'older' @param array $prop Information to retrieve. Default array( 'revid', 'user', 'parsedcomment', 'minor', 'len', 'content', 'token' ) @return array
[ "List", "all", "deleted", "contributions", ".", "The", "logged", "in", "user", "must", "have", "the", "deletedhistory", "right" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/User.php#L744-L770
budde377/Part
lib/util/db/MySQLDBImpl.php
MySQLDBImpl.getConnection
public function getConnection() { if ($this->connection === null) { $this->connection = new PDO( 'mysql:dbname=' . $this->database . ';host=' . $this->host, $this->username, $this->password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } return $this->connection; }
php
public function getConnection() { if ($this->connection === null) { $this->connection = new PDO( 'mysql:dbname=' . $this->database . ';host=' . $this->host, $this->username, $this->password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } return $this->connection; }
[ "public", "function", "getConnection", "(", ")", "{", "if", "(", "$", "this", "->", "connection", "===", "null", ")", "{", "$", "this", "->", "connection", "=", "new", "PDO", "(", "'mysql:dbname='", ".", "$", "this", "->", "database", ".", "';host='", ...
This returns the current connection, with info provided in config. @return PDO
[ "This", "returns", "the", "current", "connection", "with", "info", "provided", "in", "config", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/db/MySQLDBImpl.php#L47-L58
budde377/Part
lib/util/db/MySQLDBImpl.php
MySQLDBImpl.update
public function update() { $this->setUpVersion(); $connection = $this->getConnection(); foreach ($this->folders as $name => $path) { $folder = new FolderImpl($path); if (!$folder->exists()) { continue; } /** @var File[] $files */ $files = $folder->listFolder(Folder::LIST_FOLDER_FILES); usort($files, function (File $a, File $b) { return $this->leadingNumber($a->getFilename()) - $this->leadingNumber($b->getFilename()); }); $lastFile = null; $version = $this->getVersion($name); foreach ($files as $file) { if ($file->getExtension() != 'sql') { continue; } if ($this->leadingNumber($file->getFilename()) <= $version) { continue; } $stmt = $connection->prepare($file->getContents()); $stmt->execute(); while ($stmt->nextRowset()) ; //Polling row sets $lastFile = $file; } if ($lastFile == null) { continue; } $this->setVersion($name, $this->leadingNumber($lastFile->getFilename())); } }
php
public function update() { $this->setUpVersion(); $connection = $this->getConnection(); foreach ($this->folders as $name => $path) { $folder = new FolderImpl($path); if (!$folder->exists()) { continue; } /** @var File[] $files */ $files = $folder->listFolder(Folder::LIST_FOLDER_FILES); usort($files, function (File $a, File $b) { return $this->leadingNumber($a->getFilename()) - $this->leadingNumber($b->getFilename()); }); $lastFile = null; $version = $this->getVersion($name); foreach ($files as $file) { if ($file->getExtension() != 'sql') { continue; } if ($this->leadingNumber($file->getFilename()) <= $version) { continue; } $stmt = $connection->prepare($file->getContents()); $stmt->execute(); while ($stmt->nextRowset()) ; //Polling row sets $lastFile = $file; } if ($lastFile == null) { continue; } $this->setVersion($name, $this->leadingNumber($lastFile->getFilename())); } }
[ "public", "function", "update", "(", ")", "{", "$", "this", "->", "setUpVersion", "(", ")", ";", "$", "connection", "=", "$", "this", "->", "getConnection", "(", ")", ";", "foreach", "(", "$", "this", "->", "folders", "as", "$", "name", "=>", "$", ...
Updates the database according to the sql files in the designated db folders. @return void
[ "Updates", "the", "database", "according", "to", "the", "sql", "files", "in", "the", "designated", "db", "folders", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/db/MySQLDBImpl.php#L67-L106
baleen/migrations
src/Service/DomainBus/Migrate/Collection/CollectionHandler.php
CollectionHandler.handle
public function handle(CollectionCommand $command) { $target = $command->getTarget(); $collection = $command->getCollection(); $options = $command->getOptions(); $direction = $options->getDirection(); $comparator = $collection->getComparator(); if ($direction->isDown()) { $comparator = $comparator->getReverse(); } // filter to only get versions that need to be migrated $filter = function (DeltaInterface $v) use ($target, $comparator, $direction) { return ($direction->isUp() ^ $v->isMigrated()) // direction must be opposite to migration status && $comparator->compare($v, $target) <= 0; // version must be before or be equal to target (not // affected by direction because comparator is reversed) }; $scheduled = $collection->filter($filter)->sort($comparator); // we don't check if $scheduled is empty after filtering because the collection-before and -after events should // still be triggered by the runner $event = $this->createRunnerFor($scheduled)->run($target, $options); return $command->getVersionRepository()->updateAll($event->getCollection()); }
php
public function handle(CollectionCommand $command) { $target = $command->getTarget(); $collection = $command->getCollection(); $options = $command->getOptions(); $direction = $options->getDirection(); $comparator = $collection->getComparator(); if ($direction->isDown()) { $comparator = $comparator->getReverse(); } // filter to only get versions that need to be migrated $filter = function (DeltaInterface $v) use ($target, $comparator, $direction) { return ($direction->isUp() ^ $v->isMigrated()) // direction must be opposite to migration status && $comparator->compare($v, $target) <= 0; // version must be before or be equal to target (not // affected by direction because comparator is reversed) }; $scheduled = $collection->filter($filter)->sort($comparator); // we don't check if $scheduled is empty after filtering because the collection-before and -after events should // still be triggered by the runner $event = $this->createRunnerFor($scheduled)->run($target, $options); return $command->getVersionRepository()->updateAll($event->getCollection()); }
[ "public", "function", "handle", "(", "CollectionCommand", "$", "command", ")", "{", "$", "target", "=", "$", "command", "->", "getTarget", "(", ")", ";", "$", "collection", "=", "$", "command", "->", "getCollection", "(", ")", ";", "$", "options", "=", ...
Handle an "up" migration against a collection @param CollectionCommand $command @return bool The result of saving the collection of updated versions to the repository
[ "Handle", "an", "up", "migration", "against", "a", "collection" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Service/DomainBus/Migrate/Collection/CollectionHandler.php#L56-L80
marvin255/bxcodegen
src/Factory.php
Factory.registerCommands
public static function registerCommands(Application $app, $pathToYaml) { $bxcodegen = self::createCodegenFromYaml($pathToYaml); $app->add((new ComponentCommand)->setBxcodegen($bxcodegen)); $app->add((new ModuleCommand)->setBxcodegen($bxcodegen)); $app->add((new RocketeerCommand)->setBxcodegen($bxcodegen)); $app->add((new OrmCommand)->setBxcodegen($bxcodegen)); return $bxcodegen; }
php
public static function registerCommands(Application $app, $pathToYaml) { $bxcodegen = self::createCodegenFromYaml($pathToYaml); $app->add((new ComponentCommand)->setBxcodegen($bxcodegen)); $app->add((new ModuleCommand)->setBxcodegen($bxcodegen)); $app->add((new RocketeerCommand)->setBxcodegen($bxcodegen)); $app->add((new OrmCommand)->setBxcodegen($bxcodegen)); return $bxcodegen; }
[ "public", "static", "function", "registerCommands", "(", "Application", "$", "app", ",", "$", "pathToYaml", ")", "{", "$", "bxcodegen", "=", "self", "::", "createCodegenFromYaml", "(", "$", "pathToYaml", ")", ";", "$", "app", "->", "add", "(", "(", "new", ...
Регистрирует консольные команды в объекте приложения Symfony console, из настроек, указанных в yaml файле. @param \Symfony\Component\Console\Application $app @param string $pathToYaml @return \marvin255\bxcodegen\Bxcodegen
[ "Регистрирует", "консольные", "команды", "в", "объекте", "приложения", "Symfony", "console", "из", "настроек", "указанных", "в", "yaml", "файле", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/Factory.php#L35-L45
marvin255/bxcodegen
src/Factory.php
Factory.createDefault
public static function createDefault($workDir) { $arOptions = [ 'services' => [ 'pathManager' => [ PathManager::class, $workDir, [ 'components' => '/web/local/components', 'modules' => '/web/local/modules', ], ], 'renderer' => [ Twig::class, ], 'copier' => [ Copier::class, ], ], 'generators' => [ 'rocketeer' => [ 'class' => Rocketeer::class, ], 'component' => [ 'class' => Component::class, ], 'module' => [ 'class' => Module::class, ], 'orm' => [ 'class' => Orm::class, ], ], ]; return new Bxcodegen(new Collection($arOptions), new ServiceLocator); }
php
public static function createDefault($workDir) { $arOptions = [ 'services' => [ 'pathManager' => [ PathManager::class, $workDir, [ 'components' => '/web/local/components', 'modules' => '/web/local/modules', ], ], 'renderer' => [ Twig::class, ], 'copier' => [ Copier::class, ], ], 'generators' => [ 'rocketeer' => [ 'class' => Rocketeer::class, ], 'component' => [ 'class' => Component::class, ], 'module' => [ 'class' => Module::class, ], 'orm' => [ 'class' => Orm::class, ], ], ]; return new Bxcodegen(new Collection($arOptions), new ServiceLocator); }
[ "public", "static", "function", "createDefault", "(", "$", "workDir", ")", "{", "$", "arOptions", "=", "[", "'services'", "=>", "[", "'pathManager'", "=>", "[", "PathManager", "::", "class", ",", "$", "workDir", ",", "[", "'components'", "=>", "'/web/local/c...
Создает менеджер генераторов с дефолтными настройками. @param string $workDir @return \marvin255\bxcodegen\Bxcodegen
[ "Создает", "менеджер", "генераторов", "с", "дефолтными", "настройками", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/Factory.php#L54-L90
marvin255/bxcodegen
src/Factory.php
Factory.createCodegenFromYaml
protected static function createCodegenFromYaml($pathToYaml = null) { $realPathToYaml = $pathToYaml ? realpath($pathToYaml) : false; if ($realPathToYaml && file_exists($realPathToYaml)) { $arOptions = self::getOptionsFromYaml($realPathToYaml); } else { throw new InvalidArgumentException("Yaml file doesn't exist"); } return new Bxcodegen(new Collection($arOptions), new ServiceLocator); }
php
protected static function createCodegenFromYaml($pathToYaml = null) { $realPathToYaml = $pathToYaml ? realpath($pathToYaml) : false; if ($realPathToYaml && file_exists($realPathToYaml)) { $arOptions = self::getOptionsFromYaml($realPathToYaml); } else { throw new InvalidArgumentException("Yaml file doesn't exist"); } return new Bxcodegen(new Collection($arOptions), new ServiceLocator); }
[ "protected", "static", "function", "createCodegenFromYaml", "(", "$", "pathToYaml", "=", "null", ")", "{", "$", "realPathToYaml", "=", "$", "pathToYaml", "?", "realpath", "(", "$", "pathToYaml", ")", ":", "false", ";", "if", "(", "$", "realPathToYaml", "&&",...
Создает объект Bxcodegen из настроек в yaml файле. @param string $pathToYaml @return \marvin255\bxcodegen\Bxcodegen @throws \InvalidArgumentException
[ "Создает", "объект", "Bxcodegen", "из", "настроек", "в", "yaml", "файле", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/Factory.php#L101-L112
marvin255/bxcodegen
src/Factory.php
Factory.getOptionsFromYaml
protected static function getOptionsFromYaml($pathToYaml) { $raw = (new SymfonyYaml)->parseFromFile($pathToYaml) ?: []; return self::setReplacesToArray($raw, [ '@currFile' => $pathToYaml, '@currDir' => pathinfo($pathToYaml, PATHINFO_DIRNAME), ]); }
php
protected static function getOptionsFromYaml($pathToYaml) { $raw = (new SymfonyYaml)->parseFromFile($pathToYaml) ?: []; return self::setReplacesToArray($raw, [ '@currFile' => $pathToYaml, '@currDir' => pathinfo($pathToYaml, PATHINFO_DIRNAME), ]); }
[ "protected", "static", "function", "getOptionsFromYaml", "(", "$", "pathToYaml", ")", "{", "$", "raw", "=", "(", "new", "SymfonyYaml", ")", "->", "parseFromFile", "(", "$", "pathToYaml", ")", "?", ":", "[", "]", ";", "return", "self", "::", "setReplacesToA...
Получает список настроек из yaml файла. @param string $pathToYaml @return array
[ "Получает", "список", "настроек", "из", "yaml", "файла", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/Factory.php#L121-L129
marvin255/bxcodegen
src/Factory.php
Factory.setReplacesToArray
protected static function setReplacesToArray(array $params, array $replaces) { $return = []; foreach ($params as $key => $value) { if (is_array($value)) { $return[$key] = self::setReplacesToArray($value, $replaces); } elseif (array_key_exists($value, $replaces)) { $return[$key] = $replaces[$value]; } else { $return[$key] = $value; } } return $return; }
php
protected static function setReplacesToArray(array $params, array $replaces) { $return = []; foreach ($params as $key => $value) { if (is_array($value)) { $return[$key] = self::setReplacesToArray($value, $replaces); } elseif (array_key_exists($value, $replaces)) { $return[$key] = $replaces[$value]; } else { $return[$key] = $value; } } return $return; }
[ "protected", "static", "function", "setReplacesToArray", "(", "array", "$", "params", ",", "array", "$", "replaces", ")", "{", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "("...
Производит замену плейсхолдеров на предопределенные значения. @param array $params @param array $replaces @return array
[ "Производит", "замену", "плейсхолдеров", "на", "предопределенные", "значения", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/Factory.php#L139-L153
budde377/Part
lib/util/file/FolderImpl.php
FolderImpl.current
public function current() { if($this->folderList == null){ $this->folderList = $this->listFolder(); } return $this->folderList[$this->key]; }
php
public function current() { if($this->folderList == null){ $this->folderList = $this->listFolder(); } return $this->folderList[$this->key]; }
[ "public", "function", "current", "(", ")", "{", "if", "(", "$", "this", "->", "folderList", "==", "null", ")", "{", "$", "this", "->", "folderList", "=", "$", "this", "->", "listFolder", "(", ")", ";", "}", "return", "$", "this", "->", "folderList", ...
(PHP 5 &gt;= 5.0.0)<br/> Return the current element @link http://php.net/manual/en/iterator.current.php @return mixed Can return any type.
[ "(", "PHP", "5", "&gt", ";", "=", "5", ".", "0", ".", "0", ")", "<br", "/", ">", "Return", "the", "current", "element" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FolderImpl.php#L35-L41
budde377/Part
lib/util/file/FolderImpl.php
FolderImpl.valid
public function valid() { if($this->folderList == null){ $this->folderList = $this->listFolder(); } return is_array($this->folderList) && isset($this->folderList[$this->key]); }
php
public function valid() { if($this->folderList == null){ $this->folderList = $this->listFolder(); } return is_array($this->folderList) && isset($this->folderList[$this->key]); }
[ "public", "function", "valid", "(", ")", "{", "if", "(", "$", "this", "->", "folderList", "==", "null", ")", "{", "$", "this", "->", "folderList", "=", "$", "this", "->", "listFolder", "(", ")", ";", "}", "return", "is_array", "(", "$", "this", "->...
(PHP 5 &gt;= 5.0.0)<br/> Checks if current position is valid @link http://php.net/manual/en/iterator.valid.php @return boolean The return value will be casted to boolean and then evaluated. Returns true on success or false on failure.
[ "(", "PHP", "5", "&gt", ";", "=", "5", ".", "0", ".", "0", ")", "<br", "/", ">", "Checks", "if", "current", "position", "is", "valid" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FolderImpl.php#L72-L78
budde377/Part
lib/util/file/FolderImpl.php
FolderImpl.clean
public function clean() { foreach($this->listFolder() as $f){ if($f instanceof Folder){ $f->delete(Folder::DELETE_FOLDER_RECURSIVE); } else if($f instanceof File){ $f->delete(); } } }
php
public function clean() { foreach($this->listFolder() as $f){ if($f instanceof Folder){ $f->delete(Folder::DELETE_FOLDER_RECURSIVE); } else if($f instanceof File){ $f->delete(); } } }
[ "public", "function", "clean", "(", ")", "{", "foreach", "(", "$", "this", "->", "listFolder", "(", ")", "as", "$", "f", ")", "{", "if", "(", "$", "f", "instanceof", "Folder", ")", "{", "$", "f", "->", "delete", "(", "Folder", "::", "DELETE_FOLDER_...
Cleans the folder for all content, folders as files. @return void
[ "Cleans", "the", "folder", "for", "all", "content", "folders", "as", "files", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FolderImpl.php#L284-L293
budde377/Part
lib/util/file/FolderImpl.php
FolderImpl.putFile
public function putFile(File $file, $newName = null) { if($file == null){ return null; } $name = $newName == null?$file->getFilename():$newName; if(($f = $file->copy($this->folderPath."/".$name)) == null){ return null; } return $f; }
php
public function putFile(File $file, $newName = null) { if($file == null){ return null; } $name = $newName == null?$file->getFilename():$newName; if(($f = $file->copy($this->folderPath."/".$name)) == null){ return null; } return $f; }
[ "public", "function", "putFile", "(", "File", "$", "file", ",", "$", "newName", "=", "null", ")", "{", "if", "(", "$", "file", "==", "null", ")", "{", "return", "null", ";", "}", "$", "name", "=", "$", "newName", "==", "null", "?", "$", "file", ...
Will put a folder to the folder (copy the folder into current folder) @param File $file @param null $newName The new name of the file, if Null then new file will preserve name @return null | File Return new file in folder on success and Null on failure
[ "Will", "put", "a", "folder", "to", "the", "folder", "(", "copy", "the", "folder", "into", "current", "folder", ")" ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FolderImpl.php#L301-L315
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/ClassWithEmbeddedMessageProperty/Meta/EmbeddedMeta.php
EmbeddedMeta.create
public static function create() { switch (func_num_args()) { case 0: return new Embedded(); case 1: return new Embedded(func_get_arg(0)); case 2: return new Embedded(func_get_arg(0), func_get_arg(1)); case 3: return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new Embedded(); case 1: return new Embedded(func_get_arg(0)); case 2: return new Embedded(func_get_arg(0), func_get_arg(1)); case 3: return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new Embedded(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "Embedded", "(", ")", ";", "case", "1", ":", "return", "new", "Embedded", "(", "func_get_arg", "(", "0", "...
Creates new instance of \Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty\Embedded @throws \InvalidArgumentException @return Embedded
[ "Creates", "new", "instance", "of", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithEmbeddedMessageProperty", "\\", "Embedded" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/ClassWithEmbeddedMessageProperty/Meta/EmbeddedMeta.php#L66-L90
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/ClassWithEmbeddedMessageProperty/Meta/EmbeddedMeta.php
EmbeddedMeta.fromArray
public static function fromArray($input, $group = NULL, $object = NULL) { if (!isset(self::$groups[$group])) { throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithEmbeddedMessageProperty\\Embedded' . '.'); } else { $id = self::$groups[$group]; } if ($object === null) { $object = new Embedded(); } elseif (!($object instanceof Embedded)) { throw new \InvalidArgumentException('You have to pass object of class Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty\Embedded.'); } if (($id & 1) > 0 && isset($input['x'])) { $object->x = $input['x']; } elseif (($id & 1) > 0 && array_key_exists('x', $input) && $input['x'] === null) { $object->x = null; } return $object; }
php
public static function fromArray($input, $group = NULL, $object = NULL) { if (!isset(self::$groups[$group])) { throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithEmbeddedMessageProperty\\Embedded' . '.'); } else { $id = self::$groups[$group]; } if ($object === null) { $object = new Embedded(); } elseif (!($object instanceof Embedded)) { throw new \InvalidArgumentException('You have to pass object of class Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty\Embedded.'); } if (($id & 1) > 0 && isset($input['x'])) { $object->x = $input['x']; } elseif (($id & 1) > 0 && array_key_exists('x', $input) && $input['x'] === null) { $object->x = null; } return $object; }
[ "public", "static", "function", "fromArray", "(", "$", "input", ",", "$", "group", "=", "NULL", ",", "$", "object", "=", "NULL", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "groups", "[", "$", "group", "]", ")", ")", "{", "throw", ...
Creates \Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty\Embedded object from array @param array $input @param string $group @param Embedded $object @throws \Exception @return Embedded
[ "Creates", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithEmbeddedMessageProperty", "\\", "Embedded", "object", "from", "array" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/ClassWithEmbeddedMessageProperty/Meta/EmbeddedMeta.php#L153-L174
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/ClassWithEmbeddedMessageProperty/Meta/EmbeddedMeta.php
EmbeddedMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new Embedded(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->x = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
php
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new Embedded(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->x = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
[ "public", "static", "function", "fromProtobuf", "(", "$", "input", ",", "$", "object", "=", "NULL", ",", "&", "$", "start", "=", "0", ",", "$", "end", "=", "NULL", ")", "{", "if", "(", "$", "object", "===", "null", ")", "{", "$", "object", "=", ...
Creates \Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty\Embedded object from serialized Protocol Buffers message. @param string $input @param Embedded $object @param int $start @param int $end @throws \Exception @return Embedded
[ "Creates", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithEmbeddedMessageProperty", "\\", "Embedded", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/ClassWithEmbeddedMessageProperty/Meta/EmbeddedMeta.php#L332-L383
fab2s/NodalFlow
src/Events/CallbackWrapper.php
CallbackWrapper.progress
public function progress(FlowEventInterface $event) { $this->callBack->progress($event->getFlow(), $event->getNode()); }
php
public function progress(FlowEventInterface $event) { $this->callBack->progress($event->getFlow(), $event->getNode()); }
[ "public", "function", "progress", "(", "FlowEventInterface", "$", "event", ")", "{", "$", "this", "->", "callBack", "->", "progress", "(", "$", "event", "->", "getFlow", "(", ")", ",", "$", "event", "->", "getNode", "(", ")", ")", ";", "}" ]
Triggered when a Flow progresses, eg exec once or generates once @param FlowEventInterface $event
[ "Triggered", "when", "a", "Flow", "progresses", "eg", "exec", "once", "or", "generates", "once" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Events/CallbackWrapper.php#L66-L69
joetannenbaum/phpushbullet
src/Request/PushAddress.php
PushAddress.setAddress
protected function setAddress($address) { if (is_array($address)) { $new_address = []; foreach (['address', 'city', 'state', 'zip'] as $field) { if (array_key_exists($field, $address)) { $new_address[] = $address[$field]; } } $address = implode(' ', $new_address); } return $address; }
php
protected function setAddress($address) { if (is_array($address)) { $new_address = []; foreach (['address', 'city', 'state', 'zip'] as $field) { if (array_key_exists($field, $address)) { $new_address[] = $address[$field]; } } $address = implode(' ', $new_address); } return $address; }
[ "protected", "function", "setAddress", "(", "$", "address", ")", "{", "if", "(", "is_array", "(", "$", "address", ")", ")", "{", "$", "new_address", "=", "[", "]", ";", "foreach", "(", "[", "'address'", ",", "'city'", ",", "'state'", ",", "'zip'", "]...
The address can either be a string or an array, make sure it's a string in the end @param string|array $address @return string
[ "The", "address", "can", "either", "be", "a", "string", "or", "an", "array", "make", "sure", "it", "s", "a", "string", "in", "the", "end" ]
train
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/Request/PushAddress.php#L29-L44
toni-kolev/MultilingualExtension
src/Context/RawMultilingualContext.php
RawMultilingualContext.getMultilingualParameter
protected function getMultilingualParameter($name) { return isset($this->multilingual_parameters[$name]) ? $this->multilingual_parameters[$name] : false; }
php
protected function getMultilingualParameter($name) { return isset($this->multilingual_parameters[$name]) ? $this->multilingual_parameters[$name] : false; }
[ "protected", "function", "getMultilingualParameter", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "multilingual_parameters", "[", "$", "name", "]", ")", "?", "$", "this", "->", "multilingual_parameters", "[", "$", "name", "]", ":", ...
@param string $name The name of parameter from behat.yml. @return mixed
[ "@param", "string", "$name", "The", "name", "of", "parameter", "from", "behat", ".", "yml", "." ]
train
https://github.com/toni-kolev/MultilingualExtension/blob/e0e1a9fc30e176e597bebb467ddf195cd5d555c3/src/Context/RawMultilingualContext.php#L39-L42
skrz/meta
gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php
LocationMeta.create
public static function create() { switch (func_num_args()) { case 0: return new Location(); case 1: return new Location(func_get_arg(0)); case 2: return new Location(func_get_arg(0), func_get_arg(1)); case 3: return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new Location(); case 1: return new Location(func_get_arg(0)); case 2: return new Location(func_get_arg(0), func_get_arg(1)); case 3: return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new Location(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "Location", "(", ")", ";", "case", "1", ":", "return", "new", "Location", "(", "func_get_arg", "(", "0", "...
Creates new instance of \Google\Protobuf\SourceCodeInfo\Location @throws \InvalidArgumentException @return Location
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "SourceCodeInfo", "\\", "Location" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php#L61-L85
skrz/meta
gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php
LocationMeta.reset
public static function reset($object) { if (!($object instanceof Location)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\SourceCodeInfo\Location.'); } $object->path = NULL; $object->span = NULL; $object->leadingComments = NULL; $object->trailingComments = NULL; $object->leadingDetachedComments = NULL; }
php
public static function reset($object) { if (!($object instanceof Location)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\SourceCodeInfo\Location.'); } $object->path = NULL; $object->span = NULL; $object->leadingComments = NULL; $object->trailingComments = NULL; $object->leadingDetachedComments = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "Location", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\\SourceCode...
Resets properties of \Google\Protobuf\SourceCodeInfo\Location to default values @param Location $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "SourceCodeInfo", "\\", "Location", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php#L98-L108
skrz/meta
gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php
LocationMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->path)) { hash_update($ctx, 'path'); foreach ($object->path instanceof \Traversable ? $object->path : (array)$object->path as $v0) { hash_update($ctx, (string)$v0); } } if (isset($object->span)) { hash_update($ctx, 'span'); foreach ($object->span instanceof \Traversable ? $object->span : (array)$object->span as $v0) { hash_update($ctx, (string)$v0); } } if (isset($object->leadingComments)) { hash_update($ctx, 'leadingComments'); hash_update($ctx, (string)$object->leadingComments); } if (isset($object->trailingComments)) { hash_update($ctx, 'trailingComments'); hash_update($ctx, (string)$object->trailingComments); } if (isset($object->leadingDetachedComments)) { hash_update($ctx, 'leadingDetachedComments'); foreach ($object->leadingDetachedComments instanceof \Traversable ? $object->leadingDetachedComments : (array)$object->leadingDetachedComments as $v0) { hash_update($ctx, (string)$v0); } } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
php
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->path)) { hash_update($ctx, 'path'); foreach ($object->path instanceof \Traversable ? $object->path : (array)$object->path as $v0) { hash_update($ctx, (string)$v0); } } if (isset($object->span)) { hash_update($ctx, 'span'); foreach ($object->span instanceof \Traversable ? $object->span : (array)$object->span as $v0) { hash_update($ctx, (string)$v0); } } if (isset($object->leadingComments)) { hash_update($ctx, 'leadingComments'); hash_update($ctx, (string)$object->leadingComments); } if (isset($object->trailingComments)) { hash_update($ctx, 'trailingComments'); hash_update($ctx, (string)$object->trailingComments); } if (isset($object->leadingDetachedComments)) { hash_update($ctx, 'leadingDetachedComments'); foreach ($object->leadingDetachedComments instanceof \Traversable ? $object->leadingDetachedComments : (array)$object->leadingDetachedComments as $v0) { hash_update($ctx, (string)$v0); } } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
[ "public", "static", "function", "hash", "(", "$", "object", ",", "$", "algoOrCtx", "=", "'md5'", ",", "$", "raw", "=", "FALSE", ")", "{", "if", "(", "is_string", "(", "$", "algoOrCtx", ")", ")", "{", "$", "ctx", "=", "hash_init", "(", "$", "algoOrC...
Computes hash of \Google\Protobuf\SourceCodeInfo\Location @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "SourceCodeInfo", "\\", "Location" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php#L120-L164
skrz/meta
gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php
LocationMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new Location(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->path) && is_array($object->path))) { $object->path = array(); } $packedLength = Binary::decodeVarint($input, $start); $expectedPacked = $start + $packedLength; if ($expectedPacked > $end) { throw new ProtobufException('Not enough data.'); } while ($start < $expectedPacked) { $object->path[] = Binary::decodeVarint($input, $start); } if ($start !== $expectedPacked) { throw new ProtobufException('Unexpected start. Expected ' . $expectedPacked . ', got ' . $start . '.', $number); } break; case 2: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->span) && is_array($object->span))) { $object->span = array(); } $packedLength = Binary::decodeVarint($input, $start); $expectedPacked = $start + $packedLength; if ($expectedPacked > $end) { throw new ProtobufException('Not enough data.'); } while ($start < $expectedPacked) { $object->span[] = Binary::decodeVarint($input, $start); } if ($start !== $expectedPacked) { throw new ProtobufException('Unexpected start. Expected ' . $expectedPacked . ', got ' . $start . '.', $number); } break; case 3: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->leadingComments = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 4: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->trailingComments = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 6: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->leadingDetachedComments) && is_array($object->leadingDetachedComments))) { $object->leadingDetachedComments = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->leadingDetachedComments[] = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
php
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new Location(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->path) && is_array($object->path))) { $object->path = array(); } $packedLength = Binary::decodeVarint($input, $start); $expectedPacked = $start + $packedLength; if ($expectedPacked > $end) { throw new ProtobufException('Not enough data.'); } while ($start < $expectedPacked) { $object->path[] = Binary::decodeVarint($input, $start); } if ($start !== $expectedPacked) { throw new ProtobufException('Unexpected start. Expected ' . $expectedPacked . ', got ' . $start . '.', $number); } break; case 2: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->span) && is_array($object->span))) { $object->span = array(); } $packedLength = Binary::decodeVarint($input, $start); $expectedPacked = $start + $packedLength; if ($expectedPacked > $end) { throw new ProtobufException('Not enough data.'); } while ($start < $expectedPacked) { $object->span[] = Binary::decodeVarint($input, $start); } if ($start !== $expectedPacked) { throw new ProtobufException('Unexpected start. Expected ' . $expectedPacked . ', got ' . $start . '.', $number); } break; case 3: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->leadingComments = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 4: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->trailingComments = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 6: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } if (!(isset($object->leadingDetachedComments) && is_array($object->leadingDetachedComments))) { $object->leadingDetachedComments = array(); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->leadingDetachedComments[] = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
[ "public", "static", "function", "fromProtobuf", "(", "$", "input", ",", "$", "object", "=", "NULL", ",", "&", "$", "start", "=", "0", ",", "$", "end", "=", "NULL", ")", "{", "if", "(", "$", "object", "===", "null", ")", "{", "$", "object", "=", ...
Creates \Google\Protobuf\SourceCodeInfo\Location object from serialized Protocol Buffers message. @param string $input @param Location $object @param int $start @param int $end @throws \Exception @return Location
[ "Creates", "\\", "Google", "\\", "Protobuf", "\\", "SourceCodeInfo", "\\", "Location", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php#L179-L301
skrz/meta
gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php
LocationMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->path) && ($filter === null || isset($filter['path']))) { $packedBuffer = ''; $output .= "\x0a"; foreach ($object->path instanceof \Traversable ? $object->path : (array)$object->path as $k => $v) { $packedBuffer .= Binary::encodeVarint($v); } $output .= Binary::encodeVarint(strlen($packedBuffer)); $output .= $packedBuffer; } if (isset($object->span) && ($filter === null || isset($filter['span']))) { $packedBuffer = ''; $output .= "\x12"; foreach ($object->span instanceof \Traversable ? $object->span : (array)$object->span as $k => $v) { $packedBuffer .= Binary::encodeVarint($v); } $output .= Binary::encodeVarint(strlen($packedBuffer)); $output .= $packedBuffer; } if (isset($object->leadingComments) && ($filter === null || isset($filter['leadingComments']))) { $output .= "\x1a"; $output .= Binary::encodeVarint(strlen($object->leadingComments)); $output .= $object->leadingComments; } if (isset($object->trailingComments) && ($filter === null || isset($filter['trailingComments']))) { $output .= "\x22"; $output .= Binary::encodeVarint(strlen($object->trailingComments)); $output .= $object->trailingComments; } if (isset($object->leadingDetachedComments) && ($filter === null || isset($filter['leadingDetachedComments']))) { foreach ($object->leadingDetachedComments instanceof \Traversable ? $object->leadingDetachedComments : (array)$object->leadingDetachedComments as $k => $v) { $output .= "\x32"; $output .= Binary::encodeVarint(strlen($v)); $output .= $v; } } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->path) && ($filter === null || isset($filter['path']))) { $packedBuffer = ''; $output .= "\x0a"; foreach ($object->path instanceof \Traversable ? $object->path : (array)$object->path as $k => $v) { $packedBuffer .= Binary::encodeVarint($v); } $output .= Binary::encodeVarint(strlen($packedBuffer)); $output .= $packedBuffer; } if (isset($object->span) && ($filter === null || isset($filter['span']))) { $packedBuffer = ''; $output .= "\x12"; foreach ($object->span instanceof \Traversable ? $object->span : (array)$object->span as $k => $v) { $packedBuffer .= Binary::encodeVarint($v); } $output .= Binary::encodeVarint(strlen($packedBuffer)); $output .= $packedBuffer; } if (isset($object->leadingComments) && ($filter === null || isset($filter['leadingComments']))) { $output .= "\x1a"; $output .= Binary::encodeVarint(strlen($object->leadingComments)); $output .= $object->leadingComments; } if (isset($object->trailingComments) && ($filter === null || isset($filter['trailingComments']))) { $output .= "\x22"; $output .= Binary::encodeVarint(strlen($object->trailingComments)); $output .= $object->trailingComments; } if (isset($object->leadingDetachedComments) && ($filter === null || isset($filter['leadingDetachedComments']))) { foreach ($object->leadingDetachedComments instanceof \Traversable ? $object->leadingDetachedComments : (array)$object->leadingDetachedComments as $k => $v) { $output .= "\x32"; $output .= Binary::encodeVarint(strlen($v)); $output .= $v; } } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "path", ")", "&&", "(", "$", "filter", "===", "null", "||", ...
Serialized \Google\Protobuf\SourceCodeInfo\Location to Protocol Buffers message. @param Location $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "SourceCodeInfo", "\\", "Location", "to", "Protocol", "Buffers", "message", "." ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/SourceCodeInfo/Meta/LocationMeta.php#L314-L359
marvin255/bxcodegen
src/service/path/PathManager.php
PathManager.setAlias
public function setAlias($alias, $path) { if (!preg_match('/^[a-z0-9_]{3,}$/', $alias)) { throw new InvalidArgumentException( 'Alias name must consist of more than 2 symbols of latin, digits and _.' . " Got: {$alias}" ); } $this->aliases[$alias] = PathHelper::unify($path); return $this; }
php
public function setAlias($alias, $path) { if (!preg_match('/^[a-z0-9_]{3,}$/', $alias)) { throw new InvalidArgumentException( 'Alias name must consist of more than 2 symbols of latin, digits and _.' . " Got: {$alias}" ); } $this->aliases[$alias] = PathHelper::unify($path); return $this; }
[ "public", "function", "setAlias", "(", "$", "alias", ",", "$", "path", ")", "{", "if", "(", "!", "preg_match", "(", "'/^[a-z0-9_]{3,}$/'", ",", "$", "alias", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Alias name must consist of more than 2...
{@inheritdoc} @throws \InvalidArgumentException
[ "{", "@inheritdoc", "}" ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/service/path/PathManager.php#L69-L81
marvin255/bxcodegen
src/service/path/PathManager.php
PathManager.setPathForNamespace
public function setPathForNamespace($namespace, $path) { $unifiedNamespace = $this->unifyNamespace($namespace); if (!preg_match('/^[a-zA-Z0-9_\\\]{3,}$/', $unifiedNamespace)) { throw new InvalidArgumentException("Invalid namespace {$namespace}"); } $this->namespaces[$unifiedNamespace] = $path; return $this; }
php
public function setPathForNamespace($namespace, $path) { $unifiedNamespace = $this->unifyNamespace($namespace); if (!preg_match('/^[a-zA-Z0-9_\\\]{3,}$/', $unifiedNamespace)) { throw new InvalidArgumentException("Invalid namespace {$namespace}"); } $this->namespaces[$unifiedNamespace] = $path; return $this; }
[ "public", "function", "setPathForNamespace", "(", "$", "namespace", ",", "$", "path", ")", "{", "$", "unifiedNamespace", "=", "$", "this", "->", "unifyNamespace", "(", "$", "namespace", ")", ";", "if", "(", "!", "preg_match", "(", "'/^[a-zA-Z0-9_\\\\\\]{3,}$/'...
{@inheritdoc} @throws \InvalidArgumentException
[ "{", "@inheritdoc", "}" ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/service/path/PathManager.php#L98-L108
marvin255/bxcodegen
src/service/path/PathManager.php
PathManager.replaceAliases
protected function replaceAliases($path) { $toSearch = array_map(function ($item) { return "@{$item}"; }, array_keys($this->aliases)); $toReplace = array_values($this->aliases); return str_replace($toSearch, $toReplace, $path); }
php
protected function replaceAliases($path) { $toSearch = array_map(function ($item) { return "@{$item}"; }, array_keys($this->aliases)); $toReplace = array_values($this->aliases); return str_replace($toSearch, $toReplace, $path); }
[ "protected", "function", "replaceAliases", "(", "$", "path", ")", "{", "$", "toSearch", "=", "array_map", "(", "function", "(", "$", "item", ")", "{", "return", "\"@{$item}\"", ";", "}", ",", "array_keys", "(", "$", "this", "->", "aliases", ")", ")", "...
Заменяет псевдонимы в пути на их значения. @param string $path @return string
[ "Заменяет", "псевдонимы", "в", "пути", "на", "их", "значения", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/service/path/PathManager.php#L139-L148
marvin255/bxcodegen
src/service/path/PathManager.php
PathManager.selectNamespace
protected function selectNamespace($className) { $selectedNamespace = null; $selectedPath = null; foreach ($this->namespaces as $namespace => $path) { if ( strpos($className, $namespace) === 0 && (!$selectedNamespace || strlen($namespace) > strlen($selectedNamespace)) ) { $selectedNamespace = $namespace; $selectedPath = $this->getAbsolutePath($path); } } if (!$selectedNamespace) { $explodeClass = explode('\\', $className); if (count($explodeClass) > 2) { $moduleName = strtolower("{$explodeClass[0]}.{$explodeClass[1]}"); $pathToModule = "@modules/{$moduleName}/lib"; $absolutePathToModule = $this->getAbsolutePath($pathToModule); if (is_dir($absolutePathToModule)) { $selectedNamespace = "{$explodeClass[0]}\\{$explodeClass[1]}"; $selectedPath = $absolutePathToModule; } } } return [$selectedNamespace, $selectedPath]; }
php
protected function selectNamespace($className) { $selectedNamespace = null; $selectedPath = null; foreach ($this->namespaces as $namespace => $path) { if ( strpos($className, $namespace) === 0 && (!$selectedNamespace || strlen($namespace) > strlen($selectedNamespace)) ) { $selectedNamespace = $namespace; $selectedPath = $this->getAbsolutePath($path); } } if (!$selectedNamespace) { $explodeClass = explode('\\', $className); if (count($explodeClass) > 2) { $moduleName = strtolower("{$explodeClass[0]}.{$explodeClass[1]}"); $pathToModule = "@modules/{$moduleName}/lib"; $absolutePathToModule = $this->getAbsolutePath($pathToModule); if (is_dir($absolutePathToModule)) { $selectedNamespace = "{$explodeClass[0]}\\{$explodeClass[1]}"; $selectedPath = $absolutePathToModule; } } } return [$selectedNamespace, $selectedPath]; }
[ "protected", "function", "selectNamespace", "(", "$", "className", ")", "{", "$", "selectedNamespace", "=", "null", ";", "$", "selectedPath", "=", "null", ";", "foreach", "(", "$", "this", "->", "namespaces", "as", "$", "namespace", "=>", "$", "path", ")",...
Выбирает подходящее для класса пространство имен. Пробует подобрать самое длинное, которое входит в имя класса, если ничего подобрать не удается, то пробует найти соответствующий модуль согласно правилам автозагрузки в битриксе. @param string $className @return array
[ "Выбирает", "подходящее", "для", "класса", "пространство", "имен", "." ]
train
https://github.com/marvin255/bxcodegen/blob/2afa44426aa40c9cbfcdae745367d9dafd4d2f9f/src/service/path/PathManager.php#L161-L189
fab2s/NodalFlow
src/Nodes/AggregateNode.php
AggregateNode.getTraversable
public function getTraversable($param) { $value = null; /** @var $nodes TraversableNodeInterface[] */ $nodes = $this->payload->getNodes(); foreach ($nodes as $node) { $returnVal = $node->isReturningVal(); foreach ($node->getTraversable($param) as $value) { if ($returnVal) { yield $value; continue; } yield $param; } if ($returnVal) { // since this node is returning something // we will pass its last yield to the next // traversable. It will be up to him to // do whatever is necessary with it, including // nothing $param = $value; } } }
php
public function getTraversable($param) { $value = null; /** @var $nodes TraversableNodeInterface[] */ $nodes = $this->payload->getNodes(); foreach ($nodes as $node) { $returnVal = $node->isReturningVal(); foreach ($node->getTraversable($param) as $value) { if ($returnVal) { yield $value; continue; } yield $param; } if ($returnVal) { // since this node is returning something // we will pass its last yield to the next // traversable. It will be up to him to // do whatever is necessary with it, including // nothing $param = $value; } } }
[ "public", "function", "getTraversable", "(", "$", "param", ")", "{", "$", "value", "=", "null", ";", "/** @var $nodes TraversableNodeInterface[] */", "$", "nodes", "=", "$", "this", "->", "payload", "->", "getNodes", "(", ")", ";", "foreach", "(", "$", "node...
Get the traversable to traverse within the Flow @param mixed $param @return \Generator
[ "Get", "the", "traversable", "to", "traverse", "within", "the", "Flow" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Nodes/AggregateNode.php#L64-L89
MW-Peachy/Peachy
Includes/limeOutput.php
lime_output.diag
public function diag() { $messages = func_get_args(); foreach ($messages as $message) { echo $this->colorizer->colorize('# ' . join("\n# ", (array)$message), 'COMMENT') . "\n"; } }
php
public function diag() { $messages = func_get_args(); foreach ($messages as $message) { echo $this->colorizer->colorize('# ' . join("\n# ", (array)$message), 'COMMENT') . "\n"; } }
[ "public", "function", "diag", "(", ")", "{", "$", "messages", "=", "func_get_args", "(", ")", ";", "foreach", "(", "$", "messages", "as", "$", "message", ")", "{", "echo", "$", "this", "->", "colorizer", "->", "colorize", "(", "'# '", ".", "join", "(...
Produces an Echo
[ "Produces", "an", "Echo" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/limeOutput.php#L25-L31
entrecloud/php-gtmetrix
src/GTMetrixClient.php
GTMetrixClient.apiCall
protected function apiCall($url, $data = array(), $json = true) { if (!$this->username || !$this->apiKey) { throw new GTMetrixConfigurationException('Username and API key must be set up before using API calls!' . 'See setUsername() and setAPIKey() for details.'); } $ch = curl_init($this->endpoint . $url); if (!empty($data)) { curl_setopt($ch, CURLOPT_POST, count($data)); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); } curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, $this->username . ':' . $this->apiKey); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CAINFO, dirname(__DIR__) . '/data/ca-bundle.crt'); $result = curl_exec($ch); $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curlErrNo = curl_errno($ch); $curlError = curl_error($ch); curl_close ($ch); if (!\preg_match('/^(2|3)/', $statusCode)) { if ($statusCode == 0) { throw new GTMetrixException('cURL error ' . $curlErrNo . ': ' . $curlError); } throw new GTMetrixException('API error ' . $statusCode . ': ' . $result); } if ($json) { $data = json_decode($result, true); if (json_last_error()) { throw new GTMetrixException('Invalid JSON received: ' . json_last_error_msg()); } } else { $data = $result; } return $data; }
php
protected function apiCall($url, $data = array(), $json = true) { if (!$this->username || !$this->apiKey) { throw new GTMetrixConfigurationException('Username and API key must be set up before using API calls!' . 'See setUsername() and setAPIKey() for details.'); } $ch = curl_init($this->endpoint . $url); if (!empty($data)) { curl_setopt($ch, CURLOPT_POST, count($data)); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); } curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, $this->username . ':' . $this->apiKey); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CAINFO, dirname(__DIR__) . '/data/ca-bundle.crt'); $result = curl_exec($ch); $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curlErrNo = curl_errno($ch); $curlError = curl_error($ch); curl_close ($ch); if (!\preg_match('/^(2|3)/', $statusCode)) { if ($statusCode == 0) { throw new GTMetrixException('cURL error ' . $curlErrNo . ': ' . $curlError); } throw new GTMetrixException('API error ' . $statusCode . ': ' . $result); } if ($json) { $data = json_decode($result, true); if (json_last_error()) { throw new GTMetrixException('Invalid JSON received: ' . json_last_error_msg()); } } else { $data = $result; } return $data; }
[ "protected", "function", "apiCall", "(", "$", "url", ",", "$", "data", "=", "array", "(", ")", ",", "$", "json", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "username", "||", "!", "$", "this", "->", "apiKey", ")", "{", "throw", "n...
@param string $url @param array $data @param bool $json @return array|string @throws GTMetrixConfigurationException @throws GTMetrixException
[ "@param", "string", "$url", "@param", "array", "$data", "@param", "bool", "$json" ]
train
https://github.com/entrecloud/php-gtmetrix/blob/17cc2941242cb7ea7a3dcb0056643f17b9c56a4b/src/GTMetrixClient.php#L81-L119
entrecloud/php-gtmetrix
src/GTMetrixClient.php
GTMetrixClient.getLocations
public function getLocations() { $result = $this->apiCall('/locations'); $locations = array(); foreach ($result as $locationData) { $location = new GTMetrixLocation(); $location->fromArray($locationData); $locations[] = $location; } return $locations; }
php
public function getLocations() { $result = $this->apiCall('/locations'); $locations = array(); foreach ($result as $locationData) { $location = new GTMetrixLocation(); $location->fromArray($locationData); $locations[] = $location; } return $locations; }
[ "public", "function", "getLocations", "(", ")", "{", "$", "result", "=", "$", "this", "->", "apiCall", "(", "'/locations'", ")", ";", "$", "locations", "=", "array", "(", ")", ";", "foreach", "(", "$", "result", "as", "$", "locationData", ")", "{", "...
@return GTMetrixLocation[] @throws GTMetrixConfigurationException
[ "@return", "GTMetrixLocation", "[]" ]
train
https://github.com/entrecloud/php-gtmetrix/blob/17cc2941242cb7ea7a3dcb0056643f17b9c56a4b/src/GTMetrixClient.php#L133-L143
entrecloud/php-gtmetrix
src/GTMetrixClient.php
GTMetrixClient.getBrowsers
public function getBrowsers() { $result = $this->apiCall('/browsers'); $browsers = array(); foreach ($result as $browserData) { $browser = new GTMetrixBrowser(); $browser->fromArray($browserData); $browsers[] = $browser; } return $browsers; }
php
public function getBrowsers() { $result = $this->apiCall('/browsers'); $browsers = array(); foreach ($result as $browserData) { $browser = new GTMetrixBrowser(); $browser->fromArray($browserData); $browsers[] = $browser; } return $browsers; }
[ "public", "function", "getBrowsers", "(", ")", "{", "$", "result", "=", "$", "this", "->", "apiCall", "(", "'/browsers'", ")", ";", "$", "browsers", "=", "array", "(", ")", ";", "foreach", "(", "$", "result", "as", "$", "browserData", ")", "{", "$", ...
@return GTMetrixBrowser[] @throws GTMetrixConfigurationException
[ "@return", "GTMetrixBrowser", "[]" ]
train
https://github.com/entrecloud/php-gtmetrix/blob/17cc2941242cb7ea7a3dcb0056643f17b9c56a4b/src/GTMetrixClient.php#L150-L160
entrecloud/php-gtmetrix
src/GTMetrixClient.php
GTMetrixClient.getBrowser
public function getBrowser($id) { $result = $this->apiCall('/browsers/' . urlencode($id)); $browser = new GTMetrixBrowser(); $browser->fromArray($result); return $browser; }
php
public function getBrowser($id) { $result = $this->apiCall('/browsers/' . urlencode($id)); $browser = new GTMetrixBrowser(); $browser->fromArray($result); return $browser; }
[ "public", "function", "getBrowser", "(", "$", "id", ")", "{", "$", "result", "=", "$", "this", "->", "apiCall", "(", "'/browsers/'", ".", "urlencode", "(", "$", "id", ")", ")", ";", "$", "browser", "=", "new", "GTMetrixBrowser", "(", ")", ";", "$", ...
@param string $id @return GTMetrixBrowser @throws GTMetrixConfigurationException @throws GTMetrixException
[ "@param", "string", "$id" ]
train
https://github.com/entrecloud/php-gtmetrix/blob/17cc2941242cb7ea7a3dcb0056643f17b9c56a4b/src/GTMetrixClient.php#L169-L174
skeeks-semenov/yii2-ckeditor
src/CKEditorPresets.php
CKEditorPresets.skins
static public function skins() { return [ self::SKIN_MOONO => 'Moono', self::SKIN_KAMA => 'Kama', self::SKIN_MOONO_BLUE => 'Moono blue', self::SKIN_MOONO_COLOR => 'Moono Color', self::SKIN_OFFICE_2013 => 'Office 2013', self::SKIN_BOOTSTRAPCK => 'BootstrapCK4', self::SKIN_MOONO_DARK => 'Moono Dark', ]; }
php
static public function skins() { return [ self::SKIN_MOONO => 'Moono', self::SKIN_KAMA => 'Kama', self::SKIN_MOONO_BLUE => 'Moono blue', self::SKIN_MOONO_COLOR => 'Moono Color', self::SKIN_OFFICE_2013 => 'Office 2013', self::SKIN_BOOTSTRAPCK => 'BootstrapCK4', self::SKIN_MOONO_DARK => 'Moono Dark', ]; }
[ "static", "public", "function", "skins", "(", ")", "{", "return", "[", "self", "::", "SKIN_MOONO", "=>", "'Moono'", ",", "self", "::", "SKIN_KAMA", "=>", "'Kama'", ",", "self", "::", "SKIN_MOONO_BLUE", "=>", "'Moono blue'", ",", "self", "::", "SKIN_MOONO_COL...
Доступные скины @return array
[ "Доступные", "скины" ]
train
https://github.com/skeeks-semenov/yii2-ckeditor/blob/ffb4ef7b7ff4d68d25a0b00493554f93e525e2f4/src/CKEditorPresets.php#L223-L234
skeeks-semenov/yii2-ckeditor
src/CKEditorPresets.php
CKEditorPresets.getPresets
static public function getPresets($name = self::FULL) { if ($presets = ArrayHelper::getValue(self::$presets, $name)) { return (array)$presets; } return []; }
php
static public function getPresets($name = self::FULL) { if ($presets = ArrayHelper::getValue(self::$presets, $name)) { return (array)$presets; } return []; }
[ "static", "public", "function", "getPresets", "(", "$", "name", "=", "self", "::", "FULL", ")", "{", "if", "(", "$", "presets", "=", "ArrayHelper", "::", "getValue", "(", "self", "::", "$", "presets", ",", "$", "name", ")", ")", "{", "return", "(", ...
Получение настроек по названию @param string $name @return array
[ "Получение", "настроек", "по", "названию" ]
train
https://github.com/skeeks-semenov/yii2-ckeditor/blob/ffb4ef7b7ff4d68d25a0b00493554f93e525e2f4/src/CKEditorPresets.php#L254-L261
baleen/migrations
src/Service/Runner/CollectionRunner.php
CollectionRunner.run
public function run(DeltaInterface $target, OptionsInterface $options) { $current = 1; $collection = $this->getCollection(); $context = CollectionContext::createWithProgress(max($collection->count(), 1), $current); $migrationRunner = $this->migrationRunner->withContext($context); $this->getPublisher()->publish(new CollectionBeforeEvent($target, $options, $collection)); $modified = new Collection(); $comparator = $collection->getComparator(); // IMPROVE: add tests to see if rewind is necessary $collection->first(); // rewind foreach ($collection as $version) { $context->getProgress()->update($current); $result = $migrationRunner->run($version, $options); if ($result) { $modified->add($version); } if ($comparator->compare($version, $target) >= 0) { break; } $current += 1; } $event = new CollectionAfterEvent($target, $options, $modified); $this->getPublisher()->publish($event); return $event; }
php
public function run(DeltaInterface $target, OptionsInterface $options) { $current = 1; $collection = $this->getCollection(); $context = CollectionContext::createWithProgress(max($collection->count(), 1), $current); $migrationRunner = $this->migrationRunner->withContext($context); $this->getPublisher()->publish(new CollectionBeforeEvent($target, $options, $collection)); $modified = new Collection(); $comparator = $collection->getComparator(); // IMPROVE: add tests to see if rewind is necessary $collection->first(); // rewind foreach ($collection as $version) { $context->getProgress()->update($current); $result = $migrationRunner->run($version, $options); if ($result) { $modified->add($version); } if ($comparator->compare($version, $target) >= 0) { break; } $current += 1; } $event = new CollectionAfterEvent($target, $options, $modified); $this->getPublisher()->publish($event); return $event; }
[ "public", "function", "run", "(", "DeltaInterface", "$", "target", ",", "OptionsInterface", "$", "options", ")", "{", "$", "current", "=", "1", ";", "$", "collection", "=", "$", "this", "->", "getCollection", "(", ")", ";", "$", "context", "=", "Collecti...
Runs a collection of versions towards the specified goal and using the specified options @param DeltaInterface $target @param OptionsInterface $options @return CollectionAfterEvent
[ "Runs", "a", "collection", "of", "versions", "towards", "the", "specified", "goal", "and", "using", "the", "specified", "options" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Service/Runner/CollectionRunner.php#L74-L104
skrz/meta
gen-src/Google/Protobuf/Meta/MethodOptionsMeta.php
MethodOptionsMeta.create
public static function create() { switch (func_num_args()) { case 0: return new MethodOptions(); case 1: return new MethodOptions(func_get_arg(0)); case 2: return new MethodOptions(func_get_arg(0), func_get_arg(1)); case 3: return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new MethodOptions(); case 1: return new MethodOptions(func_get_arg(0)); case 2: return new MethodOptions(func_get_arg(0), func_get_arg(1)); case 3: return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new MethodOptions(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "MethodOptions", "(", ")", ";", "case", "1", ":", "return", "new", "MethodOptions", "(", "func_get_arg", "(", ...
Creates new instance of \Google\Protobuf\MethodOptions @throws \InvalidArgumentException @return MethodOptions
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "MethodOptions" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MethodOptionsMeta.php#L58-L82
skrz/meta
gen-src/Google/Protobuf/Meta/MethodOptionsMeta.php
MethodOptionsMeta.reset
public static function reset($object) { if (!($object instanceof MethodOptions)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\MethodOptions.'); } $object->deprecated = NULL; $object->uninterpretedOption = NULL; }
php
public static function reset($object) { if (!($object instanceof MethodOptions)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\MethodOptions.'); } $object->deprecated = NULL; $object->uninterpretedOption = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "MethodOptions", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\\Metho...
Resets properties of \Google\Protobuf\MethodOptions to default values @param MethodOptions $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "MethodOptions", "to", "default", "values" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/MethodOptionsMeta.php#L95-L102
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/Date.php
Zend_Validate_Date.setLocale
public function setLocale($locale = null) { if ($locale === null) { $this->_locale = null; return $this; } include_once 'Zend/Locale.php'; if (!Zend_Locale::isLocale($locale, true)) { if (!Zend_Locale::isLocale($locale, false)) { include_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The locale '$locale' is no known locale"); } $locale = new Zend_Locale($locale); } $this->_locale = (string) $locale; return $this; }
php
public function setLocale($locale = null) { if ($locale === null) { $this->_locale = null; return $this; } include_once 'Zend/Locale.php'; if (!Zend_Locale::isLocale($locale, true)) { if (!Zend_Locale::isLocale($locale, false)) { include_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The locale '$locale' is no known locale"); } $locale = new Zend_Locale($locale); } $this->_locale = (string) $locale; return $this; }
[ "public", "function", "setLocale", "(", "$", "locale", "=", "null", ")", "{", "if", "(", "$", "locale", "===", "null", ")", "{", "$", "this", "->", "_locale", "=", "null", ";", "return", "$", "this", ";", "}", "include_once", "'Zend/Locale.php'", ";", ...
Sets the locale option @param string|Zend_Locale $locale @return Zend_Validate_Date provides a fluent interface
[ "Sets", "the", "locale", "option" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/Date.php#L107-L126
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/Date.php
Zend_Validate_Date.isValid
public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if (($this->_format !== null) or ($this->_locale !== null)) { include_once 'Zend/Date.php'; if (!Zend_Date::isDate($value, $this->_format, $this->_locale)) { if ($this->_checkFormat($value) === false) { $this->_error(self::FALSEFORMAT); } else { $this->_error(self::INVALID); } return false; } } else { if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $valueString)) { $this->_error(self::NOT_YYYY_MM_DD); return false; } list($year, $month, $day) = sscanf($valueString, '%d-%d-%d'); if (!checkdate($month, $day, $year)) { $this->_error(self::INVALID); return false; } } return true; }
php
public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if (($this->_format !== null) or ($this->_locale !== null)) { include_once 'Zend/Date.php'; if (!Zend_Date::isDate($value, $this->_format, $this->_locale)) { if ($this->_checkFormat($value) === false) { $this->_error(self::FALSEFORMAT); } else { $this->_error(self::INVALID); } return false; } } else { if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $valueString)) { $this->_error(self::NOT_YYYY_MM_DD); return false; } list($year, $month, $day) = sscanf($valueString, '%d-%d-%d'); if (!checkdate($month, $day, $year)) { $this->_error(self::INVALID); return false; } } return true; }
[ "public", "function", "isValid", "(", "$", "value", ")", "{", "$", "valueString", "=", "(", "string", ")", "$", "value", ";", "$", "this", "->", "_setValue", "(", "$", "valueString", ")", ";", "if", "(", "(", "$", "this", "->", "_format", "!==", "n...
Defined by Zend_Validate_Interface Returns true if $value is a valid date of the format YYYY-MM-DD If optional $format or $locale is set the date format is checked according to Zend_Date, see Zend_Date::isDate() @param string $value @return boolean
[ "Defined", "by", "Zend_Validate_Interface" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/Date.php#L160-L191
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/Date.php
Zend_Validate_Date._checkFormat
private function _checkFormat($value) { try { include_once 'Zend/Locale/Format.php'; $parsed = Zend_Locale_Format::getDate( $value, array( 'date_format' => $this->_format, 'format_type' => 'iso', 'fix_date' => false) ); if (isset($parsed['year']) and ((strpos(strtoupper($this->_format), 'YY') !== false) and (strpos(strtoupper($this->_format), 'YYYY') === false)) ) { $parsed['year'] = Zend_Date::_century($parsed['year']); } } catch (Exception $e) { // Date can not be parsed return false; } if (((strpos($this->_format, 'Y') !== false) or (strpos($this->_format, 'y') !== false)) and (!isset($parsed['year'])) ) { // Year expected but not found return false; } if ((strpos($this->_format, 'M') !== false) and (!isset($parsed['month']))) { // Month expected but not found return false; } if ((strpos($this->_format, 'd') !== false) and (!isset($parsed['day']))) { // Day expected but not found return false; } if (((strpos($this->_format, 'H') !== false) or (strpos($this->_format, 'h') !== false)) and (!isset($parsed['hour'])) ) { // Hour expected but not found return false; } if ((strpos($this->_format, 'm') !== false) and (!isset($parsed['minute']))) { // Minute expected but not found return false; } if ((strpos($this->_format, 's') !== false) and (!isset($parsed['second']))) { // Second expected but not found return false; } // Date fits the format return true; }
php
private function _checkFormat($value) { try { include_once 'Zend/Locale/Format.php'; $parsed = Zend_Locale_Format::getDate( $value, array( 'date_format' => $this->_format, 'format_type' => 'iso', 'fix_date' => false) ); if (isset($parsed['year']) and ((strpos(strtoupper($this->_format), 'YY') !== false) and (strpos(strtoupper($this->_format), 'YYYY') === false)) ) { $parsed['year'] = Zend_Date::_century($parsed['year']); } } catch (Exception $e) { // Date can not be parsed return false; } if (((strpos($this->_format, 'Y') !== false) or (strpos($this->_format, 'y') !== false)) and (!isset($parsed['year'])) ) { // Year expected but not found return false; } if ((strpos($this->_format, 'M') !== false) and (!isset($parsed['month']))) { // Month expected but not found return false; } if ((strpos($this->_format, 'd') !== false) and (!isset($parsed['day']))) { // Day expected but not found return false; } if (((strpos($this->_format, 'H') !== false) or (strpos($this->_format, 'h') !== false)) and (!isset($parsed['hour'])) ) { // Hour expected but not found return false; } if ((strpos($this->_format, 'm') !== false) and (!isset($parsed['minute']))) { // Minute expected but not found return false; } if ((strpos($this->_format, 's') !== false) and (!isset($parsed['second']))) { // Second expected but not found return false; } // Date fits the format return true; }
[ "private", "function", "_checkFormat", "(", "$", "value", ")", "{", "try", "{", "include_once", "'Zend/Locale/Format.php'", ";", "$", "parsed", "=", "Zend_Locale_Format", "::", "getDate", "(", "$", "value", ",", "array", "(", "'date_format'", "=>", "$", "this"...
Check if the given date fits the given format @param string $value Date to check @return boolean False when date does not fit the format
[ "Check", "if", "the", "given", "date", "fits", "the", "given", "format" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/Date.php#L199-L254
txj123/zilf
src/Zilf/Routing/Router.php
Router.mergeRuleRegex
public function mergeRuleRegex($merge = true) { $this->mergeRuleRegex = $merge; $this->group->mergeRuleRegex($merge); return $this; }
php
public function mergeRuleRegex($merge = true) { $this->mergeRuleRegex = $merge; $this->group->mergeRuleRegex($merge); return $this; }
[ "public", "function", "mergeRuleRegex", "(", "$", "merge", "=", "true", ")", "{", "$", "this", "->", "mergeRuleRegex", "=", "$", "merge", ";", "$", "this", "->", "group", "->", "mergeRuleRegex", "(", "$", "merge", ")", ";", "return", "$", "this", ";", ...
设置路由域名及分组(包括资源路由)是否合并解析 @access public @param bool $merge 路由是否合并解析 @return $this
[ "设置路由域名及分组(包括资源路由)是否合并解析" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L191-L197
txj123/zilf
src/Zilf/Routing/Router.php
Router.setDefaultDomain
protected function setDefaultDomain() { // 默认域名 $this->domain = $this->host; // 注册默认域名 $domain = new Domain($this, $this->host); $this->domains[$this->host] = $domain; // 默认分组 $this->group = $domain; }
php
protected function setDefaultDomain() { // 默认域名 $this->domain = $this->host; // 注册默认域名 $domain = new Domain($this, $this->host); $this->domains[$this->host] = $domain; // 默认分组 $this->group = $domain; }
[ "protected", "function", "setDefaultDomain", "(", ")", "{", "// 默认域名", "$", "this", "->", "domain", "=", "$", "this", "->", "host", ";", "// 注册默认域名", "$", "domain", "=", "new", "Domain", "(", "$", "this", ",", "$", "this", "->", "host", ")", ";", "$"...
初始化默认域名 @access protected @return void
[ "初始化默认域名" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L216-L228
txj123/zilf
src/Zilf/Routing/Router.php
Router.domain
public function domain($name, $rule = '', $option = [], $pattern = []) { // 支持多个域名使用相同路由规则 $domainName = is_array($name) ? array_shift($name) : $name; if ('*' != $domainName && false === strpos($domainName, '.')) { $domainName .= '.' . $this->request->rootDomain(); } if (!isset($this->domains[$domainName])) { $domain = (new Domain($this, $domainName, $rule, $option, $pattern)) ->lazy($this->lazy) ->mergeRuleRegex($this->mergeRuleRegex); $this->domains[$domainName] = $domain; } else { $domain = $this->domains[$domainName]; $domain->parseGroupRule($rule); } if (is_array($name) && !empty($name)) { $root = $this->request->rootDomain(); foreach ($name as $item) { if (false === strpos($item, '.')) { $item .= '.' . $root; } $this->domains[$item] = $domainName; } } // 返回域名对象 return $domain; }
php
public function domain($name, $rule = '', $option = [], $pattern = []) { // 支持多个域名使用相同路由规则 $domainName = is_array($name) ? array_shift($name) : $name; if ('*' != $domainName && false === strpos($domainName, '.')) { $domainName .= '.' . $this->request->rootDomain(); } if (!isset($this->domains[$domainName])) { $domain = (new Domain($this, $domainName, $rule, $option, $pattern)) ->lazy($this->lazy) ->mergeRuleRegex($this->mergeRuleRegex); $this->domains[$domainName] = $domain; } else { $domain = $this->domains[$domainName]; $domain->parseGroupRule($rule); } if (is_array($name) && !empty($name)) { $root = $this->request->rootDomain(); foreach ($name as $item) { if (false === strpos($item, '.')) { $item .= '.' . $root; } $this->domains[$item] = $domainName; } } // 返回域名对象 return $domain; }
[ "public", "function", "domain", "(", "$", "name", ",", "$", "rule", "=", "''", ",", "$", "option", "=", "[", "]", ",", "$", "pattern", "=", "[", "]", ")", "{", "// 支持多个域名使用相同路由规则", "$", "domainName", "=", "is_array", "(", "$", "name", ")", "?", "...
注册域名路由 @access public @param string|array $name 子域名 @param mixed $rule 路由规则 @param array $option 路由参数 @param array $pattern 变量规则 @return Domain
[ "注册域名路由" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L288-L321
txj123/zilf
src/Zilf/Routing/Router.php
Router.bind
public function bind($bind, $domain = null) { $domain = is_null($domain) ? $this->domain : $domain; $this->bind[$domain] = $bind; return $this; }
php
public function bind($bind, $domain = null) { $domain = is_null($domain) ? $this->domain : $domain; $this->bind[$domain] = $bind; return $this; }
[ "public", "function", "bind", "(", "$", "bind", ",", "$", "domain", "=", "null", ")", "{", "$", "domain", "=", "is_null", "(", "$", "domain", ")", "?", "$", "this", "->", "domain", ":", "$", "domain", ";", "$", "this", "->", "bind", "[", "$", "...
设置路由绑定 @access public @param string $bind 绑定信息 @param string $domain 域名 @return $this
[ "设置路由绑定" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L340-L347
txj123/zilf
src/Zilf/Routing/Router.php
Router.getBind
public function getBind($domain = null) { if (is_null($domain)) { $domain = $this->domain; } elseif (true === $domain) { return $this->bind; } elseif (false === strpos($domain, '.')) { $domain .= '.' . $this->request->rootDomain(); } $subDomain = $this->getSubDomain(); if (strpos($subDomain, '.')) { $name = '*' . strstr($subDomain, '.'); } if (isset($this->bind[$domain])) { $result = $this->bind[$domain]; } elseif (isset($name) && isset($this->bind[$name])) { $result = $this->bind[$name]; } elseif (isset($this->bind['*'])) { $result = $this->bind['*']; } else { $result = null; } return $result; }
php
public function getBind($domain = null) { if (is_null($domain)) { $domain = $this->domain; } elseif (true === $domain) { return $this->bind; } elseif (false === strpos($domain, '.')) { $domain .= '.' . $this->request->rootDomain(); } $subDomain = $this->getSubDomain(); if (strpos($subDomain, '.')) { $name = '*' . strstr($subDomain, '.'); } if (isset($this->bind[$domain])) { $result = $this->bind[$domain]; } elseif (isset($name) && isset($this->bind[$name])) { $result = $this->bind[$name]; } elseif (isset($this->bind['*'])) { $result = $this->bind['*']; } else { $result = null; } return $result; }
[ "public", "function", "getBind", "(", "$", "domain", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "domain", ")", ")", "{", "$", "domain", "=", "$", "this", "->", "domain", ";", "}", "elseif", "(", "true", "===", "$", "domain", ")", "{",...
读取路由绑定 @access public @param string $domain 域名 @return string|null
[ "读取路由绑定" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L355-L382
txj123/zilf
src/Zilf/Routing/Router.php
Router.getName
public function getName($name = null, $domain = null, $method = '*') { return Zilf::$container->getShare('ruleName')->get($name, $domain, $method); }
php
public function getName($name = null, $domain = null, $method = '*') { return Zilf::$container->getShare('ruleName')->get($name, $domain, $method); }
[ "public", "function", "getName", "(", "$", "name", "=", "null", ",", "$", "domain", "=", "null", ",", "$", "method", "=", "'*'", ")", "{", "return", "Zilf", "::", "$", "container", "->", "getShare", "(", "'ruleName'", ")", "->", "get", "(", "$", "n...
读取路由标识 @access public @param string $name 路由标识 @param string $domain 域名 @return mixed
[ "读取路由标识" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L391-L394
txj123/zilf
src/Zilf/Routing/Router.php
Router.getRule
public function getRule($rule, $domain = null) { if (is_null($domain)) { $domain = $this->domain; } return $this->app['rule_name']->getRule($rule, $domain); }
php
public function getRule($rule, $domain = null) { if (is_null($domain)) { $domain = $this->domain; } return $this->app['rule_name']->getRule($rule, $domain); }
[ "public", "function", "getRule", "(", "$", "rule", ",", "$", "domain", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "domain", ")", ")", "{", "$", "domain", "=", "$", "this", "->", "domain", ";", "}", "return", "$", "this", "->", "app", ...
读取路由 @access public @param string $rule 路由规则 @param string $domain 域名 @return array
[ "读取路由" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L403-L410
txj123/zilf
src/Zilf/Routing/Router.php
Router.import
public function import(array $rules, $type = '*') { // 检查域名部署 if (isset($rules['__domain__'])) { foreach ($rules['__domain__'] as $key => $rule) { $this->domain($key, $rule); } unset($rules['__domain__']); } // 检查变量规则 if (isset($rules['__pattern__'])) { $this->pattern($rules['__pattern__']); unset($rules['__pattern__']); } // 检查路由别名 if (isset($rules['__alias__'])) { foreach ($rules['__alias__'] as $key => $val) { $this->alias($key, $val); } unset($rules['__alias__']); } // 检查资源路由 if (isset($rules['__rest__'])) { foreach ($rules['__rest__'] as $key => $rule) { $this->resource($key, $rule); } unset($rules['__rest__']); } // 检查路由规则(包含分组) foreach ($rules as $key => $val) { if (is_numeric($key)) { $key = array_shift($val); } if (empty($val)) { continue; } if (is_string($key) && 0 === strpos($key, '[')) { $key = substr($key, 1, -1); $this->group($key, $val); } elseif (is_array($val)) { $this->rule($key, $val[0], $type, $val[1], isset($val[2]) ? $val[2] : []); } else { $this->rule($key, $val, $type); } } }
php
public function import(array $rules, $type = '*') { // 检查域名部署 if (isset($rules['__domain__'])) { foreach ($rules['__domain__'] as $key => $rule) { $this->domain($key, $rule); } unset($rules['__domain__']); } // 检查变量规则 if (isset($rules['__pattern__'])) { $this->pattern($rules['__pattern__']); unset($rules['__pattern__']); } // 检查路由别名 if (isset($rules['__alias__'])) { foreach ($rules['__alias__'] as $key => $val) { $this->alias($key, $val); } unset($rules['__alias__']); } // 检查资源路由 if (isset($rules['__rest__'])) { foreach ($rules['__rest__'] as $key => $rule) { $this->resource($key, $rule); } unset($rules['__rest__']); } // 检查路由规则(包含分组) foreach ($rules as $key => $val) { if (is_numeric($key)) { $key = array_shift($val); } if (empty($val)) { continue; } if (is_string($key) && 0 === strpos($key, '[')) { $key = substr($key, 1, -1); $this->group($key, $val); } elseif (is_array($val)) { $this->rule($key, $val[0], $type, $val[1], isset($val[2]) ? $val[2] : []); } else { $this->rule($key, $val, $type); } } }
[ "public", "function", "import", "(", "array", "$", "rules", ",", "$", "type", "=", "'*'", ")", "{", "// 检查域名部署", "if", "(", "isset", "(", "$", "rules", "[", "'__domain__'", "]", ")", ")", "{", "foreach", "(", "$", "rules", "[", "'__domain__'", "]", ...
导入配置文件的路由规则 @access public @param array $rules 路由规则 @param string $type 请求类型 @return void
[ "导入配置文件的路由规则" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L442-L493
txj123/zilf
src/Zilf/Routing/Router.php
Router.rule
public function rule($rule, $route, $method = '*', array $option = [], array $pattern = []) { return $this->group->addRule($rule, $route, $method, $option, $pattern); }
php
public function rule($rule, $route, $method = '*', array $option = [], array $pattern = []) { return $this->group->addRule($rule, $route, $method, $option, $pattern); }
[ "public", "function", "rule", "(", "$", "rule", ",", "$", "route", ",", "$", "method", "=", "'*'", ",", "array", "$", "option", "=", "[", "]", ",", "array", "$", "pattern", "=", "[", "]", ")", "{", "return", "$", "this", "->", "group", "->", "a...
注册路由规则 @access public @param string $rule 路由规则 @param mixed $route 路由地址 @param string $method 请求类型 @param array $option 路由参数 @param array $pattern 变量规则 @return RuleItem
[ "注册路由规则" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L505-L508
txj123/zilf
src/Zilf/Routing/Router.php
Router.setCrossDomainRule
public function setCrossDomainRule($rule, $method = '*') { if (!isset($this->cross)) { $this->cross = (new RuleGroup($this))->mergeRuleRegex($this->mergeRuleRegex); } $this->cross->addRuleItem($rule, $method); return $this; }
php
public function setCrossDomainRule($rule, $method = '*') { if (!isset($this->cross)) { $this->cross = (new RuleGroup($this))->mergeRuleRegex($this->mergeRuleRegex); } $this->cross->addRuleItem($rule, $method); return $this; }
[ "public", "function", "setCrossDomainRule", "(", "$", "rule", ",", "$", "method", "=", "'*'", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "cross", ")", ")", "{", "$", "this", "->", "cross", "=", "(", "new", "RuleGroup", "(", "$", "...
设置跨域有效路由规则 @access public @param Rule $rule 路由规则 @param string $method 请求类型 @return $this
[ "设置跨域有效路由规则" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L517-L526
txj123/zilf
src/Zilf/Routing/Router.php
Router.rules
public function rules($rules, $method = '*', array $option = [], array $pattern = []) { $this->group->addRules($rules, $method, $option, $pattern); }
php
public function rules($rules, $method = '*', array $option = [], array $pattern = []) { $this->group->addRules($rules, $method, $option, $pattern); }
[ "public", "function", "rules", "(", "$", "rules", ",", "$", "method", "=", "'*'", ",", "array", "$", "option", "=", "[", "]", ",", "array", "$", "pattern", "=", "[", "]", ")", "{", "$", "this", "->", "group", "->", "addRules", "(", "$", "rules", ...
批量注册路由规则 @access public @param array $rules 路由规则 @param string $method 请求类型 @param array $option 路由参数 @param array $pattern 变量规则 @return void
[ "批量注册路由规则" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L537-L540
txj123/zilf
src/Zilf/Routing/Router.php
Router.group
public function group($name, $route, array $option = [], array $pattern = []) { if (is_array($name)) { $option = $name; $name = isset($option['name']) ? $option['name'] : ''; } return (new RuleGroup($this, $this->group, $name, $route, $option, $pattern)) ->lazy($this->lazy) ->mergeRuleRegex($this->mergeRuleRegex); }
php
public function group($name, $route, array $option = [], array $pattern = []) { if (is_array($name)) { $option = $name; $name = isset($option['name']) ? $option['name'] : ''; } return (new RuleGroup($this, $this->group, $name, $route, $option, $pattern)) ->lazy($this->lazy) ->mergeRuleRegex($this->mergeRuleRegex); }
[ "public", "function", "group", "(", "$", "name", ",", "$", "route", ",", "array", "$", "option", "=", "[", "]", ",", "array", "$", "pattern", "=", "[", "]", ")", "{", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "$", "option", "=", ...
注册路由分组 @access public @param string|array $name 分组名称或者参数 @param array|\Closure $route 分组路由 @param array $option 路由参数 @param array $pattern 变量规则 @return RuleGroup
[ "注册路由分组" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L551-L561
txj123/zilf
src/Zilf/Routing/Router.php
Router.any
public function any($rule, $route = '', array $option = [], array $pattern = []) { return $this->rule($rule, $route, '*', $option, $pattern); }
php
public function any($rule, $route = '', array $option = [], array $pattern = []) { return $this->rule($rule, $route, '*', $option, $pattern); }
[ "public", "function", "any", "(", "$", "rule", ",", "$", "route", "=", "''", ",", "array", "$", "option", "=", "[", "]", ",", "array", "$", "pattern", "=", "[", "]", ")", "{", "return", "$", "this", "->", "rule", "(", "$", "rule", ",", "$", "...
注册路由 @access public @param string $rule 路由规则 @param mixed $route 路由地址 @param array $option 路由参数 @param array $pattern 变量规则 @return RuleItem
[ "注册路由" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L572-L575
txj123/zilf
src/Zilf/Routing/Router.php
Router.get
public function get($rule, $route = '', array $option = [], array $pattern = []) { return $this->rule($rule, $route, 'GET', $option, $pattern); }
php
public function get($rule, $route = '', array $option = [], array $pattern = []) { return $this->rule($rule, $route, 'GET', $option, $pattern); }
[ "public", "function", "get", "(", "$", "rule", ",", "$", "route", "=", "''", ",", "array", "$", "option", "=", "[", "]", ",", "array", "$", "pattern", "=", "[", "]", ")", "{", "return", "$", "this", "->", "rule", "(", "$", "rule", ",", "$", "...
注册GET路由 @access public @param string $rule 路由规则 @param mixed $route 路由地址 @param array $option 路由参数 @param array $pattern 变量规则 @return RuleItem
[ "注册GET路由" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L586-L589
txj123/zilf
src/Zilf/Routing/Router.php
Router.post
public function post($rule, $route = '', array $option = [], array $pattern = []) { return $this->rule($rule, $route, 'POST', $option, $pattern); }
php
public function post($rule, $route = '', array $option = [], array $pattern = []) { return $this->rule($rule, $route, 'POST', $option, $pattern); }
[ "public", "function", "post", "(", "$", "rule", ",", "$", "route", "=", "''", ",", "array", "$", "option", "=", "[", "]", ",", "array", "$", "pattern", "=", "[", "]", ")", "{", "return", "$", "this", "->", "rule", "(", "$", "rule", ",", "$", ...
注册POST路由 @access public @param string $rule 路由规则 @param mixed $route 路由地址 @param array $option 路由参数 @param array $pattern 变量规则 @return RuleItem
[ "注册POST路由" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L600-L603
txj123/zilf
src/Zilf/Routing/Router.php
Router.put
public function put($rule, $route = '', array $option = [], array $pattern = []) { return $this->rule($rule, $route, 'PUT', $option, $pattern); }
php
public function put($rule, $route = '', array $option = [], array $pattern = []) { return $this->rule($rule, $route, 'PUT', $option, $pattern); }
[ "public", "function", "put", "(", "$", "rule", ",", "$", "route", "=", "''", ",", "array", "$", "option", "=", "[", "]", ",", "array", "$", "pattern", "=", "[", "]", ")", "{", "return", "$", "this", "->", "rule", "(", "$", "rule", ",", "$", "...
注册PUT路由 @access public @param string $rule 路由规则 @param mixed $route 路由地址 @param array $option 路由参数 @param array $pattern 变量规则 @return RuleItem
[ "注册PUT路由" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L614-L617
txj123/zilf
src/Zilf/Routing/Router.php
Router.delete
public function delete($rule, $route = '', array $option = [], array $pattern = []) { return $this->rule($rule, $route, 'DELETE', $option, $pattern); }
php
public function delete($rule, $route = '', array $option = [], array $pattern = []) { return $this->rule($rule, $route, 'DELETE', $option, $pattern); }
[ "public", "function", "delete", "(", "$", "rule", ",", "$", "route", "=", "''", ",", "array", "$", "option", "=", "[", "]", ",", "array", "$", "pattern", "=", "[", "]", ")", "{", "return", "$", "this", "->", "rule", "(", "$", "rule", ",", "$", ...
注册DELETE路由 @access public @param string $rule 路由规则 @param mixed $route 路由地址 @param array $option 路由参数 @param array $pattern 变量规则 @return RuleItem
[ "注册DELETE路由" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L628-L631
txj123/zilf
src/Zilf/Routing/Router.php
Router.patch
public function patch($rule, $route = '', array $option = [], array $pattern = []) { return $this->rule($rule, $route, 'PATCH', $option, $pattern); }
php
public function patch($rule, $route = '', array $option = [], array $pattern = []) { return $this->rule($rule, $route, 'PATCH', $option, $pattern); }
[ "public", "function", "patch", "(", "$", "rule", ",", "$", "route", "=", "''", ",", "array", "$", "option", "=", "[", "]", ",", "array", "$", "pattern", "=", "[", "]", ")", "{", "return", "$", "this", "->", "rule", "(", "$", "rule", ",", "$", ...
注册PATCH路由 @access public @param string $rule 路由规则 @param mixed $route 路由地址 @param array $option 路由参数 @param array $pattern 变量规则 @return RuleItem
[ "注册PATCH路由" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L642-L645
txj123/zilf
src/Zilf/Routing/Router.php
Router.resource
public function resource($rule, $route = '', array $option = [], array $pattern = []) { return (new Resource($this, $this->group, $rule, $route, $option, $pattern, $this->rest)) ->lazy($this->lazy); }
php
public function resource($rule, $route = '', array $option = [], array $pattern = []) { return (new Resource($this, $this->group, $rule, $route, $option, $pattern, $this->rest)) ->lazy($this->lazy); }
[ "public", "function", "resource", "(", "$", "rule", ",", "$", "route", "=", "''", ",", "array", "$", "option", "=", "[", "]", ",", "array", "$", "pattern", "=", "[", "]", ")", "{", "return", "(", "new", "Resource", "(", "$", "this", ",", "$", "...
注册资源路由 @access public @param string $rule 路由规则 @param string $route 路由地址 @param array $option 路由参数 @param array $pattern 变量规则 @return Resource
[ "注册资源路由" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L656-L660
txj123/zilf
src/Zilf/Routing/Router.php
Router.controller
public function controller($rule, $route = '', array $option = [], array $pattern = []) { $group = new RuleGroup($this, $this->group, $rule, null, $option, $pattern); foreach ($this->methodPrefix as $type => $val) { $group->addRule('<action>', $val . '<action>', $type); } return $group->prefix($route . '/'); }
php
public function controller($rule, $route = '', array $option = [], array $pattern = []) { $group = new RuleGroup($this, $this->group, $rule, null, $option, $pattern); foreach ($this->methodPrefix as $type => $val) { $group->addRule('<action>', $val . '<action>', $type); } return $group->prefix($route . '/'); }
[ "public", "function", "controller", "(", "$", "rule", ",", "$", "route", "=", "''", ",", "array", "$", "option", "=", "[", "]", ",", "array", "$", "pattern", "=", "[", "]", ")", "{", "$", "group", "=", "new", "RuleGroup", "(", "$", "this", ",", ...
注册控制器路由 操作方法对应不同的请求前缀 @access public @param string $rule 路由规则 @param string $route 路由地址 @param array $option 路由参数 @param array $pattern 变量规则 @return RuleGroup
[ "注册控制器路由", "操作方法对应不同的请求前缀" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L671-L680
txj123/zilf
src/Zilf/Routing/Router.php
Router.view
public function view($rule, $template = '', array $vars = [], array $option = [], array $pattern = []) { return $this->rule($rule, $template, 'GET', $option, $pattern)->view($vars); }
php
public function view($rule, $template = '', array $vars = [], array $option = [], array $pattern = []) { return $this->rule($rule, $template, 'GET', $option, $pattern)->view($vars); }
[ "public", "function", "view", "(", "$", "rule", ",", "$", "template", "=", "''", ",", "array", "$", "vars", "=", "[", "]", ",", "array", "$", "option", "=", "[", "]", ",", "array", "$", "pattern", "=", "[", "]", ")", "{", "return", "$", "this",...
注册视图路由 @access public @param string|array $rule 路由规则 @param string $template 路由模板地址 @param array $vars 模板变量 @param array $option 路由参数 @param array $pattern 变量规则 @return RuleItem
[ "注册视图路由" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L692-L695
txj123/zilf
src/Zilf/Routing/Router.php
Router.redirect
public function redirect($rule, $route = '', $status = 301, array $option = [], array $pattern = []) { return $this->rule($rule, $route, '*', $option, $pattern)->redirect()->status($status); }
php
public function redirect($rule, $route = '', $status = 301, array $option = [], array $pattern = []) { return $this->rule($rule, $route, '*', $option, $pattern)->redirect()->status($status); }
[ "public", "function", "redirect", "(", "$", "rule", ",", "$", "route", "=", "''", ",", "$", "status", "=", "301", ",", "array", "$", "option", "=", "[", "]", ",", "array", "$", "pattern", "=", "[", "]", ")", "{", "return", "$", "this", "->", "r...
注册重定向路由 @access public @param string|array $rule 路由规则 @param string $route 路由地址 @param array $status 状态码 @param array $option 路由参数 @param array $pattern 变量规则 @return RuleItem
[ "注册重定向路由" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L707-L710
txj123/zilf
src/Zilf/Routing/Router.php
Router.alias
public function alias($rule, $route, array $option = []) { $aliasRule = new AliasRule($this, $this->group, $rule, $route, $option); $this->alias[$rule] = $aliasRule; return $aliasRule; }
php
public function alias($rule, $route, array $option = []) { $aliasRule = new AliasRule($this, $this->group, $rule, $route, $option); $this->alias[$rule] = $aliasRule; return $aliasRule; }
[ "public", "function", "alias", "(", "$", "rule", ",", "$", "route", ",", "array", "$", "option", "=", "[", "]", ")", "{", "$", "aliasRule", "=", "new", "AliasRule", "(", "$", "this", ",", "$", "this", "->", "group", ",", "$", "rule", ",", "$", ...
注册别名路由 @access public @param string $rule 路由别名 @param string $route 路由地址 @param array $option 路由参数 @return AliasRule
[ "注册别名路由" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L720-L727
txj123/zilf
src/Zilf/Routing/Router.php
Router.getAlias
public function getAlias($name = null) { if (is_null($name)) { return $this->alias; } return isset($this->alias[$name]) ? $this->alias[$name] : null; }
php
public function getAlias($name = null) { if (is_null($name)) { return $this->alias; } return isset($this->alias[$name]) ? $this->alias[$name] : null; }
[ "public", "function", "getAlias", "(", "$", "name", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "alias", ";", "}", "return", "isset", "(", "$", "this", "->", "alias", "[", "$", "name"...
获取别名路由定义 @access public @param string $name 路由别名 @return string|array|null
[ "获取别名路由定义" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L735-L742
txj123/zilf
src/Zilf/Routing/Router.php
Router.setMethodPrefix
public function setMethodPrefix($method, $prefix = '') { if (is_array($method)) { $this->methodPrefix = array_merge($this->methodPrefix, array_change_key_case($method)); } else { $this->methodPrefix[strtolower($method)] = $prefix; } return $this; }
php
public function setMethodPrefix($method, $prefix = '') { if (is_array($method)) { $this->methodPrefix = array_merge($this->methodPrefix, array_change_key_case($method)); } else { $this->methodPrefix[strtolower($method)] = $prefix; } return $this; }
[ "public", "function", "setMethodPrefix", "(", "$", "method", ",", "$", "prefix", "=", "''", ")", "{", "if", "(", "is_array", "(", "$", "method", ")", ")", "{", "$", "this", "->", "methodPrefix", "=", "array_merge", "(", "$", "this", "->", "methodPrefix...
设置不同请求类型下面的方法前缀 @access public @param string|array $method 请求类型 @param string $prefix 类型前缀 @return $this
[ "设置不同请求类型下面的方法前缀" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L751-L760
txj123/zilf
src/Zilf/Routing/Router.php
Router.getMethodPrefix
public function getMethodPrefix($method) { $method = strtolower($method); return isset($this->methodPrefix[$method]) ? $this->methodPrefix[$method] : null; }
php
public function getMethodPrefix($method) { $method = strtolower($method); return isset($this->methodPrefix[$method]) ? $this->methodPrefix[$method] : null; }
[ "public", "function", "getMethodPrefix", "(", "$", "method", ")", "{", "$", "method", "=", "strtolower", "(", "$", "method", ")", ";", "return", "isset", "(", "$", "this", "->", "methodPrefix", "[", "$", "method", "]", ")", "?", "$", "this", "->", "m...
获取请求类型的方法前缀 @access public @param string $method 请求类型 @param string $prefix 类型前缀 @return string|null
[ "获取请求类型的方法前缀" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L769-L774
txj123/zilf
src/Zilf/Routing/Router.php
Router.rest
public function rest($name, $resource = []) { if (is_array($name)) { $this->rest = $resource ? $name : array_merge($this->rest, $name); } else { $this->rest[$name] = $resource; } return $this; }
php
public function rest($name, $resource = []) { if (is_array($name)) { $this->rest = $resource ? $name : array_merge($this->rest, $name); } else { $this->rest[$name] = $resource; } return $this; }
[ "public", "function", "rest", "(", "$", "name", ",", "$", "resource", "=", "[", "]", ")", "{", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "$", "this", "->", "rest", "=", "$", "resource", "?", "$", "name", ":", "array_merge", "(", "...
rest方法定义和修改 @access public @param string $name 方法名称 @param array|bool $resource 资源 @return $this
[ "rest方法定义和修改" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L783-L792
txj123/zilf
src/Zilf/Routing/Router.php
Router.getRest
public function getRest($name = null) { if (is_null($name)) { return $this->rest; } return isset($this->rest[$name]) ? $this->rest[$name] : null; }
php
public function getRest($name = null) { if (is_null($name)) { return $this->rest; } return isset($this->rest[$name]) ? $this->rest[$name] : null; }
[ "public", "function", "getRest", "(", "$", "name", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "rest", ";", "}", "return", "isset", "(", "$", "this", "->", "rest", "[", "$", "name", ...
获取rest方法定义的参数 @access public @param string $name 方法名称 @return array|null
[ "获取rest方法定义的参数" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L800-L807
txj123/zilf
src/Zilf/Routing/Router.php
Router.miss
public function miss($route, $method = '*', array $option = []) { return $this->group->addMissRule($route, $method, $option); }
php
public function miss($route, $method = '*', array $option = []) { return $this->group->addMissRule($route, $method, $option); }
[ "public", "function", "miss", "(", "$", "route", ",", "$", "method", "=", "'*'", ",", "array", "$", "option", "=", "[", "]", ")", "{", "return", "$", "this", "->", "group", "->", "addMissRule", "(", "$", "route", ",", "$", "method", ",", "$", "op...
注册未匹配路由规则后的处理 @access public @param string $route 路由地址 @param string $method 请求类型 @param array $option 路由参数 @return RuleItem
[ "注册未匹配路由规则后的处理" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L817-L820
txj123/zilf
src/Zilf/Routing/Router.php
Router.check
public function check($url, $must = false) { // 自动检测域名路由 $domain = $this->checkDomain(); $url = str_replace($this->config['app.pathinfo_depr'], '|', $url); $completeMatch = $this->config['app.route_complete_match']; $result = $domain->check($url, $completeMatch); if ($result) { $re = array_merge($result, ['is_route' => true]); return $re; } elseif ($must) { // 强制路由不匹配则抛出异常 throw new NotFoundHttpException('强制路由,不匹配'); } else { // 检测跨域路由 // if (!empty($this->cross)) { // $result = $this->cross->check($this->request, $url, $completeMatch); // } // // if (false !== $result) { // // 路由匹配 // return $result; // } // 默认路由解析 $re = new UrlDispatch($this->group, $url, [ 'auto_search' => $this->autoSearchController, ]); return array_merge($re->init(), ['is_route' => false]); } }
php
public function check($url, $must = false) { // 自动检测域名路由 $domain = $this->checkDomain(); $url = str_replace($this->config['app.pathinfo_depr'], '|', $url); $completeMatch = $this->config['app.route_complete_match']; $result = $domain->check($url, $completeMatch); if ($result) { $re = array_merge($result, ['is_route' => true]); return $re; } elseif ($must) { // 强制路由不匹配则抛出异常 throw new NotFoundHttpException('强制路由,不匹配'); } else { // 检测跨域路由 // if (!empty($this->cross)) { // $result = $this->cross->check($this->request, $url, $completeMatch); // } // // if (false !== $result) { // // 路由匹配 // return $result; // } // 默认路由解析 $re = new UrlDispatch($this->group, $url, [ 'auto_search' => $this->autoSearchController, ]); return array_merge($re->init(), ['is_route' => false]); } }
[ "public", "function", "check", "(", "$", "url", ",", "$", "must", "=", "false", ")", "{", "// 自动检测域名路由", "$", "domain", "=", "$", "this", "->", "checkDomain", "(", ")", ";", "$", "url", "=", "str_replace", "(", "$", "this", "->", "config", "[", "'a...
检测URL路由 @access public @param string $url URL地址 @param bool $must 是否强制路由 @return Dispatch @throws RouteNotFoundException
[ "检测URL路由" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L841-L876
txj123/zilf
src/Zilf/Routing/Router.php
Router.checkDomain
protected function checkDomain() { // 获取当前子域名 $subDomain = $this->getSubDomain(); $item = false; if ($subDomain && count($this->domains) > 1) { $domain = explode('.', $subDomain); $domain2 = array_pop($domain); if ($domain) { // 存在三级域名 $domain3 = array_pop($domain); } if ($subDomain && isset($this->domains[$subDomain])) { // 子域名配置 $item = $this->domains[$subDomain]; } elseif (isset($this->domains['*.' . $domain2]) && !empty($domain3)) { // 泛三级域名 $item = $this->domains['*.' . $domain2]; $panDomain = $domain3; } elseif (isset($this->domains['*']) && !empty($domain2)) { // 泛二级域名 if ('www' != $domain2) { $item = $this->domains['*']; $panDomain = $domain2; } } if (isset($panDomain)) { // 保存当前泛域名 $this->request->setPanDomain($panDomain); } } if (false === $item) { // 检测当前完整域名 $item = $this->domains[$this->host]; } if (is_string($item)) { $item = $this->domains[$item]; } return $item; }
php
protected function checkDomain() { // 获取当前子域名 $subDomain = $this->getSubDomain(); $item = false; if ($subDomain && count($this->domains) > 1) { $domain = explode('.', $subDomain); $domain2 = array_pop($domain); if ($domain) { // 存在三级域名 $domain3 = array_pop($domain); } if ($subDomain && isset($this->domains[$subDomain])) { // 子域名配置 $item = $this->domains[$subDomain]; } elseif (isset($this->domains['*.' . $domain2]) && !empty($domain3)) { // 泛三级域名 $item = $this->domains['*.' . $domain2]; $panDomain = $domain3; } elseif (isset($this->domains['*']) && !empty($domain2)) { // 泛二级域名 if ('www' != $domain2) { $item = $this->domains['*']; $panDomain = $domain2; } } if (isset($panDomain)) { // 保存当前泛域名 $this->request->setPanDomain($panDomain); } } if (false === $item) { // 检测当前完整域名 $item = $this->domains[$this->host]; } if (is_string($item)) { $item = $this->domains[$item]; } return $item; }
[ "protected", "function", "checkDomain", "(", ")", "{", "// 获取当前子域名", "$", "subDomain", "=", "$", "this", "->", "getSubDomain", "(", ")", ";", "$", "item", "=", "false", ";", "if", "(", "$", "subDomain", "&&", "count", "(", "$", "this", "->", "domains",...
检测域名的路由规则 @access protected @return Domain
[ "检测域名的路由规则" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L883-L930
txj123/zilf
src/Zilf/Routing/Router.php
Router.getSubDomain
public function getSubDomain() { // 获取当前主域名 $rootDomain = $this->config['app.url_domain']; if ($rootDomain) { // 配置域名根 例如 thinkphp.cn 163.com.cn 如果是国家级域名 com.cn net.cn 之类的域名需要配置 $domain = explode('.', rtrim(stristr($this->host, $rootDomain, true), '.')); } else { $domain = explode('.', $this->host, -2); } $this->subDomain = implode('.', $domain); return $this->subDomain; }
php
public function getSubDomain() { // 获取当前主域名 $rootDomain = $this->config['app.url_domain']; if ($rootDomain) { // 配置域名根 例如 thinkphp.cn 163.com.cn 如果是国家级域名 com.cn net.cn 之类的域名需要配置 $domain = explode('.', rtrim(stristr($this->host, $rootDomain, true), '.')); } else { $domain = explode('.', $this->host, -2); } $this->subDomain = implode('.', $domain); return $this->subDomain; }
[ "public", "function", "getSubDomain", "(", ")", "{", "// 获取当前主域名", "$", "rootDomain", "=", "$", "this", "->", "config", "[", "'app.url_domain'", "]", ";", "if", "(", "$", "rootDomain", ")", "{", "// 配置域名根 例如 thinkphp.cn 163.com.cn 如果是国家级域名 com.cn net.cn 之类的域名需要配置", ...
获取子域名 @return string
[ "获取子域名" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Routing/Router.php#L937-L952
oxygen-cms/core
src/Translation/Translator.php
Translator.get
public function get($key, array $replace = [], $locale = null, $fallback = true) { foreach($this->bulkReplacements as $match => $extraReplace) { if(starts_with($key, $match)) { $replace = array_merge($replace, $extraReplace); } } return parent::get($key, $replace, $locale, $fallback); }
php
public function get($key, array $replace = [], $locale = null, $fallback = true) { foreach($this->bulkReplacements as $match => $extraReplace) { if(starts_with($key, $match)) { $replace = array_merge($replace, $extraReplace); } } return parent::get($key, $replace, $locale, $fallback); }
[ "public", "function", "get", "(", "$", "key", ",", "array", "$", "replace", "=", "[", "]", ",", "$", "locale", "=", "null", ",", "$", "fallback", "=", "true", ")", "{", "foreach", "(", "$", "this", "->", "bulkReplacements", "as", "$", "match", "=>"...
Get the translation for the given key. @param string $key @param array $replace @param string $locale @return string
[ "Get", "the", "translation", "for", "the", "given", "key", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Translation/Translator.php#L48-L56
xutl/qcloud-cmq
src/Requests/BatchReceiveMessageRequest.php
BatchReceiveMessageRequest.setNumOfMsg
public function setNumOfMsg($numOfMsg) { if ($numOfMsg > 16 || $numOfMsg = null) $numOfMsg = 16; $this->setParameter('numOfMsg', $numOfMsg); return $this; }
php
public function setNumOfMsg($numOfMsg) { if ($numOfMsg > 16 || $numOfMsg = null) $numOfMsg = 16; $this->setParameter('numOfMsg', $numOfMsg); return $this; }
[ "public", "function", "setNumOfMsg", "(", "$", "numOfMsg", ")", "{", "if", "(", "$", "numOfMsg", ">", "16", "||", "$", "numOfMsg", "=", "null", ")", "$", "numOfMsg", "=", "16", ";", "$", "this", "->", "setParameter", "(", "'numOfMsg'", ",", "$", "num...
本次消费的消息数量。取值范围 1-16。 @param string $numOfMsg @return BaseRequest
[ "本次消费的消息数量。取值范围", "1", "-", "16。" ]
train
https://github.com/xutl/qcloud-cmq/blob/f48b905c2d4001817126f0c25a0433acda79ea6a/src/Requests/BatchReceiveMessageRequest.php#L43-L48
oscarotero/uploader
src/Adapters/Upload.php
Upload.save
public static function save($original, $destination) { if (empty($original['tmp_name']) || !empty($original['error'])) { throw new \RuntimeException('Unable to copy the uploaded file because has an error'); } $moved = php_sapi_name() == 'cli' ? rename($original['tmp_name'], $destination) : move_uploaded_file($original['tmp_name'], $destination); if (!$moved) { throw new \RuntimeException("Unable to copy '{$original['tmp_name']}' to '{$destination}'"); } chmod($destination, 0755); }
php
public static function save($original, $destination) { if (empty($original['tmp_name']) || !empty($original['error'])) { throw new \RuntimeException('Unable to copy the uploaded file because has an error'); } $moved = php_sapi_name() == 'cli' ? rename($original['tmp_name'], $destination) : move_uploaded_file($original['tmp_name'], $destination); if (!$moved) { throw new \RuntimeException("Unable to copy '{$original['tmp_name']}' to '{$destination}'"); } chmod($destination, 0755); }
[ "public", "static", "function", "save", "(", "$", "original", ",", "$", "destination", ")", "{", "if", "(", "empty", "(", "$", "original", "[", "'tmp_name'", "]", ")", "||", "!", "empty", "(", "$", "original", "[", "'error'", "]", ")", ")", "{", "t...
{@inheritdoc}
[ "{" ]
train
https://github.com/oscarotero/uploader/blob/94f1461d324b467e2047568fcc5d88d53ab9ac8f/src/Adapters/Upload.php#L39-L52
xutl/qcloud-cmq
src/Http/HttpClient.php
HttpClient._buildParamStr
protected function _buildParamStr($requestParams, $requestMethod = 'POST') { $paramStr = ''; ksort($requestParams); $i = 0; foreach ($requestParams as $key => $value) { if ($key == 'Signature') { continue; } // 排除上传文件的参数 if ($requestMethod == 'POST' && substr($value, 0, 1) == '@') { continue; } // 把 参数中的 _ 替换成 . if (strpos($key, '_')) { $key = str_replace('_', '.', $key); } if ($i == 0) { $paramStr .= '?'; } else { $paramStr .= '&'; } $paramStr .= $key . '=' . $value; ++$i; } return $paramStr; }
php
protected function _buildParamStr($requestParams, $requestMethod = 'POST') { $paramStr = ''; ksort($requestParams); $i = 0; foreach ($requestParams as $key => $value) { if ($key == 'Signature') { continue; } // 排除上传文件的参数 if ($requestMethod == 'POST' && substr($value, 0, 1) == '@') { continue; } // 把 参数中的 _ 替换成 . if (strpos($key, '_')) { $key = str_replace('_', '.', $key); } if ($i == 0) { $paramStr .= '?'; } else { $paramStr .= '&'; } $paramStr .= $key . '=' . $value; ++$i; } return $paramStr; }
[ "protected", "function", "_buildParamStr", "(", "$", "requestParams", ",", "$", "requestMethod", "=", "'POST'", ")", "{", "$", "paramStr", "=", "''", ";", "ksort", "(", "$", "requestParams", ")", ";", "$", "i", "=", "0", ";", "foreach", "(", "$", "requ...
_buildParamStr 拼接参数 @param array $requestParams 请求参数 @param string $requestMethod 请求方法 @return string
[ "_buildParamStr", "拼接参数" ]
train
https://github.com/xutl/qcloud-cmq/blob/f48b905c2d4001817126f0c25a0433acda79ea6a/src/Http/HttpClient.php#L110-L138
xutl/qcloud-cmq
src/Http/HttpClient.php
HttpClient.makeSignPlainText
public function makeSignPlainText($requestParams, $requestMethod = 'POST', $requestHost = '', $requestPath = '/v2/index.php') { $url = $requestHost . $requestPath; // 取出所有的参数 $paramStr = $this->_buildParamStr($requestParams, $requestMethod); $plainText = $requestMethod . $url . $paramStr; return $plainText; }
php
public function makeSignPlainText($requestParams, $requestMethod = 'POST', $requestHost = '', $requestPath = '/v2/index.php') { $url = $requestHost . $requestPath; // 取出所有的参数 $paramStr = $this->_buildParamStr($requestParams, $requestMethod); $plainText = $requestMethod . $url . $paramStr; return $plainText; }
[ "public", "function", "makeSignPlainText", "(", "$", "requestParams", ",", "$", "requestMethod", "=", "'POST'", ",", "$", "requestHost", "=", "''", ",", "$", "requestPath", "=", "'/v2/index.php'", ")", "{", "$", "url", "=", "$", "requestHost", ".", "$", "r...
makeSignPlainText 生成拼接签名源文字符串 @param array $requestParams 请求参数 @param string $requestMethod 请求方法 @param string $requestHost 接口域名 @param string $requestPath url路径 @return string
[ "makeSignPlainText", "生成拼接签名源文字符串" ]
train
https://github.com/xutl/qcloud-cmq/blob/f48b905c2d4001817126f0c25a0433acda79ea6a/src/Http/HttpClient.php#L149-L156
xutl/qcloud-cmq
src/Http/HttpClient.php
HttpClient.buildRequestBody
public function buildRequestBody(BaseRequest &$request) { $params = $request->getParameters(); $params['SecretId'] = $this->secretId; $params['Nonce'] = rand(1, 65535); $params['Timestamp'] = time(); $params['SignatureMethod'] = $this->signatureMethod; $host = str_replace(['http://', 'https://'], '', $this->endPoint); $plainText = $this->makeSignPlainText($params, $this->requestMethod, $host, $this->requestPath); //签名 if ($this->signatureMethod == self::SIGNATURE_METHOD_HMAC_SHA256) { $params['Signature'] = base64_encode(hash_hmac('sha256', $plainText, $this->secretKey, true)); } elseif ($this->signatureMethod == self::SIGNATURE_METHOD_HMAC_SHA1) { $params['Signature'] = base64_encode(hash_hmac('sha1', $plainText, $this->secretKey, true)); } //var_dump($params);exit; return $params; }
php
public function buildRequestBody(BaseRequest &$request) { $params = $request->getParameters(); $params['SecretId'] = $this->secretId; $params['Nonce'] = rand(1, 65535); $params['Timestamp'] = time(); $params['SignatureMethod'] = $this->signatureMethod; $host = str_replace(['http://', 'https://'], '', $this->endPoint); $plainText = $this->makeSignPlainText($params, $this->requestMethod, $host, $this->requestPath); //签名 if ($this->signatureMethod == self::SIGNATURE_METHOD_HMAC_SHA256) { $params['Signature'] = base64_encode(hash_hmac('sha256', $plainText, $this->secretKey, true)); } elseif ($this->signatureMethod == self::SIGNATURE_METHOD_HMAC_SHA1) { $params['Signature'] = base64_encode(hash_hmac('sha1', $plainText, $this->secretKey, true)); } //var_dump($params);exit; return $params; }
[ "public", "function", "buildRequestBody", "(", "BaseRequest", "&", "$", "request", ")", "{", "$", "params", "=", "$", "request", "->", "getParameters", "(", ")", ";", "$", "params", "[", "'SecretId'", "]", "=", "$", "this", "->", "secretId", ";", "$", ...
编译请求参数 @param BaseRequest $request @return array
[ "编译请求参数" ]
train
https://github.com/xutl/qcloud-cmq/blob/f48b905c2d4001817126f0c25a0433acda79ea6a/src/Http/HttpClient.php#L163-L180
xutl/qcloud-cmq
src/Http/HttpClient.php
HttpClient.sendRequestAsyncInternal
private function sendRequestAsyncInternal(BaseRequest &$request, BaseResponse &$response, AsyncCallback $callback = null) { $options = ['exceptions' => false, 'http_errors' => false]; $options['form_params'] = $this->buildRequestBody($request); $options['timeout'] = $this->requestTimeout; $options['connect_timeout'] = $this->connectTimeout; $request = new Request($this->requestMethod, $this->requestPath); try { if ($callback != null) { return $this->client->sendAsync($request, $options)->then( function (ResponseInterface $res) use (&$response, $callback) { try { $response->unwrapResponse($res); $callback->onSucceed($response); } catch (CMQException $e) { $callback->onFailed($e); } } ); } else { return $this->client->sendAsync($request, $options); } } catch (TransferException $e) { $message = $e->getMessage(); if ($e->hasResponse()) { $message = $e->getResponse()->getBody(); } throw new CMQException($message, $e->getCode()); } }
php
private function sendRequestAsyncInternal(BaseRequest &$request, BaseResponse &$response, AsyncCallback $callback = null) { $options = ['exceptions' => false, 'http_errors' => false]; $options['form_params'] = $this->buildRequestBody($request); $options['timeout'] = $this->requestTimeout; $options['connect_timeout'] = $this->connectTimeout; $request = new Request($this->requestMethod, $this->requestPath); try { if ($callback != null) { return $this->client->sendAsync($request, $options)->then( function (ResponseInterface $res) use (&$response, $callback) { try { $response->unwrapResponse($res); $callback->onSucceed($response); } catch (CMQException $e) { $callback->onFailed($e); } } ); } else { return $this->client->sendAsync($request, $options); } } catch (TransferException $e) { $message = $e->getMessage(); if ($e->hasResponse()) { $message = $e->getResponse()->getBody(); } throw new CMQException($message, $e->getCode()); } }
[ "private", "function", "sendRequestAsyncInternal", "(", "BaseRequest", "&", "$", "request", ",", "BaseResponse", "&", "$", "response", ",", "AsyncCallback", "$", "callback", "=", "null", ")", "{", "$", "options", "=", "[", "'exceptions'", "=>", "false", ",", ...
内部方法,发送异步请求 @param BaseRequest $request @param BaseResponse $response @param AsyncCallback|null $callback @return \GuzzleHttp\Promise\PromiseInterface
[ "内部方法,发送异步请求" ]
train
https://github.com/xutl/qcloud-cmq/blob/f48b905c2d4001817126f0c25a0433acda79ea6a/src/Http/HttpClient.php#L214-L243
oscarotero/fly-crud
src/Document.php
Document.arrayToObject
private static function arrayToObject(array $array) { $is_object = false; foreach ($array as $key => &$value) { if (is_array($value)) { $value = self::arrayToObject($value); } if (is_string($key)) { $is_object = true; } } return $is_object ? (object) $array : $array; }
php
private static function arrayToObject(array $array) { $is_object = false; foreach ($array as $key => &$value) { if (is_array($value)) { $value = self::arrayToObject($value); } if (is_string($key)) { $is_object = true; } } return $is_object ? (object) $array : $array; }
[ "private", "static", "function", "arrayToObject", "(", "array", "$", "array", ")", "{", "$", "is_object", "=", "false", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ...
Converts the associative arrays to stdClass object recursively. @return array|stdClass
[ "Converts", "the", "associative", "arrays", "to", "stdClass", "object", "recursively", "." ]
train
https://github.com/oscarotero/fly-crud/blob/df826e4db5df954d3cace9c12762ec0309b050bf/src/Document.php#L65-L80
oscarotero/fly-crud
src/Document.php
Document.objectToArray
private static function objectToArray(array $array): array { foreach ($array as $key => &$value) { if (is_object($value) || is_array($value)) { $value = self::objectToArray((array) $value); } } return (array) $array; }
php
private static function objectToArray(array $array): array { foreach ($array as $key => &$value) { if (is_object($value) || is_array($value)) { $value = self::objectToArray((array) $value); } } return (array) $array; }
[ "private", "static", "function", "objectToArray", "(", "array", "$", "array", ")", ":", "array", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", "||", "is_array",...
Converts stdClass objects to arrays recursively.
[ "Converts", "stdClass", "objects", "to", "arrays", "recursively", "." ]
train
https://github.com/oscarotero/fly-crud/blob/df826e4db5df954d3cace9c12762ec0309b050bf/src/Document.php#L85-L94
txj123/zilf
src/Zilf/Db/ActiveRelationTrait.php
ActiveRelationTrait.populateRelation
public function populateRelation($name, &$primaryModels) { if (!is_array($this->link)) { throw new InvalidConfigException('Invalid link: it must be an array of key-value pairs.'); } if ($this->via instanceof self) { // via junction table /* @var $viaQuery ActiveRelationTrait */ $viaQuery = $this->via; $viaModels = $viaQuery->findJunctionRows($primaryModels); $this->filterByModels($viaModels); } elseif (is_array($this->via)) { // via relation /* @var $viaQuery ActiveRelationTrait|ActiveQueryTrait */ list($viaName, $viaQuery) = $this->via; if ($viaQuery->asArray === null) { // inherit asArray from primary query $viaQuery->asArray($this->asArray); } $viaQuery->primaryModel = null; $viaModels = $viaQuery->populateRelation($viaName, $primaryModels); $this->filterByModels($viaModels); } else { $this->filterByModels($primaryModels); } if (!$this->multiple && count($primaryModels) === 1) { $model = $this->one(); $primaryModel = reset($primaryModels); if ($primaryModel instanceof ActiveRecordInterface) { $primaryModel->populateRelation($name, $model); } else { $primaryModels[key($primaryModels)][$name] = $model; } if ($this->inverseOf !== null) { $this->populateInverseRelation($primaryModels, [$model], $name, $this->inverseOf); } return [$model]; } // https://github.com/Zilfsoft/Zilf2/issues/3197 // delay indexing related models after buckets are built $indexBy = $this->indexBy; $this->indexBy = null; $models = $this->all(); if (isset($viaModels, $viaQuery)) { $buckets = $this->buildBuckets($models, $this->link, $viaModels, $viaQuery->link); } else { $buckets = $this->buildBuckets($models, $this->link); } $this->indexBy = $indexBy; if ($this->indexBy !== null && $this->multiple) { $buckets = $this->indexBuckets($buckets, $this->indexBy); } $link = array_values(isset($viaQuery) ? $viaQuery->link : $this->link); foreach ($primaryModels as $i => $primaryModel) { if ($this->multiple && count($link) === 1 && is_array($keys = $primaryModel[reset($link)])) { $value = []; foreach ($keys as $key) { $key = $this->normalizeModelKey($key); if (isset($buckets[$key])) { if ($this->indexBy !== null) { // if indexBy is set, array_merge will cause renumbering of numeric array foreach ($buckets[$key] as $bucketKey => $bucketValue) { $value[$bucketKey] = $bucketValue; } } else { $value = array_merge($value, $buckets[$key]); } } } } else { $key = $this->getModelKey($primaryModel, $link); $value = isset($buckets[$key]) ? $buckets[$key] : ($this->multiple ? [] : null); } if ($primaryModel instanceof ActiveRecordInterface) { $primaryModel->populateRelation($name, $value); } else { $primaryModels[$i][$name] = $value; } } if ($this->inverseOf !== null) { $this->populateInverseRelation($primaryModels, $models, $name, $this->inverseOf); } return $models; }
php
public function populateRelation($name, &$primaryModels) { if (!is_array($this->link)) { throw new InvalidConfigException('Invalid link: it must be an array of key-value pairs.'); } if ($this->via instanceof self) { // via junction table /* @var $viaQuery ActiveRelationTrait */ $viaQuery = $this->via; $viaModels = $viaQuery->findJunctionRows($primaryModels); $this->filterByModels($viaModels); } elseif (is_array($this->via)) { // via relation /* @var $viaQuery ActiveRelationTrait|ActiveQueryTrait */ list($viaName, $viaQuery) = $this->via; if ($viaQuery->asArray === null) { // inherit asArray from primary query $viaQuery->asArray($this->asArray); } $viaQuery->primaryModel = null; $viaModels = $viaQuery->populateRelation($viaName, $primaryModels); $this->filterByModels($viaModels); } else { $this->filterByModels($primaryModels); } if (!$this->multiple && count($primaryModels) === 1) { $model = $this->one(); $primaryModel = reset($primaryModels); if ($primaryModel instanceof ActiveRecordInterface) { $primaryModel->populateRelation($name, $model); } else { $primaryModels[key($primaryModels)][$name] = $model; } if ($this->inverseOf !== null) { $this->populateInverseRelation($primaryModels, [$model], $name, $this->inverseOf); } return [$model]; } // https://github.com/Zilfsoft/Zilf2/issues/3197 // delay indexing related models after buckets are built $indexBy = $this->indexBy; $this->indexBy = null; $models = $this->all(); if (isset($viaModels, $viaQuery)) { $buckets = $this->buildBuckets($models, $this->link, $viaModels, $viaQuery->link); } else { $buckets = $this->buildBuckets($models, $this->link); } $this->indexBy = $indexBy; if ($this->indexBy !== null && $this->multiple) { $buckets = $this->indexBuckets($buckets, $this->indexBy); } $link = array_values(isset($viaQuery) ? $viaQuery->link : $this->link); foreach ($primaryModels as $i => $primaryModel) { if ($this->multiple && count($link) === 1 && is_array($keys = $primaryModel[reset($link)])) { $value = []; foreach ($keys as $key) { $key = $this->normalizeModelKey($key); if (isset($buckets[$key])) { if ($this->indexBy !== null) { // if indexBy is set, array_merge will cause renumbering of numeric array foreach ($buckets[$key] as $bucketKey => $bucketValue) { $value[$bucketKey] = $bucketValue; } } else { $value = array_merge($value, $buckets[$key]); } } } } else { $key = $this->getModelKey($primaryModel, $link); $value = isset($buckets[$key]) ? $buckets[$key] : ($this->multiple ? [] : null); } if ($primaryModel instanceof ActiveRecordInterface) { $primaryModel->populateRelation($name, $value); } else { $primaryModels[$i][$name] = $value; } } if ($this->inverseOf !== null) { $this->populateInverseRelation($primaryModels, $models, $name, $this->inverseOf); } return $models; }
[ "public", "function", "populateRelation", "(", "$", "name", ",", "&", "$", "primaryModels", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "link", ")", ")", "{", "throw", "new", "InvalidConfigException", "(", "'Invalid link: it must be an array ...
Finds the related records and populates them into the primary models. @param string $name the relation name @param array $primaryModels primary models @return array the related models @throws InvalidConfigException if [[link]] is invalid
[ "Finds", "the", "related", "records", "and", "populates", "them", "into", "the", "primary", "models", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/ActiveRelationTrait.php#L226-L317
txj123/zilf
src/Zilf/Db/base/Controller.php
Controller.findLayoutFile
public function findLayoutFile($view) { $module = $this->module; if (is_string($this->layout)) { $layout = $this->layout; } elseif ($this->layout === null) { while ($module !== null && $module->layout === null) { $module = $module->module; } if ($module !== null && is_string($module->layout)) { $layout = $module->layout; } } if (!isset($layout)) { return false; } if (strncmp($layout, '@', 1) === 0) { $file = Zilf::getAlias($layout); } elseif (strncmp($layout, '/', 1) === 0) { $file = Zilf::$app->getLayoutPath() . DIRECTORY_SEPARATOR . substr($layout, 1); } else { $file = $module->getLayoutPath() . DIRECTORY_SEPARATOR . $layout; } if (pathinfo($file, PATHINFO_EXTENSION) !== '') { return $file; } $path = $file . '.' . $view->defaultExtension; if ($view->defaultExtension !== 'php' && !is_file($path)) { $path = $file . '.php'; } return $path; }
php
public function findLayoutFile($view) { $module = $this->module; if (is_string($this->layout)) { $layout = $this->layout; } elseif ($this->layout === null) { while ($module !== null && $module->layout === null) { $module = $module->module; } if ($module !== null && is_string($module->layout)) { $layout = $module->layout; } } if (!isset($layout)) { return false; } if (strncmp($layout, '@', 1) === 0) { $file = Zilf::getAlias($layout); } elseif (strncmp($layout, '/', 1) === 0) { $file = Zilf::$app->getLayoutPath() . DIRECTORY_SEPARATOR . substr($layout, 1); } else { $file = $module->getLayoutPath() . DIRECTORY_SEPARATOR . $layout; } if (pathinfo($file, PATHINFO_EXTENSION) !== '') { return $file; } $path = $file . '.' . $view->defaultExtension; if ($view->defaultExtension !== 'php' && !is_file($path)) { $path = $file . '.php'; } return $path; }
[ "public", "function", "findLayoutFile", "(", "$", "view", ")", "{", "$", "module", "=", "$", "this", "->", "module", ";", "if", "(", "is_string", "(", "$", "this", "->", "layout", ")", ")", "{", "$", "layout", "=", "$", "this", "->", "layout", ";",...
Finds the applicable layout file. @param View $view the view object to render the layout file. @return string|bool the layout file path, or false if layout is not needed. Please refer to [[render()]] on how to specify this parameter. @throws InvalidArgumentException if an invalid path alias is used to specify the layout.
[ "Finds", "the", "applicable", "layout", "file", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/base/Controller.php#L504-L539
crysalead/sql-dialect
src/Statement/Select.php
Select.fields
public function fields($fields) { $fields = is_array($fields) && func_num_args() === 1 ? $fields : func_get_args(); $this->_parts['fields'] = Set::merge($this->_parts['fields'], $fields); return $this; }
php
public function fields($fields) { $fields = is_array($fields) && func_num_args() === 1 ? $fields : func_get_args(); $this->_parts['fields'] = Set::merge($this->_parts['fields'], $fields); return $this; }
[ "public", "function", "fields", "(", "$", "fields", ")", "{", "$", "fields", "=", "is_array", "(", "$", "fields", ")", "&&", "func_num_args", "(", ")", "===", "1", "?", "$", "fields", ":", "func_get_args", "(", ")", ";", "$", "this", "->", "_parts", ...
Adds some fields to the query. @param string|array $fields The fields. @return string Formatted fields list.
[ "Adds", "some", "fields", "to", "the", "query", "." ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Select.php#L60-L65
crysalead/sql-dialect
src/Statement/Select.php
Select.from
public function from($sources) { if (!$sources) { throw new SqlException("A `FROM` clause requires a non empty table."); } $sources = is_array($sources) ? $sources : func_get_args(); $this->_parts['from'] += array_merge($this->_parts['from'], $sources); return $this; }
php
public function from($sources) { if (!$sources) { throw new SqlException("A `FROM` clause requires a non empty table."); } $sources = is_array($sources) ? $sources : func_get_args(); $this->_parts['from'] += array_merge($this->_parts['from'], $sources); return $this; }
[ "public", "function", "from", "(", "$", "sources", ")", "{", "if", "(", "!", "$", "sources", ")", "{", "throw", "new", "SqlException", "(", "\"A `FROM` clause requires a non empty table.\"", ")", ";", "}", "$", "sources", "=", "is_array", "(", "$", "sources"...
Adds some tables in the from statement @param string|array $sources The source tables. @return string Formatted source table list.
[ "Adds", "some", "tables", "in", "the", "from", "statement" ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Select.php#L73-L81
crysalead/sql-dialect
src/Statement/Select.php
Select.join
public function join($join = null, $on = [], $type = 'LEFT') { if (!$join) { return $this; } $this->_parts['joins'][] = compact('join', 'on', 'type'); return $this; }
php
public function join($join = null, $on = [], $type = 'LEFT') { if (!$join) { return $this; } $this->_parts['joins'][] = compact('join', 'on', 'type'); return $this; }
[ "public", "function", "join", "(", "$", "join", "=", "null", ",", "$", "on", "=", "[", "]", ",", "$", "type", "=", "'LEFT'", ")", "{", "if", "(", "!", "$", "join", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "_parts", "[", ...
Adds a join to the query. @param string|array $join A join definition. @return string Formatted `JOIN` clause.
[ "Adds", "a", "join", "to", "the", "query", "." ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Select.php#L89-L96
crysalead/sql-dialect
src/Statement/Select.php
Select.group
public function group($fields) { if (!$fields) { return $this; } if ($fields = is_array($fields) ? $fields : func_get_args()) { $this->_parts['group'] = array_merge($this->_parts['group'], array_fill_keys($fields, true)); } return $this; }
php
public function group($fields) { if (!$fields) { return $this; } if ($fields = is_array($fields) ? $fields : func_get_args()) { $this->_parts['group'] = array_merge($this->_parts['group'], array_fill_keys($fields, true)); } return $this; }
[ "public", "function", "group", "(", "$", "fields", ")", "{", "if", "(", "!", "$", "fields", ")", "{", "return", "$", "this", ";", "}", "if", "(", "$", "fields", "=", "is_array", "(", "$", "fields", ")", "?", "$", "fields", ":", "func_get_args", "...
Adds some group by fields to the query. @param string|array $fields The fields. @return object Returns `$this`.
[ "Adds", "some", "group", "by", "fields", "to", "the", "query", "." ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Select.php#L104-L113