_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q6200 | Httpclient.post | train | public function post($url, $params = array(), $options = array())
{
| php | {
"resource": ""
} |
q6201 | Httpclient.put | train | public function put($url, $params = array(), $options = array())
{
| php | {
"resource": ""
} |
q6202 | Httpclient.patch | train | public function patch($url, $params = array(), $options = array())
{
| php | {
"resource": ""
} |
q6203 | Httpclient.delete | train | public function delete($url, $params = array(), $options = array())
{
| php | {
"resource": ""
} |
q6204 | Httpclient.splitHeaders | train | protected function splitHeaders($rawHeaders)
{
$headers = array();
$lines = explode("\n", trim($rawHeaders));
$headers['HTTP'] = array_shift($lines);
foreach ($lines as $h) {
$h = explode(':', $h, 2);
| php | {
"resource": ""
} |
q6205 | Httpclient.doCurl | train | protected function doCurl()
{
$response = curl_exec($this->curl);
if (curl_errno($this->curl)) {
throw new \Exception(curl_error($this->curl), 1);
}
$curlInfo = curl_getinfo($this->curl);
$results = array(
| php | {
"resource": ""
} |
q6206 | T3Salutation.translate | train | public function translate( $value )
{
switch( $value )
{
case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR:
return 0;
case \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS:
return 1;
| php | {
"resource": ""
} |
q6207 | T3Salutation.reverse | train | public function reverse( $value )
{
switch( $value )
{
case 0:
return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MR;
case 1:
return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MRS;
case 2:
return \Aimeos\MShop\Common\Item\Address\Base::SALUTATION_MISS;
case 10:
| php | {
"resource": ""
} |
q6208 | JsonApiExtension.createJsonApi | train | protected function createJsonApi($source, DocumentHydrator $hydrator): JsonApiObject
{
$jsonApi = isset($source->version)
? new JsonApiObject($source->version)
| php | {
"resource": ""
} |
q6209 | AttachmentsController.preview | train | public function preview($attachmentId = null)
{
// FIXME cache previews
$attachment = $this->Attachments->get($attachmentId);
$this->_checkAuthorization($attachment);
switch ($attachment->filetype) {
case 'image/png':
case 'image/jpg':
case 'image/jpeg':
case 'image/gif':
$image = new \Imagick($attachment->getAbsolutePath());
if (Configure::read('Attachments.autorotate')) {
$this->_autorotate($image);
}
break;
case 'application/pdf':
// Will render a preview of the first page of this PDF
$image = new \Imagick($attachment->getAbsolutePath() . '[0]');
break;
default:
$image = | php | {
"resource": ""
} |
q6210 | AttachmentsController.view | train | public function view($attachmentId = null)
{
// FIXME cache previews
$attachment = $this->Attachments->get($attachmentId);
$this->_checkAuthorization($attachment);
switch ($attachment->filetype) {
case 'image/png':
case 'image/jpg':
case 'image/jpeg':
case 'image/gif':
$image = new \Imagick($attachment->getAbsolutePath());
if (Configure::read('Attachments.autorotate')) {
$this->_autorotate($image);
}
break;
case 'application/pdf':
header('Content-Type: ' . $attachment->filetype);
$file = new File($attachment->getAbsolutePath());
echo $file->read();
exit;
break;
| php | {
"resource": ""
} |
q6211 | AttachmentsController.download | train | public function download($attachmentId = null)
{
$attachment = $this->Attachments->get($attachmentId);
$this->_checkAuthorization($attachment);
$this->response->file($attachment->getAbsolutePath(), [
| php | {
"resource": ""
} |
q6212 | AttachmentsController._checkAuthorization | train | protected function _checkAuthorization(Attachment $attachment)
{
if ($attachmentsBehavior = $attachment->getRelatedTable()->behaviors()->get('Attachments')) {
$behaviorConfig = $attachmentsBehavior->config();
if (is_callable($behaviorConfig['downloadAuthorizeCallback'])) {
$relatedEntity = $attachment->getRelatedEntity();
| php | {
"resource": ""
} |
q6213 | AttachmentsController._autorotate | train | protected function _autorotate(\Imagick $image)
{
switch ($image->getImageOrientation()) {
case \Imagick::ORIENTATION_TOPRIGHT:
$image->flopImage();
break;
case \Imagick::ORIENTATION_BOTTOMRIGHT:
$image->rotateImage('#000', 180);
break;
case \Imagick::ORIENTATION_BOTTOMLEFT:
$image->flopImage();
$image->rotateImage('#000', 180);
break;
case \Imagick::ORIENTATION_LEFTTOP:
$image->flopImage();
$image->rotateImage('#000', -90);
break;
case \Imagick::ORIENTATION_RIGHTTOP:
$image->rotateImage('#000', 90);
break;
case | php | {
"resource": ""
} |
q6214 | AttachmentsController.saveTags | train | public function saveTags($attachmentId = null)
{
$this->request->allowMethod('post');
$attachment = $this->Attachments->get($attachmentId);
$this->_checkAuthorization($attachment);
if (!TableRegistry::get($attachment->model)) {
throw new \Cake\ORM\Exception\MissingTableClassException('Could not find Table ' . $attachment->model);
}
$inputArray = explode('&', $this->request->input('urldecode'));
$tags = explode('$', explode('=', $inputArray[0])[1]);
| php | {
"resource": ""
} |
q6215 | Autoload.autoload | train | public function autoload($class)
{
/* On explose la classe par '\' */
$parts = preg_split('#\\\#', $class);
/* On extrait le dernier element. */
$className = array_pop($parts);
/* On créé le chemin vers la classe */
$path = implode('\\', $parts);
$file = $className . '.php';
/*
* Si la classe recherchée est à la racine du namespace le chemin sera
* égale à la clé. Cette condition peut éviter la boucle.
*/
if (isset($this->prefix[ $path ])) {
$filepath = $this->relplaceSlash($this->prefix[ $path ] . self::DS . $file);
if ($this->requireFile($filepath)) {
return $filepath;
}
}
/*
* Recherche une correspondance entre le namespace fournit en librairie
* et la classe instanciée.
*/
foreach ($this->lib as $nameSpace => $src) {
$filepath = $this->relplaceSlash(str_replace($nameSpace, $src, $class) . '.php');
| php | {
"resource": ""
} |
q6216 | Min.sizeMin | train | protected function sizeMin($key, $lengthValue, $min, $not = true)
{
if ($lengthValue < $min && $not) {
$this->addReturn($key, 'must', [ ':min' => $min ]);
} | php | {
"resource": ""
} |
q6217 | DataStoreController.listAction | train | public function listAction()
{
/** @var FeatureTypeService $featureService */
$featureService = $this->container->get("features");
$featureTypes | php | {
"resource": ""
} |
q6218 | Signature.verify | train | final public function verify(string $header, string $body, int $threshold = 3600): bool
{
$signature = new Verify($this->key, 'sha256', | php | {
"resource": ""
} |
q6219 | Signature.verifyFrom | train | final public function verifyFrom(ResponseInterface $message, int $threshold = 3600): bool
{
$response = new Response($message);
return $this->verify(
| php | {
"resource": ""
} |
q6220 | AttributeProcessor.processMethod | train | protected function processMethod(\ReflectionMethod $method, Definition $definition)
{
$annotations = $this->reader->getMethodAnnotations($method);
foreach ($annotations as $annotation)
{
if ($annotation instanceof AttributeAnnotation) {
| php | {
"resource": ""
} |
q6221 | AttributeProcessor.validateMethodAttribute | train | protected function validateMethodAttribute(AttributeAnnotation $annotation, \ReflectionMethod $method)
{
if (! $method->isPublic()) {
throw new \LogicException(sprintf(
'Attribute annotation can be applied only to non public method "%s".',
$method->getName()
));
}
if ($annotation->getter !== null) {
throw new | php | {
"resource": ""
} |
q6222 | AttributeProcessor.createAttributeByProperty | train | protected function createAttributeByProperty(AttributeAnnotation $annotation, \ReflectionProperty $property): Attribute
{
$name = ($annotation->name === null)
? $property->getName()
: $annotation->name;
$getter = ($annotation->getter === null)
? $this->resolveGetter($property)
: $annotation->getter;
$setter = ($annotation->setter === null)
? $this->resolveSetter($property)
: $annotation->setter;
$attribute = new Attribute($name, $getter);
| php | {
"resource": ""
} |
q6223 | AttributeProcessor.createAttributeByMethod | train | protected function createAttributeByMethod(AttributeAnnotation $annotation, \ReflectionMethod $method): Attribute
{
$name = ($annotation->name === null)
? $this->resolveNameByMethod($method)
: $annotation->name;
$attribute = new Attribute($name, $method->getName());
if ($annotation->setter !== null) {
| php | {
"resource": ""
} |
q6224 | AttributeProcessor.resolveNameByMethod | train | protected function resolveNameByMethod(\ReflectionMethod $method): string
{
$name = $method->getName();
| php | {
"resource": ""
} |
q6225 | PaymentProcessor.executeQuery | train | public function executeQuery($queryName, PaymentTransaction $paymentTransaction)
{
$query = $this->getQuery($queryName);
$response = null;
try
{
$request = $query->createRequest($paymentTransaction);
| php | {
"resource": ""
} |
q6226 | PaymentProcessor.processCustomerReturn | train | public function processCustomerReturn(CallbackResponse $callbackResponse, PaymentTransaction $paymentTransaction)
{
$callbackResponse->setType('customer_return');
| php | {
"resource": ""
} |
q6227 | PaymentProcessor.processPaynetEasyCallback | train | public function processPaynetEasyCallback(CallbackResponse $callbackResponse, PaymentTransaction $paymentTransaction)
{
try
{
$this->getCallback($callbackResponse->getType())
->processCallback($paymentTransaction, $callbackResponse);
}
catch (Exception $e)
{
| php | {
"resource": ""
} |
q6228 | PaymentProcessor.setHandler | train | public function setHandler($handlerName, $handlerCallback)
{
$this->checkHandlerName($handlerName);
if (!is_callable($handlerCallback))
{
| php | {
"resource": ""
} |
q6229 | PaymentProcessor.callHandler | train | protected function callHandler($handlerName)
{
$this->checkHandlerName($handlerName);
$arguments = func_get_args();
array_shift($arguments);
if ($this->hasHandler($handlerName))
{
| php | {
"resource": ""
} |
q6230 | Link.merge | train | public function merge(self $link)
{
$this->parameters = array_replace(
$link->getParameters(),
| php | {
"resource": ""
} |
q6231 | PasswordGrant.authenticate | train | public function authenticate(string $username, string $password, ?string $scope = '*'): Response
{
$body = $this->mergeApiBody(
\array_filter(\compact('username', 'password', 'scope'))
);
return $this->send('POST', 'oauth/token', $this->getApiHeaders(), $body)
->validateWith(function ($statusCode, $response) {
if ($statusCode !== 200) {
| php | {
"resource": ""
} |
q6232 | PasswordGrant.getApiBody | train | protected function getApiBody(): array
{
$clientId = $this->client->getClientId();
$clientSecret = $this->client->getClientSecret();
if (empty($clientId) || empty($clientSecret)) {
throw new InvalidArgumentException('Missing client_id and client_secret information!');
}
| php | {
"resource": ""
} |
q6233 | Validator.isValid | train | public function isValid()
{
$this->key = [];
$this->errors = [];
$this->correctInputs();
foreach ($this->rules as $key => $test) {
/* Si la valeur est requise uniquement avec la présence de certains champs. */
if ($this->isRequiredWhith($key) && $this->isOneVoidValue($key)) {
continue;
}
/* Si la valeur est requise uniquement en l'absence de certains champs. */
if ($this->isRequiredWhithout($key) && !$this->isAllVoidValue($key)) {
continue;
}
/* Si la valeur n'est | php | {
"resource": ""
} |
q6234 | Validator.isNotRequired | train | protected function isNotRequired($key)
{
return strstr($this->rules[ $key ], '!required') && | php | {
"resource": ""
} |
q6235 | Validator.isVoidValue | train | protected function isVoidValue($key)
{
$require = new Rules\Required;
$require->execute('required', $key, | php | {
"resource": ""
} |
q6236 | StatusQuery.setNeededAction | train | protected function setNeededAction(Response $response) {
if ($response->hasHtml())
{
$response->setNeededAction(Response::NEEDED_SHOW_HTML);
}
elseif | php | {
"resource": ""
} |
q6237 | StatusQuery.setFieldsFromResponse | train | protected function setFieldsFromResponse(PaymentTransaction $paymentTransaction, Response $response) {
$payment = $paymentTransaction->getPayment();
$card = $payment->getRecurrentCardFrom();
if ($response->offsetExists('card-ref-id'))
{
$card->setPaynetId($response['card-ref-id']);
}
if ($response->offsetExists('last-four-digits'))
{
$card->setLastFourDigits($response['last-four-digits']);
}
if ($response->offsetExists('bin'))
{
$card->setBin($response['bin']);
}
if ($response->offsetExists('cardholder-name'))
{
$card->setCardPrintedName($response['cardholder-name']);
} | php | {
"resource": ""
} |
q6238 | Colors.colorize | train | public static function colorize($text, $fgcolor = null, $bgcolor = null)
{
$colors = '';
if ($bgcolor) {
$colors .= self::getBgColorString(self::getColorCode($bgcolor));
| php | {
"resource": ""
} |
q6239 | Colors.colorizeLines | train | public static function colorizeLines($text, $fgcolor = null, $bgcolor = null)
{
$lines = explode("\n", $text);
foreach ($lines as &$line) {
| php | {
"resource": ""
} |
q6240 | Colors.getColorCode | train | public static function getColorCode($color, $options = array())
{
$code = (int) $color;
if (is_string($color)) {
$options = array_merge(explode('+', strtolower($color)), $options);
$color = array_shift($options);
if (!isset(self::$colors[$color])) {
throw new ConsoleException("Unknown color '$color'");
}
$code = self::$colors[$color];
}
foreach ($options as $opt) {
| php | {
"resource": ""
} |
q6241 | Colors.getFgColorString | train | public static function getFgColorString($colorCode)
{
list($color, $options) = self::extractColorAndOptions($colorCode);
$codes | php | {
"resource": ""
} |
q6242 | Colors.extractColorAndOptions | train | private static function extractColorAndOptions($colorCode)
{
$options = array();
foreach (self::$options as $name => $bit) {
if (($colorCode & $bit) === $bit) {
$options[] = self::$codes[$bit];
$colorCode = $colorCode & ~$bit;
| php | {
"resource": ""
} |
q6243 | CookieSwoole.setSecret | train | public function setSecret($name, $value, $expire = 604800, $path = '/', $domain = '')
{
$value = \ePHP\Hash\Encrypt::encryptG($value, | php | {
"resource": ""
} |
q6244 | CookieSwoole.getSecret | train | public function getSecret($name)
{
$value = $this->get($name);
if (empty($value)) {
| php | {
"resource": ""
} |
q6245 | Vehicles.get | train | public function get(int $vehicleId, ?Query $query = null): Response
{
$this->requiresAccessToken();
return $this->send(
| php | {
"resource": ""
} |
q6246 | Vehicles.update | train | public function update(int $vehicleId, array $payload): Response
{
$this->requiresAccessToken();
return $this->sendJson(
| php | {
"resource": ""
} |
q6247 | DataTypeManager.registerDataTypeHandler | train | public function registerDataTypeHandler(DataTypeHandlerInterface $handler)
{
foreach ($handler->supports() as $name) {
| php | {
"resource": ""
} |
q6248 | DataTypeManager.processHandlerToResource | train | protected function processHandlerToResource(Attribute $definition, $value)
{
$type = $definition->getType();
$handler = $this->handlers[$type];
$parameters = $definition->getTypeParameters();
if (! $definition->isMany()) {
return $handler->toResource($value, $type, $parameters);
}
if (! $value instanceof \Traversable && ! is_array($value)) {
| php | {
"resource": ""
} |
q6249 | DataTypeManager.processHandlerFromResource | train | protected function processHandlerFromResource(Attribute $definition, $value)
{
$type = $definition->getType();
$handler = $this->handlers[$type];
$parameters = $definition->getTypeParameters();
if (! $definition->isMany()) {
return $handler->fromResource($value, $type, $parameters);
}
if (! $value instanceof \Traversable && ! is_array($value)) {
| php | {
"resource": ""
} |
q6250 | FieldsManagerTrait.filterFieldList | train | public static function filterFieldList($fieldsList, $filters = array())
{
$result = array();
foreach ($fieldsList as $field) {
if (in_array($field->id, | php | {
"resource": ""
} |
q6251 | FieldsManagerTrait.filterFieldListByTag | train | public static function filterFieldListByTag($fieldsList, $itemType, $itemProp)
{
$result = array();
$tag = md5($itemProp.IDSPLIT.$itemType);
foreach ($fieldsList as $field) {
| php | {
"resource": ""
} |
q6252 | FieldsManagerTrait.reduceFieldList | train | public static function reduceFieldList($fieldsList, $isRead = false, $isWrite = false)
{
$result = array();
foreach ($fieldsList as $field) {
//==============================================================================
// Filter Non-Readable Fields
| php | {
"resource": ""
} |
q6253 | FieldsManagerTrait.isListField | train | public static function isListField($fieldType)
{
//====================================================================//
// Safety Check
if (empty($fieldType)) {
return false;
}
//====================================================================//
// Detects Lists
$list = explode(LISTSPLIT, $fieldType);
if (is_array($list) && (2 == | php | {
"resource": ""
} |
q6254 | FieldsManagerTrait.fieldName | train | public static function fieldName($listFieldName)
{
//====================================================================//
// Decode
$result = self::isListField($listFieldName);
if (empty($result)) {
return false;
}
| php | {
"resource": ""
} |
q6255 | FieldsManagerTrait.listName | train | public static function listName($listFieldName)
{
//====================================================================//
// Decode
$result = self::isListField($listFieldName);
if (empty($result)) {
return false;
}
| php | {
"resource": ""
} |
q6256 | FieldsManagerTrait.baseType | train | public static function baseType($fieldId)
{
//====================================================================//
// Detect List Id Fields
if (self::isListField($fieldId)) {
| php | {
"resource": ""
} |
q6257 | FieldsManagerTrait.isIdField | train | public static function isIdField($fieldId)
{
//====================================================================//
// Safety Check
if (empty($fieldId)) {
return false;
}
//====================================================================//
// Detects ObjectId
$list = explode(IDSPLIT, $fieldId);
if (is_array($list) && (2 == | php | {
"resource": ""
} |
q6258 | FieldsManagerTrait.objectId | train | public static function objectId($fieldId)
{
//====================================================================//
// decode
$result = self::isIdField($fieldId);
if (empty($result)) {
return false;
}
| php | {
"resource": ""
} |
q6259 | FieldsManagerTrait.objectType | train | public static function objectType($fieldId)
{
//====================================================================//
// decode
$result = self::isIdField($fieldId);
if (empty($result)) {
return false;
}
| php | {
"resource": ""
} |
q6260 | FieldsManagerTrait.extractRawData | train | public static function extractRawData($objectData, $filter)
{
$filteredData = self::filterData($objectData, array($filter));
//====================================================================//
// Explode List Field Id
$isList = self::isListField($filter);
//====================================================================//
// Simple Single Field
if (!$isList) {
if (isset($filteredData[$filter])) {
return $filteredData[$filter];
}
//====================================================================//
// List Field
} else {
//====================================================================//
// Check List Exists
if (!isset($filteredData[self::listName($filter)])) {
| php | {
"resource": ""
} |
q6261 | FieldsManagerTrait.filterData | train | public static function filterData($objectData, $filters = array())
{
$result = array();
$listFilters = array();
//====================================================================//
// Process All Single Fields Ids & Store Sorted List Fields Ids
foreach ($filters as $fieldId) {
//====================================================================//
// Explode List Field Id
$isList = self::isListField($fieldId);
//====================================================================//
// Single Field Data Type
if ((!$isList) && (array_key_exists($fieldId, $objectData))) {
$result[$fieldId] = $objectData[$fieldId];
} elseif (!$isList) {
continue;
}
//====================================================================//
// List Field Data Type
$listName = $isList['listname'];
$fieldName = $isList['fieldname'];
//====================================================================//
// Check List Data are Present in Block
if | php | {
"resource": ""
} |
q6262 | FieldsManagerTrait.filterListData | train | public static function filterListData($objectData, $filters = array())
{
$result = array();
foreach ($objectData as $fieldData) {
$filteredItems = array();
//====================================================================//
// Ensure Item is An Array of Fields
if (!is_array($fieldData) && !($fieldData instanceof ArrayObject)) {
continue;
}
//====================================================================//
// Convert ArrayObjects to Array
if ($fieldData instanceof ArrayObject) {
$fieldData = $fieldData->getArrayCopy();
| php | {
"resource": ""
} |
q6263 | Response.setNeededAction | train | public function setNeededAction($neededAction)
{
if (!in_array($neededAction, static::$allowedNeededActions))
{
| php | {
"resource": ""
} |
q6264 | Response.getError | train | public function getError()
{
if($this->isError() || $this->isDeclined())
{
return new PaynetException($this->getErrorMessage(), $this->getErrorCode());
}
| php | {
"resource": ""
} |
q6265 | Response.getAnyKey | train | protected function getAnyKey(array $keys)
{
foreach($keys as $key)
{
$value = $this->getValue($key);
| php | {
"resource": ""
} |
q6266 | Jwt.loadToken | train | public function loadToken($token, $validate = true, $verify = true)
{
$token = $this->getParser()->parse((string) $token);
if ($validate && !$this->validateToken($token)) {
return null;
}
| php | {
"resource": ""
} |
q6267 | Xml._toArray | train | private static function _toArray($data, $recursion = false)
{
$tmp = array();
$data = (array) $data;
foreach ($data as $k => $v) {
$v = (array) $v;
if (isset($v[0]) && is_string($v[0])) {
| php | {
"resource": ""
} |
q6268 | Utils.find | train | public static function find($filename, $dirs = array())
{
if (empty($dirs)) {
if ($filename = realpath($filename)) {
return $filename;
}
| php | {
"resource": ""
} |
q6269 | Utils.filterFiles | train | public static function filterFiles($args, $allowWildcards = true)
{
$files = array();
foreach ($args as $arg) {
if (file_exists($arg)) {
$files[] = $arg;
} else if ($allowWildcards | php | {
"resource": ""
} |
q6270 | Utils.join | train | public static function join($path1, $path2) {
$ds = DIRECTORY_SEPARATOR;
return | php | {
"resource": ""
} |
q6271 | Utils.touch | train | public static function touch($filename, $content = '')
{
self::mkdir(dirname($filename));
| php | {
"resource": ""
} |
q6272 | Utils.computeFuncParams | train | public static function computeFuncParams(ReflectionFunctionAbstract $reflection, array $args, array $options, $needTagInDocComment = true)
{
if ($needTagInDocComment && !preg_match('/@compute-params/', $reflection->getDocComment())) {
return array($args, $options);
}
$nbRequiredParams = $reflection->getNumberOfRequiredParameters();
if (count($args) < $nbRequiredParams) {
throw new ConsoleException("Not enough parameters in '" . $reflection->getName() . "'");
| php | {
"resource": ""
} |
q6273 | ControllerManager.initialize | train | private function initialize(AbstractController $controller)
{
foreach ($this->initializers as $initializer) {
if ($initializer instanceof InitializerInterface) {
| php | {
"resource": ""
} |
q6274 | Stream.tell | train | public function tell() : int
{
if (! \is_resource($this->resource))
{
throw new Exception\UntellableStreamException('Stream is not resourceable');
}
$result = \ftell($this->resource);
if (false === $result)
| php | {
"resource": ""
} |
q6275 | Stream.isSeekable | train | public function isSeekable() : bool
{
if (! \is_resource($this->resource))
| php | {
"resource": ""
} |
q6276 | Stream.rewind | train | public function rewind() : void
{
if (! \is_resource($this->resource))
{
throw new Exception\UnseekableStreamException('Stream is not resourceable');
}
if (! $this->isSeekable())
{
throw new Exception\UnseekableStreamException('Stream is not seekable');
}
| php | {
"resource": ""
} |
q6277 | Stream.seek | train | public function seek($offset, $whence = \SEEK_SET) : void
{
if (! \is_resource($this->resource))
{
throw new Exception\UnseekableStreamException('Stream is not resourceable');
}
if (! $this->isSeekable())
{
throw new Exception\UnseekableStreamException('Stream is not seekable');
}
| php | {
"resource": ""
} |
q6278 | Stream.isWritable | train | public function isWritable() : bool
{
if (! \is_resource($this->resource))
{
return false;
}
$metadata = | php | {
"resource": ""
} |
q6279 | Stream.write | train | public function write($string) : int
{
if (! \is_resource($this->resource))
{
throw new Exception\UnwritableStreamException('Stream is not resourceable');
}
if (! $this->isWritable())
{
throw new Exception\UnwritableStreamException('Stream is not writable');
}
| php | {
"resource": ""
} |
q6280 | Stream.read | train | public function read($length) : string
{
if (! \is_resource($this->resource))
{
throw new Exception\UnreadableStreamException('Stream is not resourceable');
}
if (! $this->isReadable())
{
throw new Exception\UnreadableStreamException('Stream is not readable');
}
| php | {
"resource": ""
} |
q6281 | Stream.getContents | train | public function getContents() : string
{
if (! \is_resource($this->resource))
{
throw new Exception\UnreadableStreamException('Stream is not resourceable');
}
if (! $this->isReadable())
{
throw new Exception\UnreadableStreamException('Stream is not readable');
}
| php | {
"resource": ""
} |
q6282 | Stream.getMetadata | train | public function getMetadata($key = null)
{
if (! \is_resource($this->resource))
{
return null;
| php | {
"resource": ""
} |
q6283 | Stream.getSize | train | public function getSize() : ?int
{
if (! \is_resource($this->resource))
{
return null; | php | {
"resource": ""
} |
q6284 | SayCommand.executeHello | train | public function executeHello(array $args, array $options = array())
{
$name = 'unknown';
if (empty($args)) {
$dialog = new Dialog($this->console);
$name = $dialog->ask('What | php | {
"resource": ""
} |
q6285 | Uri.filterPort | train | protected function filterPort($port)
{
if (empty($port)) {
return null;
}
if (!self::validePort($port)) {
throw new \InvalidArgumentException('The port is not in the TCP/UDP port.');
}
| php | {
"resource": ""
} |
q6286 | Uri.filterFragment | train | protected function filterFragment($fragment)
{
$fragmentStr = $this->filterString($fragment);
$fragmentDecode | php | {
"resource": ""
} |
q6287 | Uri.filterPath | train | protected function filterPath($path)
{
$pathStr = $this->filterString($path);
$pathDecode = rawurldecode($pathStr);
$dataPath = array_map(
function ($value) {
| php | {
"resource": ""
} |
q6288 | Uri.validPortStandard | train | protected function validPortStandard($port)
{
return in_array($port, $this->ports) &&
| php | {
"resource": ""
} |
q6289 | FEUsersAddSiteIdTypo3.migrate | train | public function migrate()
{
$table = 'fe_users';
$column = 'siteid';
$this->msg( sprintf( 'Adding "%1$s" column to "%2$s" table', $column, $table ), 0 );
$schema = $this->getSchema( 'db-customer' );
if( isset( $this->migrate[$schema->getName()] )
&& $schema->tableExists( $table ) === true
&& $schema->columnExists( $table, $column | php | {
"resource": ""
} |
q6290 | DIContainerFactory.getDefinitionsFilePath | train | private function getDefinitionsFilePath(array $config)
{
$filePath = __DIR__ . '/../../../../../../../config/php-di.config.php';
if (isset($config['definitionsFile'])) {
| php | {
"resource": ""
} |
q6291 | ConsoleController.clearCacheAction | train | public function clearCacheAction()
{
/* @var $cache FlushableCache */
$cache = $this->serviceLocator->get('DiCache');
if ($cache instanceof FlushableCache) {
| php | {
"resource": ""
} |
q6292 | ErrorsContainer.errorsToArray | train | protected function errorsToArray(): array
{
$errors = [];
foreach ($this->errors as $error)
{
| php | {
"resource": ""
} |
q6293 | AttachmentsTable.addUploads | train | public function addUploads(EntityInterface $entity, array $uploads)
{
$attachments = [];
foreach ($uploads as $path => $tags) {
if (!(array_keys($uploads) !== range(0, count($uploads) - 1))) {
// if only paths and no tags
$path = $tags;
$tags = [];
}
$file = Configure::read('Attachments.tmpUploadsPath') . $path;
| php | {
"resource": ""
} |
q6294 | AttachmentsTable.addUpload | train | public function addUpload(EntityInterface $entity, $upload)
{
$tags = [];
$path = $upload;
if (is_array($upload)) {
$tags = reset($upload);
$path = reset(array_flip($upload));
| php | {
"resource": ""
} |
q6295 | AttachmentsTable.afterSave | train | public function afterSave(Event $event, Attachment $attachment, \ArrayObject $options)
{
if ($attachment->tmpPath) {
// Make sure the folder is created
$folder = new Folder();
$targetDir = Configure::read('Attachments.path') . dirname($attachment->filepath);
if (!$folder->create($targetDir)) { | php | {
"resource": ""
} |
q6296 | AttachmentsTable.createAttachmentEntity | train | public function createAttachmentEntity(EntityInterface $entity, $filePath, array $tags = [])
{
if (!file_exists($filePath)) {
throw new \Exception("File {$filePath} does not exist.");
}
if (!is_readable($filePath)) {
throw new \Exception("File {$filePath} cannot be read.");
}
$file = new File($filePath);
$info = $file->info();
// in filepath, we store the path relative to the Attachment.path configuration
// to make it easy to switch storage
$info = $this->__getFileName($info, $entity);
$targetPath = $entity->source() . '/' . $entity->id . '/' . $info['basename'];
$attachment = $this->newEntity([
| php | {
"resource": ""
} |
q6297 | AttachmentsTable.__getFileName | train | private function __getFileName($fileInfo, EntityInterface $entity, $id = 0)
{
if (!file_exists(Configure::read('Attachments.path') . $entity->source() . '/' . $entity->id . '/' . $fileInfo['basename'])) {
return $fileInfo;
}
| php | {
"resource": ""
} |
q6298 | DocumentHydrator.hydrate | train | public function hydrate($source): AbstractDocument
{
if (! isset($source->data)) {
return $this->processNoDataDocument($source);
}
if (is_object($source->data)) {
return $this->processSingleResourceDocument($source);
}
if (is_array($source->data)) {
| php | {
"resource": ""
} |
q6299 | DocumentHydrator.processNoDataDocument | train | protected function processNoDataDocument($source): NoDataDocument
{
$document = new NoDataDocument();
| php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.