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
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.fetchByMessageNr
public function fetchByMessageNr( $number, $deleteFromServer = false ) { if ( $this->options->uidReferencing ) { $messages = array_flip( $this->listUniqueIdentifiers() ); } else { $messages = $this->listMessages(); } if ( !isset( $messages[$number] ) ) { throw new ezcMailNoSuchMessageException( $number ); } return new ezcMailImapSet( $this->connection, array( 0 => $number ), $deleteFromServer, array( 'uidReferencing' => $this->options->uidReferencing ) ); }
php
public function fetchByMessageNr( $number, $deleteFromServer = false ) { if ( $this->options->uidReferencing ) { $messages = array_flip( $this->listUniqueIdentifiers() ); } else { $messages = $this->listMessages(); } if ( !isset( $messages[$number] ) ) { throw new ezcMailNoSuchMessageException( $number ); } return new ezcMailImapSet( $this->connection, array( 0 => $number ), $deleteFromServer, array( 'uidReferencing' => $this->options->uidReferencing ) ); }
[ "public", "function", "fetchByMessageNr", "(", "$", "number", ",", "$", "deleteFromServer", "=", "false", ")", "{", "if", "(", "$", "this", "->", "options", "->", "uidReferencing", ")", "{", "$", "messages", "=", "array_flip", "(", "$", "this", "->", "listUniqueIdentifiers", "(", ")", ")", ";", "}", "else", "{", "$", "messages", "=", "$", "this", "->", "listMessages", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "messages", "[", "$", "number", "]", ")", ")", "{", "throw", "new", "ezcMailNoSuchMessageException", "(", "$", "number", ")", ";", "}", "return", "new", "ezcMailImapSet", "(", "$", "this", "->", "connection", ",", "array", "(", "0", "=>", "$", "number", ")", ",", "$", "deleteFromServer", ",", "array", "(", "'uidReferencing'", "=>", "$", "this", "->", "options", "->", "uidReferencing", ")", ")", ";", "}" ]
Returns an {@link ezcMailImapSet} containing only the $number -th message in the current mailbox. This method supports unique IDs instead of message numbers. See {@link ezcMailImapTransportOptions} for how to enable unique IDs referencing. If $deleteFromServer is set to true the mail will be marked for deletion after retrieval. If not it will be left intact. Note: for IMAP the first message is 1 (so for $number = 0 an exception will be thrown). Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. Example: <code> $imap = new ezcMailImapTransport( 'imap.example.com' ); $imap->authenticate( 'username', 'password' ); $imap->selectMailbox( 'Inbox' ); $set = $imap->fetchByMessageNr( 1 ); // $set can be parsed with ezcMailParser </code> @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response @throws ezcMailNoSuchMessageException if the message $number is out of range @param int $number @param bool $deleteFromServer @return ezcMailImapSet
[ "Returns", "an", "{", "@link", "ezcMailImapSet", "}", "containing", "only", "the", "$number", "-", "th", "message", "in", "the", "current", "mailbox", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L1528-L1545
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.fetchFromOffset
public function fetchFromOffset( $offset, $count = 0, $deleteFromServer = false ) { if ( $count < 0 ) { throw new ezcMailInvalidLimitException( $offset, $count ); } if ( $this->options->uidReferencing ) { $messages = array_values( $this->listUniqueIdentifiers() ); $ids = array_flip( $messages ); if ( $count === 0 ) { $count = count( $messages ); } if ( !isset( $ids[$offset] ) ) { throw new ezcMailOffsetOutOfRangeException( $offset, $count ); } $range = array(); for ( $i = $ids[$offset]; $i < min( $count, count( $messages ) ); $i++ ) { $range[] = $messages[$i]; } } else { $messages = array_keys( $this->listMessages() ); if ( $count === 0 ) { $count = count( $messages ); } $range = array_slice( $messages, $offset - 1, $count, true ); if ( !isset( $range[$offset - 1] ) ) { throw new ezcMailOffsetOutOfRangeException( $offset, $count ); } } return new ezcMailImapSet( $this->connection, $range, $deleteFromServer, array( 'uidReferencing' => $this->options->uidReferencing ) ); }
php
public function fetchFromOffset( $offset, $count = 0, $deleteFromServer = false ) { if ( $count < 0 ) { throw new ezcMailInvalidLimitException( $offset, $count ); } if ( $this->options->uidReferencing ) { $messages = array_values( $this->listUniqueIdentifiers() ); $ids = array_flip( $messages ); if ( $count === 0 ) { $count = count( $messages ); } if ( !isset( $ids[$offset] ) ) { throw new ezcMailOffsetOutOfRangeException( $offset, $count ); } $range = array(); for ( $i = $ids[$offset]; $i < min( $count, count( $messages ) ); $i++ ) { $range[] = $messages[$i]; } } else { $messages = array_keys( $this->listMessages() ); if ( $count === 0 ) { $count = count( $messages ); } $range = array_slice( $messages, $offset - 1, $count, true ); if ( !isset( $range[$offset - 1] ) ) { throw new ezcMailOffsetOutOfRangeException( $offset, $count ); } } return new ezcMailImapSet( $this->connection, $range, $deleteFromServer, array( 'uidReferencing' => $this->options->uidReferencing ) ); }
[ "public", "function", "fetchFromOffset", "(", "$", "offset", ",", "$", "count", "=", "0", ",", "$", "deleteFromServer", "=", "false", ")", "{", "if", "(", "$", "count", "<", "0", ")", "{", "throw", "new", "ezcMailInvalidLimitException", "(", "$", "offset", ",", "$", "count", ")", ";", "}", "if", "(", "$", "this", "->", "options", "->", "uidReferencing", ")", "{", "$", "messages", "=", "array_values", "(", "$", "this", "->", "listUniqueIdentifiers", "(", ")", ")", ";", "$", "ids", "=", "array_flip", "(", "$", "messages", ")", ";", "if", "(", "$", "count", "===", "0", ")", "{", "$", "count", "=", "count", "(", "$", "messages", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "ids", "[", "$", "offset", "]", ")", ")", "{", "throw", "new", "ezcMailOffsetOutOfRangeException", "(", "$", "offset", ",", "$", "count", ")", ";", "}", "$", "range", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "$", "ids", "[", "$", "offset", "]", ";", "$", "i", "<", "min", "(", "$", "count", ",", "count", "(", "$", "messages", ")", ")", ";", "$", "i", "++", ")", "{", "$", "range", "[", "]", "=", "$", "messages", "[", "$", "i", "]", ";", "}", "}", "else", "{", "$", "messages", "=", "array_keys", "(", "$", "this", "->", "listMessages", "(", ")", ")", ";", "if", "(", "$", "count", "===", "0", ")", "{", "$", "count", "=", "count", "(", "$", "messages", ")", ";", "}", "$", "range", "=", "array_slice", "(", "$", "messages", ",", "$", "offset", "-", "1", ",", "$", "count", ",", "true", ")", ";", "if", "(", "!", "isset", "(", "$", "range", "[", "$", "offset", "-", "1", "]", ")", ")", "{", "throw", "new", "ezcMailOffsetOutOfRangeException", "(", "$", "offset", ",", "$", "count", ")", ";", "}", "}", "return", "new", "ezcMailImapSet", "(", "$", "this", "->", "connection", ",", "$", "range", ",", "$", "deleteFromServer", ",", "array", "(", "'uidReferencing'", "=>", "$", "this", "->", "options", "->", "uidReferencing", ")", ")", ";", "}" ]
Returns an {@link ezcMailImapSet} with $count messages starting from $offset from the current mailbox. This method supports unique IDs instead of message numbers. See {@link ezcMailImapTransportOptions} for how to enable unique IDs referencing. Fetches $count messages starting from the $offset and returns them as a {@link ezcMailImapSet}. If $count is not specified or if it is 0, it fetches all messages starting from the $offset. Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. Example: <code> $imap = new ezcMailImapTransport( 'imap.example.com' ); $imap->authenticate( 'username', 'password' ); $imap->selectMailbox( 'Inbox' ); $set = $imap->fetchFromOffset( 1, 10 ); // $set can be parsed with ezcMailParser </code> @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response @throws ezcMailInvalidLimitException if $count is negative @throws ezcMailOffsetOutOfRangeException if $offset is outside of the existing range of messages @param int $offset @param int $count @param bool $deleteFromServer @return ezcMailImapSet
[ "Returns", "an", "{", "@link", "ezcMailImapSet", "}", "with", "$count", "messages", "starting", "from", "$offset", "from", "the", "current", "mailbox", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L1586-L1632
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.searchMailbox
public function searchMailbox( $criteria = null ) { $uid = ( $this->options->uidReferencing ) ? self::UID : self::NO_UID; if ( $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call searchMailbox() on the IMAP transport when a mailbox is not selected." ); } $criteria = trim( $criteria ); if ( empty( $criteria ) ) { $criteria = 'ALL'; } $matchingMessages = array(); $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} {$uid}SEARCH {$criteria}" ); $response = $this->getResponse( '* SEARCH' ); if ( strpos( $response, '* SEARCH' ) !== false ) { $ids = substr( trim( $response ), 9 ); if ( trim( $ids ) !== "" ) { $matchingMessages = explode( ' ', $ids ); } } $response = trim( $this->getResponse( $tag, $response ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not search the messages by the specified criteria: {$response}." ); } return new ezcMailImapSet( $this->connection, array_values( $matchingMessages ), false, array( 'uidReferencing' => $this->options->uidReferencing ) ); }
php
public function searchMailbox( $criteria = null ) { $uid = ( $this->options->uidReferencing ) ? self::UID : self::NO_UID; if ( $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call searchMailbox() on the IMAP transport when a mailbox is not selected." ); } $criteria = trim( $criteria ); if ( empty( $criteria ) ) { $criteria = 'ALL'; } $matchingMessages = array(); $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} {$uid}SEARCH {$criteria}" ); $response = $this->getResponse( '* SEARCH' ); if ( strpos( $response, '* SEARCH' ) !== false ) { $ids = substr( trim( $response ), 9 ); if ( trim( $ids ) !== "" ) { $matchingMessages = explode( ' ', $ids ); } } $response = trim( $this->getResponse( $tag, $response ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not search the messages by the specified criteria: {$response}." ); } return new ezcMailImapSet( $this->connection, array_values( $matchingMessages ), false, array( 'uidReferencing' => $this->options->uidReferencing ) ); }
[ "public", "function", "searchMailbox", "(", "$", "criteria", "=", "null", ")", "{", "$", "uid", "=", "(", "$", "this", "->", "options", "->", "uidReferencing", ")", "?", "self", "::", "UID", ":", "self", "::", "NO_UID", ";", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED_READONLY", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call searchMailbox() on the IMAP transport when a mailbox is not selected.\"", ")", ";", "}", "$", "criteria", "=", "trim", "(", "$", "criteria", ")", ";", "if", "(", "empty", "(", "$", "criteria", ")", ")", "{", "$", "criteria", "=", "'ALL'", ";", "}", "$", "matchingMessages", "=", "array", "(", ")", ";", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} {$uid}SEARCH {$criteria}\"", ")", ";", "$", "response", "=", "$", "this", "->", "getResponse", "(", "'* SEARCH'", ")", ";", "if", "(", "strpos", "(", "$", "response", ",", "'* SEARCH'", ")", "!==", "false", ")", "{", "$", "ids", "=", "substr", "(", "trim", "(", "$", "response", ")", ",", "9", ")", ";", "if", "(", "trim", "(", "$", "ids", ")", "!==", "\"\"", ")", "{", "$", "matchingMessages", "=", "explode", "(", "' '", ",", "$", "ids", ")", ";", "}", "}", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "$", "tag", ",", "$", "response", ")", ")", ";", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The IMAP server could not search the messages by the specified criteria: {$response}.\"", ")", ";", "}", "return", "new", "ezcMailImapSet", "(", "$", "this", "->", "connection", ",", "array_values", "(", "$", "matchingMessages", ")", ",", "false", ",", "array", "(", "'uidReferencing'", "=>", "$", "this", "->", "options", "->", "uidReferencing", ")", ")", ";", "}" ]
Returns an {@link ezcMailImapSet} containing the messages which match the provided $criteria from the current mailbox. This method supports unique IDs instead of message numbers. See {@link ezcMailImapTransportOptions} for how to enable unique IDs referencing. See {@link http://www.faqs.org/rfcs/rfc1730.html} - 6.4.4. (or {@link http://www.faqs.org/rfcs/rfc1730.html} - 6.4.4.) for criterias which can be used for searching. The criterias can be combined in the same search string (separate the criterias with spaces). If $criteria is null or empty then it will default to 'ALL' (returns all messages in the mailbox). Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. Examples: <code> $imap = new ezcMailImapTransport( 'imap.example.com' ); $imap->authenticate( 'username', 'password' ); $imap->selectMailbox( 'mailbox' ); // Inbox or another mailbox // return an ezcMailImapSet containing all messages flagged as 'SEEN' $set = $imap->searchMailbox( 'SEEN' ); // return an ezcMailImapSet containing messages with 'release' in their Subject $set = $imap->searchMailbox( 'SUBJECT "release"' ); // criterias can be combined: // return an ezcMailImapSet containing messages flagged as 'SEEN' and // with 'release' in their Subject $set = $imap->searchMailbox( 'SEEN SUBJECT "release"' ); // $set can be parsed with ezcMailParser </code> @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response @param string $criteria @return ezcMailImapSet
[ "Returns", "an", "{", "@link", "ezcMailImapSet", "}", "containing", "the", "messages", "which", "match", "the", "provided", "$criteria", "from", "the", "current", "mailbox", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L1680-L1717
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.sortFromOffset
public function sortFromOffset( $offset, $count = 0, $sortCriteria, $reverse = false ) { if ( $count < 0 ) { throw new ezcMailInvalidLimitException( $offset, $count ); } $range = array(); if ( $this->options->uidReferencing ) { $uids = array_values( $this->listUniqueIdentifiers() ); $flip = array_flip( $uids ); if ( !isset( $flip[$offset] ) ) { throw new ezcMailOffsetOutOfRangeException( $offset, $count ); } $start = $flip[$offset]; $messages = $this->sort( $uids, $sortCriteria, $reverse ); if ( $count === 0 ) { $count = count( $messages ); } $ids = array_keys( $messages ); for ( $i = $start; $i < $count; $i++ ) { $range[] = $ids[$i]; } } else { $messageCount = $this->countByFlag( 'ALL' ); $messages = array_keys( $this->sort( range( 1, $messageCount ), $sortCriteria, $reverse ) ); if ( $count === 0 ) { $count = count( $messages ); } $range = array_slice( $messages, $offset - 1, $count, true ); if ( !isset( $range[$offset - 1] ) ) { throw new ezcMailOffsetOutOfRangeException( $offset, $count ); } } return new ezcMailImapSet( $this->connection, $range, false, array( 'uidReferencing' => $this->options->uidReferencing ) ); }
php
public function sortFromOffset( $offset, $count = 0, $sortCriteria, $reverse = false ) { if ( $count < 0 ) { throw new ezcMailInvalidLimitException( $offset, $count ); } $range = array(); if ( $this->options->uidReferencing ) { $uids = array_values( $this->listUniqueIdentifiers() ); $flip = array_flip( $uids ); if ( !isset( $flip[$offset] ) ) { throw new ezcMailOffsetOutOfRangeException( $offset, $count ); } $start = $flip[$offset]; $messages = $this->sort( $uids, $sortCriteria, $reverse ); if ( $count === 0 ) { $count = count( $messages ); } $ids = array_keys( $messages ); for ( $i = $start; $i < $count; $i++ ) { $range[] = $ids[$i]; } } else { $messageCount = $this->countByFlag( 'ALL' ); $messages = array_keys( $this->sort( range( 1, $messageCount ), $sortCriteria, $reverse ) ); if ( $count === 0 ) { $count = count( $messages ); } $range = array_slice( $messages, $offset - 1, $count, true ); if ( !isset( $range[$offset - 1] ) ) { throw new ezcMailOffsetOutOfRangeException( $offset, $count ); } } return new ezcMailImapSet( $this->connection, $range, false, array( 'uidReferencing' => $this->options->uidReferencing ) ); }
[ "public", "function", "sortFromOffset", "(", "$", "offset", ",", "$", "count", "=", "0", ",", "$", "sortCriteria", ",", "$", "reverse", "=", "false", ")", "{", "if", "(", "$", "count", "<", "0", ")", "{", "throw", "new", "ezcMailInvalidLimitException", "(", "$", "offset", ",", "$", "count", ")", ";", "}", "$", "range", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "options", "->", "uidReferencing", ")", "{", "$", "uids", "=", "array_values", "(", "$", "this", "->", "listUniqueIdentifiers", "(", ")", ")", ";", "$", "flip", "=", "array_flip", "(", "$", "uids", ")", ";", "if", "(", "!", "isset", "(", "$", "flip", "[", "$", "offset", "]", ")", ")", "{", "throw", "new", "ezcMailOffsetOutOfRangeException", "(", "$", "offset", ",", "$", "count", ")", ";", "}", "$", "start", "=", "$", "flip", "[", "$", "offset", "]", ";", "$", "messages", "=", "$", "this", "->", "sort", "(", "$", "uids", ",", "$", "sortCriteria", ",", "$", "reverse", ")", ";", "if", "(", "$", "count", "===", "0", ")", "{", "$", "count", "=", "count", "(", "$", "messages", ")", ";", "}", "$", "ids", "=", "array_keys", "(", "$", "messages", ")", ";", "for", "(", "$", "i", "=", "$", "start", ";", "$", "i", "<", "$", "count", ";", "$", "i", "++", ")", "{", "$", "range", "[", "]", "=", "$", "ids", "[", "$", "i", "]", ";", "}", "}", "else", "{", "$", "messageCount", "=", "$", "this", "->", "countByFlag", "(", "'ALL'", ")", ";", "$", "messages", "=", "array_keys", "(", "$", "this", "->", "sort", "(", "range", "(", "1", ",", "$", "messageCount", ")", ",", "$", "sortCriteria", ",", "$", "reverse", ")", ")", ";", "if", "(", "$", "count", "===", "0", ")", "{", "$", "count", "=", "count", "(", "$", "messages", ")", ";", "}", "$", "range", "=", "array_slice", "(", "$", "messages", ",", "$", "offset", "-", "1", ",", "$", "count", ",", "true", ")", ";", "if", "(", "!", "isset", "(", "$", "range", "[", "$", "offset", "-", "1", "]", ")", ")", "{", "throw", "new", "ezcMailOffsetOutOfRangeException", "(", "$", "offset", ",", "$", "count", ")", ";", "}", "}", "return", "new", "ezcMailImapSet", "(", "$", "this", "->", "connection", ",", "$", "range", ",", "false", ",", "array", "(", "'uidReferencing'", "=>", "$", "this", "->", "options", "->", "uidReferencing", ")", ")", ";", "}" ]
Returns an {@link ezcMailImapSet} containing $count messages starting from $offset sorted by $sortCriteria from the current mailbox. This method supports unique IDs instead of message numbers. See {@link ezcMailImapTransportOptions} for how to enable unique IDs referencing. It is useful for paging through a mailbox. Fetches $count messages starting from the $offset and returns them as a {@link ezcMailImapSet}. If $count is is 0, it fetches all messages starting from the $offset. $sortCriteria is an email header like: Subject, To, From, Date, Sender, etc. Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. Example: <code> $imap = new ezcMailImapTransport( 'imap.example.com' ); $imap->authenticate( 'username', 'password' ); $imap->selectMailbox( 'mailbox' ); // Inbox or another mailbox // Fetch a range of messages sorted by Date $set = $imap->sortFromOffset( 1, 10, "Date" ); // $set can be parsed with ezcMailParser </code> @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response @throws ezcMailInvalidLimitException if $count is negative @throws ezcMailOffsetOutOfRangeException if $offset is outside of the existing range of messages @param int $offset @param int $count @param string $sortCriteria @param bool $reverse @return ezcMailImapSet
[ "Returns", "an", "{", "@link", "ezcMailImapSet", "}", "containing", "$count", "messages", "starting", "from", "$offset", "sorted", "by", "$sortCriteria", "from", "the", "current", "mailbox", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L1764-L1817
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.sortMessages
public function sortMessages( $messages, $sortCriteria, $reverse = false ) { $messages = $this->sort( $messages, $sortCriteria, $reverse ); return new ezcMailImapSet( $this->connection, array_keys ( $messages ), false, array( 'uidReferencing' => $this->options->uidReferencing ) ); }
php
public function sortMessages( $messages, $sortCriteria, $reverse = false ) { $messages = $this->sort( $messages, $sortCriteria, $reverse ); return new ezcMailImapSet( $this->connection, array_keys ( $messages ), false, array( 'uidReferencing' => $this->options->uidReferencing ) ); }
[ "public", "function", "sortMessages", "(", "$", "messages", ",", "$", "sortCriteria", ",", "$", "reverse", "=", "false", ")", "{", "$", "messages", "=", "$", "this", "->", "sort", "(", "$", "messages", ",", "$", "sortCriteria", ",", "$", "reverse", ")", ";", "return", "new", "ezcMailImapSet", "(", "$", "this", "->", "connection", ",", "array_keys", "(", "$", "messages", ")", ",", "false", ",", "array", "(", "'uidReferencing'", "=>", "$", "this", "->", "options", "->", "uidReferencing", ")", ")", ";", "}" ]
Returns an {@link ezcMailImapSet} containing messages $messages sorted by $sortCriteria from the current mailbox. This method supports unique IDs instead of message numbers. See {@link ezcMailImapTransportOptions} for how to enable unique IDs referencing. $messages is an array of message numbers, for example: <code> array( 1, 2, 4 ); </code> $sortCriteria is an email header like: Subject, To, From, Date, Sender, etc. Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. Example: <code> $imap = new ezcMailImapTransport( 'imap.example.com' ); $imap->authenticate( 'username', 'password' ); $imap->selectMailbox( 'mailbox' ); // Inbox or another mailbox // Fetch the list of messages sorted by Date $set = $imap->sortMessages( 1, 10, "Date" ); // $set can be parsed with ezcMailParser </code> @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response or if array $messages is empty @param array(int) $messages @param string $sortCriteria @param bool $reverse @return ezcMailImapSet
[ "Returns", "an", "{", "@link", "ezcMailImapSet", "}", "containing", "messages", "$messages", "sorted", "by", "$sortCriteria", "from", "the", "current", "mailbox", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L1859-L1863
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.fetchByFlag
public function fetchByFlag( $flag ) { $messages = $this->searchByFlag( $flag ); return new ezcMailImapSet( $this->connection, $messages, false, array( 'uidReferencing' => $this->options->uidReferencing ) ); }
php
public function fetchByFlag( $flag ) { $messages = $this->searchByFlag( $flag ); return new ezcMailImapSet( $this->connection, $messages, false, array( 'uidReferencing' => $this->options->uidReferencing ) ); }
[ "public", "function", "fetchByFlag", "(", "$", "flag", ")", "{", "$", "messages", "=", "$", "this", "->", "searchByFlag", "(", "$", "flag", ")", ";", "return", "new", "ezcMailImapSet", "(", "$", "this", "->", "connection", ",", "$", "messages", ",", "false", ",", "array", "(", "'uidReferencing'", "=>", "$", "this", "->", "options", "->", "uidReferencing", ")", ")", ";", "}" ]
Returns an {@link ezcMailImapSet} containing messages with a certain flag from the current mailbox. This method supports unique IDs instead of message numbers. See {@link ezcMailImapTransportOptions} for how to enable unique IDs referencing. $flag can be one of: Basic flags: - ANSWERED - message has been answered - DELETED - message is marked to be deleted by later EXPUNGE - DRAFT - message is marked as a draft - FLAGGED - message is "flagged" for urgent/special attention - RECENT - message is recent - SEEN - message has been read Opposites of the above flags: - UNANSWERED - UNDELETED - UNDRAFT - UNFLAGGED - OLD - UNSEEN Composite flags: - NEW - equivalent to RECENT + UNSEEN - ALL - all the messages Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. Example: <code> $imap = new ezcMailImapTransport( 'imap.example.com' ); $imap->authenticate( 'username', 'password' ); $imap->selectMailbox( 'mailbox' ); // Inbox or another mailbox // Fetch the messages marked with the RECENT flag $set = $imap->fetchByFlag( 'RECENT' ); // $set can be parsed with ezcMailParser </code> @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response or if $flag is not valid @param string $flag @return ezcMailImapSet
[ "Returns", "an", "{", "@link", "ezcMailImapSet", "}", "containing", "messages", "with", "a", "certain", "flag", "from", "the", "current", "mailbox", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L1918-L1922
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.countByFlag
public function countByFlag( $flag ) { $flag = $this->normalizeFlag( $flag ); $messages = $this->searchByFlag( $flag ); return count( $messages ); }
php
public function countByFlag( $flag ) { $flag = $this->normalizeFlag( $flag ); $messages = $this->searchByFlag( $flag ); return count( $messages ); }
[ "public", "function", "countByFlag", "(", "$", "flag", ")", "{", "$", "flag", "=", "$", "this", "->", "normalizeFlag", "(", "$", "flag", ")", ";", "$", "messages", "=", "$", "this", "->", "searchByFlag", "(", "$", "flag", ")", ";", "return", "count", "(", "$", "messages", ")", ";", "}" ]
Wrapper function to fetch count of messages by a certain flag. $flag can be one of: Basic flags: - ANSWERED - message has been answered - DELETED - message is marked to be deleted by later EXPUNGE - DRAFT - message is marked as a draft - FLAGGED - message is "flagged" for urgent/special attention - RECENT - message is recent - SEEN - message has been read Opposites of the above flags: - UNANSWERED - UNDELETED - UNDRAFT - UNFLAGGED - OLD - UNSEEN Composite flags: - NEW - equivalent to RECENT + UNSEEN - ALL - all the messages Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response or if $flag is not valid @param string $flag @return int
[ "Wrapper", "function", "to", "fetch", "count", "of", "messages", "by", "a", "certain", "flag", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L1960-L1965
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.setFlag
public function setFlag( $messages, $flag ) { $uid = ( $this->options->uidReferencing ) ? self::UID : self::NO_UID; if ( $this->state != self::STATE_SELECTED ) { throw new ezcMailTransportException( "Can't call setFlag() when a mailbox is not selected." ); } $flag = $this->normalizeFlag( $flag ); if ( in_array( $flag, self::$basicFlags ) ) { $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} {$uid}STORE {$messages} +FLAGS (\\{$flag})" ); $response = trim( $this->getResponse( $tag ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not set flag '{$flag}' on the messages '{$messages}': {$response}." ); } } else { throw new ezcMailTransportException( "Flag '{$flag}' is not allowed for setting." ); } return true; }
php
public function setFlag( $messages, $flag ) { $uid = ( $this->options->uidReferencing ) ? self::UID : self::NO_UID; if ( $this->state != self::STATE_SELECTED ) { throw new ezcMailTransportException( "Can't call setFlag() when a mailbox is not selected." ); } $flag = $this->normalizeFlag( $flag ); if ( in_array( $flag, self::$basicFlags ) ) { $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} {$uid}STORE {$messages} +FLAGS (\\{$flag})" ); $response = trim( $this->getResponse( $tag ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not set flag '{$flag}' on the messages '{$messages}': {$response}." ); } } else { throw new ezcMailTransportException( "Flag '{$flag}' is not allowed for setting." ); } return true; }
[ "public", "function", "setFlag", "(", "$", "messages", ",", "$", "flag", ")", "{", "$", "uid", "=", "(", "$", "this", "->", "options", "->", "uidReferencing", ")", "?", "self", "::", "UID", ":", "self", "::", "NO_UID", ";", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call setFlag() when a mailbox is not selected.\"", ")", ";", "}", "$", "flag", "=", "$", "this", "->", "normalizeFlag", "(", "$", "flag", ")", ";", "if", "(", "in_array", "(", "$", "flag", ",", "self", "::", "$", "basicFlags", ")", ")", "{", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} {$uid}STORE {$messages} +FLAGS (\\\\{$flag})\"", ")", ";", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "$", "tag", ")", ")", ";", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The IMAP server could not set flag '{$flag}' on the messages '{$messages}': {$response}.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "ezcMailTransportException", "(", "\"Flag '{$flag}' is not allowed for setting.\"", ")", ";", "}", "return", "true", ";", "}" ]
Sets $flag on $messages. This method supports unique IDs instead of message numbers. See {@link ezcMailImapTransportOptions} for how to enable unique IDs referencing. $messages can be: - a single message number (eg. 1) - a message range (eg. 1:4) - a message list (eg. 1,2,4) $flag can be one of: - ANSWERED - message has been answered - DELETED - message is marked to be deleted by later EXPUNGE - DRAFT - message is marked as a draft - FLAGGED - message is "flagged" for urgent/special attention - SEEN - message has been read This function automatically adds the '\' in front of the flag when calling the server command. Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. Example: <code> $imap = new ezcMailImapTransport( 'imap.example.com' ); $imap->authenticate( 'username', 'password' ); $imap->selectMailbox( 'mailbox' ); // Inbox or another mailbox $imap->setFlag( '1:4', 'DRAFT' ); </code> @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response or if $flag is not valid @param string $messages @param string $flag @return bool
[ "Sets", "$flag", "on", "$messages", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2098-L2123
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.searchByFlag
protected function searchByFlag( $flag ) { $uid = ( $this->options->uidReferencing ) ? self::UID : self::NO_UID; if ( $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call searchByFlag() on the IMAP transport when a mailbox is not selected." ); } $matchingMessages = array(); $flag = $this->normalizeFlag( $flag ); if ( in_array( $flag, self::$extendedFlags ) ) { $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} {$uid}SEARCH ({$flag})" ); $response = $this->getResponse( '* SEARCH' ); if ( strpos( $response, '* SEARCH' ) !== false ) { $ids = substr( trim( $response ), 9 ); if ( trim( $ids ) !== "" ) { $matchingMessages = explode( ' ', $ids ); } } $response = trim( $this->getResponse( $tag, $response ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not search the messages by flags: {$response}." ); } } else { throw new ezcMailTransportException( "Flag '{$flag}' is not allowed for searching." ); } return $matchingMessages; }
php
protected function searchByFlag( $flag ) { $uid = ( $this->options->uidReferencing ) ? self::UID : self::NO_UID; if ( $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call searchByFlag() on the IMAP transport when a mailbox is not selected." ); } $matchingMessages = array(); $flag = $this->normalizeFlag( $flag ); if ( in_array( $flag, self::$extendedFlags ) ) { $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} {$uid}SEARCH ({$flag})" ); $response = $this->getResponse( '* SEARCH' ); if ( strpos( $response, '* SEARCH' ) !== false ) { $ids = substr( trim( $response ), 9 ); if ( trim( $ids ) !== "" ) { $matchingMessages = explode( ' ', $ids ); } } $response = trim( $this->getResponse( $tag, $response ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not search the messages by flags: {$response}." ); } } else { throw new ezcMailTransportException( "Flag '{$flag}' is not allowed for searching." ); } return $matchingMessages; }
[ "protected", "function", "searchByFlag", "(", "$", "flag", ")", "{", "$", "uid", "=", "(", "$", "this", "->", "options", "->", "uidReferencing", ")", "?", "self", "::", "UID", ":", "self", "::", "NO_UID", ";", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED_READONLY", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call searchByFlag() on the IMAP transport when a mailbox is not selected.\"", ")", ";", "}", "$", "matchingMessages", "=", "array", "(", ")", ";", "$", "flag", "=", "$", "this", "->", "normalizeFlag", "(", "$", "flag", ")", ";", "if", "(", "in_array", "(", "$", "flag", ",", "self", "::", "$", "extendedFlags", ")", ")", "{", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} {$uid}SEARCH ({$flag})\"", ")", ";", "$", "response", "=", "$", "this", "->", "getResponse", "(", "'* SEARCH'", ")", ";", "if", "(", "strpos", "(", "$", "response", ",", "'* SEARCH'", ")", "!==", "false", ")", "{", "$", "ids", "=", "substr", "(", "trim", "(", "$", "response", ")", ",", "9", ")", ";", "if", "(", "trim", "(", "$", "ids", ")", "!==", "\"\"", ")", "{", "$", "matchingMessages", "=", "explode", "(", "' '", ",", "$", "ids", ")", ";", "}", "}", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "$", "tag", ",", "$", "response", ")", ")", ";", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The IMAP server could not search the messages by flags: {$response}.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "ezcMailTransportException", "(", "\"Flag '{$flag}' is not allowed for searching.\"", ")", ";", "}", "return", "$", "matchingMessages", ";", "}" ]
Returns an array of message numbers from the selected mailbox which have a certain flag set. This method supports unique IDs instead of message numbers. See {@link ezcMailImapTransportOptions} for how to enable unique IDs referencing. $flag can be one of: Basic flags: - ANSWERED - message has been answered - DELETED - message is marked to be deleted by later EXPUNGE - DRAFT - message is marked as a draft - FLAGGED - message is "flagged" for urgent/special attention - RECENT - message is recent - SEEN - message has been read Opposites of the above flags: - UNANSWERED - UNDELETED - UNDRAFT - UNFLAGGED - OLD - UNSEEN Composite flags: - NEW - equivalent to RECENT + UNSEEN - ALL - all the messages The returned array is something like this: <code> array( 0 => 1, 1 => 5 ); </code> Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response or if $flag is not valid @param string $flag @return array(int)
[ "Returns", "an", "array", "of", "message", "numbers", "from", "the", "selected", "mailbox", "which", "have", "a", "certain", "flag", "set", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2241-L2278
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.noop
public function noop() { if ( $this->state != self::STATE_NOT_AUTHENTICATED && $this->state != self::STATE_AUTHENTICATED && $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can not issue NOOP command if not connected." ); } $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} NOOP" ); $response = trim( $this->getResponse( $tag ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "NOOP failed: {$response}." ); } }
php
public function noop() { if ( $this->state != self::STATE_NOT_AUTHENTICATED && $this->state != self::STATE_AUTHENTICATED && $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can not issue NOOP command if not connected." ); } $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} NOOP" ); $response = trim( $this->getResponse( $tag ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "NOOP failed: {$response}." ); } }
[ "public", "function", "noop", "(", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_NOT_AUTHENTICATED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_AUTHENTICATED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED_READONLY", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can not issue NOOP command if not connected.\"", ")", ";", "}", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} NOOP\"", ")", ";", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "$", "tag", ")", ")", ";", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"NOOP failed: {$response}.\"", ")", ";", "}", "}" ]
Sends a NOOP command to the server, use it to keep the connection alive. Before calling this method, a connection to the IMAP server must be established. @throws ezcMailTransportException if there was no connection to the server or if the server sent a negative response
[ "Sends", "a", "NOOP", "command", "to", "the", "server", "use", "it", "to", "keep", "the", "connection", "alive", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2290-L2307
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.capability
public function capability() { if ( $this->state != self::STATE_NOT_AUTHENTICATED && $this->state != self::STATE_AUTHENTICATED && $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Trying to request capability when not connected to server." ); } $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} CAPABILITY" ); $response = $this->connection->getLine(); while ( $this->responseType( $response ) != self::RESPONSE_UNTAGGED && strpos( $response, '* CAPABILITY ' ) === false ) { $response = $this->connection->getLine(); } $result = trim( $response ); $response = trim( $this->getResponse( $tag ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server responded negative to the CAPABILITY command: {$response}." ); } return explode( ' ', str_replace( '* CAPABILITY ', '', $result ) ); }
php
public function capability() { if ( $this->state != self::STATE_NOT_AUTHENTICATED && $this->state != self::STATE_AUTHENTICATED && $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Trying to request capability when not connected to server." ); } $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} CAPABILITY" ); $response = $this->connection->getLine(); while ( $this->responseType( $response ) != self::RESPONSE_UNTAGGED && strpos( $response, '* CAPABILITY ' ) === false ) { $response = $this->connection->getLine(); } $result = trim( $response ); $response = trim( $this->getResponse( $tag ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server responded negative to the CAPABILITY command: {$response}." ); } return explode( ' ', str_replace( '* CAPABILITY ', '', $result ) ); }
[ "public", "function", "capability", "(", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_NOT_AUTHENTICATED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_AUTHENTICATED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED_READONLY", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Trying to request capability when not connected to server.\"", ")", ";", "}", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} CAPABILITY\"", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "while", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_UNTAGGED", "&&", "strpos", "(", "$", "response", ",", "'* CAPABILITY '", ")", "===", "false", ")", "{", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "}", "$", "result", "=", "trim", "(", "$", "response", ")", ";", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "$", "tag", ")", ")", ";", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The IMAP server responded negative to the CAPABILITY command: {$response}.\"", ")", ";", "}", "return", "explode", "(", "' '", ",", "str_replace", "(", "'* CAPABILITY '", ",", "''", ",", "$", "result", ")", ")", ";", "}" ]
Returns an array with the capabilities of the IMAP server. The returned array will be something like this: <code> array( 'IMAP4rev1', 'SASL-IR SORT', 'THREAD=REFERENCES', 'MULTIAPPEND', 'UNSELECT', 'LITERAL+', 'IDLE', 'CHILDREN', 'NAMESPACE', 'LOGIN-REFERRALS' ); </code> Before calling this method, a connection to the IMAP server must be established. @throws ezcMailTransportException if there was no connection to the server or if the server sent a negative response @return array(string)
[ "Returns", "an", "array", "with", "the", "capabilities", "of", "the", "IMAP", "server", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2328-L2356
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.expunge
public function expunge() { if ( $this->state != self::STATE_SELECTED ) { throw new ezcMailTransportException( "Can not issue EXPUNGE command if a mailbox is not selected." ); } $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} EXPUNGE" ); $response = trim( $this->getResponse( $tag ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "EXPUNGE failed: {$response}." ); } }
php
public function expunge() { if ( $this->state != self::STATE_SELECTED ) { throw new ezcMailTransportException( "Can not issue EXPUNGE command if a mailbox is not selected." ); } $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} EXPUNGE" ); $response = trim( $this->getResponse( $tag ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "EXPUNGE failed: {$response}." ); } }
[ "public", "function", "expunge", "(", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can not issue EXPUNGE command if a mailbox is not selected.\"", ")", ";", "}", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} EXPUNGE\"", ")", ";", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "$", "tag", ")", ")", ";", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"EXPUNGE failed: {$response}.\"", ")", ";", "}", "}" ]
Sends an EXPUNGE command to the server. This method permanently deletes the messages marked for deletion by the method {@link delete()}. Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. @throws ezcMailTransportException if a mailbox was not selected or if the server sent a negative response
[ "Sends", "an", "EXPUNGE", "command", "to", "the", "server", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2372-L2386
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.append
public function append( $mailbox, $mail, $flags = null ) { if ( $this->state != self::STATE_AUTHENTICATED && $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call append() if not authenticated." ); } $tag = $this->getNextTag(); $mailSize = strlen( $mail ); if ( !is_null( $flags ) ) { for ( $i = 0; $i < count( $flags ); $i++ ) { $flags[$i] = '\\' . $this->normalizeFlag( $flags[$i] ); } $flagList = implode( ' ', $flags ); $command = "{$tag} APPEND {$mailbox} ({$flagList}) {{$mailSize}}"; } else { $command = "{$tag} APPEND {$mailbox} {{$mailSize}}"; } $this->connection->sendData( $command ); $response = trim( $this->connection->getLine() ); if ( strpos( $response, 'TRYCREATE' ) !== false ) { throw new ezcMailTransportException( "Mailbox does not exist: {$response}." ); } if ( $this->responseType( $response ) == self::RESPONSE_FEEDBACK ) { $this->connection->sendData( $mail ); $response = trim( $this->getResponse( $tag ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not append message to mailbox '{$mailbox}': {$response}." ); } } elseif ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not append message to mailbox '{$mailbox}': {$response}." ); } }
php
public function append( $mailbox, $mail, $flags = null ) { if ( $this->state != self::STATE_AUTHENTICATED && $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call append() if not authenticated." ); } $tag = $this->getNextTag(); $mailSize = strlen( $mail ); if ( !is_null( $flags ) ) { for ( $i = 0; $i < count( $flags ); $i++ ) { $flags[$i] = '\\' . $this->normalizeFlag( $flags[$i] ); } $flagList = implode( ' ', $flags ); $command = "{$tag} APPEND {$mailbox} ({$flagList}) {{$mailSize}}"; } else { $command = "{$tag} APPEND {$mailbox} {{$mailSize}}"; } $this->connection->sendData( $command ); $response = trim( $this->connection->getLine() ); if ( strpos( $response, 'TRYCREATE' ) !== false ) { throw new ezcMailTransportException( "Mailbox does not exist: {$response}." ); } if ( $this->responseType( $response ) == self::RESPONSE_FEEDBACK ) { $this->connection->sendData( $mail ); $response = trim( $this->getResponse( $tag ) ); if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not append message to mailbox '{$mailbox}': {$response}." ); } } elseif ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not append message to mailbox '{$mailbox}': {$response}." ); } }
[ "public", "function", "append", "(", "$", "mailbox", ",", "$", "mail", ",", "$", "flags", "=", "null", ")", "{", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_AUTHENTICATED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED_READONLY", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call append() if not authenticated.\"", ")", ";", "}", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "mailSize", "=", "strlen", "(", "$", "mail", ")", ";", "if", "(", "!", "is_null", "(", "$", "flags", ")", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "flags", ")", ";", "$", "i", "++", ")", "{", "$", "flags", "[", "$", "i", "]", "=", "'\\\\'", ".", "$", "this", "->", "normalizeFlag", "(", "$", "flags", "[", "$", "i", "]", ")", ";", "}", "$", "flagList", "=", "implode", "(", "' '", ",", "$", "flags", ")", ";", "$", "command", "=", "\"{$tag} APPEND {$mailbox} ({$flagList}) {{$mailSize}}\"", ";", "}", "else", "{", "$", "command", "=", "\"{$tag} APPEND {$mailbox} {{$mailSize}}\"", ";", "}", "$", "this", "->", "connection", "->", "sendData", "(", "$", "command", ")", ";", "$", "response", "=", "trim", "(", "$", "this", "->", "connection", "->", "getLine", "(", ")", ")", ";", "if", "(", "strpos", "(", "$", "response", ",", "'TRYCREATE'", ")", "!==", "false", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Mailbox does not exist: {$response}.\"", ")", ";", "}", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "==", "self", "::", "RESPONSE_FEEDBACK", ")", "{", "$", "this", "->", "connection", "->", "sendData", "(", "$", "mail", ")", ";", "$", "response", "=", "trim", "(", "$", "this", "->", "getResponse", "(", "$", "tag", ")", ")", ";", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The IMAP server could not append message to mailbox '{$mailbox}': {$response}.\"", ")", ";", "}", "}", "elseif", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The IMAP server could not append message to mailbox '{$mailbox}': {$response}.\"", ")", ";", "}", "}" ]
Appends $mail to the $mailbox mailbox. Use this method to create email messages in a mailbox such as Sent or Draft. $flags is an array of flags to be set to the $mail (if provided): $flag can be one of: - ANSWERED - message has been answered - DELETED - message is marked to be deleted by later EXPUNGE - DRAFT - message is marked as a draft - FLAGGED - message is "flagged" for urgent/special attention - SEEN - message has been read This function automatically adds the '\' in front of each flag when calling the server command. Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully. @throws ezcMailTransportException if user is not authenticated or if the server sent a negative response or if $mailbox does not exists @param string $mailbox @param string $mail @param array(string) $flags
[ "Appends", "$mail", "to", "the", "$mailbox", "mailbox", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2417-L2463
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.normalizeFlag
protected function normalizeFlag( $flag ) { $flag = strtoupper( $flag ); $flag = str_replace( '\\', '', $flag ); return trim( $flag ); }
php
protected function normalizeFlag( $flag ) { $flag = strtoupper( $flag ); $flag = str_replace( '\\', '', $flag ); return trim( $flag ); }
[ "protected", "function", "normalizeFlag", "(", "$", "flag", ")", "{", "$", "flag", "=", "strtoupper", "(", "$", "flag", ")", ";", "$", "flag", "=", "str_replace", "(", "'\\\\'", ",", "''", ",", "$", "flag", ")", ";", "return", "trim", "(", "$", "flag", ")", ";", "}" ]
Clears $flag of unwanted characters and makes it uppercase. @param string $flag @return string
[ "Clears", "$flag", "of", "unwanted", "characters", "and", "makes", "it", "uppercase", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2471-L2476
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.sort
protected function sort( $messages, $sortCriteria, $reverse = false ) { $uid = ( $this->options->uidReferencing ) ? self::UID : self::NO_UID; if ( $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call sort() on the IMAP transport when a mailbox is not selected." ); } $result = array(); $query = ucfirst( strtolower( $sortCriteria ) ); $messageNumbers = implode( ',', $messages ); $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} {$uid}FETCH {$messageNumbers} (BODY.PEEK[HEADER.FIELDS ({$query})])" ); $response = trim( $this->connection->getLine() ); while ( strpos( $response, $tag ) === false ) { if ( strpos( $response, ' FETCH (' ) !== false ) { if ( $this->options->uidReferencing ) { preg_match('/^\* [0-9]+ FETCH \(UID ([0-9]+)/', $response, $matches ); } else { preg_match('/^\* ([0-9]+) FETCH/', $response, $matches ); } $messageNumber = $matches[1]; } if ( strpos( $response, $query ) !== false ) { $strippedResponse = trim( trim( str_replace( "{$query}: ", '', $response ) ), '"' ); switch ( $query ) { case 'Date': $strippedResponse = strtotime( $strippedResponse ); break; case 'Subject': case 'From': case 'Sender': case 'To': $strippedResponse = ezcMailTools::mimeDecode( $strippedResponse ); break; default: break; } $result[$messageNumber] = $strippedResponse; } // in case the mail doesn't have the $sortCriteria header (like junk mail missing Subject header) if ( strpos( $response, ')' ) !== false && !isset( $result[$messageNumber] ) ) { $result[$messageNumber] = ''; } $response = trim( $this->connection->getLine() ); } if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not sort the messages: {$response}." ); } if ( $reverse === true ) { natcasesort( $result ); $result = array_reverse( $result, true ); } else { natcasesort( $result ); } return $result; }
php
protected function sort( $messages, $sortCriteria, $reverse = false ) { $uid = ( $this->options->uidReferencing ) ? self::UID : self::NO_UID; if ( $this->state != self::STATE_SELECTED && $this->state != self::STATE_SELECTED_READONLY ) { throw new ezcMailTransportException( "Can't call sort() on the IMAP transport when a mailbox is not selected." ); } $result = array(); $query = ucfirst( strtolower( $sortCriteria ) ); $messageNumbers = implode( ',', $messages ); $tag = $this->getNextTag(); $this->connection->sendData( "{$tag} {$uid}FETCH {$messageNumbers} (BODY.PEEK[HEADER.FIELDS ({$query})])" ); $response = trim( $this->connection->getLine() ); while ( strpos( $response, $tag ) === false ) { if ( strpos( $response, ' FETCH (' ) !== false ) { if ( $this->options->uidReferencing ) { preg_match('/^\* [0-9]+ FETCH \(UID ([0-9]+)/', $response, $matches ); } else { preg_match('/^\* ([0-9]+) FETCH/', $response, $matches ); } $messageNumber = $matches[1]; } if ( strpos( $response, $query ) !== false ) { $strippedResponse = trim( trim( str_replace( "{$query}: ", '', $response ) ), '"' ); switch ( $query ) { case 'Date': $strippedResponse = strtotime( $strippedResponse ); break; case 'Subject': case 'From': case 'Sender': case 'To': $strippedResponse = ezcMailTools::mimeDecode( $strippedResponse ); break; default: break; } $result[$messageNumber] = $strippedResponse; } // in case the mail doesn't have the $sortCriteria header (like junk mail missing Subject header) if ( strpos( $response, ')' ) !== false && !isset( $result[$messageNumber] ) ) { $result[$messageNumber] = ''; } $response = trim( $this->connection->getLine() ); } if ( $this->responseType( $response ) != self::RESPONSE_OK ) { throw new ezcMailTransportException( "The IMAP server could not sort the messages: {$response}." ); } if ( $reverse === true ) { natcasesort( $result ); $result = array_reverse( $result, true ); } else { natcasesort( $result ); } return $result; }
[ "protected", "function", "sort", "(", "$", "messages", ",", "$", "sortCriteria", ",", "$", "reverse", "=", "false", ")", "{", "$", "uid", "=", "(", "$", "this", "->", "options", "->", "uidReferencing", ")", "?", "self", "::", "UID", ":", "self", "::", "NO_UID", ";", "if", "(", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED", "&&", "$", "this", "->", "state", "!=", "self", "::", "STATE_SELECTED_READONLY", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"Can't call sort() on the IMAP transport when a mailbox is not selected.\"", ")", ";", "}", "$", "result", "=", "array", "(", ")", ";", "$", "query", "=", "ucfirst", "(", "strtolower", "(", "$", "sortCriteria", ")", ")", ";", "$", "messageNumbers", "=", "implode", "(", "','", ",", "$", "messages", ")", ";", "$", "tag", "=", "$", "this", "->", "getNextTag", "(", ")", ";", "$", "this", "->", "connection", "->", "sendData", "(", "\"{$tag} {$uid}FETCH {$messageNumbers} (BODY.PEEK[HEADER.FIELDS ({$query})])\"", ")", ";", "$", "response", "=", "trim", "(", "$", "this", "->", "connection", "->", "getLine", "(", ")", ")", ";", "while", "(", "strpos", "(", "$", "response", ",", "$", "tag", ")", "===", "false", ")", "{", "if", "(", "strpos", "(", "$", "response", ",", "' FETCH ('", ")", "!==", "false", ")", "{", "if", "(", "$", "this", "->", "options", "->", "uidReferencing", ")", "{", "preg_match", "(", "'/^\\* [0-9]+ FETCH \\(UID ([0-9]+)/'", ",", "$", "response", ",", "$", "matches", ")", ";", "}", "else", "{", "preg_match", "(", "'/^\\* ([0-9]+) FETCH/'", ",", "$", "response", ",", "$", "matches", ")", ";", "}", "$", "messageNumber", "=", "$", "matches", "[", "1", "]", ";", "}", "if", "(", "strpos", "(", "$", "response", ",", "$", "query", ")", "!==", "false", ")", "{", "$", "strippedResponse", "=", "trim", "(", "trim", "(", "str_replace", "(", "\"{$query}: \"", ",", "''", ",", "$", "response", ")", ")", ",", "'\"'", ")", ";", "switch", "(", "$", "query", ")", "{", "case", "'Date'", ":", "$", "strippedResponse", "=", "strtotime", "(", "$", "strippedResponse", ")", ";", "break", ";", "case", "'Subject'", ":", "case", "'From'", ":", "case", "'Sender'", ":", "case", "'To'", ":", "$", "strippedResponse", "=", "ezcMailTools", "::", "mimeDecode", "(", "$", "strippedResponse", ")", ";", "break", ";", "default", ":", "break", ";", "}", "$", "result", "[", "$", "messageNumber", "]", "=", "$", "strippedResponse", ";", "}", "// in case the mail doesn't have the $sortCriteria header (like junk mail missing Subject header)", "if", "(", "strpos", "(", "$", "response", ",", "')'", ")", "!==", "false", "&&", "!", "isset", "(", "$", "result", "[", "$", "messageNumber", "]", ")", ")", "{", "$", "result", "[", "$", "messageNumber", "]", "=", "''", ";", "}", "$", "response", "=", "trim", "(", "$", "this", "->", "connection", "->", "getLine", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "responseType", "(", "$", "response", ")", "!=", "self", "::", "RESPONSE_OK", ")", "{", "throw", "new", "ezcMailTransportException", "(", "\"The IMAP server could not sort the messages: {$response}.\"", ")", ";", "}", "if", "(", "$", "reverse", "===", "true", ")", "{", "natcasesort", "(", "$", "result", ")", ";", "$", "result", "=", "array_reverse", "(", "$", "result", ",", "true", ")", ";", "}", "else", "{", "natcasesort", "(", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}" ]
Sorts message numbers array $messages by the specified $sortCriteria. This method supports unique IDs instead of message numbers. See {@link ezcMailImapTransportOptions} for how to enable unique IDs referencing. $messages is an array of message numbers, for example: <code> array( 1, 2, 4 ); </code> $sortCriteria is an email header like: Subject, To, From, Date, Sender. The sorting is done with the php function natcasesort(). Before calling this method, a connection to the IMAP server must be established and a user must be authenticated successfully, and a mailbox must be selected. @throws ezcMailTransportException if a mailbox is not selected or if the server sent a negative response or if the array $messages is empty @param array(int) $messages @param string $sortCriteria @param bool $reverse @return array(string)
[ "Sorts", "message", "numbers", "array", "$messages", "by", "the", "specified", "$sortCriteria", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2507-L2584
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.responseType
protected function responseType( $line ) { if ( strpos( $line, 'OK ' ) !== false && strpos( $line, 'OK ' ) == 6 ) { return self::RESPONSE_OK; } if ( strpos( $line, 'NO ' ) !== false && strpos( $line, 'NO ' ) == 6 ) { return self::RESPONSE_NO; } if ( strpos( $line, 'BAD ' ) !== false && strpos( $line, 'BAD ' ) == 6 ) { return self::RESPONSE_BAD; } if ( strpos( $line, '* ' ) !== false && strpos( $line, '* ' ) == 0 ) { return self::RESPONSE_UNTAGGED; } if ( strpos( $line, '+ ' ) !== false && strpos( $line, '+ ' ) == 0 ) { return self::RESPONSE_FEEDBACK; } throw new ezcMailTransportException( "Unrecognized IMAP response in line: {$line}" ); }
php
protected function responseType( $line ) { if ( strpos( $line, 'OK ' ) !== false && strpos( $line, 'OK ' ) == 6 ) { return self::RESPONSE_OK; } if ( strpos( $line, 'NO ' ) !== false && strpos( $line, 'NO ' ) == 6 ) { return self::RESPONSE_NO; } if ( strpos( $line, 'BAD ' ) !== false && strpos( $line, 'BAD ' ) == 6 ) { return self::RESPONSE_BAD; } if ( strpos( $line, '* ' ) !== false && strpos( $line, '* ' ) == 0 ) { return self::RESPONSE_UNTAGGED; } if ( strpos( $line, '+ ' ) !== false && strpos( $line, '+ ' ) == 0 ) { return self::RESPONSE_FEEDBACK; } throw new ezcMailTransportException( "Unrecognized IMAP response in line: {$line}" ); }
[ "protected", "function", "responseType", "(", "$", "line", ")", "{", "if", "(", "strpos", "(", "$", "line", ",", "'OK '", ")", "!==", "false", "&&", "strpos", "(", "$", "line", ",", "'OK '", ")", "==", "6", ")", "{", "return", "self", "::", "RESPONSE_OK", ";", "}", "if", "(", "strpos", "(", "$", "line", ",", "'NO '", ")", "!==", "false", "&&", "strpos", "(", "$", "line", ",", "'NO '", ")", "==", "6", ")", "{", "return", "self", "::", "RESPONSE_NO", ";", "}", "if", "(", "strpos", "(", "$", "line", ",", "'BAD '", ")", "!==", "false", "&&", "strpos", "(", "$", "line", ",", "'BAD '", ")", "==", "6", ")", "{", "return", "self", "::", "RESPONSE_BAD", ";", "}", "if", "(", "strpos", "(", "$", "line", ",", "'* '", ")", "!==", "false", "&&", "strpos", "(", "$", "line", ",", "'* '", ")", "==", "0", ")", "{", "return", "self", "::", "RESPONSE_UNTAGGED", ";", "}", "if", "(", "strpos", "(", "$", "line", ",", "'+ '", ")", "!==", "false", "&&", "strpos", "(", "$", "line", ",", "'+ '", ")", "==", "0", ")", "{", "return", "self", "::", "RESPONSE_FEEDBACK", ";", "}", "throw", "new", "ezcMailTransportException", "(", "\"Unrecognized IMAP response in line: {$line}\"", ")", ";", "}" ]
Parses $line to return the response code. Returns one of the following: - {@link RESPONSE_OK} - {@link RESPONSE_NO} - {@link RESPONSE_BAD} - {@link RESPONSE_UNTAGGED} - {@link RESPONSE_FEEDBACK} @throws ezcMailTransportException if the IMAP response ($line) is not recognized @param string $line @return int
[ "Parses", "$line", "to", "return", "the", "response", "code", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2601-L2624
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.getResponse
protected function getResponse( $tag, $response = null ) { if ( is_null( $response ) ) { $response = $this->connection->getLine(); } while ( strpos( $response, $tag ) === false ) { if ( strpos( $response, ' BAD ' ) !== false || strpos( $response, ' NO ' ) !== false ) { break; } $response = $this->connection->getLine(); } return $response; }
php
protected function getResponse( $tag, $response = null ) { if ( is_null( $response ) ) { $response = $this->connection->getLine(); } while ( strpos( $response, $tag ) === false ) { if ( strpos( $response, ' BAD ' ) !== false || strpos( $response, ' NO ' ) !== false ) { break; } $response = $this->connection->getLine(); } return $response; }
[ "protected", "function", "getResponse", "(", "$", "tag", ",", "$", "response", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "response", ")", ")", "{", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "}", "while", "(", "strpos", "(", "$", "response", ",", "$", "tag", ")", "===", "false", ")", "{", "if", "(", "strpos", "(", "$", "response", ",", "' BAD '", ")", "!==", "false", "||", "strpos", "(", "$", "response", ",", "' NO '", ")", "!==", "false", ")", "{", "break", ";", "}", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "}", "return", "$", "response", ";", "}" ]
Reads the responses from the server until encountering $tag. In IMAP, each command sent by the client is prepended with a alphanumeric tag like 'A1234'. The server sends the response to the client command as lines, and the last line in the response is prepended with the same tag, and it contains the status of the command completion ('OK', 'NO' or 'BAD'). Sometimes the server sends alerts and response lines from other commands before sending the tagged line, so this method just reads all the responses until it encounters $tag. It returns the tagged line to be processed by the calling method. If $response is specified, then it will not read the response from the server before searching for $tag in $response. Before calling this method, a connection to the IMAP server must be established. @param string $tag @param string $response @return string
[ "Reads", "the", "responses", "from", "the", "server", "until", "encountering", "$tag", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2651-L2667
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.getNextTag
protected function getNextTag() { $tagLetter = substr( $this->currentTag, 0, 1 ); $tagNumber = intval( substr( $this->currentTag, 1 ) ); $tagNumber++; if ( $tagLetter == 'Z' && $tagNumber == 10000 ) { $tagLetter = 'A'; $tagNumber = 1; } if ( $tagNumber == 10000 ) { $tagLetter++; $tagNumber = 0; } $this->currentTag = $tagLetter . sprintf( "%04s", $tagNumber ); return $this->currentTag; }
php
protected function getNextTag() { $tagLetter = substr( $this->currentTag, 0, 1 ); $tagNumber = intval( substr( $this->currentTag, 1 ) ); $tagNumber++; if ( $tagLetter == 'Z' && $tagNumber == 10000 ) { $tagLetter = 'A'; $tagNumber = 1; } if ( $tagNumber == 10000 ) { $tagLetter++; $tagNumber = 0; } $this->currentTag = $tagLetter . sprintf( "%04s", $tagNumber ); return $this->currentTag; }
[ "protected", "function", "getNextTag", "(", ")", "{", "$", "tagLetter", "=", "substr", "(", "$", "this", "->", "currentTag", ",", "0", ",", "1", ")", ";", "$", "tagNumber", "=", "intval", "(", "substr", "(", "$", "this", "->", "currentTag", ",", "1", ")", ")", ";", "$", "tagNumber", "++", ";", "if", "(", "$", "tagLetter", "==", "'Z'", "&&", "$", "tagNumber", "==", "10000", ")", "{", "$", "tagLetter", "=", "'A'", ";", "$", "tagNumber", "=", "1", ";", "}", "if", "(", "$", "tagNumber", "==", "10000", ")", "{", "$", "tagLetter", "++", ";", "$", "tagNumber", "=", "0", ";", "}", "$", "this", "->", "currentTag", "=", "$", "tagLetter", ".", "sprintf", "(", "\"%04s\"", ",", "$", "tagNumber", ")", ";", "return", "$", "this", "->", "currentTag", ";", "}" ]
Generates the next IMAP tag to prepend to client commands. The structure of the IMAP tag is Axxxx, where: - A is a letter (uppercase for conformity) - x is a digit from 0 to 9 example of generated tag: T5439 It uses the class variable $this->currentTag. Everytime it is called, the tag increases by 1. If it reaches the last tag, it wraps around to the first tag. By default, the first generated tag is A0001. @return string
[ "Generates", "the", "next", "IMAP", "tag", "to", "prepend", "to", "client", "commands", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2688-L2705
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php
ezcMailImapTransport.getMessageSectionSize
protected function getMessageSectionSize( $response ) { $size = 0; preg_match( '/\{(.*)\}/', $response, $matches ); if ( count( $matches ) > 0 ) { $size = (int) $matches[1]; } return $size; }
php
protected function getMessageSectionSize( $response ) { $size = 0; preg_match( '/\{(.*)\}/', $response, $matches ); if ( count( $matches ) > 0 ) { $size = (int) $matches[1]; } return $size; }
[ "protected", "function", "getMessageSectionSize", "(", "$", "response", ")", "{", "$", "size", "=", "0", ";", "preg_match", "(", "'/\\{(.*)\\}/'", ",", "$", "response", ",", "$", "matches", ")", ";", "if", "(", "count", "(", "$", "matches", ")", ">", "0", ")", "{", "$", "size", "=", "(", "int", ")", "$", "matches", "[", "1", "]", ";", "}", "return", "$", "size", ";", "}" ]
Returns the size of a FETCH section in bytes. The section header looks like: * id FETCH (BODY[TEXT] {size} where size is the size in bytes and id is the message number or ID. Example: for " * 2 FETCH (BODY[TEXT] {377}" this function returns 377. @return int
[ "Returns", "the", "size", "of", "a", "FETCH", "section", "in", "bytes", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/imap/imap_transport.php#L2717-L2726
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_set.php
ezcMailPop3Set.getNextLine
public function getNextLine() { if ( $this->currentMessage === null ) { $this->nextMail(); } if ( $this->hasMoreMailData ) { $data = $this->connection->getLine(); if ( rtrim( $data ) === "." ) { $this->hasMoreMailData = false; // remove the mail if required by the user. if ( $this->deleteFromServer == true ) { $this->connection->sendData( "DELE {$this->currentMessage}" ); $response = $this->connection->getLine(); // ignore response } return null; } return $data; } return null; }
php
public function getNextLine() { if ( $this->currentMessage === null ) { $this->nextMail(); } if ( $this->hasMoreMailData ) { $data = $this->connection->getLine(); if ( rtrim( $data ) === "." ) { $this->hasMoreMailData = false; // remove the mail if required by the user. if ( $this->deleteFromServer == true ) { $this->connection->sendData( "DELE {$this->currentMessage}" ); $response = $this->connection->getLine(); // ignore response } return null; } return $data; } return null; }
[ "public", "function", "getNextLine", "(", ")", "{", "if", "(", "$", "this", "->", "currentMessage", "===", "null", ")", "{", "$", "this", "->", "nextMail", "(", ")", ";", "}", "if", "(", "$", "this", "->", "hasMoreMailData", ")", "{", "$", "data", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "if", "(", "rtrim", "(", "$", "data", ")", "===", "\".\"", ")", "{", "$", "this", "->", "hasMoreMailData", "=", "false", ";", "// remove the mail if required by the user.", "if", "(", "$", "this", "->", "deleteFromServer", "==", "true", ")", "{", "$", "this", "->", "connection", "->", "sendData", "(", "\"DELE {$this->currentMessage}\"", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "// ignore response", "}", "return", "null", ";", "}", "return", "$", "data", ";", "}", "return", "null", ";", "}" ]
Returns one line of data from the current mail in the set. Null is returned if there is no current mail in the set or the end of the mail is reached. @return string
[ "Returns", "one", "line", "of", "data", "from", "the", "current", "mail", "in", "the", "set", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_set.php#L101-L124
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_set.php
ezcMailPop3Set.nextMail
public function nextMail() { if ( $this->currentMessage === null ) { $this->currentMessage = reset( $this->messages ); } else { $this->currentMessage = next( $this->messages ); } if ( $this->currentMessage !== false ) { $this->connection->sendData( "RETR {$this->currentMessage}" ); $response = $this->connection->getLine(); if ( strpos( $response, "+OK" ) === 0 ) { $this->hasMoreMailData = true; return true; } else { throw new ezcMailTransportException( "The POP3 server sent a negative reply when requesting mail." ); } } return false; }
php
public function nextMail() { if ( $this->currentMessage === null ) { $this->currentMessage = reset( $this->messages ); } else { $this->currentMessage = next( $this->messages ); } if ( $this->currentMessage !== false ) { $this->connection->sendData( "RETR {$this->currentMessage}" ); $response = $this->connection->getLine(); if ( strpos( $response, "+OK" ) === 0 ) { $this->hasMoreMailData = true; return true; } else { throw new ezcMailTransportException( "The POP3 server sent a negative reply when requesting mail." ); } } return false; }
[ "public", "function", "nextMail", "(", ")", "{", "if", "(", "$", "this", "->", "currentMessage", "===", "null", ")", "{", "$", "this", "->", "currentMessage", "=", "reset", "(", "$", "this", "->", "messages", ")", ";", "}", "else", "{", "$", "this", "->", "currentMessage", "=", "next", "(", "$", "this", "->", "messages", ")", ";", "}", "if", "(", "$", "this", "->", "currentMessage", "!==", "false", ")", "{", "$", "this", "->", "connection", "->", "sendData", "(", "\"RETR {$this->currentMessage}\"", ")", ";", "$", "response", "=", "$", "this", "->", "connection", "->", "getLine", "(", ")", ";", "if", "(", "strpos", "(", "$", "response", ",", "\"+OK\"", ")", "===", "0", ")", "{", "$", "this", "->", "hasMoreMailData", "=", "true", ";", "return", "true", ";", "}", "else", "{", "throw", "new", "ezcMailTransportException", "(", "\"The POP3 server sent a negative reply when requesting mail.\"", ")", ";", "}", "}", "return", "false", ";", "}" ]
Moves the set to the next mail and returns true upon success. False is returned if there are no more mail in the set. @throws ezcMailTransportException if the server sent a negative response @return bool
[ "Moves", "the", "set", "to", "the", "next", "mail", "and", "returns", "true", "upon", "success", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/transports/pop3/pop3_set.php#L135-L160
inhere/php-librarys
src/Traits/LiteContainerTrait.php
LiteContainerTrait.register
public function register($name, $service, $replace = false) { $this->set($name, $service, $replace); return $this; }
php
public function register($name, $service, $replace = false) { $this->set($name, $service, $replace); return $this; }
[ "public", "function", "register", "(", "$", "name", ",", "$", "service", ",", "$", "replace", "=", "false", ")", "{", "$", "this", "->", "set", "(", "$", "name", ",", "$", "service", ",", "$", "replace", ")", ";", "return", "$", "this", ";", "}" ]
register a app service @param string $name the service name @param mixed $service service @param bool $replace replace exists service @return static
[ "register", "a", "app", "service" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/LiteContainerTrait.php#L40-L45
zhouyl/mellivora
Mellivora/Database/Console/Migrations/MigrateCommand.php
MigrateCommand.fire
public function fire() { if (!$this->confirmToProceed()) { return; } $this->prepareDatabase(); // Next, we will check to see if a path option has been defined. If it has // we will use the path relative to the root of this installation folder // so that migrations may be run for any path within the applications. $this->container['migrator']->run($this->getMigrationPaths(), [ 'pretend' => $this->option('pretend'), 'step' => $this->option('step'), ]); // Once the migrator has run we will grab the note output and send it out to // the console screen, since the migrator itself functions without having // any instances of the OutputInterface contract passed into the class. foreach ($this->container['migrator']->getNotes() as $note) { $this->output->writeln($note); } // Finally, if the "seed" option has been given, we will re-run the database // seed task to re-populate the database, which is convenient when adding // a migration and a seed at the same time, as it is only this command. if ($this->option('seed')) { $this->call('db:seed', ['--force' => true]); } }
php
public function fire() { if (!$this->confirmToProceed()) { return; } $this->prepareDatabase(); // Next, we will check to see if a path option has been defined. If it has // we will use the path relative to the root of this installation folder // so that migrations may be run for any path within the applications. $this->container['migrator']->run($this->getMigrationPaths(), [ 'pretend' => $this->option('pretend'), 'step' => $this->option('step'), ]); // Once the migrator has run we will grab the note output and send it out to // the console screen, since the migrator itself functions without having // any instances of the OutputInterface contract passed into the class. foreach ($this->container['migrator']->getNotes() as $note) { $this->output->writeln($note); } // Finally, if the "seed" option has been given, we will re-run the database // seed task to re-populate the database, which is convenient when adding // a migration and a seed at the same time, as it is only this command. if ($this->option('seed')) { $this->call('db:seed', ['--force' => true]); } }
[ "public", "function", "fire", "(", ")", "{", "if", "(", "!", "$", "this", "->", "confirmToProceed", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "prepareDatabase", "(", ")", ";", "// Next, we will check to see if a path option has been defined. If it has", "// we will use the path relative to the root of this installation folder", "// so that migrations may be run for any path within the applications.", "$", "this", "->", "container", "[", "'migrator'", "]", "->", "run", "(", "$", "this", "->", "getMigrationPaths", "(", ")", ",", "[", "'pretend'", "=>", "$", "this", "->", "option", "(", "'pretend'", ")", ",", "'step'", "=>", "$", "this", "->", "option", "(", "'step'", ")", ",", "]", ")", ";", "// Once the migrator has run we will grab the note output and send it out to", "// the console screen, since the migrator itself functions without having", "// any instances of the OutputInterface contract passed into the class.", "foreach", "(", "$", "this", "->", "container", "[", "'migrator'", "]", "->", "getNotes", "(", ")", "as", "$", "note", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "$", "note", ")", ";", "}", "// Finally, if the \"seed\" option has been given, we will re-run the database", "// seed task to re-populate the database, which is convenient when adding", "// a migration and a seed at the same time, as it is only this command.", "if", "(", "$", "this", "->", "option", "(", "'seed'", ")", ")", "{", "$", "this", "->", "call", "(", "'db:seed'", ",", "[", "'--force'", "=>", "true", "]", ")", ";", "}", "}" ]
Execute the console command. @return void
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Console/Migrations/MigrateCommand.php#L35-L64
zhouyl/mellivora
Mellivora/Database/Console/Migrations/MigrateCommand.php
MigrateCommand.prepareDatabase
protected function prepareDatabase() { $this->container['migrator']->setConnection($this->option('database')); if (!$this->container['migrator']->repositoryExists()) { $this->call( 'migrate:install', ['--database' => $this->option('database')] ); } }
php
protected function prepareDatabase() { $this->container['migrator']->setConnection($this->option('database')); if (!$this->container['migrator']->repositoryExists()) { $this->call( 'migrate:install', ['--database' => $this->option('database')] ); } }
[ "protected", "function", "prepareDatabase", "(", ")", "{", "$", "this", "->", "container", "[", "'migrator'", "]", "->", "setConnection", "(", "$", "this", "->", "option", "(", "'database'", ")", ")", ";", "if", "(", "!", "$", "this", "->", "container", "[", "'migrator'", "]", "->", "repositoryExists", "(", ")", ")", "{", "$", "this", "->", "call", "(", "'migrate:install'", ",", "[", "'--database'", "=>", "$", "this", "->", "option", "(", "'database'", ")", "]", ")", ";", "}", "}" ]
Prepare the migration database for running. @return void
[ "Prepare", "the", "migration", "database", "for", "running", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Console/Migrations/MigrateCommand.php#L71-L81
caffeinated/beverage
src/Traits/EventDispatcher.php
EventDispatcher.registerEvent
protected function registerEvent($name, Closure $callback) { if (! isset(static::$dispatcher)) { $this->initEventDispatcher(); } static::$dispatcher->listen($name, $callback); }
php
protected function registerEvent($name, Closure $callback) { if (! isset(static::$dispatcher)) { $this->initEventDispatcher(); } static::$dispatcher->listen($name, $callback); }
[ "protected", "function", "registerEvent", "(", "$", "name", ",", "Closure", "$", "callback", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "dispatcher", ")", ")", "{", "$", "this", "->", "initEventDispatcher", "(", ")", ";", "}", "static", "::", "$", "dispatcher", "->", "listen", "(", "$", "name", ",", "$", "callback", ")", ";", "}" ]
Register an event for the dispatcher to listen for. @param string $name @param Closure $callback @return void
[ "Register", "an", "event", "for", "the", "dispatcher", "to", "listen", "for", "." ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Traits/EventDispatcher.php#L55-L62
caffeinated/beverage
src/Traits/EventDispatcher.php
EventDispatcher.fireEvent
protected function fireEvent($name, $payload = null) { if (! isset(static::$dispatcher)) { $this->initEventDispatcher(); } static::$dispatcher->fire($name, $payload); }
php
protected function fireEvent($name, $payload = null) { if (! isset(static::$dispatcher)) { $this->initEventDispatcher(); } static::$dispatcher->fire($name, $payload); }
[ "protected", "function", "fireEvent", "(", "$", "name", ",", "$", "payload", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "dispatcher", ")", ")", "{", "$", "this", "->", "initEventDispatcher", "(", ")", ";", "}", "static", "::", "$", "dispatcher", "->", "fire", "(", "$", "name", ",", "$", "payload", ")", ";", "}" ]
Fire off an event. @param string $name @param mixed $payload @return mixed
[ "Fire", "off", "an", "event", "." ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Traits/EventDispatcher.php#L71-L78
tigron/skeleton-file
migration/20160503_173014_init.php
Migration_20160503_173014_Init.up
public function up() { $db = Database::get(); $table = File::trait_get_database_table(); $tables = $db->get_column("SHOW TABLES LIKE '" . $table . "'", []); if (count($tables) == 0) { $db->query(" CREATE TABLE IF NOT EXISTS `" . $table . "` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(128) COLLATE utf8_unicode_ci NOT NULL, `unique_name` varchar(128) COLLATE utf8_unicode_ci NOT NULL, `md5sum` varchar(128) COLLATE utf8_unicode_ci NOT NULL, `mime_type` varchar(128) COLLATE utf8_unicode_ci NOT NULL, `size` int(11) NOT NULL, `created` datetime NOT NULL, `deleted` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ", []); } }
php
public function up() { $db = Database::get(); $table = File::trait_get_database_table(); $tables = $db->get_column("SHOW TABLES LIKE '" . $table . "'", []); if (count($tables) == 0) { $db->query(" CREATE TABLE IF NOT EXISTS `" . $table . "` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(128) COLLATE utf8_unicode_ci NOT NULL, `unique_name` varchar(128) COLLATE utf8_unicode_ci NOT NULL, `md5sum` varchar(128) COLLATE utf8_unicode_ci NOT NULL, `mime_type` varchar(128) COLLATE utf8_unicode_ci NOT NULL, `size` int(11) NOT NULL, `created` datetime NOT NULL, `deleted` datetime NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ", []); } }
[ "public", "function", "up", "(", ")", "{", "$", "db", "=", "Database", "::", "get", "(", ")", ";", "$", "table", "=", "File", "::", "trait_get_database_table", "(", ")", ";", "$", "tables", "=", "$", "db", "->", "get_column", "(", "\"SHOW TABLES LIKE '\"", ".", "$", "table", ".", "\"'\"", ",", "[", "]", ")", ";", "if", "(", "count", "(", "$", "tables", ")", "==", "0", ")", "{", "$", "db", "->", "query", "(", "\"\n\t\t\t\tCREATE TABLE IF NOT EXISTS `\"", ".", "$", "table", ".", "\"` (\n\t\t\t\t `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t `name` varchar(128) COLLATE utf8_unicode_ci NOT NULL,\n\t\t\t\t `unique_name` varchar(128) COLLATE utf8_unicode_ci NOT NULL,\n\t\t\t\t `md5sum` varchar(128) COLLATE utf8_unicode_ci NOT NULL,\n\t\t\t\t `mime_type` varchar(128) COLLATE utf8_unicode_ci NOT NULL,\n\t\t\t\t `size` int(11) NOT NULL,\n\t\t\t\t `created` datetime NOT NULL,\n\t\t\t\t `deleted` datetime NOT NULL,\n\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;\n\t\t\t\"", ",", "[", "]", ")", ";", "}", "}" ]
Migrate up @access public
[ "Migrate", "up" ]
train
https://github.com/tigron/skeleton-file/blob/97978d49f179f07c76380ddc8919b8a7d56dee61/migration/20160503_173014_init.php#L19-L40
CupOfTea696/WordPress-Composer
src/WordPressInstallationCleaner.php
WordPressInstallationCleaner.clean
public function clean(Composer $composer) { $rootPkg = $composer->getPackage(); $extra = $rootPkg->getExtra(); if (! isset($extra['wordpress-install-dir'])) { return; } $filesystem = new Filesystem(); $filesystem->remove($extra['wordpress-install-dir'] . '/wp-content'); }
php
public function clean(Composer $composer) { $rootPkg = $composer->getPackage(); $extra = $rootPkg->getExtra(); if (! isset($extra['wordpress-install-dir'])) { return; } $filesystem = new Filesystem(); $filesystem->remove($extra['wordpress-install-dir'] . '/wp-content'); }
[ "public", "function", "clean", "(", "Composer", "$", "composer", ")", "{", "$", "rootPkg", "=", "$", "composer", "->", "getPackage", "(", ")", ";", "$", "extra", "=", "$", "rootPkg", "->", "getExtra", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "extra", "[", "'wordpress-install-dir'", "]", ")", ")", "{", "return", ";", "}", "$", "filesystem", "=", "new", "Filesystem", "(", ")", ";", "$", "filesystem", "->", "remove", "(", "$", "extra", "[", "'wordpress-install-dir'", "]", ".", "'/wp-content'", ")", ";", "}" ]
Clean up the WordPress installation directory. @param \Composer\Composer $composer @return void
[ "Clean", "up", "the", "WordPress", "installation", "directory", "." ]
train
https://github.com/CupOfTea696/WordPress-Composer/blob/8c0abc10f82b8ce1db5354f6a041c7587ad3fb90/src/WordPressInstallationCleaner.php#L35-L46
ekuiter/feature-php
FeaturePhp/File/TextFileContent.php
TextFileContent.copy
public function copy($target) { if (!parent::copy($target)) return false; return file_put_contents($target, $this->content) !== false; }
php
public function copy($target) { if (!parent::copy($target)) return false; return file_put_contents($target, $this->content) !== false; }
[ "public", "function", "copy", "(", "$", "target", ")", "{", "if", "(", "!", "parent", "::", "copy", "(", "$", "target", ")", ")", "return", "false", ";", "return", "file_put_contents", "(", "$", "target", ",", "$", "this", "->", "content", ")", "!==", "false", ";", "}" ]
Copies the text file's content to the local filesystem. @param string $target the file target in the filesystem
[ "Copies", "the", "text", "file", "s", "content", "to", "the", "local", "filesystem", "." ]
train
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/File/TextFileContent.php#L50-L54
ShaoZeMing/laravel-merchant
src/Traits/ModelTree.php
ModelTree.boot
protected static function boot() { parent::boot(); static::saving(function (Model $branch) { $parentColumn = $branch->getParentColumn(); if (Request::has($parentColumn) && Request::input($parentColumn) == $branch->getKey()) { throw new \Exception(trans('merchant.parent_select_error')); } if (Request::has('_order')) { $order = Request::input('_order'); Request::offsetUnset('_order'); static::tree()->saveOrder($order); return false; } return $branch; }); }
php
protected static function boot() { parent::boot(); static::saving(function (Model $branch) { $parentColumn = $branch->getParentColumn(); if (Request::has($parentColumn) && Request::input($parentColumn) == $branch->getKey()) { throw new \Exception(trans('merchant.parent_select_error')); } if (Request::has('_order')) { $order = Request::input('_order'); Request::offsetUnset('_order'); static::tree()->saveOrder($order); return false; } return $branch; }); }
[ "protected", "static", "function", "boot", "(", ")", "{", "parent", "::", "boot", "(", ")", ";", "static", "::", "saving", "(", "function", "(", "Model", "$", "branch", ")", "{", "$", "parentColumn", "=", "$", "branch", "->", "getParentColumn", "(", ")", ";", "if", "(", "Request", "::", "has", "(", "$", "parentColumn", ")", "&&", "Request", "::", "input", "(", "$", "parentColumn", ")", "==", "$", "branch", "->", "getKey", "(", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "trans", "(", "'merchant.parent_select_error'", ")", ")", ";", "}", "if", "(", "Request", "::", "has", "(", "'_order'", ")", ")", "{", "$", "order", "=", "Request", "::", "input", "(", "'_order'", ")", ";", "Request", "::", "offsetUnset", "(", "'_order'", ")", ";", "static", "::", "tree", "(", ")", "->", "saveOrder", "(", "$", "order", ")", ";", "return", "false", ";", "}", "return", "$", "branch", ";", "}", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Traits/ModelTree.php#L289-L312
glynnforrest/blockade
src/Blockade/Firewall.php
Firewall.setPermissionNames
public function setPermissionNames($any, $none, $user, $anon) { if ($any) { $this->any = $any; } if ($none) { $this->none = $none; } if ($user) { $this->user = $user; } if ($anon) { $this->anon = $anon; } }
php
public function setPermissionNames($any, $none, $user, $anon) { if ($any) { $this->any = $any; } if ($none) { $this->none = $none; } if ($user) { $this->user = $user; } if ($anon) { $this->anon = $anon; } }
[ "public", "function", "setPermissionNames", "(", "$", "any", ",", "$", "none", ",", "$", "user", ",", "$", "anon", ")", "{", "if", "(", "$", "any", ")", "{", "$", "this", "->", "any", "=", "$", "any", ";", "}", "if", "(", "$", "none", ")", "{", "$", "this", "->", "none", "=", "$", "none", ";", "}", "if", "(", "$", "user", ")", "{", "$", "this", "->", "user", "=", "$", "user", ";", "}", "if", "(", "$", "anon", ")", "{", "$", "this", "->", "anon", "=", "$", "anon", ";", "}", "}" ]
Set the names of the permissions to use for any, none, user and anonymous rules. Set any of these to null to continue using the current name. @param string $any The rule that allows any request @param string $none The rule that blocks any request @param string $user The rule that allows any authentication @param string $anon The rule that allows anonymous access only
[ "Set", "the", "names", "of", "the", "permissions", "to", "use", "for", "any", "none", "user", "and", "anonymous", "rules", ".", "Set", "any", "of", "these", "to", "null", "to", "continue", "using", "the", "current", "name", "." ]
train
https://github.com/glynnforrest/blockade/blob/5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b/src/Blockade/Firewall.php#L79-L93
glynnforrest/blockade
src/Blockade/Firewall.php
Firewall.check
public function check(Request $request) { //first check the exemptions. If the request passes any of //these, skip all other rules and grant explicit access. foreach ($this->exemptions as $exemption) { try { if (true === $this->checkRule($request, $exemption)) { return true; } //catch any exceptions - a failed exemption shouldn't //fail the firewall entirely. Just move to on to the //next one. } catch (BlockadeException $e) {} } //check the rules. If they fail they will throw exceptions. foreach ($this->rules as $rule) { $this->checkRule($request, $rule); } //all rules have passed, but we can't be sure the request is //good as there may be other firewalls. Returning false is //this Firewall saying 'not sure' to the FirewallListener. return false; }
php
public function check(Request $request) { //first check the exemptions. If the request passes any of //these, skip all other rules and grant explicit access. foreach ($this->exemptions as $exemption) { try { if (true === $this->checkRule($request, $exemption)) { return true; } //catch any exceptions - a failed exemption shouldn't //fail the firewall entirely. Just move to on to the //next one. } catch (BlockadeException $e) {} } //check the rules. If they fail they will throw exceptions. foreach ($this->rules as $rule) { $this->checkRule($request, $rule); } //all rules have passed, but we can't be sure the request is //good as there may be other firewalls. Returning false is //this Firewall saying 'not sure' to the FirewallListener. return false; }
[ "public", "function", "check", "(", "Request", "$", "request", ")", "{", "//first check the exemptions. If the request passes any of", "//these, skip all other rules and grant explicit access.", "foreach", "(", "$", "this", "->", "exemptions", "as", "$", "exemption", ")", "{", "try", "{", "if", "(", "true", "===", "$", "this", "->", "checkRule", "(", "$", "request", ",", "$", "exemption", ")", ")", "{", "return", "true", ";", "}", "//catch any exceptions - a failed exemption shouldn't", "//fail the firewall entirely. Just move to on to the", "//next one.", "}", "catch", "(", "BlockadeException", "$", "e", ")", "{", "}", "}", "//check the rules. If they fail they will throw exceptions.", "foreach", "(", "$", "this", "->", "rules", "as", "$", "rule", ")", "{", "$", "this", "->", "checkRule", "(", "$", "request", ",", "$", "rule", ")", ";", "}", "//all rules have passed, but we can't be sure the request is", "//good as there may be other firewalls. Returning false is", "//this Firewall saying 'not sure' to the FirewallListener.", "return", "false", ";", "}" ]
Check if a Request has permission to access a resource. @param Request $request The request to check @return Boolean true if the request is granted explicit access via an exemption, false if the request passed but has not been granted explicit access (allowing other firewalls to check) @throws AuthenticationException if the request is not authenticated @throws AuthorizationException if the request is not authorized
[ "Check", "if", "a", "Request", "has", "permission", "to", "access", "a", "resource", "." ]
train
https://github.com/glynnforrest/blockade/blob/5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b/src/Blockade/Firewall.php#L117-L141
mmanos/laravel-casset
src/Mmanos/Casset/Compressors/Css.php
Css._process
protected function _process($css) { $css = str_replace("\r\n", "\n", $css); // preserve empty comment after '>' // http://www.webdevout.net/css-hacks#in_css-selectors $css = preg_replace('@>/\\*\\s*\\*/@', '>/*keep*/', $css); // preserve empty comment between property and value // http://css-discuss.incutio.com/?page=BoxModelHack $css = preg_replace('@/\\*\\s*\\*/\\s*:@', '/*keep*/:', $css); $css = preg_replace('@:\\s*/\\*\\s*\\*/@', ':/*keep*/', $css); // apply callback to all valid comments (and strip out surrounding ws $css = preg_replace_callback('@\\s*/\\*([\\s\\S]*?)\\*/\\s*@' ,array($this, '_commentCB'), $css); // remove ws around { } and last semicolon in declaration block $css = preg_replace('/\\s*{\\s*/', '{', $css); $css = preg_replace('/;?\\s*}\\s*/', '}', $css); // remove ws surrounding semicolons $css = preg_replace('/\\s*;\\s*/', ';', $css); // remove ws around urls $css = preg_replace('/ url\\( # url( \\s* ([^\\)]+?) # 1 = the URL (really just a bunch of non right parenthesis) \\s* \\) # ) /x', 'url($1)', $css); // remove ws between rules and colons $css = preg_replace('/ \\s* ([{;]) # 1 = beginning of block or rule separator \\s* ([\\*_]?[\\w\\-]+) # 2 = property (and maybe IE filter) \\s* : \\s* (\\b|[#\'"]) # 3 = first character of a value /x', '$1$2:$3', $css); // remove ws in selectors $css = preg_replace_callback('/ (?: # non-capture \\s* [^~>+,\\s]+ # selector part \\s* [,>+~] # combinators )+ \\s* [^~>+,\\s]+ # selector part { # open declaration block /x' ,array($this, '_selectorsCB'), $css); // minimize hex colors $css = preg_replace('/([^=])#([a-f\\d])\\2([a-f\\d])\\3([a-f\\d])\\4([\\s;\\}])/i' , '$1#$2$3$4$5', $css); // remove spaces between font families $css = preg_replace_callback('/font-family:([^;}]+)([;}])/' ,array($this, '_fontFamilyCB'), $css); $css = preg_replace('/@import\\s+url/', '@import url', $css); // replace any ws involving newlines with a single newline $css = preg_replace('/[ \\t]*\\n+\\s*/', "\n", $css); // separate common descendent selectors w/ newlines (to limit line lengths) $css = preg_replace('/([\\w#\\.\\*]+)\\s+([\\w#\\.\\*]+){/', "$1\n$2{", $css); // Use newline after 1st numeric value (to limit line lengths). $css = preg_replace('/ ((?:padding|margin|border|outline):\\d+(?:px|em)?) # 1 = prop : 1st numeric value \\s+ /x' ,"$1\n", $css); // prevent triggering IE6 bug: http://www.crankygeek.com/ie6pebug/ $css = preg_replace('/:first-l(etter|ine)\\{/', ':first-l$1 {', $css); return trim($css); }
php
protected function _process($css) { $css = str_replace("\r\n", "\n", $css); // preserve empty comment after '>' // http://www.webdevout.net/css-hacks#in_css-selectors $css = preg_replace('@>/\\*\\s*\\*/@', '>/*keep*/', $css); // preserve empty comment between property and value // http://css-discuss.incutio.com/?page=BoxModelHack $css = preg_replace('@/\\*\\s*\\*/\\s*:@', '/*keep*/:', $css); $css = preg_replace('@:\\s*/\\*\\s*\\*/@', ':/*keep*/', $css); // apply callback to all valid comments (and strip out surrounding ws $css = preg_replace_callback('@\\s*/\\*([\\s\\S]*?)\\*/\\s*@' ,array($this, '_commentCB'), $css); // remove ws around { } and last semicolon in declaration block $css = preg_replace('/\\s*{\\s*/', '{', $css); $css = preg_replace('/;?\\s*}\\s*/', '}', $css); // remove ws surrounding semicolons $css = preg_replace('/\\s*;\\s*/', ';', $css); // remove ws around urls $css = preg_replace('/ url\\( # url( \\s* ([^\\)]+?) # 1 = the URL (really just a bunch of non right parenthesis) \\s* \\) # ) /x', 'url($1)', $css); // remove ws between rules and colons $css = preg_replace('/ \\s* ([{;]) # 1 = beginning of block or rule separator \\s* ([\\*_]?[\\w\\-]+) # 2 = property (and maybe IE filter) \\s* : \\s* (\\b|[#\'"]) # 3 = first character of a value /x', '$1$2:$3', $css); // remove ws in selectors $css = preg_replace_callback('/ (?: # non-capture \\s* [^~>+,\\s]+ # selector part \\s* [,>+~] # combinators )+ \\s* [^~>+,\\s]+ # selector part { # open declaration block /x' ,array($this, '_selectorsCB'), $css); // minimize hex colors $css = preg_replace('/([^=])#([a-f\\d])\\2([a-f\\d])\\3([a-f\\d])\\4([\\s;\\}])/i' , '$1#$2$3$4$5', $css); // remove spaces between font families $css = preg_replace_callback('/font-family:([^;}]+)([;}])/' ,array($this, '_fontFamilyCB'), $css); $css = preg_replace('/@import\\s+url/', '@import url', $css); // replace any ws involving newlines with a single newline $css = preg_replace('/[ \\t]*\\n+\\s*/', "\n", $css); // separate common descendent selectors w/ newlines (to limit line lengths) $css = preg_replace('/([\\w#\\.\\*]+)\\s+([\\w#\\.\\*]+){/', "$1\n$2{", $css); // Use newline after 1st numeric value (to limit line lengths). $css = preg_replace('/ ((?:padding|margin|border|outline):\\d+(?:px|em)?) # 1 = prop : 1st numeric value \\s+ /x' ,"$1\n", $css); // prevent triggering IE6 bug: http://www.crankygeek.com/ie6pebug/ $css = preg_replace('/:first-l(etter|ine)\\{/', ':first-l$1 {', $css); return trim($css); }
[ "protected", "function", "_process", "(", "$", "css", ")", "{", "$", "css", "=", "str_replace", "(", "\"\\r\\n\"", ",", "\"\\n\"", ",", "$", "css", ")", ";", "// preserve empty comment after '>'", "// http://www.webdevout.net/css-hacks#in_css-selectors", "$", "css", "=", "preg_replace", "(", "'@>/\\\\*\\\\s*\\\\*/@'", ",", "'>/*keep*/'", ",", "$", "css", ")", ";", "// preserve empty comment between property and value", "// http://css-discuss.incutio.com/?page=BoxModelHack", "$", "css", "=", "preg_replace", "(", "'@/\\\\*\\\\s*\\\\*/\\\\s*:@'", ",", "'/*keep*/:'", ",", "$", "css", ")", ";", "$", "css", "=", "preg_replace", "(", "'@:\\\\s*/\\\\*\\\\s*\\\\*/@'", ",", "':/*keep*/'", ",", "$", "css", ")", ";", "// apply callback to all valid comments (and strip out surrounding ws", "$", "css", "=", "preg_replace_callback", "(", "'@\\\\s*/\\\\*([\\\\s\\\\S]*?)\\\\*/\\\\s*@'", ",", "array", "(", "$", "this", ",", "'_commentCB'", ")", ",", "$", "css", ")", ";", "// remove ws around { } and last semicolon in declaration block", "$", "css", "=", "preg_replace", "(", "'/\\\\s*{\\\\s*/'", ",", "'{'", ",", "$", "css", ")", ";", "$", "css", "=", "preg_replace", "(", "'/;?\\\\s*}\\\\s*/'", ",", "'}'", ",", "$", "css", ")", ";", "// remove ws surrounding semicolons", "$", "css", "=", "preg_replace", "(", "'/\\\\s*;\\\\s*/'", ",", "';'", ",", "$", "css", ")", ";", "// remove ws around urls", "$", "css", "=", "preg_replace", "(", "'/\n url\\\\( # url(\n \\\\s*\n ([^\\\\)]+?) # 1 = the URL (really just a bunch of non right parenthesis)\n \\\\s*\n \\\\) # )\n /x'", ",", "'url($1)'", ",", "$", "css", ")", ";", "// remove ws between rules and colons", "$", "css", "=", "preg_replace", "(", "'/\n \\\\s*\n ([{;]) # 1 = beginning of block or rule separator \n \\\\s*\n ([\\\\*_]?[\\\\w\\\\-]+) # 2 = property (and maybe IE filter)\n \\\\s*\n :\n \\\\s*\n (\\\\b|[#\\'\"]) # 3 = first character of a value\n /x'", ",", "'$1$2:$3'", ",", "$", "css", ")", ";", "// remove ws in selectors", "$", "css", "=", "preg_replace_callback", "(", "'/\n (?: # non-capture\n \\\\s*\n [^~>+,\\\\s]+ # selector part\n \\\\s*\n [,>+~] # combinators\n )+\n \\\\s*\n [^~>+,\\\\s]+ # selector part\n { # open declaration block\n /x'", ",", "array", "(", "$", "this", ",", "'_selectorsCB'", ")", ",", "$", "css", ")", ";", "// minimize hex colors", "$", "css", "=", "preg_replace", "(", "'/([^=])#([a-f\\\\d])\\\\2([a-f\\\\d])\\\\3([a-f\\\\d])\\\\4([\\\\s;\\\\}])/i'", ",", "'$1#$2$3$4$5'", ",", "$", "css", ")", ";", "// remove spaces between font families", "$", "css", "=", "preg_replace_callback", "(", "'/font-family:([^;}]+)([;}])/'", ",", "array", "(", "$", "this", ",", "'_fontFamilyCB'", ")", ",", "$", "css", ")", ";", "$", "css", "=", "preg_replace", "(", "'/@import\\\\s+url/'", ",", "'@import url'", ",", "$", "css", ")", ";", "// replace any ws involving newlines with a single newline", "$", "css", "=", "preg_replace", "(", "'/[ \\\\t]*\\\\n+\\\\s*/'", ",", "\"\\n\"", ",", "$", "css", ")", ";", "// separate common descendent selectors w/ newlines (to limit line lengths)", "$", "css", "=", "preg_replace", "(", "'/([\\\\w#\\\\.\\\\*]+)\\\\s+([\\\\w#\\\\.\\\\*]+){/'", ",", "\"$1\\n$2{\"", ",", "$", "css", ")", ";", "// Use newline after 1st numeric value (to limit line lengths).", "$", "css", "=", "preg_replace", "(", "'/\n ((?:padding|margin|border|outline):\\\\d+(?:px|em)?) # 1 = prop : 1st numeric value\n \\\\s+\n /x'", ",", "\"$1\\n\"", ",", "$", "css", ")", ";", "// prevent triggering IE6 bug: http://www.crankygeek.com/ie6pebug/", "$", "css", "=", "preg_replace", "(", "'/:first-l(etter|ine)\\\\{/'", ",", "':first-l$1 {'", ",", "$", "css", ")", ";", "return", "trim", "(", "$", "css", ")", ";", "}" ]
Minify a CSS string @param string $css @return string
[ "Minify", "a", "CSS", "string" ]
train
https://github.com/mmanos/laravel-casset/blob/0f7db71211c1daa99bde30afa41da2692a39b81c/src/Mmanos/Casset/Compressors/Css.php#L65-L151
mmanos/laravel-casset
src/Mmanos/Casset/Compressors/Css.php
Css._commentCB
protected function _commentCB($m) { $hasSurroundingWs = (trim($m[0]) !== $m[1]); $m = $m[1]; // $m is the comment content w/o the surrounding tokens, // but the return value will replace the entire comment. if ($m === 'keep') { return '/**/'; } if ($m === '" "') { // component of http://tantek.com/CSS/Examples/midpass.html return '/*" "*/'; } if (preg_match('@";\\}\\s*\\}/\\*\\s+@', $m)) { // component of http://tantek.com/CSS/Examples/midpass.html return '/*";}}/* */'; } if ($this->_inHack) { // inversion: feeding only to one browser if (preg_match('@ ^/ # comment started like /*/ \\s* (\\S[\\s\\S]+?) # has at least some non-ws content \\s* /\\* # ends like /*/ or /**/ @x', $m, $n)) { // end hack mode after this comment, but preserve the hack and comment content $this->_inHack = false; return "/*/{$n[1]}/**/"; } } if (substr($m, -1) === '\\') { // comment ends like \*/ // begin hack mode and preserve hack $this->_inHack = true; return '/*\\*/'; } if ($m !== '' && $m[0] === '/') { // comment looks like /*/ foo */ // begin hack mode and preserve hack $this->_inHack = true; return '/*/*/'; } if ($this->_inHack) { // a regular comment ends hack mode but should be preserved $this->_inHack = false; return '/**/'; } // Issue 107: if there's any surrounding whitespace, it may be important, so // replace the comment with a single space return $hasSurroundingWs // remove all other comments ? ' ' : ''; }
php
protected function _commentCB($m) { $hasSurroundingWs = (trim($m[0]) !== $m[1]); $m = $m[1]; // $m is the comment content w/o the surrounding tokens, // but the return value will replace the entire comment. if ($m === 'keep') { return '/**/'; } if ($m === '" "') { // component of http://tantek.com/CSS/Examples/midpass.html return '/*" "*/'; } if (preg_match('@";\\}\\s*\\}/\\*\\s+@', $m)) { // component of http://tantek.com/CSS/Examples/midpass.html return '/*";}}/* */'; } if ($this->_inHack) { // inversion: feeding only to one browser if (preg_match('@ ^/ # comment started like /*/ \\s* (\\S[\\s\\S]+?) # has at least some non-ws content \\s* /\\* # ends like /*/ or /**/ @x', $m, $n)) { // end hack mode after this comment, but preserve the hack and comment content $this->_inHack = false; return "/*/{$n[1]}/**/"; } } if (substr($m, -1) === '\\') { // comment ends like \*/ // begin hack mode and preserve hack $this->_inHack = true; return '/*\\*/'; } if ($m !== '' && $m[0] === '/') { // comment looks like /*/ foo */ // begin hack mode and preserve hack $this->_inHack = true; return '/*/*/'; } if ($this->_inHack) { // a regular comment ends hack mode but should be preserved $this->_inHack = false; return '/**/'; } // Issue 107: if there's any surrounding whitespace, it may be important, so // replace the comment with a single space return $hasSurroundingWs // remove all other comments ? ' ' : ''; }
[ "protected", "function", "_commentCB", "(", "$", "m", ")", "{", "$", "hasSurroundingWs", "=", "(", "trim", "(", "$", "m", "[", "0", "]", ")", "!==", "$", "m", "[", "1", "]", ")", ";", "$", "m", "=", "$", "m", "[", "1", "]", ";", "// $m is the comment content w/o the surrounding tokens, ", "// but the return value will replace the entire comment.", "if", "(", "$", "m", "===", "'keep'", ")", "{", "return", "'/**/'", ";", "}", "if", "(", "$", "m", "===", "'\" \"'", ")", "{", "// component of http://tantek.com/CSS/Examples/midpass.html", "return", "'/*\" \"*/'", ";", "}", "if", "(", "preg_match", "(", "'@\";\\\\}\\\\s*\\\\}/\\\\*\\\\s+@'", ",", "$", "m", ")", ")", "{", "// component of http://tantek.com/CSS/Examples/midpass.html", "return", "'/*\";}}/* */'", ";", "}", "if", "(", "$", "this", "->", "_inHack", ")", "{", "// inversion: feeding only to one browser", "if", "(", "preg_match", "(", "'@\n ^/ # comment started like /*/\n \\\\s*\n (\\\\S[\\\\s\\\\S]+?) # has at least some non-ws content\n \\\\s*\n /\\\\* # ends like /*/ or /**/\n @x'", ",", "$", "m", ",", "$", "n", ")", ")", "{", "// end hack mode after this comment, but preserve the hack and comment content", "$", "this", "->", "_inHack", "=", "false", ";", "return", "\"/*/{$n[1]}/**/\"", ";", "}", "}", "if", "(", "substr", "(", "$", "m", ",", "-", "1", ")", "===", "'\\\\'", ")", "{", "// comment ends like \\*/", "// begin hack mode and preserve hack", "$", "this", "->", "_inHack", "=", "true", ";", "return", "'/*\\\\*/'", ";", "}", "if", "(", "$", "m", "!==", "''", "&&", "$", "m", "[", "0", "]", "===", "'/'", ")", "{", "// comment looks like /*/ foo */", "// begin hack mode and preserve hack", "$", "this", "->", "_inHack", "=", "true", ";", "return", "'/*/*/'", ";", "}", "if", "(", "$", "this", "->", "_inHack", ")", "{", "// a regular comment ends hack mode but should be preserved", "$", "this", "->", "_inHack", "=", "false", ";", "return", "'/**/'", ";", "}", "// Issue 107: if there's any surrounding whitespace, it may be important, so ", "// replace the comment with a single space", "return", "$", "hasSurroundingWs", "// remove all other comments", "?", "' '", ":", "''", ";", "}" ]
Process a comment and return a replacement @param array $m regex matches @return string
[ "Process", "a", "comment", "and", "return", "a", "replacement" ]
train
https://github.com/mmanos/laravel-casset/blob/0f7db71211c1daa99bde30afa41da2692a39b81c/src/Mmanos/Casset/Compressors/Css.php#L173-L224
sabre-io/cs
lib/FunctionDeclaration.php
FunctionDeclaration.fix
function fix(\SplFileInfo $file, $content) { $tokens = Tokens::fromCode($content); for ($index = $tokens->count() - 1; $index >= 0; --$index) { $token = $tokens[$index]; if (!$token->isGivenKind(T_FUNCTION)) { continue; } $startParenthesisIndex = $tokens->getNextTokenOfKind($index, ['(']); $endParenthesisIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $startParenthesisIndex); $startBraceIndex = $tokens->getNextTokenOfKind($endParenthesisIndex, [';', '{']); $startBraceToken = $tokens[$startBraceIndex]; if ($startBraceToken->equals('{')) { // fix single-line whitespace before { // eg: `function foo(){}` => `function foo() {}` // eg: `function foo() {}` => `function foo() {}` if ( !$tokens[$startBraceIndex - 1]->isWhitespace() || $tokens[$startBraceIndex - 1]->isWhitespace($this->singleLineWhitespaceOptions) ) { $tokens->ensureWhitespaceAtIndex($startBraceIndex - 1, 1, ' '); } } $afterParenthesisIndex = $tokens->getNextNonWhitespace($endParenthesisIndex); $afterParenthesisToken = $tokens[$afterParenthesisIndex]; if ($afterParenthesisToken->isGivenKind(T_USE)) { $useStartParenthesisIndex = $tokens->getNextTokenOfKind($afterParenthesisIndex, ['(']); $useEndParenthesisIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $useStartParenthesisIndex); // fix whitespace after T_USE $tokens->ensureWhitespaceAtIndex($afterParenthesisIndex + 1, 0, ' '); // remove single-line edge whitespaces inside use parentheses $this->fixParenthesisInnerEdge($tokens, $useStartParenthesisIndex, $useEndParenthesisIndex); // fix whitespace before T_USE $tokens->ensureWhitespaceAtIndex($afterParenthesisIndex - 1, 1, ' '); } // remove single-line edge whitespaces inside parameters list parentheses $this->fixParenthesisInnerEdge($tokens, $startParenthesisIndex, $endParenthesisIndex); // remove whitespace before ( // eg: `function foo () {}` => `function foo() {}` if ($tokens[$startParenthesisIndex - 1]->isWhitespace()) { $tokens[$startParenthesisIndex - 1]->clear(); } // fix whitespace after T_FUNCTION // eg: `function foo() {}` => `function foo() {}` // $tokens->ensureWhitespaceAtIndex($index + 1, 0, ' '); } return $tokens->generateCode(); }
php
function fix(\SplFileInfo $file, $content) { $tokens = Tokens::fromCode($content); for ($index = $tokens->count() - 1; $index >= 0; --$index) { $token = $tokens[$index]; if (!$token->isGivenKind(T_FUNCTION)) { continue; } $startParenthesisIndex = $tokens->getNextTokenOfKind($index, ['(']); $endParenthesisIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $startParenthesisIndex); $startBraceIndex = $tokens->getNextTokenOfKind($endParenthesisIndex, [';', '{']); $startBraceToken = $tokens[$startBraceIndex]; if ($startBraceToken->equals('{')) { // fix single-line whitespace before { // eg: `function foo(){}` => `function foo() {}` // eg: `function foo() {}` => `function foo() {}` if ( !$tokens[$startBraceIndex - 1]->isWhitespace() || $tokens[$startBraceIndex - 1]->isWhitespace($this->singleLineWhitespaceOptions) ) { $tokens->ensureWhitespaceAtIndex($startBraceIndex - 1, 1, ' '); } } $afterParenthesisIndex = $tokens->getNextNonWhitespace($endParenthesisIndex); $afterParenthesisToken = $tokens[$afterParenthesisIndex]; if ($afterParenthesisToken->isGivenKind(T_USE)) { $useStartParenthesisIndex = $tokens->getNextTokenOfKind($afterParenthesisIndex, ['(']); $useEndParenthesisIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $useStartParenthesisIndex); // fix whitespace after T_USE $tokens->ensureWhitespaceAtIndex($afterParenthesisIndex + 1, 0, ' '); // remove single-line edge whitespaces inside use parentheses $this->fixParenthesisInnerEdge($tokens, $useStartParenthesisIndex, $useEndParenthesisIndex); // fix whitespace before T_USE $tokens->ensureWhitespaceAtIndex($afterParenthesisIndex - 1, 1, ' '); } // remove single-line edge whitespaces inside parameters list parentheses $this->fixParenthesisInnerEdge($tokens, $startParenthesisIndex, $endParenthesisIndex); // remove whitespace before ( // eg: `function foo () {}` => `function foo() {}` if ($tokens[$startParenthesisIndex - 1]->isWhitespace()) { $tokens[$startParenthesisIndex - 1]->clear(); } // fix whitespace after T_FUNCTION // eg: `function foo() {}` => `function foo() {}` // $tokens->ensureWhitespaceAtIndex($index + 1, 0, ' '); } return $tokens->generateCode(); }
[ "function", "fix", "(", "\\", "SplFileInfo", "$", "file", ",", "$", "content", ")", "{", "$", "tokens", "=", "Tokens", "::", "fromCode", "(", "$", "content", ")", ";", "for", "(", "$", "index", "=", "$", "tokens", "->", "count", "(", ")", "-", "1", ";", "$", "index", ">=", "0", ";", "--", "$", "index", ")", "{", "$", "token", "=", "$", "tokens", "[", "$", "index", "]", ";", "if", "(", "!", "$", "token", "->", "isGivenKind", "(", "T_FUNCTION", ")", ")", "{", "continue", ";", "}", "$", "startParenthesisIndex", "=", "$", "tokens", "->", "getNextTokenOfKind", "(", "$", "index", ",", "[", "'('", "]", ")", ";", "$", "endParenthesisIndex", "=", "$", "tokens", "->", "findBlockEnd", "(", "Tokens", "::", "BLOCK_TYPE_PARENTHESIS_BRACE", ",", "$", "startParenthesisIndex", ")", ";", "$", "startBraceIndex", "=", "$", "tokens", "->", "getNextTokenOfKind", "(", "$", "endParenthesisIndex", ",", "[", "';'", ",", "'{'", "]", ")", ";", "$", "startBraceToken", "=", "$", "tokens", "[", "$", "startBraceIndex", "]", ";", "if", "(", "$", "startBraceToken", "->", "equals", "(", "'{'", ")", ")", "{", "// fix single-line whitespace before {", "// eg: `function foo(){}` => `function foo() {}`", "// eg: `function foo() {}` => `function foo() {}`", "if", "(", "!", "$", "tokens", "[", "$", "startBraceIndex", "-", "1", "]", "->", "isWhitespace", "(", ")", "||", "$", "tokens", "[", "$", "startBraceIndex", "-", "1", "]", "->", "isWhitespace", "(", "$", "this", "->", "singleLineWhitespaceOptions", ")", ")", "{", "$", "tokens", "->", "ensureWhitespaceAtIndex", "(", "$", "startBraceIndex", "-", "1", ",", "1", ",", "' '", ")", ";", "}", "}", "$", "afterParenthesisIndex", "=", "$", "tokens", "->", "getNextNonWhitespace", "(", "$", "endParenthesisIndex", ")", ";", "$", "afterParenthesisToken", "=", "$", "tokens", "[", "$", "afterParenthesisIndex", "]", ";", "if", "(", "$", "afterParenthesisToken", "->", "isGivenKind", "(", "T_USE", ")", ")", "{", "$", "useStartParenthesisIndex", "=", "$", "tokens", "->", "getNextTokenOfKind", "(", "$", "afterParenthesisIndex", ",", "[", "'('", "]", ")", ";", "$", "useEndParenthesisIndex", "=", "$", "tokens", "->", "findBlockEnd", "(", "Tokens", "::", "BLOCK_TYPE_PARENTHESIS_BRACE", ",", "$", "useStartParenthesisIndex", ")", ";", "// fix whitespace after T_USE", "$", "tokens", "->", "ensureWhitespaceAtIndex", "(", "$", "afterParenthesisIndex", "+", "1", ",", "0", ",", "' '", ")", ";", "// remove single-line edge whitespaces inside use parentheses", "$", "this", "->", "fixParenthesisInnerEdge", "(", "$", "tokens", ",", "$", "useStartParenthesisIndex", ",", "$", "useEndParenthesisIndex", ")", ";", "// fix whitespace before T_USE", "$", "tokens", "->", "ensureWhitespaceAtIndex", "(", "$", "afterParenthesisIndex", "-", "1", ",", "1", ",", "' '", ")", ";", "}", "// remove single-line edge whitespaces inside parameters list parentheses", "$", "this", "->", "fixParenthesisInnerEdge", "(", "$", "tokens", ",", "$", "startParenthesisIndex", ",", "$", "endParenthesisIndex", ")", ";", "// remove whitespace before (", "// eg: `function foo () {}` => `function foo() {}`", "if", "(", "$", "tokens", "[", "$", "startParenthesisIndex", "-", "1", "]", "->", "isWhitespace", "(", ")", ")", "{", "$", "tokens", "[", "$", "startParenthesisIndex", "-", "1", "]", "->", "clear", "(", ")", ";", "}", "// fix whitespace after T_FUNCTION", "// eg: `function foo() {}` => `function foo() {}`", "// $tokens->ensureWhitespaceAtIndex($index + 1, 0, ' ');", "}", "return", "$", "tokens", "->", "generateCode", "(", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/sabre-io/cs/blob/a4c57e213bf3f5e7d6b29a2f70d1ca4b0dce6d86/lib/FunctionDeclaration.php#L41-L100
netvlies/NetvliesFormBundle
EventListener/SubmitListener.php
SubmitListener.onKernelRequest
public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); if ($request->isMethod('post')) { $formId = $request->request->getInt('form[form_id]', 0, true); if ($formId > 0) { $form = $this->container->get('netvlies.form')->get($formId); $sf2Form = $form->getSf2Form(); $sf2Form->bind($request); if ($sf2Form->isValid()) { $form->setSuccess(true); $event = new FormEvent($form); $dispatcher = $this->container->get('event_dispatcher'); $dispatcher->dispatch('form.success', $event); } } } }
php
public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); if ($request->isMethod('post')) { $formId = $request->request->getInt('form[form_id]', 0, true); if ($formId > 0) { $form = $this->container->get('netvlies.form')->get($formId); $sf2Form = $form->getSf2Form(); $sf2Form->bind($request); if ($sf2Form->isValid()) { $form->setSuccess(true); $event = new FormEvent($form); $dispatcher = $this->container->get('event_dispatcher'); $dispatcher->dispatch('form.success', $event); } } } }
[ "public", "function", "onKernelRequest", "(", "GetResponseEvent", "$", "event", ")", "{", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "if", "(", "$", "request", "->", "isMethod", "(", "'post'", ")", ")", "{", "$", "formId", "=", "$", "request", "->", "request", "->", "getInt", "(", "'form[form_id]'", ",", "0", ",", "true", ")", ";", "if", "(", "$", "formId", ">", "0", ")", "{", "$", "form", "=", "$", "this", "->", "container", "->", "get", "(", "'netvlies.form'", ")", "->", "get", "(", "$", "formId", ")", ";", "$", "sf2Form", "=", "$", "form", "->", "getSf2Form", "(", ")", ";", "$", "sf2Form", "->", "bind", "(", "$", "request", ")", ";", "if", "(", "$", "sf2Form", "->", "isValid", "(", ")", ")", "{", "$", "form", "->", "setSuccess", "(", "true", ")", ";", "$", "event", "=", "new", "FormEvent", "(", "$", "form", ")", ";", "$", "dispatcher", "=", "$", "this", "->", "container", "->", "get", "(", "'event_dispatcher'", ")", ";", "$", "dispatcher", "->", "dispatch", "(", "'form.success'", ",", "$", "event", ")", ";", "}", "}", "}", "}" ]
Checks if a form post request was mad. If so, it validates the form input and upon success dispatches the form success event, which can be used for further custom handling of the received data. @param $event
[ "Checks", "if", "a", "form", "post", "request", "was", "mad", ".", "If", "so", "it", "validates", "the", "form", "input", "and", "upon", "success", "dispatches", "the", "form", "success", "event", "which", "can", "be", "used", "for", "further", "custom", "handling", "of", "the", "received", "data", "." ]
train
https://github.com/netvlies/NetvliesFormBundle/blob/93f9a3321d9925040111374e7c1014a6400a2d08/EventListener/SubmitListener.php#L27-L51
felipeweb11/eloquent-value-object
src/CastsValueObjects.php
CastsValueObjects.getAttribute
public function getAttribute($key) { if (! $this->isValueObject($key)) { return parent::getAttribute($key); } if (! $this->isValueObjectCached($key)) { // Allow other mutators and such to do their work first. $value = parent::getAttribute($key); // Don't cast empty $value. if ($value === null || $value === '') { return null; } // Cache the instantiated value for future access. // This allows tests such as ($model->casted === $model->casted) to be true. $this->cacheValueObject($key, $this->createValueObject($key, $value)); } return $this->getCachedValueObject($key); }
php
public function getAttribute($key) { if (! $this->isValueObject($key)) { return parent::getAttribute($key); } if (! $this->isValueObjectCached($key)) { // Allow other mutators and such to do their work first. $value = parent::getAttribute($key); // Don't cast empty $value. if ($value === null || $value === '') { return null; } // Cache the instantiated value for future access. // This allows tests such as ($model->casted === $model->casted) to be true. $this->cacheValueObject($key, $this->createValueObject($key, $value)); } return $this->getCachedValueObject($key); }
[ "public", "function", "getAttribute", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "isValueObject", "(", "$", "key", ")", ")", "{", "return", "parent", "::", "getAttribute", "(", "$", "key", ")", ";", "}", "if", "(", "!", "$", "this", "->", "isValueObjectCached", "(", "$", "key", ")", ")", "{", "// Allow other mutators and such to do their work first.", "$", "value", "=", "parent", "::", "getAttribute", "(", "$", "key", ")", ";", "// Don't cast empty $value.", "if", "(", "$", "value", "===", "null", "||", "$", "value", "===", "''", ")", "{", "return", "null", ";", "}", "// Cache the instantiated value for future access.", "// This allows tests such as ($model->casted === $model->casted) to be true.", "$", "this", "->", "cacheValueObject", "(", "$", "key", ",", "$", "this", "->", "createValueObject", "(", "$", "key", ",", "$", "value", ")", ")", ";", "}", "return", "$", "this", "->", "getCachedValueObject", "(", "$", "key", ")", ";", "}" ]
@param string $key @return mixed
[ "@param", "string", "$key" ]
train
https://github.com/felipeweb11/eloquent-value-object/blob/017d9fe3df9246f5ee9faf823b5e42fb8958c605/src/CastsValueObjects.php#L43-L65
tequila/mongodb-odm
src/Repository/Repository.php
Repository.findAll
public function findAll(array $filter = [], array $options = []): DocumentsCollection { $cursor = $this->getCollection()->find($filter, $options); return new DocumentsCollection($this->documentManager, $cursor, $this->documentClass); }
php
public function findAll(array $filter = [], array $options = []): DocumentsCollection { $cursor = $this->getCollection()->find($filter, $options); return new DocumentsCollection($this->documentManager, $cursor, $this->documentClass); }
[ "public", "function", "findAll", "(", "array", "$", "filter", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", ":", "DocumentsCollection", "{", "$", "cursor", "=", "$", "this", "->", "getCollection", "(", ")", "->", "find", "(", "$", "filter", ",", "$", "options", ")", ";", "return", "new", "DocumentsCollection", "(", "$", "this", "->", "documentManager", ",", "$", "cursor", ",", "$", "this", "->", "documentClass", ")", ";", "}" ]
@param array $filter @param array $options @return DocumentsCollection
[ "@param", "array", "$filter", "@param", "array", "$options" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Repository/Repository.php#L40-L45
tequila/mongodb-odm
src/Repository/Repository.php
Repository.findOne
public function findOne(array $filter = [], array $options = []) { $documents = $this->findAll($filter, ['limit' => 1] + $options); return $documents->valid() ? $documents->current() : null; }
php
public function findOne(array $filter = [], array $options = []) { $documents = $this->findAll($filter, ['limit' => 1] + $options); return $documents->valid() ? $documents->current() : null; }
[ "public", "function", "findOne", "(", "array", "$", "filter", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "documents", "=", "$", "this", "->", "findAll", "(", "$", "filter", ",", "[", "'limit'", "=>", "1", "]", "+", "$", "options", ")", ";", "return", "$", "documents", "->", "valid", "(", ")", "?", "$", "documents", "->", "current", "(", ")", ":", "null", ";", "}" ]
@param array $filter @param array $options @return array|\MongoDB\BSON\Unserializable|null
[ "@param", "array", "$filter", "@param", "array", "$options" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Repository/Repository.php#L67-L72
tequila/mongodb-odm
src/Repository/Repository.php
Repository.findOneAndDelete
public function findOneAndDelete(array $filter, array $options = []) { $options['typeMap'] = [ 'root' => $this->documentManager->getProxyClass($this->documentClass), 'document' => 'array', ]; $document = $this->getCollection()->findOneAndDelete($filter, $options); if ($document instanceof DocumentManagerAwareInterface) { $document->setManager($this->documentManager); } return $document; }
php
public function findOneAndDelete(array $filter, array $options = []) { $options['typeMap'] = [ 'root' => $this->documentManager->getProxyClass($this->documentClass), 'document' => 'array', ]; $document = $this->getCollection()->findOneAndDelete($filter, $options); if ($document instanceof DocumentManagerAwareInterface) { $document->setManager($this->documentManager); } return $document; }
[ "public", "function", "findOneAndDelete", "(", "array", "$", "filter", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "[", "'typeMap'", "]", "=", "[", "'root'", "=>", "$", "this", "->", "documentManager", "->", "getProxyClass", "(", "$", "this", "->", "documentClass", ")", ",", "'document'", "=>", "'array'", ",", "]", ";", "$", "document", "=", "$", "this", "->", "getCollection", "(", ")", "->", "findOneAndDelete", "(", "$", "filter", ",", "$", "options", ")", ";", "if", "(", "$", "document", "instanceof", "DocumentManagerAwareInterface", ")", "{", "$", "document", "->", "setManager", "(", "$", "this", "->", "documentManager", ")", ";", "}", "return", "$", "document", ";", "}" ]
@param array $filter @param array $options @return object
[ "@param", "array", "$filter", "@param", "array", "$options" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Repository/Repository.php#L91-L104
tequila/mongodb-odm
src/Repository/Repository.php
Repository.findOneAndUpdate
public function findOneAndUpdate(array $filter, array $update, array $options = []) { $options['typeMap'] = [ 'root' => $this->documentManager->getProxyClass($this->documentClass), 'document' => 'array', ]; $document = $this->getCollection()->findOneAndUpdate($filter, $update, $options); if ($document instanceof DocumentManagerAwareInterface) { $document->setManager($this->documentManager); } return $document; }
php
public function findOneAndUpdate(array $filter, array $update, array $options = []) { $options['typeMap'] = [ 'root' => $this->documentManager->getProxyClass($this->documentClass), 'document' => 'array', ]; $document = $this->getCollection()->findOneAndUpdate($filter, $update, $options); if ($document instanceof DocumentManagerAwareInterface) { $document->setManager($this->documentManager); } return $document; }
[ "public", "function", "findOneAndUpdate", "(", "array", "$", "filter", ",", "array", "$", "update", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "[", "'typeMap'", "]", "=", "[", "'root'", "=>", "$", "this", "->", "documentManager", "->", "getProxyClass", "(", "$", "this", "->", "documentClass", ")", ",", "'document'", "=>", "'array'", ",", "]", ";", "$", "document", "=", "$", "this", "->", "getCollection", "(", ")", "->", "findOneAndUpdate", "(", "$", "filter", ",", "$", "update", ",", "$", "options", ")", ";", "if", "(", "$", "document", "instanceof", "DocumentManagerAwareInterface", ")", "{", "$", "document", "->", "setManager", "(", "$", "this", "->", "documentManager", ")", ";", "}", "return", "$", "document", ";", "}" ]
@param array $filter @param array $update @param array $options @return object
[ "@param", "array", "$filter", "@param", "array", "$update", "@param", "array", "$options" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Repository/Repository.php#L113-L126
tequila/mongodb-odm
src/Repository/Repository.php
Repository.findOneAndReplace
public function findOneAndReplace(array $filter, $replacement, array $options = []) { $options['typeMap'] = [ 'root' => $this->documentManager->getProxyClass($this->documentClass), 'document' => 'array', ]; $document = $this->getCollection()->findOneAndReplace($filter, $replacement, $options); if ($document instanceof DocumentManagerAwareInterface) { $document->setManager($this->documentManager); } return $document; }
php
public function findOneAndReplace(array $filter, $replacement, array $options = []) { $options['typeMap'] = [ 'root' => $this->documentManager->getProxyClass($this->documentClass), 'document' => 'array', ]; $document = $this->getCollection()->findOneAndReplace($filter, $replacement, $options); if ($document instanceof DocumentManagerAwareInterface) { $document->setManager($this->documentManager); } return $document; }
[ "public", "function", "findOneAndReplace", "(", "array", "$", "filter", ",", "$", "replacement", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "[", "'typeMap'", "]", "=", "[", "'root'", "=>", "$", "this", "->", "documentManager", "->", "getProxyClass", "(", "$", "this", "->", "documentClass", ")", ",", "'document'", "=>", "'array'", ",", "]", ";", "$", "document", "=", "$", "this", "->", "getCollection", "(", ")", "->", "findOneAndReplace", "(", "$", "filter", ",", "$", "replacement", ",", "$", "options", ")", ";", "if", "(", "$", "document", "instanceof", "DocumentManagerAwareInterface", ")", "{", "$", "document", "->", "setManager", "(", "$", "this", "->", "documentManager", ")", ";", "}", "return", "$", "document", ";", "}" ]
@param array $filter @param array|object $replacement @param array $options @return object
[ "@param", "array", "$filter", "@param", "array|object", "$replacement", "@param", "array", "$options" ]
train
https://github.com/tequila/mongodb-odm/blob/501d58529bbcb23ad7839680462f62d5c3466d23/src/Repository/Repository.php#L135-L148
hametuha/wpametu
src/WPametu/Service/Akismet.php
Akismet.is_spam
public static function is_spam( array $values = [] ){ $query_string = self::make_request( $values ); // If Akismet is not active, always return error if( !class_exists('Akismet') || ! \Akismet::get_api_key() ){ return new \WP_Error(500, 'Akismet is not active.'); } // Make request add_filter('akismet_ua', [static::class, 'get_ua'], 9); $response = \Akismet::http_post($query_string, 'comment-check'); remove_filter('akismet_ua', [static::class, 'get_ua'], 9); // Parse result switch( $response[1] ){ case 'true': return true; // This is spam. break; case 'false': return false; // This is not spam. break; default: // Something is wrong if( isset( $response[0]['x-akismet-debug-help'] ) && !empty($response[0]['x-akismet-debug-help']) ){ $message = $response[0]['x-akismet-debug-help']; }else{ $message = 'Akismet return the invalid result. Something is wrong.'; } return new \WP_Error(500, $message); break; } }
php
public static function is_spam( array $values = [] ){ $query_string = self::make_request( $values ); // If Akismet is not active, always return error if( !class_exists('Akismet') || ! \Akismet::get_api_key() ){ return new \WP_Error(500, 'Akismet is not active.'); } // Make request add_filter('akismet_ua', [static::class, 'get_ua'], 9); $response = \Akismet::http_post($query_string, 'comment-check'); remove_filter('akismet_ua', [static::class, 'get_ua'], 9); // Parse result switch( $response[1] ){ case 'true': return true; // This is spam. break; case 'false': return false; // This is not spam. break; default: // Something is wrong if( isset( $response[0]['x-akismet-debug-help'] ) && !empty($response[0]['x-akismet-debug-help']) ){ $message = $response[0]['x-akismet-debug-help']; }else{ $message = 'Akismet return the invalid result. Something is wrong.'; } return new \WP_Error(500, $message); break; } }
[ "public", "static", "function", "is_spam", "(", "array", "$", "values", "=", "[", "]", ")", "{", "$", "query_string", "=", "self", "::", "make_request", "(", "$", "values", ")", ";", "// If Akismet is not active, always return error", "if", "(", "!", "class_exists", "(", "'Akismet'", ")", "||", "!", "\\", "Akismet", "::", "get_api_key", "(", ")", ")", "{", "return", "new", "\\", "WP_Error", "(", "500", ",", "'Akismet is not active.'", ")", ";", "}", "// Make request", "add_filter", "(", "'akismet_ua'", ",", "[", "static", "::", "class", ",", "'get_ua'", "]", ",", "9", ")", ";", "$", "response", "=", "\\", "Akismet", "::", "http_post", "(", "$", "query_string", ",", "'comment-check'", ")", ";", "remove_filter", "(", "'akismet_ua'", ",", "[", "static", "::", "class", ",", "'get_ua'", "]", ",", "9", ")", ";", "// Parse result", "switch", "(", "$", "response", "[", "1", "]", ")", "{", "case", "'true'", ":", "return", "true", ";", "// This is spam.", "break", ";", "case", "'false'", ":", "return", "false", ";", "// This is not spam.", "break", ";", "default", ":", "// Something is wrong", "if", "(", "isset", "(", "$", "response", "[", "0", "]", "[", "'x-akismet-debug-help'", "]", ")", "&&", "!", "empty", "(", "$", "response", "[", "0", "]", "[", "'x-akismet-debug-help'", "]", ")", ")", "{", "$", "message", "=", "$", "response", "[", "0", "]", "[", "'x-akismet-debug-help'", "]", ";", "}", "else", "{", "$", "message", "=", "'Akismet return the invalid result. Something is wrong.'", ";", "}", "return", "new", "\\", "WP_Error", "(", "500", ",", "$", "message", ")", ";", "break", ";", "}", "}" ]
Check if data is spam @param array $values @return bool|\WP_Error
[ "Check", "if", "data", "is", "spam" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Service/Akismet.php#L24-L52
hametuha/wpametu
src/WPametu/Service/Akismet.php
Akismet.make_request
public static function make_request( array $args = [] ){ $args = wp_parse_args([ 'blog' => get_option( 'home' ), 'blog_lang' => get_locale(), 'blog_charset' => get_option( 'blog_charset' ), 'user_ip' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '', 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '', 'referrer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', ], $args); // Add server variables foreach ( $_SERVER as $key => $value ) { switch( $key ){ case 'REMOTE_ADDR': case 'HTTP_USER_AGENT': case 'HTTP_REFERER': case 'HTTP_COOKIE': case 'HTTP_COOKIE2': case 'PHP_AUTH_PW': // Ignore break; default: $args[$key] = $value; break; } } return http_build_query($args); }
php
public static function make_request( array $args = [] ){ $args = wp_parse_args([ 'blog' => get_option( 'home' ), 'blog_lang' => get_locale(), 'blog_charset' => get_option( 'blog_charset' ), 'user_ip' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '', 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '', 'referrer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', ], $args); // Add server variables foreach ( $_SERVER as $key => $value ) { switch( $key ){ case 'REMOTE_ADDR': case 'HTTP_USER_AGENT': case 'HTTP_REFERER': case 'HTTP_COOKIE': case 'HTTP_COOKIE2': case 'PHP_AUTH_PW': // Ignore break; default: $args[$key] = $value; break; } } return http_build_query($args); }
[ "public", "static", "function", "make_request", "(", "array", "$", "args", "=", "[", "]", ")", "{", "$", "args", "=", "wp_parse_args", "(", "[", "'blog'", "=>", "get_option", "(", "'home'", ")", ",", "'blog_lang'", "=>", "get_locale", "(", ")", ",", "'blog_charset'", "=>", "get_option", "(", "'blog_charset'", ")", ",", "'user_ip'", "=>", "isset", "(", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ")", "?", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ":", "''", ",", "'user_agent'", "=>", "isset", "(", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ")", "?", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ":", "''", ",", "'referrer'", "=>", "isset", "(", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", ")", "?", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", ":", "''", ",", "]", ",", "$", "args", ")", ";", "// Add server variables", "foreach", "(", "$", "_SERVER", "as", "$", "key", "=>", "$", "value", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "'REMOTE_ADDR'", ":", "case", "'HTTP_USER_AGENT'", ":", "case", "'HTTP_REFERER'", ":", "case", "'HTTP_COOKIE'", ":", "case", "'HTTP_COOKIE2'", ":", "case", "'PHP_AUTH_PW'", ":", "// Ignore", "break", ";", "default", ":", "$", "args", "[", "$", "key", "]", "=", "$", "value", ";", "break", ";", "}", "}", "return", "http_build_query", "(", "$", "args", ")", ";", "}" ]
Make request arguments @param array $args @return string
[ "Make", "request", "arguments" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Service/Akismet.php#L61-L87
zhouyl/mellivora
Mellivora/Database/Console/Migrations/BaseCommand.php
BaseCommand.getMigrationPaths
protected function getMigrationPaths() { // Here, we will check to see if a path option has been defined. If it has we will // use the path relative to the root of the installation folder so our database // migrations may be run for any customized path from within the application. if ($this->input->hasOption('path') && $this->option('path')) { return [root_path($this->option('path'))]; } return array_merge( [$this->getMigrationPath()], $this->container['migrator']->paths() ); }
php
protected function getMigrationPaths() { // Here, we will check to see if a path option has been defined. If it has we will // use the path relative to the root of the installation folder so our database // migrations may be run for any customized path from within the application. if ($this->input->hasOption('path') && $this->option('path')) { return [root_path($this->option('path'))]; } return array_merge( [$this->getMigrationPath()], $this->container['migrator']->paths() ); }
[ "protected", "function", "getMigrationPaths", "(", ")", "{", "// Here, we will check to see if a path option has been defined. If it has we will", "// use the path relative to the root of the installation folder so our database", "// migrations may be run for any customized path from within the application.", "if", "(", "$", "this", "->", "input", "->", "hasOption", "(", "'path'", ")", "&&", "$", "this", "->", "option", "(", "'path'", ")", ")", "{", "return", "[", "root_path", "(", "$", "this", "->", "option", "(", "'path'", ")", ")", "]", ";", "}", "return", "array_merge", "(", "[", "$", "this", "->", "getMigrationPath", "(", ")", "]", ",", "$", "this", "->", "container", "[", "'migrator'", "]", "->", "paths", "(", ")", ")", ";", "}" ]
Get all of the migration paths. @return array
[ "Get", "all", "of", "the", "migration", "paths", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Console/Migrations/BaseCommand.php#L14-L27
surebert/surebert-framework
src/sb/Gitlab/Client.php
Client.get
public function get($url, $data = [], $method = 'post') { $ch = curl_init($this->gitlab_host . '/api/v3' . $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'PRIVATE-TOKEN:' . $this->private_key )); if($this->debug){ curl_setopt($ch, CURLOPT_VERBOSE, true); if(!\sb\Gateway::$command_line){ $curl_log = fopen("php://temp", 'rw'); curl_setopt($ch, CURLOPT_STDERR, $curl_log); } } curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if ($data) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); if ($method != 'post') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); } } $error = curl_error($ch); $error_no = curl_errno($ch); if ($error_no) { throw(new \Exception($error . ': ' . $error_no)); } $data = json_decode(curl_exec($ch)); if($this->debug && !\sb\Gateway::$command_line){ rewind($curl_log); $output= fread($curl_log, 2048); echo "<pre>". print_r($output, 1). "</pre>"; fclose($curl_log); } return $data; }
php
public function get($url, $data = [], $method = 'post') { $ch = curl_init($this->gitlab_host . '/api/v3' . $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'PRIVATE-TOKEN:' . $this->private_key )); if($this->debug){ curl_setopt($ch, CURLOPT_VERBOSE, true); if(!\sb\Gateway::$command_line){ $curl_log = fopen("php://temp", 'rw'); curl_setopt($ch, CURLOPT_STDERR, $curl_log); } } curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if ($data) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); if ($method != 'post') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); } } $error = curl_error($ch); $error_no = curl_errno($ch); if ($error_no) { throw(new \Exception($error . ': ' . $error_no)); } $data = json_decode(curl_exec($ch)); if($this->debug && !\sb\Gateway::$command_line){ rewind($curl_log); $output= fread($curl_log, 2048); echo "<pre>". print_r($output, 1). "</pre>"; fclose($curl_log); } return $data; }
[ "public", "function", "get", "(", "$", "url", ",", "$", "data", "=", "[", "]", ",", "$", "method", "=", "'post'", ")", "{", "$", "ch", "=", "curl_init", "(", "$", "this", "->", "gitlab_host", ".", "'/api/v3'", ".", "$", "url", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HEADER", ",", "0", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HTTPHEADER", ",", "array", "(", "'PRIVATE-TOKEN:'", ".", "$", "this", "->", "private_key", ")", ")", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_VERBOSE", ",", "true", ")", ";", "if", "(", "!", "\\", "sb", "\\", "Gateway", "::", "$", "command_line", ")", "{", "$", "curl_log", "=", "fopen", "(", "\"php://temp\"", ",", "'rw'", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_STDERR", ",", "$", "curl_log", ")", ";", "}", "}", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "if", "(", "$", "data", ")", "{", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "http_build_query", "(", "$", "data", ")", ")", ";", "if", "(", "$", "method", "!=", "'post'", ")", "{", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_CUSTOMREQUEST", ",", "$", "method", ")", ";", "}", "}", "$", "error", "=", "curl_error", "(", "$", "ch", ")", ";", "$", "error_no", "=", "curl_errno", "(", "$", "ch", ")", ";", "if", "(", "$", "error_no", ")", "{", "throw", "(", "new", "\\", "Exception", "(", "$", "error", ".", "': '", ".", "$", "error_no", ")", ")", ";", "}", "$", "data", "=", "json_decode", "(", "curl_exec", "(", "$", "ch", ")", ")", ";", "if", "(", "$", "this", "->", "debug", "&&", "!", "\\", "sb", "\\", "Gateway", "::", "$", "command_line", ")", "{", "rewind", "(", "$", "curl_log", ")", ";", "$", "output", "=", "fread", "(", "$", "curl_log", ",", "2048", ")", ";", "echo", "\"<pre>\"", ".", "print_r", "(", "$", "output", ",", "1", ")", ".", "\"</pre>\"", ";", "fclose", "(", "$", "curl_log", ")", ";", "}", "return", "$", "data", ";", "}" ]
GRabs data from a URL and json_decodes it @param string $url URL to grab @param array $data http data to pass @param string $method post, put delete, default post @return object @throws Exception
[ "GRabs", "data", "from", "a", "URL", "and", "json_decodes", "it" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Gitlab/Client.php#L63-L108
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/Example/Finder.php
Finder.find
public function find(ExampleDescriptor $descriptor) { $filename = $descriptor->getFilePath(); $file = $this->getExampleFileContents($filename); if (! $file) { return "** File not found : {$filename} **"; } return implode('', array_slice($file, $descriptor->getStartingLine() - 1, $descriptor->getLineCount())); }
php
public function find(ExampleDescriptor $descriptor) { $filename = $descriptor->getFilePath(); $file = $this->getExampleFileContents($filename); if (! $file) { return "** File not found : {$filename} **"; } return implode('', array_slice($file, $descriptor->getStartingLine() - 1, $descriptor->getLineCount())); }
[ "public", "function", "find", "(", "ExampleDescriptor", "$", "descriptor", ")", "{", "$", "filename", "=", "$", "descriptor", "->", "getFilePath", "(", ")", ";", "$", "file", "=", "$", "this", "->", "getExampleFileContents", "(", "$", "filename", ")", ";", "if", "(", "!", "$", "file", ")", "{", "return", "\"** File not found : {$filename} **\"", ";", "}", "return", "implode", "(", "''", ",", "array_slice", "(", "$", "file", ",", "$", "descriptor", "->", "getStartingLine", "(", ")", "-", "1", ",", "$", "descriptor", "->", "getLineCount", "(", ")", ")", ")", ";", "}" ]
Attempts to find the example contents for the given descriptor. @param ExampleDescriptor $descriptor @return string
[ "Attempts", "to", "find", "the", "example", "contents", "for", "the", "given", "descriptor", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Example/Finder.php#L34-L44
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/Example/Finder.php
Finder.getExampleFileContents
private function getExampleFileContents($filename) { $normalizedPath = null; foreach ($this->exampleDirectories as $directory) { $exampleFileFromConfig = $this->constructExamplePath($directory, $filename); if (is_readable($exampleFileFromConfig)) { $normalizedPath = $exampleFileFromConfig; break; } } if (! $normalizedPath) { if (is_readable($this->getExamplePathFromSource($filename))) { $normalizedPath = $this->getExamplePathFromSource($filename); } elseif (is_readable($this->getExamplePathFromExampleDirectory($filename))) { $normalizedPath = $this->getExamplePathFromExampleDirectory($filename); } elseif (is_readable($filename)) { $normalizedPath = $filename; } } return $normalizedPath && is_readable($normalizedPath) ? file($normalizedPath) : null; }
php
private function getExampleFileContents($filename) { $normalizedPath = null; foreach ($this->exampleDirectories as $directory) { $exampleFileFromConfig = $this->constructExamplePath($directory, $filename); if (is_readable($exampleFileFromConfig)) { $normalizedPath = $exampleFileFromConfig; break; } } if (! $normalizedPath) { if (is_readable($this->getExamplePathFromSource($filename))) { $normalizedPath = $this->getExamplePathFromSource($filename); } elseif (is_readable($this->getExamplePathFromExampleDirectory($filename))) { $normalizedPath = $this->getExamplePathFromExampleDirectory($filename); } elseif (is_readable($filename)) { $normalizedPath = $filename; } } return $normalizedPath && is_readable($normalizedPath) ? file($normalizedPath) : null; }
[ "private", "function", "getExampleFileContents", "(", "$", "filename", ")", "{", "$", "normalizedPath", "=", "null", ";", "foreach", "(", "$", "this", "->", "exampleDirectories", "as", "$", "directory", ")", "{", "$", "exampleFileFromConfig", "=", "$", "this", "->", "constructExamplePath", "(", "$", "directory", ",", "$", "filename", ")", ";", "if", "(", "is_readable", "(", "$", "exampleFileFromConfig", ")", ")", "{", "$", "normalizedPath", "=", "$", "exampleFileFromConfig", ";", "break", ";", "}", "}", "if", "(", "!", "$", "normalizedPath", ")", "{", "if", "(", "is_readable", "(", "$", "this", "->", "getExamplePathFromSource", "(", "$", "filename", ")", ")", ")", "{", "$", "normalizedPath", "=", "$", "this", "->", "getExamplePathFromSource", "(", "$", "filename", ")", ";", "}", "elseif", "(", "is_readable", "(", "$", "this", "->", "getExamplePathFromExampleDirectory", "(", "$", "filename", ")", ")", ")", "{", "$", "normalizedPath", "=", "$", "this", "->", "getExamplePathFromExampleDirectory", "(", "$", "filename", ")", ";", "}", "elseif", "(", "is_readable", "(", "$", "filename", ")", ")", "{", "$", "normalizedPath", "=", "$", "filename", ";", "}", "}", "return", "$", "normalizedPath", "&&", "is_readable", "(", "$", "normalizedPath", ")", "?", "file", "(", "$", "normalizedPath", ")", ":", "null", ";", "}" ]
Attempts to find the requested example file and returns its contents or null if no file was found. This method will try several methods in search of the given example file, the first one it encounters is returned: 1. Iterates through all examples folders for the given filename 2. Checks the source folder for the given filename 3. Checks the 'examples' folder in the current working directory for examples 4. Checks the path relative to the current working directory for the given filename @param string $filename @return string|null
[ "Attempts", "to", "find", "the", "requested", "example", "file", "and", "returns", "its", "contents", "or", "null", "if", "no", "file", "was", "found", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Example/Finder.php#L103-L126
video-games-records/TeamBundle
Controller/GroupController.php
GroupController.rankingTeamPointsAction
public function rankingTeamPointsAction($id) { $group = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Group')->getWithGame($id); $breadcrumbs = $this->getGroupBreadcrumbs($group); $breadcrumbs->addItem('game.pointchartranking.full'); return $this->render( 'VideoGamesRecordsTeamBundle:Ranking:points-chart.html.twig', [ 'ranking' => $this->getDoctrine()->getRepository('VideoGamesRecordsTeamBundle:TeamGroup')->getRankingPoints($id, 100, null), ] ); }
php
public function rankingTeamPointsAction($id) { $group = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Group')->getWithGame($id); $breadcrumbs = $this->getGroupBreadcrumbs($group); $breadcrumbs->addItem('game.pointchartranking.full'); return $this->render( 'VideoGamesRecordsTeamBundle:Ranking:points-chart.html.twig', [ 'ranking' => $this->getDoctrine()->getRepository('VideoGamesRecordsTeamBundle:TeamGroup')->getRankingPoints($id, 100, null), ] ); }
[ "public", "function", "rankingTeamPointsAction", "(", "$", "id", ")", "{", "$", "group", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'VideoGamesRecordsCoreBundle:Group'", ")", "->", "getWithGame", "(", "$", "id", ")", ";", "$", "breadcrumbs", "=", "$", "this", "->", "getGroupBreadcrumbs", "(", "$", "group", ")", ";", "$", "breadcrumbs", "->", "addItem", "(", "'game.pointchartranking.full'", ")", ";", "return", "$", "this", "->", "render", "(", "'VideoGamesRecordsTeamBundle:Ranking:points-chart.html.twig'", ",", "[", "'ranking'", "=>", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'VideoGamesRecordsTeamBundle:TeamGroup'", ")", "->", "getRankingPoints", "(", "$", "id", ",", "100", ",", "null", ")", ",", "]", ")", ";", "}" ]
@Route("/ranking-points/id/{id}", requirements={"id": "[1-9]\d*"}, name="vgr_team_group_ranking_points") @Method("GET") @Cache(smaxage="10") @param int $id @return \Symfony\Component\HttpFoundation\Response
[ "@Route", "(", "/", "ranking", "-", "points", "/", "id", "/", "{", "id", "}", "requirements", "=", "{", "id", ":", "[", "1", "-", "9", "]", "\\", "d", "*", "}", "name", "=", "vgr_team_group_ranking_points", ")", "@Method", "(", "GET", ")", "@Cache", "(", "smaxage", "=", "10", ")" ]
train
https://github.com/video-games-records/TeamBundle/blob/4e5b73874bacb96f70ab16e74d54a1b6efc8e62f/Controller/GroupController.php#L25-L38
video-games-records/TeamBundle
Controller/GroupController.php
GroupController.rankingTeamMedalsAction
public function rankingTeamMedalsAction($id) { $group = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Group')->getWithGame($id); $breadcrumbs = $this->getGroupBreadcrumbs($group); $breadcrumbs->addItem('game.medalranking.full'); return $this->render( 'VideoGamesRecordsTeamBundle:Ranking:medals.html.twig', [ 'ranking' => $this->getDoctrine()->getRepository('VideoGamesRecordsTeamBundle:TeamGroup')->getRankingMedals($id, 100, null), ] ); }
php
public function rankingTeamMedalsAction($id) { $group = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Group')->getWithGame($id); $breadcrumbs = $this->getGroupBreadcrumbs($group); $breadcrumbs->addItem('game.medalranking.full'); return $this->render( 'VideoGamesRecordsTeamBundle:Ranking:medals.html.twig', [ 'ranking' => $this->getDoctrine()->getRepository('VideoGamesRecordsTeamBundle:TeamGroup')->getRankingMedals($id, 100, null), ] ); }
[ "public", "function", "rankingTeamMedalsAction", "(", "$", "id", ")", "{", "$", "group", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'VideoGamesRecordsCoreBundle:Group'", ")", "->", "getWithGame", "(", "$", "id", ")", ";", "$", "breadcrumbs", "=", "$", "this", "->", "getGroupBreadcrumbs", "(", "$", "group", ")", ";", "$", "breadcrumbs", "->", "addItem", "(", "'game.medalranking.full'", ")", ";", "return", "$", "this", "->", "render", "(", "'VideoGamesRecordsTeamBundle:Ranking:medals.html.twig'", ",", "[", "'ranking'", "=>", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'VideoGamesRecordsTeamBundle:TeamGroup'", ")", "->", "getRankingMedals", "(", "$", "id", ",", "100", ",", "null", ")", ",", "]", ")", ";", "}" ]
@Route("/ranking-medals/id/{id}", requirements={"id": "[1-9]\d*"}, name="vgr_team_group_ranking_medals") @Method("GET") @Cache(smaxage="10") @param int $id @return \Symfony\Component\HttpFoundation\Response
[ "@Route", "(", "/", "ranking", "-", "medals", "/", "id", "/", "{", "id", "}", "requirements", "=", "{", "id", ":", "[", "1", "-", "9", "]", "\\", "d", "*", "}", "name", "=", "vgr_team_group_ranking_medals", ")", "@Method", "(", "GET", ")", "@Cache", "(", "smaxage", "=", "10", ")" ]
train
https://github.com/video-games-records/TeamBundle/blob/4e5b73874bacb96f70ab16e74d54a1b6efc8e62f/Controller/GroupController.php#L49-L62
kbond/ControllerUtil
src/EventListener/TwigViewListener.php
TwigViewListener.getContent
protected function getContent(View $view, $format) { $template = $this->twig->resolveTemplate($view->getTemplate()); return $template->render($view->getDataAsArray()); }
php
protected function getContent(View $view, $format) { $template = $this->twig->resolveTemplate($view->getTemplate()); return $template->render($view->getDataAsArray()); }
[ "protected", "function", "getContent", "(", "View", "$", "view", ",", "$", "format", ")", "{", "$", "template", "=", "$", "this", "->", "twig", "->", "resolveTemplate", "(", "$", "view", "->", "getTemplate", "(", ")", ")", ";", "return", "$", "template", "->", "render", "(", "$", "view", "->", "getDataAsArray", "(", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/kbond/ControllerUtil/blob/67375d43c73d6a3f16356f3d683f62b176766e91/src/EventListener/TwigViewListener.php#L22-L27
Humanized/yii2-location
models/location/CountrySearch.php
CountrySearch.search
public function search($params) { $this->load($params); $query = $this->_query(); $dataProvider = new ActiveDataProvider([ 'query' => $query, 'pagination' => [ 'pageSize' => 10, ], 'sort' => [ 'attributes' => [ 'code', 'common_name', 'official_name', 'has_postcodes' ], ] ]); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['iso_2' => $this->code]); $query->andFilterWhere(['default_label.common_name' => $this->common_name]); $query->andFilterWhere(['default_label.official_name' => $this->official_name]); return $dataProvider; }
php
public function search($params) { $this->load($params); $query = $this->_query(); $dataProvider = new ActiveDataProvider([ 'query' => $query, 'pagination' => [ 'pageSize' => 10, ], 'sort' => [ 'attributes' => [ 'code', 'common_name', 'official_name', 'has_postcodes' ], ] ]); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['iso_2' => $this->code]); $query->andFilterWhere(['default_label.common_name' => $this->common_name]); $query->andFilterWhere(['default_label.official_name' => $this->official_name]); return $dataProvider; }
[ "public", "function", "search", "(", "$", "params", ")", "{", "$", "this", "->", "load", "(", "$", "params", ")", ";", "$", "query", "=", "$", "this", "->", "_query", "(", ")", ";", "$", "dataProvider", "=", "new", "ActiveDataProvider", "(", "[", "'query'", "=>", "$", "query", ",", "'pagination'", "=>", "[", "'pageSize'", "=>", "10", ",", "]", ",", "'sort'", "=>", "[", "'attributes'", "=>", "[", "'code'", ",", "'common_name'", ",", "'official_name'", ",", "'has_postcodes'", "]", ",", "]", "]", ")", ";", "if", "(", "!", "$", "this", "->", "validate", "(", ")", ")", "{", "// uncomment the following line if you do not want to return any records when validation fails", "// $query->where('0=1');", "return", "$", "dataProvider", ";", "}", "$", "query", "->", "andFilterWhere", "(", "[", "'iso_2'", "=>", "$", "this", "->", "code", "]", ")", ";", "$", "query", "->", "andFilterWhere", "(", "[", "'default_label.common_name'", "=>", "$", "this", "->", "common_name", "]", ")", ";", "$", "query", "->", "andFilterWhere", "(", "[", "'default_label.official_name'", "=>", "$", "this", "->", "official_name", "]", ")", ";", "return", "$", "dataProvider", ";", "}" ]
Creates data provider instance with search query applied @param array $params @return ActiveDataProvider
[ "Creates", "data", "provider", "instance", "with", "search", "query", "applied" ]
train
https://github.com/Humanized/yii2-location/blob/48ac12ceab741fc4c82ac8e979415a11bf9175f2/models/location/CountrySearch.php#L41-L66
gregorybesson/PlaygroundCms
src/Entity/Slideshow.php
Slideshow.populate
public function populate($data = array()) { if (isset($data['title']) && $data['title'] != null) { $this->title = $data['title']; } if (isset($data['subtitle']) && $data['subtitle'] != null) { $this->subtitle = $data['subtitle']; } if (isset($data['active']) && $data['active'] != null) { $this->active = $data['active']; } }
php
public function populate($data = array()) { if (isset($data['title']) && $data['title'] != null) { $this->title = $data['title']; } if (isset($data['subtitle']) && $data['subtitle'] != null) { $this->subtitle = $data['subtitle']; } if (isset($data['active']) && $data['active'] != null) { $this->active = $data['active']; } }
[ "public", "function", "populate", "(", "$", "data", "=", "array", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "'title'", "]", ")", "&&", "$", "data", "[", "'title'", "]", "!=", "null", ")", "{", "$", "this", "->", "title", "=", "$", "data", "[", "'title'", "]", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'subtitle'", "]", ")", "&&", "$", "data", "[", "'subtitle'", "]", "!=", "null", ")", "{", "$", "this", "->", "subtitle", "=", "$", "data", "[", "'subtitle'", "]", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'active'", "]", ")", "&&", "$", "data", "[", "'active'", "]", "!=", "null", ")", "{", "$", "this", "->", "active", "=", "$", "data", "[", "'active'", "]", ";", "}", "}" ]
Populate from an array. @param array $data
[ "Populate", "from", "an", "array", "." ]
train
https://github.com/gregorybesson/PlaygroundCms/blob/e929a283f2a6e82d4f248c930f7aa454ce20cbc3/src/Entity/Slideshow.php#L251-L264
Velliz/pte
lib/slicer/Slicer.php
Slicer.Lexer
public function Lexer($template, $output = array(), $position = 0) { $output = $this->PregCapture($template, $output, $position); $length = strlen($template); $lex = array(); $lex['text'] = substr($template, $position, $length); $lex['start'] = $position; $lex['end'] = $length; $lex['length'] = ($length - $position); $lex['flag'] = false; $lex['inverse'] = false; $lex['key'] = false; $lex['param'] = false; $output[] = $lex; return $output; }
php
public function Lexer($template, $output = array(), $position = 0) { $output = $this->PregCapture($template, $output, $position); $length = strlen($template); $lex = array(); $lex['text'] = substr($template, $position, $length); $lex['start'] = $position; $lex['end'] = $length; $lex['length'] = ($length - $position); $lex['flag'] = false; $lex['inverse'] = false; $lex['key'] = false; $lex['param'] = false; $output[] = $lex; return $output; }
[ "public", "function", "Lexer", "(", "$", "template", ",", "$", "output", "=", "array", "(", ")", ",", "$", "position", "=", "0", ")", "{", "$", "output", "=", "$", "this", "->", "PregCapture", "(", "$", "template", ",", "$", "output", ",", "$", "position", ")", ";", "$", "length", "=", "strlen", "(", "$", "template", ")", ";", "$", "lex", "=", "array", "(", ")", ";", "$", "lex", "[", "'text'", "]", "=", "substr", "(", "$", "template", ",", "$", "position", ",", "$", "length", ")", ";", "$", "lex", "[", "'start'", "]", "=", "$", "position", ";", "$", "lex", "[", "'end'", "]", "=", "$", "length", ";", "$", "lex", "[", "'length'", "]", "=", "(", "$", "length", "-", "$", "position", ")", ";", "$", "lex", "[", "'flag'", "]", "=", "false", ";", "$", "lex", "[", "'inverse'", "]", "=", "false", ";", "$", "lex", "[", "'key'", "]", "=", "false", ";", "$", "lex", "[", "'param'", "]", "=", "false", ";", "$", "output", "[", "]", "=", "$", "lex", ";", "return", "$", "output", ";", "}" ]
@param $template @param array $output @param int $position @return array Process the last of the converted html element
[ "@param", "$template", "@param", "array", "$output", "@param", "int", "$position", "@return", "array" ]
train
https://github.com/Velliz/pte/blob/8f8edc2289740d554a5942ff96eb727d838e866a/lib/slicer/Slicer.php#L30-L48
Velliz/pte
lib/slicer/Slicer.php
Slicer.PregCapture
private function PregCapture(&$template, &$output, &$position) { while (preg_match(ISlicer::PATTERN, $template, $result, PREG_OFFSET_CAPTURE, $position) > 0) { $capture = new PregOffsetCapture($result); $lex = array(); $lex['text'] = substr($template, $position, $capture->SliceBegin() - $position); $lex['start'] = $capture->SliceBegin(); $lex['end'] = $capture->SliceEnd(); $lex['length'] = $capture->SliceLength(); $lex['flag'] = $capture->Capture(ISlicer::FLAG); $lex['inverse'] = $capture->Capture(ISlicer::INVERSE); $lex['key'] = $capture->Capture(ISlicer::KEY); $lex['param'] = $capture->Capture(ISlicer::PARAMETER); $position = $lex['end']; if ($capture->Capture(ISlicer::FLAG) === ISlicer::C_CLOSE) { $output[] = $lex; break; } $a = $capture->Capture(ISlicer::BEFORE) === ISlicer::A; $b = $capture->Capture(ISlicer::AFTER) === ISlicer::H; if ($a && $b) { $this->PregCapture($template, $lex['child'], $position); } else { unset($lex['child']); } $output[] = $lex; } return $output; }
php
private function PregCapture(&$template, &$output, &$position) { while (preg_match(ISlicer::PATTERN, $template, $result, PREG_OFFSET_CAPTURE, $position) > 0) { $capture = new PregOffsetCapture($result); $lex = array(); $lex['text'] = substr($template, $position, $capture->SliceBegin() - $position); $lex['start'] = $capture->SliceBegin(); $lex['end'] = $capture->SliceEnd(); $lex['length'] = $capture->SliceLength(); $lex['flag'] = $capture->Capture(ISlicer::FLAG); $lex['inverse'] = $capture->Capture(ISlicer::INVERSE); $lex['key'] = $capture->Capture(ISlicer::KEY); $lex['param'] = $capture->Capture(ISlicer::PARAMETER); $position = $lex['end']; if ($capture->Capture(ISlicer::FLAG) === ISlicer::C_CLOSE) { $output[] = $lex; break; } $a = $capture->Capture(ISlicer::BEFORE) === ISlicer::A; $b = $capture->Capture(ISlicer::AFTER) === ISlicer::H; if ($a && $b) { $this->PregCapture($template, $lex['child'], $position); } else { unset($lex['child']); } $output[] = $lex; } return $output; }
[ "private", "function", "PregCapture", "(", "&", "$", "template", ",", "&", "$", "output", ",", "&", "$", "position", ")", "{", "while", "(", "preg_match", "(", "ISlicer", "::", "PATTERN", ",", "$", "template", ",", "$", "result", ",", "PREG_OFFSET_CAPTURE", ",", "$", "position", ")", ">", "0", ")", "{", "$", "capture", "=", "new", "PregOffsetCapture", "(", "$", "result", ")", ";", "$", "lex", "=", "array", "(", ")", ";", "$", "lex", "[", "'text'", "]", "=", "substr", "(", "$", "template", ",", "$", "position", ",", "$", "capture", "->", "SliceBegin", "(", ")", "-", "$", "position", ")", ";", "$", "lex", "[", "'start'", "]", "=", "$", "capture", "->", "SliceBegin", "(", ")", ";", "$", "lex", "[", "'end'", "]", "=", "$", "capture", "->", "SliceEnd", "(", ")", ";", "$", "lex", "[", "'length'", "]", "=", "$", "capture", "->", "SliceLength", "(", ")", ";", "$", "lex", "[", "'flag'", "]", "=", "$", "capture", "->", "Capture", "(", "ISlicer", "::", "FLAG", ")", ";", "$", "lex", "[", "'inverse'", "]", "=", "$", "capture", "->", "Capture", "(", "ISlicer", "::", "INVERSE", ")", ";", "$", "lex", "[", "'key'", "]", "=", "$", "capture", "->", "Capture", "(", "ISlicer", "::", "KEY", ")", ";", "$", "lex", "[", "'param'", "]", "=", "$", "capture", "->", "Capture", "(", "ISlicer", "::", "PARAMETER", ")", ";", "$", "position", "=", "$", "lex", "[", "'end'", "]", ";", "if", "(", "$", "capture", "->", "Capture", "(", "ISlicer", "::", "FLAG", ")", "===", "ISlicer", "::", "C_CLOSE", ")", "{", "$", "output", "[", "]", "=", "$", "lex", ";", "break", ";", "}", "$", "a", "=", "$", "capture", "->", "Capture", "(", "ISlicer", "::", "BEFORE", ")", "===", "ISlicer", "::", "A", ";", "$", "b", "=", "$", "capture", "->", "Capture", "(", "ISlicer", "::", "AFTER", ")", "===", "ISlicer", "::", "H", ";", "if", "(", "$", "a", "&&", "$", "b", ")", "{", "$", "this", "->", "PregCapture", "(", "$", "template", ",", "$", "lex", "[", "'child'", "]", ",", "$", "position", ")", ";", "}", "else", "{", "unset", "(", "$", "lex", "[", "'child'", "]", ")", ";", "}", "$", "output", "[", "]", "=", "$", "lex", ";", "}", "return", "$", "output", ";", "}" ]
@param $template @param $output @param $position @return array Converting html file into AST in PHP array
[ "@param", "$template", "@param", "$output", "@param", "$position", "@return", "array" ]
train
https://github.com/Velliz/pte/blob/8f8edc2289740d554a5942ff96eb727d838e866a/lib/slicer/Slicer.php#L58-L92
lukasz-adamski/teamspeak3-framework
src/TeamSpeak3.php
TeamSpeak3.getAdapterName
protected static function getAdapterName($name, $namespace = 'TeamSpeak3/Adapter') { $path = self::getFilePath($namespace); $scan = scandir($path); foreach($scan as $node) { $file = Str::factory($node)->toLower(); if ($file->startsWith($name) && $file->endsWith(".php")) { return str_replace('.php', '', "Adams\\TeamSpeak3\\Adapter\\" . $node); } } throw new AdapterException("adapter '" . $name . "' does not exist"); }
php
protected static function getAdapterName($name, $namespace = 'TeamSpeak3/Adapter') { $path = self::getFilePath($namespace); $scan = scandir($path); foreach($scan as $node) { $file = Str::factory($node)->toLower(); if ($file->startsWith($name) && $file->endsWith(".php")) { return str_replace('.php', '', "Adams\\TeamSpeak3\\Adapter\\" . $node); } } throw new AdapterException("adapter '" . $name . "' does not exist"); }
[ "protected", "static", "function", "getAdapterName", "(", "$", "name", ",", "$", "namespace", "=", "'TeamSpeak3/Adapter'", ")", "{", "$", "path", "=", "self", "::", "getFilePath", "(", "$", "namespace", ")", ";", "$", "scan", "=", "scandir", "(", "$", "path", ")", ";", "foreach", "(", "$", "scan", "as", "$", "node", ")", "{", "$", "file", "=", "Str", "::", "factory", "(", "$", "node", ")", "->", "toLower", "(", ")", ";", "if", "(", "$", "file", "->", "startsWith", "(", "$", "name", ")", "&&", "$", "file", "->", "endsWith", "(", "\".php\"", ")", ")", "{", "return", "str_replace", "(", "'.php'", ",", "''", ",", "\"Adams\\\\TeamSpeak3\\\\Adapter\\\\\"", ".", "$", "node", ")", ";", "}", "}", "throw", "new", "AdapterException", "(", "\"adapter '\"", ".", "$", "name", ".", "\"' does not exist\"", ")", ";", "}" ]
Returns the name of an adapter class by $name. @param string $name @param string $namespace @throws AdapterException @return string
[ "Returns", "the", "name", "of", "an", "adapter", "class", "by", "$name", "." ]
train
https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3.php#L447-L462
novaway/open-graph
src/Metadata/ClassMetadata.php
ClassMetadata.addGraphMetadata
public function addGraphMetadata(GraphNode $node, GraphMetadataInterface $data) { $this->nodes[] = [ 'node' => $node, 'object' => $data, ]; return $this; }
php
public function addGraphMetadata(GraphNode $node, GraphMetadataInterface $data) { $this->nodes[] = [ 'node' => $node, 'object' => $data, ]; return $this; }
[ "public", "function", "addGraphMetadata", "(", "GraphNode", "$", "node", ",", "GraphMetadataInterface", "$", "data", ")", "{", "$", "this", "->", "nodes", "[", "]", "=", "[", "'node'", "=>", "$", "node", ",", "'object'", "=>", "$", "data", ",", "]", ";", "return", "$", "this", ";", "}" ]
Add OpenGraph metadata @param GraphNode $type @param GraphMetadataInterface $data @return ClassMetadata
[ "Add", "OpenGraph", "metadata" ]
train
https://github.com/novaway/open-graph/blob/19817bee4b91cf26ca3fe44883ad58b32328e464/src/Metadata/ClassMetadata.php#L51-L59
blast-project/BaseEntitiesBundle
src/Entity/Repository/TreeableRepository.php
TreeableRepository.getRootNodesWithTree
public function getRootNodesWithTree() { // $all = $this->findAll(); $all = $this->findBy([], ['sortMaterializedPath' => 'ASC']); $allRootNodes = array(); foreach ($all as $node) { if ($node->isRootNode()) { $allRootNodes[] = $node; } } foreach ($allRootNodes as $root) { $root->buildTree($all); } return $allRootNodes; }
php
public function getRootNodesWithTree() { // $all = $this->findAll(); $all = $this->findBy([], ['sortMaterializedPath' => 'ASC']); $allRootNodes = array(); foreach ($all as $node) { if ($node->isRootNode()) { $allRootNodes[] = $node; } } foreach ($allRootNodes as $root) { $root->buildTree($all); } return $allRootNodes; }
[ "public", "function", "getRootNodesWithTree", "(", ")", "{", "// $all = $this->findAll();", "$", "all", "=", "$", "this", "->", "findBy", "(", "[", "]", ",", "[", "'sortMaterializedPath'", "=>", "'ASC'", "]", ")", ";", "$", "allRootNodes", "=", "array", "(", ")", ";", "foreach", "(", "$", "all", "as", "$", "node", ")", "{", "if", "(", "$", "node", "->", "isRootNode", "(", ")", ")", "{", "$", "allRootNodes", "[", "]", "=", "$", "node", ";", "}", "}", "foreach", "(", "$", "allRootNodes", "as", "$", "root", ")", "{", "$", "root", "->", "buildTree", "(", "$", "all", ")", ";", "}", "return", "$", "allRootNodes", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/Entity/Repository/TreeableRepository.php#L24-L40
expectation-php/expect
src/matcher/ToBeFalsey.php
ToBeFalsey.match
public function match($actual) { $this->actual = $actual; $truthyMatcher = new TruthyMatcher(); return $truthyMatcher->match($actual) === false; }
php
public function match($actual) { $this->actual = $actual; $truthyMatcher = new TruthyMatcher(); return $truthyMatcher->match($actual) === false; }
[ "public", "function", "match", "(", "$", "actual", ")", "{", "$", "this", "->", "actual", "=", "$", "actual", ";", "$", "truthyMatcher", "=", "new", "TruthyMatcher", "(", ")", ";", "return", "$", "truthyMatcher", "->", "match", "(", "$", "actual", ")", "===", "false", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToBeFalsey.php#L25-L32
shtrihstr/simple-rest-api
src/Router.php
Router.get
public function get( $path, callable $callback ) { $route = new Route( 'GET', $path, $callback ); $this->_routes[] = $route; return $route; }
php
public function get( $path, callable $callback ) { $route = new Route( 'GET', $path, $callback ); $this->_routes[] = $route; return $route; }
[ "public", "function", "get", "(", "$", "path", ",", "callable", "$", "callback", ")", "{", "$", "route", "=", "new", "Route", "(", "'GET'", ",", "$", "path", ",", "$", "callback", ")", ";", "$", "this", "->", "_routes", "[", "]", "=", "$", "route", ";", "return", "$", "route", ";", "}" ]
Maps a GET request to a callable. @param string $path Matched route path @param callable $callback Callback that returns the response when matched @return Route
[ "Maps", "a", "GET", "request", "to", "a", "callable", "." ]
train
https://github.com/shtrihstr/simple-rest-api/blob/e59c87a604065525729486de3081d4a44aa2468e/src/Router.php#L45-L49
shtrihstr/simple-rest-api
src/Router.php
Router.post
public function post( $path, callable $callback ) { $route = new Route( 'POST', $path, $callback ); $this->_routes[] = $route; return $route; }
php
public function post( $path, callable $callback ) { $route = new Route( 'POST', $path, $callback ); $this->_routes[] = $route; return $route; }
[ "public", "function", "post", "(", "$", "path", ",", "callable", "$", "callback", ")", "{", "$", "route", "=", "new", "Route", "(", "'POST'", ",", "$", "path", ",", "$", "callback", ")", ";", "$", "this", "->", "_routes", "[", "]", "=", "$", "route", ";", "return", "$", "route", ";", "}" ]
Maps a POST request to a callable. @param string $path Matched route path @param callable $callback Callback that returns the response when matched @return Route
[ "Maps", "a", "POST", "request", "to", "a", "callable", "." ]
train
https://github.com/shtrihstr/simple-rest-api/blob/e59c87a604065525729486de3081d4a44aa2468e/src/Router.php#L58-L62
shtrihstr/simple-rest-api
src/Router.php
Router.put
public function put( $path, callable $callback ) { $route = new Route( 'PUT', $path, $callback ); $this->_routes[] = $route; return $route; }
php
public function put( $path, callable $callback ) { $route = new Route( 'PUT', $path, $callback ); $this->_routes[] = $route; return $route; }
[ "public", "function", "put", "(", "$", "path", ",", "callable", "$", "callback", ")", "{", "$", "route", "=", "new", "Route", "(", "'PUT'", ",", "$", "path", ",", "$", "callback", ")", ";", "$", "this", "->", "_routes", "[", "]", "=", "$", "route", ";", "return", "$", "route", ";", "}" ]
Maps a PUT request to a callable. @param string $path Matched route path @param callable $callback Callback that returns the response when matched @return Route
[ "Maps", "a", "PUT", "request", "to", "a", "callable", "." ]
train
https://github.com/shtrihstr/simple-rest-api/blob/e59c87a604065525729486de3081d4a44aa2468e/src/Router.php#L71-L75
shtrihstr/simple-rest-api
src/Router.php
Router.patch
public function patch( $path, callable $callback ) { $route = new Route( 'PATCH', $path, $callback ); $this->_routes[] = $route; return $route; }
php
public function patch( $path, callable $callback ) { $route = new Route( 'PATCH', $path, $callback ); $this->_routes[] = $route; return $route; }
[ "public", "function", "patch", "(", "$", "path", ",", "callable", "$", "callback", ")", "{", "$", "route", "=", "new", "Route", "(", "'PATCH'", ",", "$", "path", ",", "$", "callback", ")", ";", "$", "this", "->", "_routes", "[", "]", "=", "$", "route", ";", "return", "$", "route", ";", "}" ]
Maps a PATCH request to a callable. @param string $path Matched route path @param callable $callback Callback that returns the response when matched @return Route
[ "Maps", "a", "PATCH", "request", "to", "a", "callable", "." ]
train
https://github.com/shtrihstr/simple-rest-api/blob/e59c87a604065525729486de3081d4a44aa2468e/src/Router.php#L84-L88
shtrihstr/simple-rest-api
src/Router.php
Router.delete
public function delete( $path, callable $callback ) { $route = new Route( 'DELETE', $path, $callback ); $this->_routes[] = $route; return $route; }
php
public function delete( $path, callable $callback ) { $route = new Route( 'DELETE', $path, $callback ); $this->_routes[] = $route; return $route; }
[ "public", "function", "delete", "(", "$", "path", ",", "callable", "$", "callback", ")", "{", "$", "route", "=", "new", "Route", "(", "'DELETE'", ",", "$", "path", ",", "$", "callback", ")", ";", "$", "this", "->", "_routes", "[", "]", "=", "$", "route", ";", "return", "$", "route", ";", "}" ]
Maps a DELETE request to a callable. @param string $path Matched route path @param callable $callback Callback that returns the response when matched @return Route
[ "Maps", "a", "DELETE", "request", "to", "a", "callable", "." ]
train
https://github.com/shtrihstr/simple-rest-api/blob/e59c87a604065525729486de3081d4a44aa2468e/src/Router.php#L97-L101
shtrihstr/simple-rest-api
src/Router.php
Router.match
public function match( $method, $path, callable $callback ) { $route = new Route( mb_strtoupper( $method ), $path, $callback ); $this->_routes[] = $route; return $route; }
php
public function match( $method, $path, callable $callback ) { $route = new Route( mb_strtoupper( $method ), $path, $callback ); $this->_routes[] = $route; return $route; }
[ "public", "function", "match", "(", "$", "method", ",", "$", "path", ",", "callable", "$", "callback", ")", "{", "$", "route", "=", "new", "Route", "(", "mb_strtoupper", "(", "$", "method", ")", ",", "$", "path", ",", "$", "callback", ")", ";", "$", "this", "->", "_routes", "[", "]", "=", "$", "route", ";", "return", "$", "route", ";", "}" ]
Maps a request to a callable. @param string $method Request method @param string $path Matched route path @param callable $callback Callback that returns the response when matched @return Route
[ "Maps", "a", "request", "to", "a", "callable", "." ]
train
https://github.com/shtrihstr/simple-rest-api/blob/e59c87a604065525729486de3081d4a44aa2468e/src/Router.php#L111-L115
GrupaZero/api
src/Gzero/Api/Controller/User/AccountController.php
AccountController.update
public function update(Request $request) { if (!$request->has('password')) { $this->validator->setData($request->except(['password', 'password_confirmation'])); } $user = $this->userRepo->getById($request->user()->id); $this->authorize('update', $user); $input = $this->validator->bind('nick', ['user_id' => $user->id])->bind('email', ['user_id' => $user->id]) ->validate('update'); $user = $this->userRepo->update($user, $input); return $this->respondWithSuccess($user, new UserTransformer()); }
php
public function update(Request $request) { if (!$request->has('password')) { $this->validator->setData($request->except(['password', 'password_confirmation'])); } $user = $this->userRepo->getById($request->user()->id); $this->authorize('update', $user); $input = $this->validator->bind('nick', ['user_id' => $user->id])->bind('email', ['user_id' => $user->id]) ->validate('update'); $user = $this->userRepo->update($user, $input); return $this->respondWithSuccess($user, new UserTransformer()); }
[ "public", "function", "update", "(", "Request", "$", "request", ")", "{", "if", "(", "!", "$", "request", "->", "has", "(", "'password'", ")", ")", "{", "$", "this", "->", "validator", "->", "setData", "(", "$", "request", "->", "except", "(", "[", "'password'", ",", "'password_confirmation'", "]", ")", ")", ";", "}", "$", "user", "=", "$", "this", "->", "userRepo", "->", "getById", "(", "$", "request", "->", "user", "(", ")", "->", "id", ")", ";", "$", "this", "->", "authorize", "(", "'update'", ",", "$", "user", ")", ";", "$", "input", "=", "$", "this", "->", "validator", "->", "bind", "(", "'nick'", ",", "[", "'user_id'", "=>", "$", "user", "->", "id", "]", ")", "->", "bind", "(", "'email'", ",", "[", "'user_id'", "=>", "$", "user", "->", "id", "]", ")", "->", "validate", "(", "'update'", ")", ";", "$", "user", "=", "$", "this", "->", "userRepo", "->", "update", "(", "$", "user", ",", "$", "input", ")", ";", "return", "$", "this", "->", "respondWithSuccess", "(", "$", "user", ",", "new", "UserTransformer", "(", ")", ")", ";", "}" ]
Updates the specified resource in the database. @param Request $request Request object @return \Illuminate\Http\JsonResponse
[ "Updates", "the", "specified", "resource", "in", "the", "database", "." ]
train
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/User/AccountController.php#L51-L63
infinity-next/sleuth
src/Traits/DetectiveTrait.php
DetectiveTrait.check
public function check($file, $verify = null) { if ($this->prepareFile($file)) { $leads = $this->leads(); if (!is_null($verify)) { if (isset($leads[$verify])) { return $this->checkLead($leads[$verify]); } return false; } else { foreach ($leads as $lead) { $results = $this->checkLead($lead); // We're sure we've found something. if ($results === true) { return true; } // We're sure this detective can find nothing. else if ($results === false) { break; } } } } return false; }
php
public function check($file, $verify = null) { if ($this->prepareFile($file)) { $leads = $this->leads(); if (!is_null($verify)) { if (isset($leads[$verify])) { return $this->checkLead($leads[$verify]); } return false; } else { foreach ($leads as $lead) { $results = $this->checkLead($lead); // We're sure we've found something. if ($results === true) { return true; } // We're sure this detective can find nothing. else if ($results === false) { break; } } } } return false; }
[ "public", "function", "check", "(", "$", "file", ",", "$", "verify", "=", "null", ")", "{", "if", "(", "$", "this", "->", "prepareFile", "(", "$", "file", ")", ")", "{", "$", "leads", "=", "$", "this", "->", "leads", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "verify", ")", ")", "{", "if", "(", "isset", "(", "$", "leads", "[", "$", "verify", "]", ")", ")", "{", "return", "$", "this", "->", "checkLead", "(", "$", "leads", "[", "$", "verify", "]", ")", ";", "}", "return", "false", ";", "}", "else", "{", "foreach", "(", "$", "leads", "as", "$", "lead", ")", "{", "$", "results", "=", "$", "this", "->", "checkLead", "(", "$", "lead", ")", ";", "// We're sure we've found something.\r", "if", "(", "$", "results", "===", "true", ")", "{", "return", "true", ";", "}", "// We're sure this detective can find nothing.\r", "else", "if", "(", "$", "results", "===", "false", ")", "{", "break", ";", "}", "}", "}", "}", "return", "false", ";", "}" ]
Check the the file against our leads. @param mixed $file File to check. @param string|null $verify Extension to verify against. Checks all possible if unset. @return boolean True if we solved the case, false if not.
[ "Check", "the", "the", "file", "against", "our", "leads", "." ]
train
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Traits/DetectiveTrait.php#L63-L99
infinity-next/sleuth
src/Traits/DetectiveTrait.php
DetectiveTrait.closeCase
protected function closeCase($ext, $mime, array $meta = array()) { $this->caseClosed = true; $this->extension = $ext; $this->mime = $mime; $this->metadata = $meta; return true; }
php
protected function closeCase($ext, $mime, array $meta = array()) { $this->caseClosed = true; $this->extension = $ext; $this->mime = $mime; $this->metadata = $meta; return true; }
[ "protected", "function", "closeCase", "(", "$", "ext", ",", "$", "mime", ",", "array", "$", "meta", "=", "array", "(", ")", ")", "{", "$", "this", "->", "caseClosed", "=", "true", ";", "$", "this", "->", "extension", "=", "$", "ext", ";", "$", "this", "->", "mime", "=", "$", "mime", ";", "$", "this", "->", "metadata", "=", "$", "meta", ";", "return", "true", ";", "}" ]
Closes the case by setting protected properties. @param string $ext File extension. @param string $mime Mime type. @param array $meta Meta data, optional. Must be array. @return boolean
[ "Closes", "the", "case", "by", "setting", "protected", "properties", "." ]
train
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Traits/DetectiveTrait.php#L120-L127
infinity-next/sleuth
src/Traits/DetectiveTrait.php
DetectiveTrait.leads
protected function leads() { // Pull a list of methods that have the leadEXT syntax. $leads = preg_grep('/^lead(?<ext>[A-Z0-9]+)$/', get_class_methods($this)); // Organize them as an array where keys and values are the same thing. $leads = array_combine($leads, $leads); // Try to find an extension method from our file. $ext = "lead" . strtoupper(pathinfo($this->file, PATHINFO_EXTENSION)); // If that method exists, // bring it to the front of the array so that it is checked first. if (isset($leads[$ext])) { $newLeads = [ $ext => $leads[$ext] ]; unset($leads[$ext]); $newLeads += $leads; $leads = $newLeads; unset($newleads); } return $leads; }
php
protected function leads() { // Pull a list of methods that have the leadEXT syntax. $leads = preg_grep('/^lead(?<ext>[A-Z0-9]+)$/', get_class_methods($this)); // Organize them as an array where keys and values are the same thing. $leads = array_combine($leads, $leads); // Try to find an extension method from our file. $ext = "lead" . strtoupper(pathinfo($this->file, PATHINFO_EXTENSION)); // If that method exists, // bring it to the front of the array so that it is checked first. if (isset($leads[$ext])) { $newLeads = [ $ext => $leads[$ext] ]; unset($leads[$ext]); $newLeads += $leads; $leads = $newLeads; unset($newleads); } return $leads; }
[ "protected", "function", "leads", "(", ")", "{", "// Pull a list of methods that have the leadEXT syntax.\r", "$", "leads", "=", "preg_grep", "(", "'/^lead(?<ext>[A-Z0-9]+)$/'", ",", "get_class_methods", "(", "$", "this", ")", ")", ";", "// Organize them as an array where keys and values are the same thing.\r", "$", "leads", "=", "array_combine", "(", "$", "leads", ",", "$", "leads", ")", ";", "// Try to find an extension method from our file.\r", "$", "ext", "=", "\"lead\"", ".", "strtoupper", "(", "pathinfo", "(", "$", "this", "->", "file", ",", "PATHINFO_EXTENSION", ")", ")", ";", "// If that method exists,\r", "// bring it to the front of the array so that it is checked first.\r", "if", "(", "isset", "(", "$", "leads", "[", "$", "ext", "]", ")", ")", "{", "$", "newLeads", "=", "[", "$", "ext", "=>", "$", "leads", "[", "$", "ext", "]", "]", ";", "unset", "(", "$", "leads", "[", "$", "ext", "]", ")", ";", "$", "newLeads", "+=", "$", "leads", ";", "$", "leads", "=", "$", "newLeads", ";", "unset", "(", "$", "newleads", ")", ";", "}", "return", "$", "leads", ";", "}" ]
Returns an array of file extensions this detective has leads on. @return array Of file extensions.
[ "Returns", "an", "array", "of", "file", "extensions", "this", "detective", "has", "leads", "on", "." ]
train
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Traits/DetectiveTrait.php#L229-L250
tompedals/radish
src/Consumer/Poller.php
Poller.consume
public function consume() { if ($this->logger) { $this->logger->debug('Starting poller'); } foreach ($this->middlewares as $middleware) { if ($middleware instanceof InitializableInterface) { $middleware->initialize(); } } while (true) { if ($this->process() === false) { break; } if ($this->sleep() === false) { break; } } if ($this->logger) { $this->logger->debug('Stopping poller'); } }
php
public function consume() { if ($this->logger) { $this->logger->debug('Starting poller'); } foreach ($this->middlewares as $middleware) { if ($middleware instanceof InitializableInterface) { $middleware->initialize(); } } while (true) { if ($this->process() === false) { break; } if ($this->sleep() === false) { break; } } if ($this->logger) { $this->logger->debug('Stopping poller'); } }
[ "public", "function", "consume", "(", ")", "{", "if", "(", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Starting poller'", ")", ";", "}", "foreach", "(", "$", "this", "->", "middlewares", "as", "$", "middleware", ")", "{", "if", "(", "$", "middleware", "instanceof", "InitializableInterface", ")", "{", "$", "middleware", "->", "initialize", "(", ")", ";", "}", "}", "while", "(", "true", ")", "{", "if", "(", "$", "this", "->", "process", "(", ")", "===", "false", ")", "{", "break", ";", "}", "if", "(", "$", "this", "->", "sleep", "(", ")", "===", "false", ")", "{", "break", ";", "}", "}", "if", "(", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'Stopping poller'", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/tompedals/radish/blob/7728567ae6226a5e3f627116118198b22d1b507d/src/Consumer/Poller.php#L41-L66
eghojansu/moe
src/Cache.php
Cache.reset
function reset($suffix=NULL,$lifetime=0) { if (!$this->dsn) return TRUE; $regex='/'.preg_quote($this->prefix.'.','/').'.+?'. preg_quote($suffix,'/').'/'; $parts=explode('=',$this->dsn,2); switch ($parts[0]) { case 'apc': case 'apcu': $info=apc_cache_info('user'); if (!empty($info['cache_list'])) { $key=array_key_exists('info',$info['cache_list'][0])?'info':'key'; $mtkey=array_key_exists('mtime',$info['cache_list'][0])? 'mtime':'modification_time'; foreach ($info['cache_list'] as $item) if (preg_match($regex,$item[$key]) && $item[$mtkey]+$lifetime<time()) apc_delete($item[$key]); } return TRUE; case 'redis': $fw=Base::instance(); $keys=$this->ref->keys($this->prefix.'.*'.$suffix); foreach($keys as $key) { $val=$fw->unserialize($this->ref->get($key)); if ($val[1]+$lifetime<time()) $this->ref->del($key); } return TRUE; case 'memcache': foreach (memcache_get_extended_stats( $this->ref,'slabs') as $slabs) foreach (array_filter(array_keys($slabs),'is_numeric') as $id) foreach (memcache_get_extended_stats( $this->ref,'cachedump',$id) as $data) if (is_array($data)) foreach ($data as $key=>$val) if (preg_match($regex,$key) && $val[1]+$lifetime<time()) memcache_delete($this->ref,$key); return TRUE; case 'wincache': $info=wincache_ucache_info(); foreach ($info['ucache_entries'] as $item) if (preg_match($regex,$item['key_name']) && $item['use_time']+$lifetime<time()) wincache_ucache_delete($item['key_name']); return TRUE; case 'xcache': return TRUE; /* Not supported */ case 'folder': if ($glob=@glob($parts[1].'*')) foreach ($glob as $file) if (preg_match($regex,basename($file)) && filemtime($file)+$lifetime<time()) @unlink($file); return TRUE; } return FALSE; }
php
function reset($suffix=NULL,$lifetime=0) { if (!$this->dsn) return TRUE; $regex='/'.preg_quote($this->prefix.'.','/').'.+?'. preg_quote($suffix,'/').'/'; $parts=explode('=',$this->dsn,2); switch ($parts[0]) { case 'apc': case 'apcu': $info=apc_cache_info('user'); if (!empty($info['cache_list'])) { $key=array_key_exists('info',$info['cache_list'][0])?'info':'key'; $mtkey=array_key_exists('mtime',$info['cache_list'][0])? 'mtime':'modification_time'; foreach ($info['cache_list'] as $item) if (preg_match($regex,$item[$key]) && $item[$mtkey]+$lifetime<time()) apc_delete($item[$key]); } return TRUE; case 'redis': $fw=Base::instance(); $keys=$this->ref->keys($this->prefix.'.*'.$suffix); foreach($keys as $key) { $val=$fw->unserialize($this->ref->get($key)); if ($val[1]+$lifetime<time()) $this->ref->del($key); } return TRUE; case 'memcache': foreach (memcache_get_extended_stats( $this->ref,'slabs') as $slabs) foreach (array_filter(array_keys($slabs),'is_numeric') as $id) foreach (memcache_get_extended_stats( $this->ref,'cachedump',$id) as $data) if (is_array($data)) foreach ($data as $key=>$val) if (preg_match($regex,$key) && $val[1]+$lifetime<time()) memcache_delete($this->ref,$key); return TRUE; case 'wincache': $info=wincache_ucache_info(); foreach ($info['ucache_entries'] as $item) if (preg_match($regex,$item['key_name']) && $item['use_time']+$lifetime<time()) wincache_ucache_delete($item['key_name']); return TRUE; case 'xcache': return TRUE; /* Not supported */ case 'folder': if ($glob=@glob($parts[1].'*')) foreach ($glob as $file) if (preg_match($regex,basename($file)) && filemtime($file)+$lifetime<time()) @unlink($file); return TRUE; } return FALSE; }
[ "function", "reset", "(", "$", "suffix", "=", "NULL", ",", "$", "lifetime", "=", "0", ")", "{", "if", "(", "!", "$", "this", "->", "dsn", ")", "return", "TRUE", ";", "$", "regex", "=", "'/'", ".", "preg_quote", "(", "$", "this", "->", "prefix", ".", "'.'", ",", "'/'", ")", ".", "'.+?'", ".", "preg_quote", "(", "$", "suffix", ",", "'/'", ")", ".", "'/'", ";", "$", "parts", "=", "explode", "(", "'='", ",", "$", "this", "->", "dsn", ",", "2", ")", ";", "switch", "(", "$", "parts", "[", "0", "]", ")", "{", "case", "'apc'", ":", "case", "'apcu'", ":", "$", "info", "=", "apc_cache_info", "(", "'user'", ")", ";", "if", "(", "!", "empty", "(", "$", "info", "[", "'cache_list'", "]", ")", ")", "{", "$", "key", "=", "array_key_exists", "(", "'info'", ",", "$", "info", "[", "'cache_list'", "]", "[", "0", "]", ")", "?", "'info'", ":", "'key'", ";", "$", "mtkey", "=", "array_key_exists", "(", "'mtime'", ",", "$", "info", "[", "'cache_list'", "]", "[", "0", "]", ")", "?", "'mtime'", ":", "'modification_time'", ";", "foreach", "(", "$", "info", "[", "'cache_list'", "]", "as", "$", "item", ")", "if", "(", "preg_match", "(", "$", "regex", ",", "$", "item", "[", "$", "key", "]", ")", "&&", "$", "item", "[", "$", "mtkey", "]", "+", "$", "lifetime", "<", "time", "(", ")", ")", "apc_delete", "(", "$", "item", "[", "$", "key", "]", ")", ";", "}", "return", "TRUE", ";", "case", "'redis'", ":", "$", "fw", "=", "Base", "::", "instance", "(", ")", ";", "$", "keys", "=", "$", "this", "->", "ref", "->", "keys", "(", "$", "this", "->", "prefix", ".", "'.*'", ".", "$", "suffix", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "val", "=", "$", "fw", "->", "unserialize", "(", "$", "this", "->", "ref", "->", "get", "(", "$", "key", ")", ")", ";", "if", "(", "$", "val", "[", "1", "]", "+", "$", "lifetime", "<", "time", "(", ")", ")", "$", "this", "->", "ref", "->", "del", "(", "$", "key", ")", ";", "}", "return", "TRUE", ";", "case", "'memcache'", ":", "foreach", "(", "memcache_get_extended_stats", "(", "$", "this", "->", "ref", ",", "'slabs'", ")", "as", "$", "slabs", ")", "foreach", "(", "array_filter", "(", "array_keys", "(", "$", "slabs", ")", ",", "'is_numeric'", ")", "as", "$", "id", ")", "foreach", "(", "memcache_get_extended_stats", "(", "$", "this", "->", "ref", ",", "'cachedump'", ",", "$", "id", ")", "as", "$", "data", ")", "if", "(", "is_array", "(", "$", "data", ")", ")", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "val", ")", "if", "(", "preg_match", "(", "$", "regex", ",", "$", "key", ")", "&&", "$", "val", "[", "1", "]", "+", "$", "lifetime", "<", "time", "(", ")", ")", "memcache_delete", "(", "$", "this", "->", "ref", ",", "$", "key", ")", ";", "return", "TRUE", ";", "case", "'wincache'", ":", "$", "info", "=", "wincache_ucache_info", "(", ")", ";", "foreach", "(", "$", "info", "[", "'ucache_entries'", "]", "as", "$", "item", ")", "if", "(", "preg_match", "(", "$", "regex", ",", "$", "item", "[", "'key_name'", "]", ")", "&&", "$", "item", "[", "'use_time'", "]", "+", "$", "lifetime", "<", "time", "(", ")", ")", "wincache_ucache_delete", "(", "$", "item", "[", "'key_name'", "]", ")", ";", "return", "TRUE", ";", "case", "'xcache'", ":", "return", "TRUE", ";", "/* Not supported */", "case", "'folder'", ":", "if", "(", "$", "glob", "=", "@", "glob", "(", "$", "parts", "[", "1", "]", ".", "'*'", ")", ")", "foreach", "(", "$", "glob", "as", "$", "file", ")", "if", "(", "preg_match", "(", "$", "regex", ",", "basename", "(", "$", "file", ")", ")", "&&", "filemtime", "(", "$", "file", ")", "+", "$", "lifetime", "<", "time", "(", ")", ")", "@", "unlink", "(", "$", "file", ")", ";", "return", "TRUE", ";", "}", "return", "FALSE", ";", "}" ]
Clear contents of cache backend @return bool @param $suffix string @param $lifetime int
[ "Clear", "contents", "of", "cache", "backend" ]
train
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/Cache.php#L137-L197
eghojansu/moe
src/Cache.php
Cache.load
function load($dsn) { $fw=Base::instance(); if ($dsn=trim($dsn)) { if (preg_match('/^redis=(.+)/',$dsn,$parts) && extension_loaded('redis')) { $port=6379; $parts=explode(':',$parts[1],2); if (count($parts)>1) list($host,$port)=$parts; else $host=$parts[0]; $this->ref=new Redis; if(!$this->ref->connect($host,$port,2)) $this->ref=NULL; } elseif (preg_match('/^memcache=(.+)/',$dsn,$parts) && extension_loaded('memcache')) foreach ($fw->split($parts[1]) as $server) { $port=11211; $parts=explode(':',$server,2); if (count($parts)>1) list($host,$port)=$parts; else $host=$parts[0]; if (empty($this->ref)) $this->ref=@memcache_connect($host,$port)?:NULL; else memcache_add_server($this->ref,$host,$port); } if (empty($this->ref) && !preg_match('/^folder\h*=/',$dsn)) $dsn=($grep=preg_grep('/^(apc|wincache|xcache)/', array_map('strtolower',get_loaded_extensions())))? // Auto-detect current($grep): // Use filesystem as fallback ('folder='.$fw->get('TEMP').'cache/'); if (preg_match('/^folder\h*=\h*(.+)/',$dsn,$parts) && !is_dir($parts[1])) mkdir($parts[1],Base::MODE,TRUE); } $this->prefix=$fw->hash($_SERVER['SERVER_NAME'].$fw->get('BASE')); return $this->dsn=$dsn; }
php
function load($dsn) { $fw=Base::instance(); if ($dsn=trim($dsn)) { if (preg_match('/^redis=(.+)/',$dsn,$parts) && extension_loaded('redis')) { $port=6379; $parts=explode(':',$parts[1],2); if (count($parts)>1) list($host,$port)=$parts; else $host=$parts[0]; $this->ref=new Redis; if(!$this->ref->connect($host,$port,2)) $this->ref=NULL; } elseif (preg_match('/^memcache=(.+)/',$dsn,$parts) && extension_loaded('memcache')) foreach ($fw->split($parts[1]) as $server) { $port=11211; $parts=explode(':',$server,2); if (count($parts)>1) list($host,$port)=$parts; else $host=$parts[0]; if (empty($this->ref)) $this->ref=@memcache_connect($host,$port)?:NULL; else memcache_add_server($this->ref,$host,$port); } if (empty($this->ref) && !preg_match('/^folder\h*=/',$dsn)) $dsn=($grep=preg_grep('/^(apc|wincache|xcache)/', array_map('strtolower',get_loaded_extensions())))? // Auto-detect current($grep): // Use filesystem as fallback ('folder='.$fw->get('TEMP').'cache/'); if (preg_match('/^folder\h*=\h*(.+)/',$dsn,$parts) && !is_dir($parts[1])) mkdir($parts[1],Base::MODE,TRUE); } $this->prefix=$fw->hash($_SERVER['SERVER_NAME'].$fw->get('BASE')); return $this->dsn=$dsn; }
[ "function", "load", "(", "$", "dsn", ")", "{", "$", "fw", "=", "Base", "::", "instance", "(", ")", ";", "if", "(", "$", "dsn", "=", "trim", "(", "$", "dsn", ")", ")", "{", "if", "(", "preg_match", "(", "'/^redis=(.+)/'", ",", "$", "dsn", ",", "$", "parts", ")", "&&", "extension_loaded", "(", "'redis'", ")", ")", "{", "$", "port", "=", "6379", ";", "$", "parts", "=", "explode", "(", "':'", ",", "$", "parts", "[", "1", "]", ",", "2", ")", ";", "if", "(", "count", "(", "$", "parts", ")", ">", "1", ")", "list", "(", "$", "host", ",", "$", "port", ")", "=", "$", "parts", ";", "else", "$", "host", "=", "$", "parts", "[", "0", "]", ";", "$", "this", "->", "ref", "=", "new", "Redis", ";", "if", "(", "!", "$", "this", "->", "ref", "->", "connect", "(", "$", "host", ",", "$", "port", ",", "2", ")", ")", "$", "this", "->", "ref", "=", "NULL", ";", "}", "elseif", "(", "preg_match", "(", "'/^memcache=(.+)/'", ",", "$", "dsn", ",", "$", "parts", ")", "&&", "extension_loaded", "(", "'memcache'", ")", ")", "foreach", "(", "$", "fw", "->", "split", "(", "$", "parts", "[", "1", "]", ")", "as", "$", "server", ")", "{", "$", "port", "=", "11211", ";", "$", "parts", "=", "explode", "(", "':'", ",", "$", "server", ",", "2", ")", ";", "if", "(", "count", "(", "$", "parts", ")", ">", "1", ")", "list", "(", "$", "host", ",", "$", "port", ")", "=", "$", "parts", ";", "else", "$", "host", "=", "$", "parts", "[", "0", "]", ";", "if", "(", "empty", "(", "$", "this", "->", "ref", ")", ")", "$", "this", "->", "ref", "=", "@", "memcache_connect", "(", "$", "host", ",", "$", "port", ")", "?", ":", "NULL", ";", "else", "memcache_add_server", "(", "$", "this", "->", "ref", ",", "$", "host", ",", "$", "port", ")", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "ref", ")", "&&", "!", "preg_match", "(", "'/^folder\\h*=/'", ",", "$", "dsn", ")", ")", "$", "dsn", "=", "(", "$", "grep", "=", "preg_grep", "(", "'/^(apc|wincache|xcache)/'", ",", "array_map", "(", "'strtolower'", ",", "get_loaded_extensions", "(", ")", ")", ")", ")", "?", "// Auto-detect", "current", "(", "$", "grep", ")", ":", "// Use filesystem as fallback", "(", "'folder='", ".", "$", "fw", "->", "get", "(", "'TEMP'", ")", ".", "'cache/'", ")", ";", "if", "(", "preg_match", "(", "'/^folder\\h*=\\h*(.+)/'", ",", "$", "dsn", ",", "$", "parts", ")", "&&", "!", "is_dir", "(", "$", "parts", "[", "1", "]", ")", ")", "mkdir", "(", "$", "parts", "[", "1", "]", ",", "Base", "::", "MODE", ",", "TRUE", ")", ";", "}", "$", "this", "->", "prefix", "=", "$", "fw", "->", "hash", "(", "$", "_SERVER", "[", "'SERVER_NAME'", "]", ".", "$", "fw", "->", "get", "(", "'BASE'", ")", ")", ";", "return", "$", "this", "->", "dsn", "=", "$", "dsn", ";", "}" ]
Load/auto-detect cache backend @return string @param $dsn bool|string
[ "Load", "/", "auto", "-", "detect", "cache", "backend" ]
train
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/Cache.php#L204-L246
FrenzelGmbH/cm-address
controllers/base/CountryController.php
CountryController.actionIndex
public function actionIndex() { $searchModel = new CountrySearch; $dataProvider = $searchModel->search($_GET); Tabs::clearLocalStorage(); Url::remember(); \Yii::$app->session['__crudReturnUrl'] = null; return $this->render('index', [ 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); }
php
public function actionIndex() { $searchModel = new CountrySearch; $dataProvider = $searchModel->search($_GET); Tabs::clearLocalStorage(); Url::remember(); \Yii::$app->session['__crudReturnUrl'] = null; return $this->render('index', [ 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "searchModel", "=", "new", "CountrySearch", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "$", "_GET", ")", ";", "Tabs", "::", "clearLocalStorage", "(", ")", ";", "Url", "::", "remember", "(", ")", ";", "\\", "Yii", "::", "$", "app", "->", "session", "[", "'__crudReturnUrl'", "]", "=", "null", ";", "return", "$", "this", "->", "render", "(", "'index'", ",", "[", "'dataProvider'", "=>", "$", "dataProvider", ",", "'searchModel'", "=>", "$", "searchModel", ",", "]", ")", ";", "}" ]
Lists all Country models. @return mixed
[ "Lists", "all", "Country", "models", "." ]
train
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/base/CountryController.php#L33-L47
FrenzelGmbH/cm-address
controllers/base/CountryController.php
CountryController.actionView
public function actionView($id) { \Yii::$app->session['__crudReturnUrl'] = Url::previous(); Url::remember(); Tabs::rememberActiveState(); return $this->render('view', [ 'model' => $this->findModel($id), ]); }
php
public function actionView($id) { \Yii::$app->session['__crudReturnUrl'] = Url::previous(); Url::remember(); Tabs::rememberActiveState(); return $this->render('view', [ 'model' => $this->findModel($id), ]); }
[ "public", "function", "actionView", "(", "$", "id", ")", "{", "\\", "Yii", "::", "$", "app", "->", "session", "[", "'__crudReturnUrl'", "]", "=", "Url", "::", "previous", "(", ")", ";", "Url", "::", "remember", "(", ")", ";", "Tabs", "::", "rememberActiveState", "(", ")", ";", "return", "$", "this", "->", "render", "(", "'view'", ",", "[", "'model'", "=>", "$", "this", "->", "findModel", "(", "$", "id", ")", ",", "]", ")", ";", "}" ]
Displays a single Country model. @param integer $id @return mixed
[ "Displays", "a", "single", "Country", "model", ".", "@param", "integer", "$id" ]
train
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/base/CountryController.php#L55-L64
FrenzelGmbH/cm-address
controllers/base/CountryController.php
CountryController.actionCreate
public function actionCreate() { $model = new Country; try { if ($model->load($_POST) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } elseif (!\Yii::$app->request->isPost) { $model->load($_GET); } } catch (\Exception $e) { $msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage(); $model->addError('_exception', $msg); } return $this->render('create', ['model' => $model]); }
php
public function actionCreate() { $model = new Country; try { if ($model->load($_POST) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } elseif (!\Yii::$app->request->isPost) { $model->load($_GET); } } catch (\Exception $e) { $msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage(); $model->addError('_exception', $msg); } return $this->render('create', ['model' => $model]); }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "model", "=", "new", "Country", ";", "try", "{", "if", "(", "$", "model", "->", "load", "(", "$", "_POST", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "[", "'view'", ",", "'id'", "=>", "$", "model", "->", "id", "]", ")", ";", "}", "elseif", "(", "!", "\\", "Yii", "::", "$", "app", "->", "request", "->", "isPost", ")", "{", "$", "model", "->", "load", "(", "$", "_GET", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "msg", "=", "(", "isset", "(", "$", "e", "->", "errorInfo", "[", "2", "]", ")", ")", "?", "$", "e", "->", "errorInfo", "[", "2", "]", ":", "$", "e", "->", "getMessage", "(", ")", ";", "$", "model", "->", "addError", "(", "'_exception'", ",", "$", "msg", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'create'", ",", "[", "'model'", "=>", "$", "model", "]", ")", ";", "}" ]
Creates a new Country model. If creation is successful, the browser will be redirected to the 'view' page. @return mixed
[ "Creates", "a", "new", "Country", "model", ".", "If", "creation", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
train
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/base/CountryController.php#L71-L86
FrenzelGmbH/cm-address
controllers/base/CountryController.php
CountryController.actionUpdate
public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load($_POST) && $model->save()) { return $this->redirect(Url::previous()); } else { return $this->render('update', [ 'model' => $model, ]); } }
php
public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load($_POST) && $model->save()) { return $this->redirect(Url::previous()); } else { return $this->render('update', [ 'model' => $model, ]); } }
[ "public", "function", "actionUpdate", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "if", "(", "$", "model", "->", "load", "(", "$", "_POST", ")", "&&", "$", "model", "->", "save", "(", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "Url", "::", "previous", "(", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "render", "(", "'update'", ",", "[", "'model'", "=>", "$", "model", ",", "]", ")", ";", "}", "}" ]
Updates an existing Country model. If update is successful, the browser will be redirected to the 'view' page. @param integer $id @return mixed
[ "Updates", "an", "existing", "Country", "model", ".", "If", "update", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
train
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/base/CountryController.php#L94-L105
FrenzelGmbH/cm-address
controllers/base/CountryController.php
CountryController.actionDelete
public function actionDelete($id) { try { $this->findModel($id)->delete(); } catch (\Exception $e) { $msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage(); \Yii::$app->getSession()->addFlash('error', $msg); return $this->redirect(Url::previous()); } // TODO: improve detection $isPivot = strstr('$id',','); if ($isPivot == true) { return $this->redirect(Url::previous()); } elseif (isset(\Yii::$app->session['__crudReturnUrl']) && \Yii::$app->session['__crudReturnUrl'] != '/') { Url::remember(null); $url = \Yii::$app->session['__crudReturnUrl']; \Yii::$app->session['__crudReturnUrl'] = null; return $this->redirect($url); } else { return $this->redirect(['index']); } }
php
public function actionDelete($id) { try { $this->findModel($id)->delete(); } catch (\Exception $e) { $msg = (isset($e->errorInfo[2]))?$e->errorInfo[2]:$e->getMessage(); \Yii::$app->getSession()->addFlash('error', $msg); return $this->redirect(Url::previous()); } // TODO: improve detection $isPivot = strstr('$id',','); if ($isPivot == true) { return $this->redirect(Url::previous()); } elseif (isset(\Yii::$app->session['__crudReturnUrl']) && \Yii::$app->session['__crudReturnUrl'] != '/') { Url::remember(null); $url = \Yii::$app->session['__crudReturnUrl']; \Yii::$app->session['__crudReturnUrl'] = null; return $this->redirect($url); } else { return $this->redirect(['index']); } }
[ "public", "function", "actionDelete", "(", "$", "id", ")", "{", "try", "{", "$", "this", "->", "findModel", "(", "$", "id", ")", "->", "delete", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "msg", "=", "(", "isset", "(", "$", "e", "->", "errorInfo", "[", "2", "]", ")", ")", "?", "$", "e", "->", "errorInfo", "[", "2", "]", ":", "$", "e", "->", "getMessage", "(", ")", ";", "\\", "Yii", "::", "$", "app", "->", "getSession", "(", ")", "->", "addFlash", "(", "'error'", ",", "$", "msg", ")", ";", "return", "$", "this", "->", "redirect", "(", "Url", "::", "previous", "(", ")", ")", ";", "}", "// TODO: improve detection", "$", "isPivot", "=", "strstr", "(", "'$id'", ",", "','", ")", ";", "if", "(", "$", "isPivot", "==", "true", ")", "{", "return", "$", "this", "->", "redirect", "(", "Url", "::", "previous", "(", ")", ")", ";", "}", "elseif", "(", "isset", "(", "\\", "Yii", "::", "$", "app", "->", "session", "[", "'__crudReturnUrl'", "]", ")", "&&", "\\", "Yii", "::", "$", "app", "->", "session", "[", "'__crudReturnUrl'", "]", "!=", "'/'", ")", "{", "Url", "::", "remember", "(", "null", ")", ";", "$", "url", "=", "\\", "Yii", "::", "$", "app", "->", "session", "[", "'__crudReturnUrl'", "]", ";", "\\", "Yii", "::", "$", "app", "->", "session", "[", "'__crudReturnUrl'", "]", "=", "null", ";", "return", "$", "this", "->", "redirect", "(", "$", "url", ")", ";", "}", "else", "{", "return", "$", "this", "->", "redirect", "(", "[", "'index'", "]", ")", ";", "}", "}" ]
Deletes an existing Country model. If deletion is successful, the browser will be redirected to the 'index' page. @param integer $id @return mixed
[ "Deletes", "an", "existing", "Country", "model", ".", "If", "deletion", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "index", "page", "." ]
train
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/controllers/base/CountryController.php#L113-L136
expectation-php/expect
src/matcher/ToThrow.php
ToThrow.match
public function match($actual) { $this->actual = $actual; try { $actual(); } catch (Exception $exception) { $this->thrownException = $exception; } return $this->thrownException instanceof $this->expected; }
php
public function match($actual) { $this->actual = $actual; try { $actual(); } catch (Exception $exception) { $this->thrownException = $exception; } return $this->thrownException instanceof $this->expected; }
[ "public", "function", "match", "(", "$", "actual", ")", "{", "$", "this", "->", "actual", "=", "$", "actual", ";", "try", "{", "$", "actual", "(", ")", ";", "}", "catch", "(", "Exception", "$", "exception", ")", "{", "$", "this", "->", "thrownException", "=", "$", "exception", ";", "}", "return", "$", "this", "->", "thrownException", "instanceof", "$", "this", "->", "expected", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToThrow.php#L59-L70
expectation-php/expect
src/matcher/ToThrow.php
ToThrow.reportFailed
public function reportFailed(FailedMessage $message) { $explanation = 'none thrown'; if ($this->thrownException) { $class = get_class($this->thrownException); $explanation = "got $class"; } $message->appendText('Expected ') ->appendText($this->expected) ->appendText(' to be thrown, ') ->appendText($explanation); }
php
public function reportFailed(FailedMessage $message) { $explanation = 'none thrown'; if ($this->thrownException) { $class = get_class($this->thrownException); $explanation = "got $class"; } $message->appendText('Expected ') ->appendText($this->expected) ->appendText(' to be thrown, ') ->appendText($explanation); }
[ "public", "function", "reportFailed", "(", "FailedMessage", "$", "message", ")", "{", "$", "explanation", "=", "'none thrown'", ";", "if", "(", "$", "this", "->", "thrownException", ")", "{", "$", "class", "=", "get_class", "(", "$", "this", "->", "thrownException", ")", ";", "$", "explanation", "=", "\"got $class\"", ";", "}", "$", "message", "->", "appendText", "(", "'Expected '", ")", "->", "appendText", "(", "$", "this", "->", "expected", ")", "->", "appendText", "(", "' to be thrown, '", ")", "->", "appendText", "(", "$", "explanation", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/matcher/ToThrow.php#L75-L88
alevilar/ristorantino-vendor
Printers/Lib/PrinterOutput/DatabasePrinterOutput.php
DatabasePrinterOutput.send
public function send( $printaitorViewObj ) { $printJob['PrinterJob'] = array( 'text' => $printaitorViewObj->viewTextRender, 'printer_id' => $printaitorViewObj->printerId, ); $PrinterJob = ClassRegistry::init("Printers.PrinterJob"); $save = $PrinterJob->save($printJob); if ( !$save ) { throw new CakeException("No se pudo guardar en en la DB el PrintJob"); } return true; }
php
public function send( $printaitorViewObj ) { $printJob['PrinterJob'] = array( 'text' => $printaitorViewObj->viewTextRender, 'printer_id' => $printaitorViewObj->printerId, ); $PrinterJob = ClassRegistry::init("Printers.PrinterJob"); $save = $PrinterJob->save($printJob); if ( !$save ) { throw new CakeException("No se pudo guardar en en la DB el PrintJob"); } return true; }
[ "public", "function", "send", "(", "$", "printaitorViewObj", ")", "{", "$", "printJob", "[", "'PrinterJob'", "]", "=", "array", "(", "'text'", "=>", "$", "printaitorViewObj", "->", "viewTextRender", ",", "'printer_id'", "=>", "$", "printaitorViewObj", "->", "printerId", ",", ")", ";", "$", "PrinterJob", "=", "ClassRegistry", "::", "init", "(", "\"Printers.PrinterJob\"", ")", ";", "$", "save", "=", "$", "PrinterJob", "->", "save", "(", "$", "printJob", ")", ";", "if", "(", "!", "$", "save", ")", "{", "throw", "new", "CakeException", "(", "\"No se pudo guardar en en la DB el PrintJob\"", ")", ";", "}", "return", "true", ";", "}" ]
Crea un archivo y lo coloca en la carpeta /tmp @param string $texto es el texto a imprimir @param string $printer_id Id de la impresora @param string $hostname nombre o IP del host @return type boolean true si salio todo bien false caso contrario
[ "Crea", "un", "archivo", "y", "lo", "coloca", "en", "la", "carpeta", "/", "tmp" ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/PrinterOutput/DatabasePrinterOutput.php#L31-L43
chippyash/Assembly-Builder
src/chippyash/Assembler/Assembler.php
Assembler.create
public static function create(array $params = []) { $assembler = new static(); if (!empty($params)) { array_walk($params, function($v, $k) use ($assembler) { $assembler->$k(function() use($v) {return $v;}); }); $assembler->assemble(); } return $assembler; }
php
public static function create(array $params = []) { $assembler = new static(); if (!empty($params)) { array_walk($params, function($v, $k) use ($assembler) { $assembler->$k(function() use($v) {return $v;}); }); $assembler->assemble(); } return $assembler; }
[ "public", "static", "function", "create", "(", "array", "$", "params", "=", "[", "]", ")", "{", "$", "assembler", "=", "new", "static", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "params", ")", ")", "{", "array_walk", "(", "$", "params", ",", "function", "(", "$", "v", ",", "$", "k", ")", "use", "(", "$", "assembler", ")", "{", "$", "assembler", "->", "$", "k", "(", "function", "(", ")", "use", "(", "$", "v", ")", "{", "return", "$", "v", ";", "}", ")", ";", "}", ")", ";", "$", "assembler", "->", "assemble", "(", ")", ";", "}", "return", "$", "assembler", ";", "}" ]
Static Assembler constructor Returns a new Assembler @param array $params Immutable parameters to send into the assembler @return static
[ "Static", "Assembler", "constructor", "Returns", "a", "new", "Assembler" ]
train
https://github.com/chippyash/Assembly-Builder/blob/be477306b7a1c09b48ce9e100f9f6680035d0df3/src/chippyash/Assembler/Assembler.php#L48-L59
chippyash/Assembly-Builder
src/chippyash/Assembler/Assembler.php
Assembler.get
public static function get(array $params = []) { if (empty(self::$singleton)) { self::$singleton = static::create($params); } return self::$singleton; }
php
public static function get(array $params = []) { if (empty(self::$singleton)) { self::$singleton = static::create($params); } return self::$singleton; }
[ "public", "static", "function", "get", "(", "array", "$", "params", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "singleton", ")", ")", "{", "self", "::", "$", "singleton", "=", "static", "::", "create", "(", "$", "params", ")", ";", "}", "return", "self", "::", "$", "singleton", ";", "}" ]
Return Singleton instance of Assembler @param array $params Immutable parameters to send into the assembler @return Assembler
[ "Return", "Singleton", "instance", "of", "Assembler" ]
train
https://github.com/chippyash/Assembly-Builder/blob/be477306b7a1c09b48ce9e100f9f6680035d0df3/src/chippyash/Assembler/Assembler.php#L68-L75
chippyash/Assembly-Builder
src/chippyash/Assembler/Assembler.php
Assembler.release
public function release($var1) { $flip = array_flip(func_get_args()); $intersect = array_intersect_key($this->values, $flip); if (count(func_get_args()) > 1) { array_walk($flip, function(&$v, $k) use ($intersect) { $v = $intersect[$k]; }); return array_values($flip); } else { return array_pop($intersect); } }
php
public function release($var1) { $flip = array_flip(func_get_args()); $intersect = array_intersect_key($this->values, $flip); if (count(func_get_args()) > 1) { array_walk($flip, function(&$v, $k) use ($intersect) { $v = $intersect[$k]; }); return array_values($flip); } else { return array_pop($intersect); } }
[ "public", "function", "release", "(", "$", "var1", ")", "{", "$", "flip", "=", "array_flip", "(", "func_get_args", "(", ")", ")", ";", "$", "intersect", "=", "array_intersect_key", "(", "$", "this", "->", "values", ",", "$", "flip", ")", ";", "if", "(", "count", "(", "func_get_args", "(", ")", ")", ">", "1", ")", "{", "array_walk", "(", "$", "flip", ",", "function", "(", "&", "$", "v", ",", "$", "k", ")", "use", "(", "$", "intersect", ")", "{", "$", "v", "=", "$", "intersect", "[", "$", "k", "]", ";", "}", ")", ";", "return", "array_values", "(", "$", "flip", ")", ";", "}", "else", "{", "return", "array_pop", "(", "$", "intersect", ")", ";", "}", "}" ]
Return an array of variables created else just a single value Usage: ->release('var1','varN') ->release('var1') Don't forget to call assemble() first if needed @param string $var1 Name of variable to return @param string $_ Next name of variable to retrieve - repeater @return mixed
[ "Return", "an", "array", "of", "variables", "created", "else", "just", "a", "single", "value", "Usage", ":", "-", ">", "release", "(", "var1", "varN", ")", "-", ">", "release", "(", "var1", ")" ]
train
https://github.com/chippyash/Assembly-Builder/blob/be477306b7a1c09b48ce9e100f9f6680035d0df3/src/chippyash/Assembler/Assembler.php#L109-L121
chippyash/Assembly-Builder
src/chippyash/Assembler/Assembler.php
Assembler.assemble
public function assemble() { foreach ($this->placeHolders as $name => $placeholder) { if (!isset($this->values[$name])) { $this->values[$name] = $this->addVars($placeholder); } } return $this; }
php
public function assemble() { foreach ($this->placeHolders as $name => $placeholder) { if (!isset($this->values[$name])) { $this->values[$name] = $this->addVars($placeholder); } } return $this; }
[ "public", "function", "assemble", "(", ")", "{", "foreach", "(", "$", "this", "->", "placeHolders", "as", "$", "name", "=>", "$", "placeholder", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "values", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "values", "[", "$", "name", "]", "=", "$", "this", "->", "addVars", "(", "$", "placeholder", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Run the Assembly not returning any value. Assembly will not overwrite anything already assembled @return $this
[ "Run", "the", "Assembly", "not", "returning", "any", "value", ".", "Assembly", "will", "not", "overwrite", "anything", "already", "assembled" ]
train
https://github.com/chippyash/Assembly-Builder/blob/be477306b7a1c09b48ce9e100f9f6680035d0df3/src/chippyash/Assembler/Assembler.php#L129-L138
chippyash/Assembly-Builder
src/chippyash/Assembler/Assembler.php
Assembler.merge
public function merge(Assembler $other) { //N.B. reflection used so as to not expose values //via some public method $refl = new \ReflectionObject($other); $reflValues = $refl->getProperty('values'); $reflValues->setAccessible(true); $oValues = $reflValues->getValue($other); if (count($oValues) == 0) { return $this; } $this->values = array_merge($this->values, $oValues); return $this; }
php
public function merge(Assembler $other) { //N.B. reflection used so as to not expose values //via some public method $refl = new \ReflectionObject($other); $reflValues = $refl->getProperty('values'); $reflValues->setAccessible(true); $oValues = $reflValues->getValue($other); if (count($oValues) == 0) { return $this; } $this->values = array_merge($this->values, $oValues); return $this; }
[ "public", "function", "merge", "(", "Assembler", "$", "other", ")", "{", "//N.B. reflection used so as to not expose values", "//via some public method", "$", "refl", "=", "new", "\\", "ReflectionObject", "(", "$", "other", ")", ";", "$", "reflValues", "=", "$", "refl", "->", "getProperty", "(", "'values'", ")", ";", "$", "reflValues", "->", "setAccessible", "(", "true", ")", ";", "$", "oValues", "=", "$", "reflValues", "->", "getValue", "(", "$", "other", ")", ";", "if", "(", "count", "(", "$", "oValues", ")", "==", "0", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "values", "=", "array_merge", "(", "$", "this", "->", "values", ",", "$", "oValues", ")", ";", "return", "$", "this", ";", "}" ]
Merge this assembly with another. Obeys the rules of array_merge @param Assembler $other @return $this
[ "Merge", "this", "assembly", "with", "another", ".", "Obeys", "the", "rules", "of", "array_merge" ]
train
https://github.com/chippyash/Assembly-Builder/blob/be477306b7a1c09b48ce9e100f9f6680035d0df3/src/chippyash/Assembler/Assembler.php#L148-L163
chippyash/Assembly-Builder
src/chippyash/Assembler/Assembler.php
Assembler.addVars
protected function addVars(\Closure $func) { $args = (new \ReflectionFunction($func))->getParameters(); if (count($args) === 0) { return $func(); } $fArgs = array_map(function($key) { return $this->values[$key]; }, array_map(function($arg) { return $arg->getName(); }, $args ) ); return call_user_func_array($func, $fArgs); }
php
protected function addVars(\Closure $func) { $args = (new \ReflectionFunction($func))->getParameters(); if (count($args) === 0) { return $func(); } $fArgs = array_map(function($key) { return $this->values[$key]; }, array_map(function($arg) { return $arg->getName(); }, $args ) ); return call_user_func_array($func, $fArgs); }
[ "protected", "function", "addVars", "(", "\\", "Closure", "$", "func", ")", "{", "$", "args", "=", "(", "new", "\\", "ReflectionFunction", "(", "$", "func", ")", ")", "->", "getParameters", "(", ")", ";", "if", "(", "count", "(", "$", "args", ")", "===", "0", ")", "{", "return", "$", "func", "(", ")", ";", "}", "$", "fArgs", "=", "array_map", "(", "function", "(", "$", "key", ")", "{", "return", "$", "this", "->", "values", "[", "$", "key", "]", ";", "}", ",", "array_map", "(", "function", "(", "$", "arg", ")", "{", "return", "$", "arg", "->", "getName", "(", ")", ";", "}", ",", "$", "args", ")", ")", ";", "return", "call_user_func_array", "(", "$", "func", ",", "$", "fArgs", ")", ";", "}" ]
Execute the function assigned to the value, binding in values created earlier in the assembly @param \Closure $func @return mixed
[ "Execute", "the", "function", "assigned", "to", "the", "value", "binding", "in", "values", "created", "earlier", "in", "the", "assembly" ]
train
https://github.com/chippyash/Assembly-Builder/blob/be477306b7a1c09b48ce9e100f9f6680035d0df3/src/chippyash/Assembler/Assembler.php#L173-L191
Eresus/EresusCMS
src/core/Admin/Controller/Content/Url.php
Eresus_Admin_Controller_Content_Url.getHtml
public function getHtml(Eresus_CMS_Request $request) { $legacyKernel = Eresus_Kernel::app()->getLegacyKernel(); $sections = $legacyKernel->sections; $args = $request->getMethod() == 'GET' ? $request->query : $request->request; $item = $sections->get($args->getInt('section')); $response = $args->has('update') // TODO Использовать getMethod вметос 'update' ? $this->updateAction($item) : $this->formAction($item, $args); return $response; }
php
public function getHtml(Eresus_CMS_Request $request) { $legacyKernel = Eresus_Kernel::app()->getLegacyKernel(); $sections = $legacyKernel->sections; $args = $request->getMethod() == 'GET' ? $request->query : $request->request; $item = $sections->get($args->getInt('section')); $response = $args->has('update') // TODO Использовать getMethod вметос 'update' ? $this->updateAction($item) : $this->formAction($item, $args); return $response; }
[ "public", "function", "getHtml", "(", "Eresus_CMS_Request", "$", "request", ")", "{", "$", "legacyKernel", "=", "Eresus_Kernel", "::", "app", "(", ")", "->", "getLegacyKernel", "(", ")", ";", "$", "sections", "=", "$", "legacyKernel", "->", "sections", ";", "$", "args", "=", "$", "request", "->", "getMethod", "(", ")", "==", "'GET'", "?", "$", "request", "->", "query", ":", "$", "request", "->", "request", ";", "$", "item", "=", "$", "sections", "->", "get", "(", "$", "args", "->", "getInt", "(", "'section'", ")", ")", ";", "$", "response", "=", "$", "args", "->", "has", "(", "'update'", ")", "// TODO Использовать getMethod вметос 'update'", "?", "$", "this", "->", "updateAction", "(", "$", "item", ")", ":", "$", "this", "->", "formAction", "(", "$", "item", ",", "$", "args", ")", ";", "return", "$", "response", ";", "}" ]
Возвращает разметку области контента @param Eresus_CMS_Request $request @return string|Eresus_HTTP_Response @since 3.01
[ "Возвращает", "разметку", "области", "контента" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Admin/Controller/Content/Url.php#L44-L54
Eresus/EresusCMS
src/core/Admin/Controller/Content/Url.php
Eresus_Admin_Controller_Content_Url.formAction
private function formAction(array $item) { $form = array( 'name' => 'editURL', 'caption' => ADM_EDIT, 'width' => '100%', 'fields' => array( array('type' => 'hidden', 'name' => 'update', 'value' => $item['id']), array('type' => 'edit', 'name' => 'url', 'label' => 'URL:', 'width' => '100%', 'value' => isset($item['content']) ? $item['content'] : ''), ), 'buttons' => array('apply', 'cancel'), ); /** @var TAdminUI $page */ $page = Eresus_Kernel::app()->getPage(); $html = $page->renderForm($form); return $html; }
php
private function formAction(array $item) { $form = array( 'name' => 'editURL', 'caption' => ADM_EDIT, 'width' => '100%', 'fields' => array( array('type' => 'hidden', 'name' => 'update', 'value' => $item['id']), array('type' => 'edit', 'name' => 'url', 'label' => 'URL:', 'width' => '100%', 'value' => isset($item['content']) ? $item['content'] : ''), ), 'buttons' => array('apply', 'cancel'), ); /** @var TAdminUI $page */ $page = Eresus_Kernel::app()->getPage(); $html = $page->renderForm($form); return $html; }
[ "private", "function", "formAction", "(", "array", "$", "item", ")", "{", "$", "form", "=", "array", "(", "'name'", "=>", "'editURL'", ",", "'caption'", "=>", "ADM_EDIT", ",", "'width'", "=>", "'100%'", ",", "'fields'", "=>", "array", "(", "array", "(", "'type'", "=>", "'hidden'", ",", "'name'", "=>", "'update'", ",", "'value'", "=>", "$", "item", "[", "'id'", "]", ")", ",", "array", "(", "'type'", "=>", "'edit'", ",", "'name'", "=>", "'url'", ",", "'label'", "=>", "'URL:'", ",", "'width'", "=>", "'100%'", ",", "'value'", "=>", "isset", "(", "$", "item", "[", "'content'", "]", ")", "?", "$", "item", "[", "'content'", "]", ":", "''", ")", ",", ")", ",", "'buttons'", "=>", "array", "(", "'apply'", ",", "'cancel'", ")", ",", ")", ";", "/** @var TAdminUI $page */", "$", "page", "=", "Eresus_Kernel", "::", "app", "(", ")", "->", "getPage", "(", ")", ";", "$", "html", "=", "$", "page", "->", "renderForm", "(", "$", "form", ")", ";", "return", "$", "html", ";", "}" ]
Возвращает разметку диалога @param array $item @return string @since 3.01
[ "Возвращает", "разметку", "диалога" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Admin/Controller/Content/Url.php#L64-L81
Eresus/EresusCMS
src/core/Admin/Controller/Content/Url.php
Eresus_Admin_Controller_Content_Url.updateAction
private function updateAction(array $item, Eresus_HTTP_Parameters $args) { $item['content'] = $args->get('url'); Eresus_Kernel::app()->getLegacyKernel()->sections->update($item); return new Eresus_HTTP_Redirect($args->get('submitURL')); }
php
private function updateAction(array $item, Eresus_HTTP_Parameters $args) { $item['content'] = $args->get('url'); Eresus_Kernel::app()->getLegacyKernel()->sections->update($item); return new Eresus_HTTP_Redirect($args->get('submitURL')); }
[ "private", "function", "updateAction", "(", "array", "$", "item", ",", "Eresus_HTTP_Parameters", "$", "args", ")", "{", "$", "item", "[", "'content'", "]", "=", "$", "args", "->", "get", "(", "'url'", ")", ";", "Eresus_Kernel", "::", "app", "(", ")", "->", "getLegacyKernel", "(", ")", "->", "sections", "->", "update", "(", "$", "item", ")", ";", "return", "new", "Eresus_HTTP_Redirect", "(", "$", "args", "->", "get", "(", "'submitURL'", ")", ")", ";", "}" ]
Сохраняет изменения @param array $item @param Eresus_HTTP_Parameters $args @return Eresus_HTTP_Redirect
[ "Сохраняет", "изменения" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Admin/Controller/Content/Url.php#L91-L96
php-lug/lug
src/Component/Grid/Handler/GridHandler.php
GridHandler.handle
public function handle(GridInterface $grid, array $filters = [], array $sorting = [], array $slicing = []) { $repository = $this->repositoryRegistry[$grid->getResource()->getName()]; $dataSourceBuilder = $repository->createDataSourceBuilder($grid->getOptions()); $this->filterer->filter($dataSourceBuilder, $grid, $filters); $this->sorter->sort($dataSourceBuilder, $grid, $sorting); $this->slicer->slice($dataSourceBuilder, $grid, $slicing); return $this->gridViewFactory->create($grid, $dataSourceBuilder); }
php
public function handle(GridInterface $grid, array $filters = [], array $sorting = [], array $slicing = []) { $repository = $this->repositoryRegistry[$grid->getResource()->getName()]; $dataSourceBuilder = $repository->createDataSourceBuilder($grid->getOptions()); $this->filterer->filter($dataSourceBuilder, $grid, $filters); $this->sorter->sort($dataSourceBuilder, $grid, $sorting); $this->slicer->slice($dataSourceBuilder, $grid, $slicing); return $this->gridViewFactory->create($grid, $dataSourceBuilder); }
[ "public", "function", "handle", "(", "GridInterface", "$", "grid", ",", "array", "$", "filters", "=", "[", "]", ",", "array", "$", "sorting", "=", "[", "]", ",", "array", "$", "slicing", "=", "[", "]", ")", "{", "$", "repository", "=", "$", "this", "->", "repositoryRegistry", "[", "$", "grid", "->", "getResource", "(", ")", "->", "getName", "(", ")", "]", ";", "$", "dataSourceBuilder", "=", "$", "repository", "->", "createDataSourceBuilder", "(", "$", "grid", "->", "getOptions", "(", ")", ")", ";", "$", "this", "->", "filterer", "->", "filter", "(", "$", "dataSourceBuilder", ",", "$", "grid", ",", "$", "filters", ")", ";", "$", "this", "->", "sorter", "->", "sort", "(", "$", "dataSourceBuilder", ",", "$", "grid", ",", "$", "sorting", ")", ";", "$", "this", "->", "slicer", "->", "slice", "(", "$", "dataSourceBuilder", ",", "$", "grid", ",", "$", "slicing", ")", ";", "return", "$", "this", "->", "gridViewFactory", "->", "create", "(", "$", "grid", ",", "$", "dataSourceBuilder", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Grid/Handler/GridHandler.php#L75-L85
infinity-next/sleuth
src/Detectives/svgDetective.php
svgDetective.leadSVG
protected function leadSVG() { // Create a new sanitizer instance $sanitizer = new Sanitizer(); // Load the dirty svg $dirtySVG = file_get_contents($this->file); // Pass it to the sanitizer and get it back clean $cleanSVG = $sanitizer->sanitize($dirtySVG); if (is_string($cleanSVG)) { return $this->closeCase("svg", "image/svg+xml"); } return false; }
php
protected function leadSVG() { // Create a new sanitizer instance $sanitizer = new Sanitizer(); // Load the dirty svg $dirtySVG = file_get_contents($this->file); // Pass it to the sanitizer and get it back clean $cleanSVG = $sanitizer->sanitize($dirtySVG); if (is_string($cleanSVG)) { return $this->closeCase("svg", "image/svg+xml"); } return false; }
[ "protected", "function", "leadSVG", "(", ")", "{", "// Create a new sanitizer instance\r", "$", "sanitizer", "=", "new", "Sanitizer", "(", ")", ";", "// Load the dirty svg\r", "$", "dirtySVG", "=", "file_get_contents", "(", "$", "this", "->", "file", ")", ";", "// Pass it to the sanitizer and get it back clean\r", "$", "cleanSVG", "=", "$", "sanitizer", "->", "sanitize", "(", "$", "dirtySVG", ")", ";", "if", "(", "is_string", "(", "$", "cleanSVG", ")", ")", "{", "return", "$", "this", "->", "closeCase", "(", "\"svg\"", ",", "\"image/svg+xml\"", ")", ";", "}", "return", "false", ";", "}" ]
Checks if thise file is a valid SVG. @return boolean|null
[ "Checks", "if", "thise", "file", "is", "a", "valid", "SVG", "." ]
train
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/Detectives/svgDetective.php#L16-L33
brianium/nomnom
src/Nomnom/UnitResolver.php
UnitResolver.resolve
public static function resolve($key) { if ($key == 'B') return 0; $dict = static::$metric; if (preg_match(static::IEC_PATTERN, $key)) $dict = static::$binary; if (array_key_exists($key, $dict)) return $dict[$key]; throw new UnitNotFoundException(sprintf('Unit "%s" not found', $key)); }
php
public static function resolve($key) { if ($key == 'B') return 0; $dict = static::$metric; if (preg_match(static::IEC_PATTERN, $key)) $dict = static::$binary; if (array_key_exists($key, $dict)) return $dict[$key]; throw new UnitNotFoundException(sprintf('Unit "%s" not found', $key)); }
[ "public", "static", "function", "resolve", "(", "$", "key", ")", "{", "if", "(", "$", "key", "==", "'B'", ")", "return", "0", ";", "$", "dict", "=", "static", "::", "$", "metric", ";", "if", "(", "preg_match", "(", "static", "::", "IEC_PATTERN", ",", "$", "key", ")", ")", "$", "dict", "=", "static", "::", "$", "binary", ";", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "dict", ")", ")", "return", "$", "dict", "[", "$", "key", "]", ";", "throw", "new", "UnitNotFoundException", "(", "sprintf", "(", "'Unit \"%s\" not found'", ",", "$", "key", ")", ")", ";", "}" ]
Lookup the exponent based on prefix @param $key @throws UnitNotFoundException @return int
[ "Lookup", "the", "exponent", "based", "on", "prefix" ]
train
https://github.com/brianium/nomnom/blob/012e3a6ad17fe2393b6a9db1a4b14c91ab91adcd/src/Nomnom/UnitResolver.php#L57-L65
brianium/nomnom
src/Nomnom/UnitResolver.php
UnitResolver.unitsAreDifferent
public static function unitsAreDifferent($first, $second) { return (preg_match(UnitResolver::SI_PATTERN, $first) && preg_match(UnitResolver::IEC_PATTERN, $second)) || (preg_match(UnitResolver::IEC_PATTERN, $first) && preg_match(UnitResolver::SI_PATTERN, $second)); }
php
public static function unitsAreDifferent($first, $second) { return (preg_match(UnitResolver::SI_PATTERN, $first) && preg_match(UnitResolver::IEC_PATTERN, $second)) || (preg_match(UnitResolver::IEC_PATTERN, $first) && preg_match(UnitResolver::SI_PATTERN, $second)); }
[ "public", "static", "function", "unitsAreDifferent", "(", "$", "first", ",", "$", "second", ")", "{", "return", "(", "preg_match", "(", "UnitResolver", "::", "SI_PATTERN", ",", "$", "first", ")", "&&", "preg_match", "(", "UnitResolver", "::", "IEC_PATTERN", ",", "$", "second", ")", ")", "||", "(", "preg_match", "(", "UnitResolver", "::", "IEC_PATTERN", ",", "$", "first", ")", "&&", "preg_match", "(", "UnitResolver", "::", "SI_PATTERN", ",", "$", "second", ")", ")", ";", "}" ]
Check if two units are in the same family @param string $first @param string $second @return bool
[ "Check", "if", "two", "units", "are", "in", "the", "same", "family" ]
train
https://github.com/brianium/nomnom/blob/012e3a6ad17fe2393b6a9db1a4b14c91ab91adcd/src/Nomnom/UnitResolver.php#L76-L81
inhere/php-librarys
src/Collections/Configuration.php
Configuration.set
public function set($path, $value) { // if is readonly if ($this->readonly && $this->has($path)) { throw new RuntimeException("Config data have been setting readonly. don't allow change."); } return parent::set($path, $value); }
php
public function set($path, $value) { // if is readonly if ($this->readonly && $this->has($path)) { throw new RuntimeException("Config data have been setting readonly. don't allow change."); } return parent::set($path, $value); }
[ "public", "function", "set", "(", "$", "path", ",", "$", "value", ")", "{", "// if is readonly", "if", "(", "$", "this", "->", "readonly", "&&", "$", "this", "->", "has", "(", "$", "path", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Config data have been setting readonly. don't allow change.\"", ")", ";", "}", "return", "parent", "::", "set", "(", "$", "path", ",", "$", "value", ")", ";", "}" ]
set config value by path @param string $path @param mixed $value @return mixed @throws \RuntimeException
[ "set", "config", "value", "by", "path" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Collections/Configuration.php#L122-L130
heidelpay/PhpDoc
src/phpDocumentor/Compiler/Pass/NamespaceTreeBuilder.php
NamespaceTreeBuilder.execute
public function execute(ProjectDescriptor $project) { $project->getIndexes()->get('elements', new Collection())->set('~\\', $project->getNamespace()); $project->getIndexes()->get('namespaces', new Collection())->add($project->getNamespace()); foreach ($project->getFiles() as $file) { $this->addElementsOfTypeToNamespace($project, $file->getConstants()->getAll(), 'constants'); $this->addElementsOfTypeToNamespace($project, $file->getFunctions()->getAll(), 'functions'); $this->addElementsOfTypeToNamespace($project, $file->getClasses()->getAll(), 'classes'); $this->addElementsOfTypeToNamespace($project, $file->getInterfaces()->getAll(), 'interfaces'); $this->addElementsOfTypeToNamespace($project, $file->getTraits()->getAll(), 'traits'); } }
php
public function execute(ProjectDescriptor $project) { $project->getIndexes()->get('elements', new Collection())->set('~\\', $project->getNamespace()); $project->getIndexes()->get('namespaces', new Collection())->add($project->getNamespace()); foreach ($project->getFiles() as $file) { $this->addElementsOfTypeToNamespace($project, $file->getConstants()->getAll(), 'constants'); $this->addElementsOfTypeToNamespace($project, $file->getFunctions()->getAll(), 'functions'); $this->addElementsOfTypeToNamespace($project, $file->getClasses()->getAll(), 'classes'); $this->addElementsOfTypeToNamespace($project, $file->getInterfaces()->getAll(), 'interfaces'); $this->addElementsOfTypeToNamespace($project, $file->getTraits()->getAll(), 'traits'); } }
[ "public", "function", "execute", "(", "ProjectDescriptor", "$", "project", ")", "{", "$", "project", "->", "getIndexes", "(", ")", "->", "get", "(", "'elements'", ",", "new", "Collection", "(", ")", ")", "->", "set", "(", "'~\\\\'", ",", "$", "project", "->", "getNamespace", "(", ")", ")", ";", "$", "project", "->", "getIndexes", "(", ")", "->", "get", "(", "'namespaces'", ",", "new", "Collection", "(", ")", ")", "->", "add", "(", "$", "project", "->", "getNamespace", "(", ")", ")", ";", "foreach", "(", "$", "project", "->", "getFiles", "(", ")", "as", "$", "file", ")", "{", "$", "this", "->", "addElementsOfTypeToNamespace", "(", "$", "project", ",", "$", "file", "->", "getConstants", "(", ")", "->", "getAll", "(", ")", ",", "'constants'", ")", ";", "$", "this", "->", "addElementsOfTypeToNamespace", "(", "$", "project", ",", "$", "file", "->", "getFunctions", "(", ")", "->", "getAll", "(", ")", ",", "'functions'", ")", ";", "$", "this", "->", "addElementsOfTypeToNamespace", "(", "$", "project", ",", "$", "file", "->", "getClasses", "(", ")", "->", "getAll", "(", ")", ",", "'classes'", ")", ";", "$", "this", "->", "addElementsOfTypeToNamespace", "(", "$", "project", ",", "$", "file", "->", "getInterfaces", "(", ")", "->", "getAll", "(", ")", ",", "'interfaces'", ")", ";", "$", "this", "->", "addElementsOfTypeToNamespace", "(", "$", "project", ",", "$", "file", "->", "getTraits", "(", ")", "->", "getAll", "(", ")", ",", "'traits'", ")", ";", "}", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/NamespaceTreeBuilder.php#L45-L57
heidelpay/PhpDoc
src/phpDocumentor/Compiler/Pass/NamespaceTreeBuilder.php
NamespaceTreeBuilder.addElementsOfTypeToNamespace
protected function addElementsOfTypeToNamespace(ProjectDescriptor $project, array $elements, $type) { /** @var DescriptorAbstract $element */ foreach ($elements as $element) { $namespaceName = (string) $element->getNamespace(); // ensure consistency by trimming the slash prefix and then re-appending it. $namespaceIndexName = '~\\' . ltrim($namespaceName, '\\'); if (!isset($project->getIndexes()->elements[$namespaceIndexName])) { $this->createNamespaceDescriptorTree($project, $namespaceName); } /** @var NamespaceDescriptor $namespace */ $namespace = $project->getIndexes()->elements[$namespaceIndexName]; // replace textual representation with an object representation $element->setNamespace($namespace); // add element to namespace $getter = 'get'.ucfirst($type); /** @var Collection $collection */ $collection = $namespace->$getter(); $collection->add($element); } }
php
protected function addElementsOfTypeToNamespace(ProjectDescriptor $project, array $elements, $type) { /** @var DescriptorAbstract $element */ foreach ($elements as $element) { $namespaceName = (string) $element->getNamespace(); // ensure consistency by trimming the slash prefix and then re-appending it. $namespaceIndexName = '~\\' . ltrim($namespaceName, '\\'); if (!isset($project->getIndexes()->elements[$namespaceIndexName])) { $this->createNamespaceDescriptorTree($project, $namespaceName); } /** @var NamespaceDescriptor $namespace */ $namespace = $project->getIndexes()->elements[$namespaceIndexName]; // replace textual representation with an object representation $element->setNamespace($namespace); // add element to namespace $getter = 'get'.ucfirst($type); /** @var Collection $collection */ $collection = $namespace->$getter(); $collection->add($element); } }
[ "protected", "function", "addElementsOfTypeToNamespace", "(", "ProjectDescriptor", "$", "project", ",", "array", "$", "elements", ",", "$", "type", ")", "{", "/** @var DescriptorAbstract $element */", "foreach", "(", "$", "elements", "as", "$", "element", ")", "{", "$", "namespaceName", "=", "(", "string", ")", "$", "element", "->", "getNamespace", "(", ")", ";", "// ensure consistency by trimming the slash prefix and then re-appending it.", "$", "namespaceIndexName", "=", "'~\\\\'", ".", "ltrim", "(", "$", "namespaceName", ",", "'\\\\'", ")", ";", "if", "(", "!", "isset", "(", "$", "project", "->", "getIndexes", "(", ")", "->", "elements", "[", "$", "namespaceIndexName", "]", ")", ")", "{", "$", "this", "->", "createNamespaceDescriptorTree", "(", "$", "project", ",", "$", "namespaceName", ")", ";", "}", "/** @var NamespaceDescriptor $namespace */", "$", "namespace", "=", "$", "project", "->", "getIndexes", "(", ")", "->", "elements", "[", "$", "namespaceIndexName", "]", ";", "// replace textual representation with an object representation", "$", "element", "->", "setNamespace", "(", "$", "namespace", ")", ";", "// add element to namespace", "$", "getter", "=", "'get'", ".", "ucfirst", "(", "$", "type", ")", ";", "/** @var Collection $collection */", "$", "collection", "=", "$", "namespace", "->", "$", "getter", "(", ")", ";", "$", "collection", "->", "add", "(", "$", "element", ")", ";", "}", "}" ]
Adds the given elements of a specific type to their respective Namespace Descriptors. This method will assign the given elements to the namespace as registered in the namespace field of that element. If a namespace does not exist yet it will automatically be created. @param ProjectDescriptor $project @param DescriptorAbstract[] $elements Series of elements to add to their respective namespace. @param string $type Declares which field of the namespace will be populated with the given series of elements. This name will be transformed to a getter which must exist. Out of performance considerations will no effort be done to verify whether the provided type is valid. @return void
[ "Adds", "the", "given", "elements", "of", "a", "specific", "type", "to", "their", "respective", "Namespace", "Descriptors", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/NamespaceTreeBuilder.php#L73-L99
heidelpay/PhpDoc
src/phpDocumentor/Compiler/Pass/NamespaceTreeBuilder.php
NamespaceTreeBuilder.createNamespaceDescriptorTree
protected function createNamespaceDescriptorTree(ProjectDescriptor $project, $namespaceName) { $parts = explode('\\', ltrim($namespaceName, '\\')); $fqnn = ''; // this method does not use recursion to traverse the tree but uses a pointer that will be overridden with the // next item that is to be traversed (child namespace) at the end of the loop. $pointer = $project->getNamespace(); foreach ($parts as $part) { $fqnn .= '\\' . $part; if ($pointer->getChildren()->get($part)) { $pointer = $pointer->getChildren()->get($part); continue; } // namespace does not exist, create it $interimNamespaceDescriptor = new NamespaceDescriptor(); $interimNamespaceDescriptor->setParent($pointer); $interimNamespaceDescriptor->setName($part); $interimNamespaceDescriptor->setFullyQualifiedStructuralElementName($fqnn); // add to the pointer's list of children $pointer->getChildren()->set($part, $interimNamespaceDescriptor); // add to index $project->getIndexes()->elements['~' . $fqnn] = $interimNamespaceDescriptor; $project->getIndexes()->get('namespaces', new Collection())->add($interimNamespaceDescriptor); // move pointer forward $pointer = $interimNamespaceDescriptor; } }
php
protected function createNamespaceDescriptorTree(ProjectDescriptor $project, $namespaceName) { $parts = explode('\\', ltrim($namespaceName, '\\')); $fqnn = ''; // this method does not use recursion to traverse the tree but uses a pointer that will be overridden with the // next item that is to be traversed (child namespace) at the end of the loop. $pointer = $project->getNamespace(); foreach ($parts as $part) { $fqnn .= '\\' . $part; if ($pointer->getChildren()->get($part)) { $pointer = $pointer->getChildren()->get($part); continue; } // namespace does not exist, create it $interimNamespaceDescriptor = new NamespaceDescriptor(); $interimNamespaceDescriptor->setParent($pointer); $interimNamespaceDescriptor->setName($part); $interimNamespaceDescriptor->setFullyQualifiedStructuralElementName($fqnn); // add to the pointer's list of children $pointer->getChildren()->set($part, $interimNamespaceDescriptor); // add to index $project->getIndexes()->elements['~' . $fqnn] = $interimNamespaceDescriptor; $project->getIndexes()->get('namespaces', new Collection())->add($interimNamespaceDescriptor); // move pointer forward $pointer = $interimNamespaceDescriptor; } }
[ "protected", "function", "createNamespaceDescriptorTree", "(", "ProjectDescriptor", "$", "project", ",", "$", "namespaceName", ")", "{", "$", "parts", "=", "explode", "(", "'\\\\'", ",", "ltrim", "(", "$", "namespaceName", ",", "'\\\\'", ")", ")", ";", "$", "fqnn", "=", "''", ";", "// this method does not use recursion to traverse the tree but uses a pointer that will be overridden with the", "// next item that is to be traversed (child namespace) at the end of the loop.", "$", "pointer", "=", "$", "project", "->", "getNamespace", "(", ")", ";", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "$", "fqnn", ".=", "'\\\\'", ".", "$", "part", ";", "if", "(", "$", "pointer", "->", "getChildren", "(", ")", "->", "get", "(", "$", "part", ")", ")", "{", "$", "pointer", "=", "$", "pointer", "->", "getChildren", "(", ")", "->", "get", "(", "$", "part", ")", ";", "continue", ";", "}", "// namespace does not exist, create it", "$", "interimNamespaceDescriptor", "=", "new", "NamespaceDescriptor", "(", ")", ";", "$", "interimNamespaceDescriptor", "->", "setParent", "(", "$", "pointer", ")", ";", "$", "interimNamespaceDescriptor", "->", "setName", "(", "$", "part", ")", ";", "$", "interimNamespaceDescriptor", "->", "setFullyQualifiedStructuralElementName", "(", "$", "fqnn", ")", ";", "// add to the pointer's list of children", "$", "pointer", "->", "getChildren", "(", ")", "->", "set", "(", "$", "part", ",", "$", "interimNamespaceDescriptor", ")", ";", "// add to index", "$", "project", "->", "getIndexes", "(", ")", "->", "elements", "[", "'~'", ".", "$", "fqnn", "]", "=", "$", "interimNamespaceDescriptor", ";", "$", "project", "->", "getIndexes", "(", ")", "->", "get", "(", "'namespaces'", ",", "new", "Collection", "(", ")", ")", "->", "add", "(", "$", "interimNamespaceDescriptor", ")", ";", "// move pointer forward", "$", "pointer", "=", "$", "interimNamespaceDescriptor", ";", "}", "}" ]
Creates a tree of NamespaceDescriptors based on the provided FQNN (namespace name). This method will examine the namespace name and create a namespace descriptor for each part of the FQNN if it doesn't exist in the namespaces field of the current namespace (starting with the root Namespace in the Project Descriptor), As an intended side effect this method also populates the *elements* index of the ProjectDescriptor with all created NamespaceDescriptors. Each index key is prefixed with a tilde (~) so that it will not conflict with other FQSEN's, such as classes or interfaces. @param ProjectDescriptor $project @param string $namespaceName A FQNN of the namespace (and parents) to create. @see ProjectDescriptor::getNamespace() for the root namespace. @see NamespaceDescriptor::getNamespaces() for the child namespaces of a given namespace. @return void
[ "Creates", "a", "tree", "of", "NamespaceDescriptors", "based", "on", "the", "provided", "FQNN", "(", "namespace", "name", ")", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/NamespaceTreeBuilder.php#L120-L151
sergmoro1/yii2-lookup
src/models/PropertyEdit.php
PropertyEdit.beforeSave
public function beforeSave($insert) { if(parent::beforeSave($insert)) { if(!$this->id && self::find()->orderBy(['id' => SORT_DESC])->one()->id < self::BARRIER) $this->id = self::BARRIER; return true; } else return false; }
php
public function beforeSave($insert) { if(parent::beforeSave($insert)) { if(!$this->id && self::find()->orderBy(['id' => SORT_DESC])->one()->id < self::BARRIER) $this->id = self::BARRIER; return true; } else return false; }
[ "public", "function", "beforeSave", "(", "$", "insert", ")", "{", "if", "(", "parent", "::", "beforeSave", "(", "$", "insert", ")", ")", "{", "if", "(", "!", "$", "this", "->", "id", "&&", "self", "::", "find", "(", ")", "->", "orderBy", "(", "[", "'id'", "=>", "SORT_DESC", "]", ")", "->", "one", "(", ")", "->", "id", "<", "self", "::", "BARRIER", ")", "$", "this", "->", "id", "=", "self", "::", "BARRIER", ";", "return", "true", ";", "}", "else", "return", "false", ";", "}" ]
This is invoked before the record is saved. @return boolean whether the record should be saved
[ "This", "is", "invoked", "before", "the", "record", "is", "saved", "." ]
train
https://github.com/sergmoro1/yii2-lookup/blob/deff08a2612b3c54d313a6c60a74fcaae1193b21/src/models/PropertyEdit.php#L51-L61
thiagodp/rtti
lib/RTTI.php
RTTI.getAttributes
static function getAttributes( $obj , $visibilityFlags = null , $getterPrefix = 'get' , $useCamelCase = true , $convertInternalObjects = false ) { if ( ! isset( $obj ) ) { return array(); } $flags = null === $visibilityFlags ? self::allFlags() : $visibilityFlags; $attributes = array(); $reflectionObject = new \ReflectionObject( $obj ); $currentClass = new \ReflectionClass( $obj ); while ( $currentClass !== false && ! $currentClass->isInterface() ) { $properties = $currentClass->getProperties( $flags ); foreach ( $properties as $property ) { $attributeName = $property->getName(); $methodName = $getterPrefix . ( $useCamelCase ? self::mb_ucfirst( $attributeName ) : $attributeName ); if ( $property->isPrivate() || $property->isProtected() ) { if ( $reflectionObject->hasMethod( $methodName ) ) { $method = $reflectionObject->getMethod( $methodName ); if ( $method->isPublic() ) { $attributes[ $attributeName ] = $method->invoke( $obj ); } } else { // maybe has a __call magic method $attributes[ $attributeName ] = $obj->{ $methodName }(); } } else { // public method try { $attributes[ $attributeName ] = $obj->{ $attributeName }; } catch ( \Exception $e ) { // Ignore } } } // No properties? -> try to retrieve public properties if ( count( $properties ) < 1 ) { $properties = get_object_vars( $obj ); foreach ( $properties as $k => $v ) { $attributes[ $k ] = $v; } } $currentClass = $currentClass->getParentClass(); } if ( $convertInternalObjects ) { // Analyse all internal objects foreach ( $attributes as $key => $value ) { if ( is_object( $value ) ) { $attributes[ $key ] = self::getAttributes( $value, $flags, $getterPrefix, $useCamelCase ); } } } return $attributes; }
php
static function getAttributes( $obj , $visibilityFlags = null , $getterPrefix = 'get' , $useCamelCase = true , $convertInternalObjects = false ) { if ( ! isset( $obj ) ) { return array(); } $flags = null === $visibilityFlags ? self::allFlags() : $visibilityFlags; $attributes = array(); $reflectionObject = new \ReflectionObject( $obj ); $currentClass = new \ReflectionClass( $obj ); while ( $currentClass !== false && ! $currentClass->isInterface() ) { $properties = $currentClass->getProperties( $flags ); foreach ( $properties as $property ) { $attributeName = $property->getName(); $methodName = $getterPrefix . ( $useCamelCase ? self::mb_ucfirst( $attributeName ) : $attributeName ); if ( $property->isPrivate() || $property->isProtected() ) { if ( $reflectionObject->hasMethod( $methodName ) ) { $method = $reflectionObject->getMethod( $methodName ); if ( $method->isPublic() ) { $attributes[ $attributeName ] = $method->invoke( $obj ); } } else { // maybe has a __call magic method $attributes[ $attributeName ] = $obj->{ $methodName }(); } } else { // public method try { $attributes[ $attributeName ] = $obj->{ $attributeName }; } catch ( \Exception $e ) { // Ignore } } } // No properties? -> try to retrieve public properties if ( count( $properties ) < 1 ) { $properties = get_object_vars( $obj ); foreach ( $properties as $k => $v ) { $attributes[ $k ] = $v; } } $currentClass = $currentClass->getParentClass(); } if ( $convertInternalObjects ) { // Analyse all internal objects foreach ( $attributes as $key => $value ) { if ( is_object( $value ) ) { $attributes[ $key ] = self::getAttributes( $value, $flags, $getterPrefix, $useCamelCase ); } } } return $attributes; }
[ "static", "function", "getAttributes", "(", "$", "obj", ",", "$", "visibilityFlags", "=", "null", ",", "$", "getterPrefix", "=", "'get'", ",", "$", "useCamelCase", "=", "true", ",", "$", "convertInternalObjects", "=", "false", ")", "{", "if", "(", "!", "isset", "(", "$", "obj", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "flags", "=", "null", "===", "$", "visibilityFlags", "?", "self", "::", "allFlags", "(", ")", ":", "$", "visibilityFlags", ";", "$", "attributes", "=", "array", "(", ")", ";", "$", "reflectionObject", "=", "new", "\\", "ReflectionObject", "(", "$", "obj", ")", ";", "$", "currentClass", "=", "new", "\\", "ReflectionClass", "(", "$", "obj", ")", ";", "while", "(", "$", "currentClass", "!==", "false", "&&", "!", "$", "currentClass", "->", "isInterface", "(", ")", ")", "{", "$", "properties", "=", "$", "currentClass", "->", "getProperties", "(", "$", "flags", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "attributeName", "=", "$", "property", "->", "getName", "(", ")", ";", "$", "methodName", "=", "$", "getterPrefix", ".", "(", "$", "useCamelCase", "?", "self", "::", "mb_ucfirst", "(", "$", "attributeName", ")", ":", "$", "attributeName", ")", ";", "if", "(", "$", "property", "->", "isPrivate", "(", ")", "||", "$", "property", "->", "isProtected", "(", ")", ")", "{", "if", "(", "$", "reflectionObject", "->", "hasMethod", "(", "$", "methodName", ")", ")", "{", "$", "method", "=", "$", "reflectionObject", "->", "getMethod", "(", "$", "methodName", ")", ";", "if", "(", "$", "method", "->", "isPublic", "(", ")", ")", "{", "$", "attributes", "[", "$", "attributeName", "]", "=", "$", "method", "->", "invoke", "(", "$", "obj", ")", ";", "}", "}", "else", "{", "// maybe has a __call magic method", "$", "attributes", "[", "$", "attributeName", "]", "=", "$", "obj", "->", "{", "$", "methodName", "}", "(", ")", ";", "}", "}", "else", "{", "// public method", "try", "{", "$", "attributes", "[", "$", "attributeName", "]", "=", "$", "obj", "->", "{", "$", "attributeName", "}", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// Ignore", "}", "}", "}", "// No properties? -> try to retrieve public properties", "if", "(", "count", "(", "$", "properties", ")", "<", "1", ")", "{", "$", "properties", "=", "get_object_vars", "(", "$", "obj", ")", ";", "foreach", "(", "$", "properties", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "attributes", "[", "$", "k", "]", "=", "$", "v", ";", "}", "}", "$", "currentClass", "=", "$", "currentClass", "->", "getParentClass", "(", ")", ";", "}", "if", "(", "$", "convertInternalObjects", ")", "{", "// Analyse all internal objects", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "attributes", "[", "$", "key", "]", "=", "self", "::", "getAttributes", "(", "$", "value", ",", "$", "flags", ",", "$", "getterPrefix", ",", "$", "useCamelCase", ")", ";", "}", "}", "}", "return", "$", "attributes", ";", "}" ]
Retrieve names and values from the attributes of a object, as a map. @param object $obj The object. @param int $visibilityFlags Filter visibility flags. Can be added. Example: RTTI::IS_PRIVATE | RTTI::IS_PROTECTED Optional, defaults to RTTI::allFlags(). @param string $getterPrefix The prefix for getter public methods. Default is 'get'. @param bool $useCamelCase If true, private and protected attributes will be accessed by camelCase public methods. Default is true. @param bool $convertInternalObjects If true, converts internal objects. Default is false. @return array @throws ReflectionException
[ "Retrieve", "names", "and", "values", "from", "the", "attributes", "of", "a", "object", "as", "a", "map", "." ]
train
https://github.com/thiagodp/rtti/blob/513056bb2843bbf495a83f8a1481c9aaec120c4b/lib/RTTI.php#L56-L126
thiagodp/rtti
lib/RTTI.php
RTTI.getPrivateAttributes
static function getPrivateAttributes( $obj, $getterPrefix = 'get', $useCamelCase = true ) { return self::getAttributes( $obj, self::IS_PRIVATE, $getterPrefix, $useCamelCase ); }
php
static function getPrivateAttributes( $obj, $getterPrefix = 'get', $useCamelCase = true ) { return self::getAttributes( $obj, self::IS_PRIVATE, $getterPrefix, $useCamelCase ); }
[ "static", "function", "getPrivateAttributes", "(", "$", "obj", ",", "$", "getterPrefix", "=", "'get'", ",", "$", "useCamelCase", "=", "true", ")", "{", "return", "self", "::", "getAttributes", "(", "$", "obj", ",", "self", "::", "IS_PRIVATE", ",", "$", "getterPrefix", ",", "$", "useCamelCase", ")", ";", "}" ]
Retrieve names and values from the private attributes of a object, as a map. This method has been kept for backward compatibility. @param object $obj The object. @param string $getterPrefix The prefix for getter public methods (defaults to 'get'). @param bool $useCamelCase If true, private attributes will be accessed by camelCase public methods (default true). @return array
[ "Retrieve", "names", "and", "values", "from", "the", "private", "attributes", "of", "a", "object", "as", "a", "map", ".", "This", "method", "has", "been", "kept", "for", "backward", "compatibility", "." ]
train
https://github.com/thiagodp/rtti/blob/513056bb2843bbf495a83f8a1481c9aaec120c4b/lib/RTTI.php#L137-L139