sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public static function reflectFunction($function, $argv = false, $namespace = '')
{
if (!is_string($function) || !function_exists($function)) {
require_once 'Zend/Server/Reflection/Exception.php';
throw new Zend_Server_Reflection_Exception('Invalid function "' . $function . '" passed... | Perform function reflection to create dispatch signatures
Creates dispatch prototypes for a function. It returns a
{@link Zend_Server_Reflection_Function} object.
If extra arguments should be passed to the dispatchable function, these
may be provided as an array to $argv.
@param string $function Function name
@param... | entailment |
public static function getIconTcaSelectItems(int $id = 1, int $typeNum = 0): array
{
$icons = [['---', '']];
foreach (self::getIcons($id, $typeNum) as $iconBasename => $iconName) {
$icons[] = [$iconName, $iconBasename];
}
return $icons;
} | Return all icons as TCA select items
@param int $id Page ID
@param int $typeNum Page type
@return array[] Icon TCA select items
@throws ServiceUnavailableException | entailment |
public static function getIcons(int $id = 1, int $typeNum = 0): array
{
$icons = [];
$typoScriptKey = 'plugin.tx_twcomponentlibrary.settings.iconDirectories';
$iconDirectories = TypoScriptUtility::extractTypoScriptKeyForPidAndType($id, $typeNum, $typoScriptKey);
$iconDire... | Return all icon assets
@param int $id Page ID
@param int $typeNum Page type
@return string[] Icon assets
@throws ServiceUnavailableException | entailment |
public function generateId()
{
return sprintf(
'%08X-%04X-%04X-%02X%02X-%012X',
mt_rand(),
mt_rand(0, 65535),
bindec(substr_replace(
sprintf('%016b', mt_rand(0, 65535)), '0100', 11, 4)
),
bindec(substr_replace(sprintf('%... | generate a unique id
Format is: ########-####-####-####-############
Where # is an uppercase letter or number
example: 6D9DC7EC-A273-83A9-ABE3-00005FD752D6
@return string | entailment |
public static function randomUid($length = 16)
{
if(!isset($length) || intval($length) <= 8 ){
$length = 16;
}
if (function_exists('random_bytes')) {
return bin2hex(random_bytes($length));
}
if (function_exists('mcrypt_create_iv')) {
... | По умолчанию длина 32 символа, если количество символов не передано в параметре $length | entailment |
public static function clean($value = "") {
$value = trim($value); // Убираем пробелы вначале и в конце
$value = stripslashes($value); // Убираем слеши, если надо // Удаляет экранирование символов
$value = strip_tags($value); // Удаляет HTML и PHP-теги из строки
$value = htmlspecia... | Функция клинер. Усиленная замена htmlspecialchars | entailment |
public function classNameForEvent($event): string
{
if ( ! isset($this->eventClasses[$event])) {
throw new \InvalidArgumentException("Could not find a class for the event {$event}.");
}
return $this->eventClasses[$event];
} | retrieve the fully qualified class name for an 'event name'
@param $event
@return string | entailment |
public function setType($type)
{
if (!in_array($type, $this->_types)) {
require_once 'Zend/Server/Exception.php';
throw new Zend_Server_Exception('Invalid method callback type passed to ' . __CLASS__ . '::' . __METHOD__);
}
$this->_type = $type;
return $this;... | Set callback type
@param string $type
@return Zend_Server_Method_Callback
@throws Zend_Server_Exception | entailment |
public function toArray()
{
$type = $this->getType();
$array = array(
'type' => $type,
);
if ('function' == $type) {
$array['function'] = $this->getFunction();
} else {
$array['class'] = $this->getClass();
$array['method'] = $t... | Cast callback to array
@return array | entailment |
public function introspect($serviceClass, $options = array())
{
$this->_options = $options;
if (strpbrk($serviceClass, '\\/<>')) {
return $this->_returnError('Invalid service name');
}
// Transform com.foo.Bar into com_foo_Bar
$serviceClass = str_replace('.' , '... | Create XML definition on an AMF service class
@param string $serviceClass Service class name
@param array $options invocation options
@return string XML with service class introspection | entailment |
protected function _addClassAttributes($typename, DOMElement $typexml)
{
// Do not try to autoload here because _phpTypeToAS should
// have already attempted to load this class
if (!class_exists($typename, false)) {
return;
}
$rc = new Zend_Reflection_Class($type... | Generate map of public class attributes
@param string $typename type name
@param DOMElement $typexml target XML element
@return void | entailment |
protected function _addService(Zend_Server_Reflection_Class $refclass, DOMElement $target)
{
foreach ($refclass->getMethods() as $method) {
if (!$method->isPublic()
|| $method->isConstructor()
|| ('__' == substr($method->name, 0, 2))
) {
... | Build XML service description from reflection class
@param Zend_Server_Reflection_Class $refclass
@param DOMElement $target target XML element
@return void | entailment |
protected function _getPropertyType(Zend_Reflection_Property $prop)
{
$docBlock = $prop->getDocComment();
if (!$docBlock) {
return 'Unknown';
}
if (!$docBlock->hasTag('var')) {
return 'Unknown';
}
$tag = $docBlock->getTag('var');
ret... | Extract type of the property from DocBlock
@param Zend_Reflection_Property $prop reflection property object
@return string Property type | entailment |
protected function _getServicePath()
{
if (isset($this->_options['server'])) {
return $this->_options['server']->getDirectory();
}
if (isset($this->_options['directories'])) {
return $this->_options['directories'];
}
return array();
} | Get the array of service directories
@return array Service class directories | entailment |
protected function _phpTypeToAS($typename)
{
if (class_exists($typename)) {
$vars = get_class_vars($typename);
if (isset($vars['_explicitType'])) {
return $vars['_explicitType'];
}
}
if (false !== ($asname = Zend_Amf_Parse_TypeLoader::get... | Map from PHP type name to AS type name
@param string $typename PHP type name
@return string AS type name | entailment |
protected function _registerType($typename)
{
// Known type - return its AS name
if (isset($this->_typesMap[$typename])) {
return $this->_typesMap[$typename];
}
// Standard types
if (in_array($typename, array('void', 'null', 'mixed', 'unknown_type'))) {
... | Register new type on the system
@param string $typename type name
@return string New type name | entailment |
public function getLanguages() {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Gets the list of languages
@return {array} Standard response base | entailment |
public function getSnippets() {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Gets a list of snippets in an array of languages
@return {array} Standard response base | entailment |
private function mapFolders(SS_List $folders, $searchQuery=null) {
$result=array();
foreach($folders as $folder) {
if(!empty($searchQuery) && $searchQuery!==false) {
$searchEngine=Config::inst()->get('CodeBank', 'snippet_search_engine');
if($searchEng... | Maps the folder and its decendents through recurrsion
@param {SS_List} $folders List of folders to be mapped
@param {string} $searchQuery Search Query
@return {array} Nested array of folder data | entailment |
public function getSnippetsByLanguage($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied'... | Gets a list of snippets that are in the selected index in an array of languages
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function searchSnippets($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Searches for snippets that match the information the client in the search field
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function getSnippetInfo($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Gets a snippet's information
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function getSnippetRevisions($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');... | Gets a revisions of the snippet
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function getSnippetTextFromRevision($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission De... | Gets the of the snippet from a revision
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function newSnippet($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Saves a new snippet
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function saveSnippet($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Saves an existing snippet
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function deleteSnippet($data) {
$response=CodeBank_ClientAPI::responseBase();
try {
$snippet=Snippet::get()->byID(intval($data->id));
if(!empty($snippet) && $snippet!==false && $snippet->ID!=0) {
if($snippet->canDelete()==false) {
... | Deletes a snippet from the database
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function getSnippetDiff($data) {
$response=CodeBank_ClientAPI::responseBase();
//Get the Main Revision
$snippet1=SnippetVersion::get()->byID(intval($data->mainRev));
if(empty($snippet1) || $snippet1===false || $snippet1->ID==0) {
$response['status']='... | Gets the snippet text for the two revisions as well as a unified diff file of the revisions
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function getPackages() {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Gets the list of packages
@return {array} Standard response base | entailment |
public function getPackageInfo($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Gets the details of a package
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function packageRemoveSnippet($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied')... | Removes a snippet from a package
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function findSnippetAutoComplete($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denie... | Finds a snippet begining with the data passed
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function addSnippetToPackage($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');... | Adds a snippet to a package
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function savePackage($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Saves a package
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function createPackage($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Saves a package
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function deletePackage($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Deletes a package
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function newFolder($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Saves a new folder
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function renameFolder($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Renames a folder
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function deleteFolder($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Deletes a folder
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
public function moveSnippet($data) {
$response=CodeBank_ClientAPI::responseBase();
//Ensure logged in
if(!Permission::check('CODE_BANK_ACCESS')) {
$response['status']='EROR';
$response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
... | Deletes a folder
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base | entailment |
final protected function arrayUnmap($array, $keyLbl='id', $valueLbl='title') {
$result=array();
foreach($array as $key=>$value) {
$result[]=array(
$keyLbl=>$key,
$valueLbl=>$value
);
}
... | Converts an array where the key and value should be mapped to a nested array
@param {array} $array Source Array
@param {string} $keyLbl Array's Key mapping name
@param {string} $valueLbl Key's value mapping name
@return {array} Unmapped array | entailment |
final protected function overviewList(SS_List $list, $labelField='Title', $idField='ID') {
$result=array();
$idFieldLower=strtolower($idField);
$labelFieldLower=strtolower($labelField);
$args=func_get_args();
unset($args[0]);
unset($args[1]);
uns... | Converts an SS_List into an array of items with and id and a title key
@param {SS_List} $list List to parse
@param {string} $labelField Label Field
@param {string} $idField ID Field
@param {string} ... Overloaded for additional fields, allows for silverstripe relation formatting ex: Relationship.Field the dot is replac... | entailment |
final protected function sortToTop($value, $field, $array) {
foreach($array as $key=>$item) {
if($item->$field==$value) {
unset($array[$key]);
array_unshift($array, $item);
break;
}
}
return $array;
} | Sorts an item to the top of the list
@param {mixed} $value Value to look for
@param {mixed} $field Field to look on
@param {array} $array Array to sort
@return {array} Finalized array | entailment |
public function send($mobile, $content)
{
if ($this->fileMode && $this->_sendAsFile($mobile, $content)) {
$this->message = '短信发送成功!';
return true;
}
return false;
} | 发送短信
@param string $mobile 对方手机号码
@param string $content 短信内容
@return boolean 短信是否发送成功 | entailment |
public function sendByTemplate($mobile, $data, $id)
{
if ($this->fileMode) {
$content = print_r($data, true);
if ($this->_sendAsFile($mobile, $content)) {
$this->message = '短信发送成功!';
return true;
}
}
return false;
... | 发送模板短信
@param string $mobile 对方手机号码
@param mixed $data 键值对
@param number $id 模板id
@return boolean 短信是否发送成功 | entailment |
private function _sendAsFile($mobile, $content)
{
$dir = Yii::getAlias('@app/runtime/smser');
try {
if (!FileHelper::createDirectory($dir)) {
throw new \Exception('无法创建目录:' . $dir);
}
$filename = $dir . DIRECTORY_SEPARATOR . time(... | 用于存储短信内容
@param string $mobile
@param string $content
@throws \Exception
@return boolean | entailment |
protected function getDependencyTemplateResources()
{
$templateResources = [];
// Run through all component dependencies
foreach ($this->dependencies as $dependency) {
$templateResources[] = $this->objectManager->get($dependency)->getPreviewTemplateResources();
}
... | Get the template resources of component dependencies
@return TemplateResources[] Component dependency templace resources | entailment |
protected function determineExtensionName()
{
$reflectionClass = new \ReflectionClass($this);
$componentFilePath = dirname($reflectionClass->getFileName());
// If the file path is invalid
$extensionDirPosition = strpos($componentFilePath, 'ext'.DIRECTORY_SEPARATOR);
if ($e... | Find the extension name the current component belongs to
@throws \RuntimeException If the component path is invalid
@throws \ReflectionException | entailment |
protected function determineNameAndVariant()
{
$reflectionClass = new \ReflectionClass($this);
$componentName = preg_replace('/Component$/', '', $reflectionClass->getShortName());
list($this->basename, $variant) = preg_split('/_+/', $componentName, 2);
$this->name = self::expand... | Determine the component name and variant | entailment |
public static function expandComponentName($componentPath)
{
return trim(
implode(
' ',
array_map(
'ucwords', preg_split('/_+/', GeneralUtility::camelCaseToLowerCaseUnderscored($componentPath))
)
)
) ?: null;... | Prepare a component path
@param string $componentPath Component path
@return string Component name | entailment |
protected function addDocumentation()
{
$docDirectory = $this->getDocumentationDirectory();
// If there's a documentation directory
if (is_dir($docDirectory)) {
$validIndexDocuments = [
'index.md',
'readme.md',
strtolower($this->ba... | Add an external documentation | entailment |
protected function getDocumentationDirectory($rootRelative = false)
{
$reflectionObject = new \ReflectionObject($this);
$componentFile = $reflectionObject->getFileName();
$docDirectory = dirname($componentFile).DIRECTORY_SEPARATOR.$this->basename;
return $rootRelative ? subst... | Return the documentation directory for this component
@param bool $rootRelative Return a root relative path
@return string Documentation directory | entailment |
protected function addNotice($notice)
{
if (!$this->variant) {
$notice = trim($notice);
$this->notice = strlen($notice) ? $this->exportNotice($notice) : null;
}
} | Add a notice
@param string $notice Notice | entailment |
protected function exportNotice($notice)
{
$docDirectoryPath = strtr($this->getDocumentationDirectory(true), [DIRECTORY_SEPARATOR => '/']).'/';
return preg_replace_callback('/\[([^\]]*?)\]\(([^\)]*?)\)/', function($match) use ($docDirectoryPath) {
return '['.$match[1].']('
... | Export a notice
@param $notice
@return mixed | entailment |
final public function export()
{
$properties = [
'status' => $this->status,
'name' => $this->name,
'variant' => $this->variant,
'label' => $this->label,
'class' => get_class($this),
'type' => $this->type,
'valid' ... | Export the component's properties
@return array Properties | entailment |
protected function exportInternal()
{
$properties = [];
// Export the configuration & $template
if (!$this->config) {
throw new \RuntimeException('Invalid configuration', 1481363496);
}
$properties['config'] = $this->config;
$properties['template'] =... | Return component specific properties
Override this method in sub classes to export specific properties.
@return array Component specific properties | entailment |
protected function exportRequest()
{
// Set the request language
if ($this->languageParameter) {
$this->request->setArgument($this->languageParameter, $this->sysLanguage);
}
$this->request->setControllerExtensionName($this->extensionName);
// Set page ID and typ... | Export the request options
@return array | entailment |
protected function addResource($resource)
{
$resource = trim($resource);
if (strlen($resource)) {
$this->resources[] = $resource;
}
} | Add an associated resource
@param string $resource Associated resource | entailment |
protected function setPreview($preview)
{
if (!($preview instanceof TemplateInterface) && !is_string($preview) && ($preview !== null)) {
throw new \RuntimeException('Invalid preview preview', 1481368492);
}
$this->preview = $preview;
} | Set a preview template
@param TemplateInterface|string|null $preview Preview template | entailment |
protected function initializeTSFE()
{
$GLOBALS['TSFE'] = TypoScriptUtility::getTSFE($this->page, $this->typeNum);
$GLOBALS['TSFE']->cObj = new ContentObjectRenderer($GLOBALS['TSFE']);
$GLOBALS['TSFE']->cObj->start($GLOBALS['TSFE']->page, 'pages');
return $GLOBALS['TSFE']->cObj... | Initialize a global Frontend renderer and return a content object renderer instance
@return ContentObjectRenderer Content object renderer
@throws \Exception
@throws \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException | entailment |
protected function addError($property, $message)
{
$this->validationErrors->forProperty($property)->addError(new Error($message, time()));
} | Register a validation error
@param string $property Property
@param string $message Validation error message | entailment |
function _added( $lines, $encode = true ) {
$r = '';
foreach ($lines as $line) {
if ( $encode )
$line = htmlspecialchars( $line );
$r .= '<tr>' . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n";
}
return $r;
} | @ignore
@access private
@param array $lines
@param bool $encode
@return string | entailment |
function _deleted( $lines, $encode = true ) {
$r = '';
foreach ($lines as $line) {
if ( $encode )
$line = htmlspecialchars( $line );
$r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . "</tr>\n";
}
return $r;
} | @ignore
@access private
@param array $lines
@param bool $encode
@return string | entailment |
function _context( $lines, $encode = true ) {
$r = '';
foreach ($lines as $line) {
if ( $encode )
$line = htmlspecialchars( $line );
$r .= '<tr>' .
$this->contextLine( $line ) . $this->contextLine( $line ) . "</tr>\n";
}
return $r;
} | @ignore
@access private
@param array $lines
@param bool $encode
@return string | entailment |
function _changed( $orig, $final ) {
$r = '';
// Does the aforementioned additional processing
// *_matches tell what rows are "the same" in orig and final. Those pairs will be diffed to get word changes
// match is numeric: an index in other column
// match is 'X': no match. It is a new row
// *_... | Process changed lines to do word-by-word diffs for extra highlighting.
(TRAC style) sometimes these lines can actually be deleted or added rows.
We do additional processing to figure that out
@access private
@since 2.6.0
@param array $orig
@param array $final
@return string | entailment |
function interleave_changed_lines( $orig, $final ) {
// Contains all pairwise string comparisons. Keys are such that this need only be a one dimensional array.
$matches = array();
foreach ( array_keys($orig) as $o ) {
foreach ( array_keys($final) as $f ) {
$matches["$o,$f"] = $this->compute_string_... | Takes changed blocks and matches which rows in orig turned into which rows in final.
Returns
*_matches ( which rows match with which )
*_rows ( order of rows in each column interleaved with blank rows as
necessary )
@since 2.6.0
@param unknown_type $orig
@param unknown_type $final
@return unknown | entailment |
function compute_string_distance( $string1, $string2 ) {
// Vectors containing character frequency for all chars in each string
$chars1 = count_chars($string1);
$chars2 = count_chars($string2);
// L1-norm of difference vector.
$difference = array_sum( array_map( array(&$this, 'difference'), $chars1, $c... | Computes a number that is intended to reflect the "distance" between two strings.
@since 2.6.0
@param string $string1
@param string $string2
@return int | entailment |
function _splitOnWords($string, $newlineEscape = "\n") {
$string = str_replace("\0", '', $string);
$words = preg_split( '/([^\w])/u', $string, -1, PREG_SPLIT_DELIM_CAPTURE );
$words = str_replace( "\n", $newlineEscape, $words );
return $words;
} | @ignore
@since 2.6.0
@param string $string
@param string $newlineEscape
@return string | entailment |
public function setAuth(Zend_Amf_Auth_Abstract $auth)
{
$this->_auth = $auth;
if ((null === $this->getAcl()) && method_exists($auth, 'getAcl')) {
$this->setAcl($auth->getAcl());
}
return $this;
} | Set authentication adapter
If the authentication adapter implements a "getAcl()" method, populate
the ACL of this instance with it (if none exists already).
@param Zend_Amf_Auth_Abstract $auth
@return Zend_Amf_Server | entailment |
protected function _checkAcl($object, $function)
{
if(!$this->_acl) {
return true;
}
if($object) {
$class = is_object($object)?get_class($object):$object;
if(!$this->_acl->has($class)) {
require_once 'Zend/Acl/Resource.php';
... | Check if the ACL allows accessing the function or method
@param string|object $object Object or class being accessed
@param string $function Function or method being accessed
@return unknown_type | entailment |
protected function _loadCommandMessage(Zend_Amf_Value_Messaging_CommandMessage $message)
{
require_once 'Zend/Amf/Value/Messaging/AcknowledgeMessage.php';
switch($message->operation) {
case Zend_Amf_Value_Messaging_CommandMessage::DISCONNECT_OPERATION :
case Zend_Amf_Value_Me... | Handles each of the 11 different command message types.
A command message is a flex.messaging.messages.CommandMessage
@see Zend_Amf_Value_Messaging_CommandMessage
@param Zend_Amf_Value_Messaging_CommandMessage $message
@return Zend_Amf_Value_Messaging_AcknowledgeMessage | entailment |
protected function _errorMessage($objectEncoding, $message, $description, $detail, $code, $line)
{
$return = null;
switch ($objectEncoding) {
case Zend_Amf_Constants::AMF0_OBJECT_ENCODING :
return array (
'description' => ($this->isProduction ()) ?... | Create appropriate error message
@param int $objectEncoding Current AMF encoding
@param string $message Message that was being processed when error happened
@param string $description Error description
@param mixed $detail Detailed data about the error
@param int $code Error code
@param int $line Error line
@return Ze... | entailment |
protected function _handleAuth( $userid, $password)
{
if (!$this->_auth) {
return true;
}
$this->_auth->setCredentials($userid, $password);
$auth = Zend_Auth::getInstance();
$result = $auth->authenticate($this->_auth);
if ($result->isValid()) {
... | Handle AMF authentication
@param string $userid
@param string $password
@return boolean | entailment |
protected function _handle(Zend_Amf_Request $request)
{
// Get the object encoding of the request.
$objectEncoding = $request->getObjectEncoding();
// create a response object to place the output from the services.
$response = $this->getResponse();
// set response encoding
... | Takes the deserialized AMF request and performs any operations.
@todo should implement and SPL observer pattern for custom AMF headers
@todo DescribeService support
@param Zend_Amf_Request $request
@return Zend_Amf_Response
@throws Zend_Amf_server_Exception|Exception | entailment |
public function handle($request = null)
{
// Check if request was passed otherwise get it from the server
if ($request === null || !$request instanceof Zend_Amf_Request) {
$request = $this->getRequest();
} else {
$this->setRequest($request);
}
if ($thi... | Handle an AMF call from the gateway.
@param null|Zend_Amf_Request $request Optional
@return Zend_Amf_Response | entailment |
public function setRequest($request)
{
if (is_string($request) && class_exists($request)) {
$request = new $request();
if (!$request instanceof Zend_Amf_Request) {
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception('Inval... | Set request object
@param string|Zend_Amf_Request $request
@return Zend_Amf_Server | entailment |
public function setResponse($response)
{
if (is_string($response) && class_exists($response)) {
$response = new $response();
if (!$response instanceof Zend_Amf_Response) {
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exceptio... | Public access method to private Zend_Amf_Server_Response reference
@param string|Zend_Amf_Server_Response $response
@return Zend_Amf_Server | entailment |
public function getResponse()
{
if (null === ($response = $this->_response)) {
require_once 'Zend/Amf/Response/Http.php';
$this->setResponse(new Zend_Amf_Response_Http());
}
return $this->_response;
} | get a reference to the Zend_Amf_response instance
@return Zend_Amf_Server_Response | entailment |
public function setClass($class, $namespace = '', $argv = null)
{
if (is_string($class) && !class_exists($class)){
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception('Invalid method or class');
} elseif (!is_string($class) && !is_object($class))... | Attach a class or object to the server
Class may be either a class name or an instantiated object. Reflection
is done on the class or object to determine the available public
methods, and each is attached to the server as and available method. If
a $namespace has been provided, that namespace is used to prefix
AMF ser... | entailment |
public function addFunction($function, $namespace = '')
{
if (!is_string($function) && !is_array($function)) {
require_once 'Zend/Amf/Server/Exception.php';
throw new Zend_Amf_Server_Exception('Unable to attach function');
}
$argv = null;
if (2 < func_num_arg... | Attach a function to the server
Additional arguments to pass to the function at dispatch may be passed;
any arguments following the namespace will be aggregated and passed at
dispatch time.
@param string|array $function Valid callback
@param string $namespace Optional namespace prefix
@return Zend_Amf_Server
@throw... | entailment |
public function getCMSFields() {
$fields=new FieldList(
new TabSet('Root',
new Tab('Main', _t('SnippetPackage.MAIN', '_Main'),
new TextField('Title', _t('SnippetPackage.TITLE', '_T... | Gets fields used in the cms
@return {FieldList} Fields to be used | entailment |
public function handleAuthenticationSuccess(TokenInterface $token, Request $request, GuardAuthenticatorInterface $guardAuthenticator, $providerKey)
{
$response = $guardAuthenticator->onAuthenticationSuccess($request, $token, $providerKey);
// check that it's a Response or null
if ($response... | Returns the "on success" response for the given GuardAuthenticator.
@param TokenInterface $token
@param Request $request
@param GuardAuthenticatorInterface $guardAuthenticator
@param string $providerKey The provider (i.e. firewall) key
@return null|Response | entailment |
public function authenticateUserAndHandleSuccess(UserInterface $user, Request $request, GuardAuthenticatorInterface $authenticator, $providerKey)
{
// create an authenticated token for the User
$token = $authenticator->createAuthenticatedToken($user, $providerKey);
// authenticate this in th... | Convenience method for authenticating the user and returning the
Response *if any* for success.
@param UserInterface $user
@param Request $request
@param GuardAuthenticatorInterface $authenticator
@param string $providerKey The provider (i.e. firewall) key
@ret... | entailment |
public function handleAuthenticationFailure(AuthenticationException $authenticationException, Request $request, GuardAuthenticatorInterface $guardAuthenticator)
{
$this->tokenStorage->setToken(null);
$response = $guardAuthenticator->onAuthenticationFailure($request, $authenticationException);
... | Handles an authentication failure and returns the Response for the
GuardAuthenticator.
@param AuthenticationException $authenticationException
@param Request $request
@param GuardAuthenticatorInterface $guardAuthenticator
@return null|Response | entailment |
public function readBytes($length)
{
if (($length + $this->_needle) > $this->_streamLength) {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Buffer underrun at needle position: ' . $this->_needle . ' while requesting length: ' . $length);
}
$byte... | Read the number of bytes in a row for the length supplied.
@todo Should check that there are enough bytes left in the stream we are about to read.
@param int $length
@return string
@throws Zend_Amf_Exception for buffer underrun | entailment |
public function readByte()
{
if (($this->_needle + 1) > $this->_streamLength) {
require_once 'Zend/Amf/Exception.php';
throw new Zend_Amf_Exception('Buffer underrun at needle position: ' . $this->_needle . ' while requesting length: ' . $length);
}
return ord($this->... | Reads a signed byte
@return int Value is in the range of -128 to 127. | entailment |
public function writeUtf($stream)
{
$this->writeInt(strlen($stream));
$this->_stream.= $stream;
return $this;
} | Wite a UTF-8 string to the outputstream
@param string $stream
@return Zend_Amf_Util_BinaryStream | entailment |
public function readDouble()
{
$bytes = substr($this->_stream, $this->_needle, 8);
$this->_needle+= 8;
if (!$this->_bigEndian) {
$bytes = strrev($bytes);
}
$double = unpack('dflt', $bytes);
return $double['flt'];
} | Reads an IEEE 754 double-precision floating point number from the data stream.
@return double Floating point number | entailment |
public function writeDouble($stream)
{
$stream = pack('d', $stream);
if (!$this->_bigEndian) {
$stream = strrev($stream);
}
$this->_stream.= $stream;
return $this;
} | Writes an IEEE 754 double-precision floating point number from the data stream.
@param string|double $stream
@return Zend_Amf_Util_BinaryStream | entailment |
public function setFile($path)
{
if (empty($path) || !is_readable($path)) {
/**
* @see Zend_Auth_Adapter_Http_Resolver_Exception
*/
require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
throw new Zend_Auth_Adapter_Http_Resolver_Exception(... | Set the path to the credentials file
@param string $path
@throws Zend_Auth_Adapter_Http_Resolver_Exception
@return Zend_Auth_Adapter_Http_Resolver_File Provides a fluent interface | entailment |
public function resolve($username, $realm)
{
if (empty($username)) {
/**
* @see Zend_Auth_Adapter_Http_Resolver_Exception
*/
require_once 'Zend/Auth/Adapter/Http/Resolver/Exception.php';
throw new Zend_Auth_Adapter_Http_Resolver_Exception('Userna... | Resolve credentials
Only the first matching username/realm combination in the file is
returned. If the file contains credentials for Digest authentication,
the returned string is the password hash, or h(a1) from RFC 2617. The
returned string is the plain-text password for Basic authentication.
The expected format of ... | entailment |
public function positiveMatch(string $name, $subject, array $arguments): ?\PhpSpec\Wrapper\DelayedCall
{
list($realEvents, $targetEvents) = $this->formatArguments($subject, $arguments);
$notFoundEvents = $this->eventsNotFound($realEvents, $targetEvents);
if ( ! empty($notFoundEvents)) {
... | Evaluates positive match.
Yes, I know that this is some really hard to understand code.
This is one of the more interesting areas to improve upon
@param string $name
@param mixed $subject
@param array $arguments | entailment |
private function eventIsFound(DomainEvent $targetEvent, DomainEvents $realEvents)
{
$found = $realEvents->filter(function ($realEvent) use ($targetEvent) {
try {
$eventsAreEqual = $this->eventsAreEqual($realEvent, $targetEvent);
} catch (FailureException $e) {
... | returns true if an event is found | entailment |
private function eventsAreEqual($e1, $e2)
{
// events aren't equal if they have different classes
if (get_class($e1) != get_class($e2)) {
return false;
}
// compare their values..
$reflection = new \ReflectionClass($e1);
$fields = array_map(function ($pr... | pull requests accepted | entailment |
public function uploadFileAction(Request $request, $dir_path)
{
/** @var FileManagerService $service */
$service = $this->get('youwe.file_manager.service');
/** @var FileManagerDriver $driver */
$driver = $this->get('youwe.file_manager.driver');
$parameters = $this->containe... | @Route(
"/upload/{dir_path}",
name="youwe_file_manager_upload",
options={"expose":true},
requirements={"dir_path":".+"}
)
@Route("/upload/", name="youwe_file_manager_upload_root", options={"expose":true}, defaults={"dir_path":""})
@param Request $request
@param string $dir_path
@return Response
@throws \Exception whe... | entailment |
public function fileActions(Request $request, $action)
{
if ($action === FileManager::FILE_PASTE && !$this->get('session')->has('copy')) {
return new Response();
}
/** @var FileManagerService $service */
$service = $this->get('youwe.file_manager.service');
if (!$... | @Route("/delete", name="youwe_file_manager_delete", defaults={"action":FileManager::FILE_DELETE}, options={"expose":true})
@Route("/move", name="youwe_file_manager_move", defaults={"action":FileManager::FILE_MOVE}, options={"expose":true})
@Route("/extract", name="youwe_file_manager_extract", defaults={"action":FileMan... | entailment |
public function DownloadAction(Request $request, $path)
{
/** @var FileManagerService $service */
$service = $this->get('youwe.file_manager.service');
$service->checkToken($request->get('token'));
/** @var FileManagerDriver $driver */
$driver = $this->get('youwe.file_manager... | @Route(
"/download/{token}/{path}",
name="youwe_file_manager_download",
requirements={"path"=".+"},
options={"expose":true}
)
@param Request $request
@param string $path the path of the file that is downloaded
@return Response | entailment |
public function authenticate() {
$id = $this->_id;
if (!empty($id)) {
$consumer = new Zend_OpenId_Consumer($this->_storage);
$consumer->setHttpClient($this->_httpClient);
/* login() is never returns on success */
if (!$this->_check_immediate) {
... | Authenticates the given OpenId identity.
Defined by Zend_Auth_Adapter_Interface.
@throws Zend_Auth_Adapter_Exception If answering the authentication query is impossible
@return Zend_Auth_Result | entailment |
protected function guardType($items) : void {
// this allows guardType($items) to receive
// both a single item or an array of items
if ( ! is_array($items)) {
$items = array($items);
}
// throw an exception if any items are not
// an instance of the required... | ensure that items added to the collection conform to
the defined collection type
@param $items | entailment |
public function map(Callable $f) : Collection {
try {
return new static(array_map($f, $this->items));
} catch (\Exception $e) {
return new Collection(array_map($f, $this->items));
}
} | return a new instance of this collection with values that
have been transformed by the provided function.
if the values conform to the defined type for this collection
then the new collection instance will be of the same type
as the original.
if the values do not conform to the defined type then a
generic untyped col... | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.