_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q268200 | RequestTrait.validateMethod | test | protected function validateMethod(string $method): void
{
if (! RequestMethod::isValid($method)) {
throw new InvalidMethod(
sprintf(
| php | {
"resource": ""
} |
q268201 | Locator.locate | test | public function locate($command)
{
$paths = $this->locateAll($command);
| php | {
"resource": ""
} |
q268202 | Locator.locateAll | test | public function locateAll($command)
{
return array_values(array_filter($this->_pathBuilde | php | {
"resource": ""
} |
q268203 | PEAR_Downloader_Package.& | test | function &download()
{
if (isset($this->_packagefile)) {
return $this->_packagefile;
}
if (isset($this->_downloadURL['url'])) {
$this->_isvalid = false;
$info = $this->getParsedPackage();
foreach ($info as $i => $p) {
$info[$i] = strtolower($p);
}
$err = $this->_fromUrl($this->_downloadURL['url'],
$this->_registry->parsedPackageNameToString($this->_parsedname, true));
$newinfo = $this->getParsedPackage();
foreach ($newinfo as $i => $p) {
$newinfo[$i] = strtolower($p);
}
if ($info != $newinfo) {
do {
if ($info['channel'] == 'pecl.php.net' && $newinfo['channel'] == 'pear.php.net') {
$info['channel'] = 'pear.php.net';
if ($info == $newinfo) {
// skip the channel check if a pecl package says it's a PEAR package
break;
}
}
if ($info['channel'] == 'pear.php.net' && $newinfo['channel'] == 'pecl.php.net') {
$info['channel'] = 'pecl.php.net';
if ($info == $newinfo) {
// skip the channel check if | php | {
"resource": ""
} |
q268204 | PEAR_Downloader_Package.removeInstalled | test | function removeInstalled(&$params)
{
if (!isset($params[0])) {
return;
}
$options = $params[0]->_downloader->getOptions();
if (!isset($options['downloadonly'])) {
foreach ($params as $i => $param) {
$package = $param->getPackage();
$channel = $param->getChannel();
// remove self if already installed with this version
// this does not need any pecl magic - we only remove exact matches
if ($param->_installRegistry->packageExists($package, $channel)) {
$packageVersion = $param->_installRegistry->packageInfo($package, 'version', $channel);
if (version_compare($packageVersion, $param->getVersion(), '==')) {
if (!isset($options['force'])) {
$info = $param->getParsedPackage();
unset($info['version']);
unset($info['state']);
if (!isset($options['soft'])) {
$param->_downloader->log(1, 'Skipping package "' .
$param->getShortName() .
'", already installed as version ' . $packageVersion);
}
| php | {
"resource": ""
} |
q268205 | PEAR_Downloader_Package.detectStupidDuplicates | test | function detectStupidDuplicates($params, &$errorparams)
{
$existing = array();
foreach ($params as $i => $param) {
$package = $param->getPackage();
$channel = $param->getChannel();
$group = $param->getGroup();
if (!isset($existing[$channel . '/' . $package])) {
$existing[$channel . '/' . $package] = array();
}
if (!isset($existing[$channel . '/' . $package][$group])) {
$existing[$channel . '/' . $package][$group] = array();
}
$existing[$channel . '/' . $package][$group][] = $i;
}
| php | {
"resource": ""
} |
q268206 | PEAR_Downloader_Package._fromFile | test | function _fromFile(&$param)
{
$saveparam = $param;
if (is_string($param)) {
if (!@file_exists($param)) {
$test = explode('#', $param);
$group = array_pop($test);
if (@file_exists(implode('#', $test))) {
$this->setGroup($group);
$param = implode('#', $test);
$this->_explicitGroup = true;
}
}
if (@is_file($param)) {
$this->_type = 'local';
$options = $this->_downloader->getOptions();
| php | {
"resource": ""
} |
q268207 | JsonParametersExtractor.getParameters | test | public function getParameters()
{
$bodyParams = json_decode($this->body, true);
if (!$bodyParams) {
return array();
| php | {
"resource": ""
} |
q268208 | Debug.enable | test | public static function enable(int $errorReportingLevel = E_ALL, bool $displayErrors = false): void
{
// If debug is already enabled
if (static::$enabled) {
// Don't do things twice
return;
}
// Debug is enabled
static::$enabled = true;
// The exception handler
$exceptionHandler = new ExceptionHandler($displayErrors);
// The error handler
$errorHandler = new ErrorHandler();
| php | {
"resource": ""
} |
q268209 | Budget.getAmountDifference | test | public function getAmountDifference()
{
$amount = ($this->hasChildren() ? $this->getGlobalAmount() : $this->getAmount());
| php | {
"resource": ""
} |
q268210 | Budget.addMonthToBitmask | test | public function addMonthToBitmask($month)
{
$month = (int) $month;
if ($month < 1 || $month > 12) {
throw new \RangeException('Month is invalid!');
}
$bit = pow(2, $month - 1);
| php | {
"resource": ""
} |
q268211 | Budget.hasMonth | test | public function hasMonth($month)
{
$bitmask = $this->getMonthBitmask();
$month = (int) $month;
| php | {
"resource": ""
} |
q268212 | HTTP_Request2_MultipartBody.getLength | test | public function getLength()
{
$boundaryLength = strlen($this->getBoundary());
$headerParamLength = strlen($this->_headerParam) - 4 + $boundaryLength;
$headerUploadLength = strlen($this->_headerUpload) - 8 + $boundaryLength;
$length | php | {
"resource": ""
} |
q268213 | HTTP_Request2_MultipartBody.getBoundary | test | public function getBoundary()
{
if (empty($this->_boundary)) {
$this->_boundary = '--' | php | {
"resource": ""
} |
q268214 | DbalUserProvider.loadUserByUsername | test | public function loadUserByUsername($username)
{
$qb = $this->_conn->createQueryBuilder();
$qb->select('su.username, su.password')
->from('security_users', 'su')
->where(
$qb->expr()->orX(
$qb->expr()->eq('su.username', ':username'),
$qb->expr()->eq('su.email', ':username')
)
)
->setParameter(':username', strtolower($username));
$stmt = $qb->execute();
if (!$user = $stmt->fetch()) {
throw new UsernameNotFoundException(
sprintf('Username "%s" does not exist.', $username)
| php | {
"resource": ""
} |
q268215 | User.create | test | public function create($sendWelcome = true) {
if ($this->getIsNewRecord() == false) {
throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
}
$this->confirmed_at = time();
$this->password = $this->password == null ? Password::generate(8) : $this->password;
$this->trigger(self::BEFORE_CREATE);
if | php | {
"resource": ""
} |
q268216 | Socket.setIpAddress | test | public function setIpAddress($ip, $port = 80) {
if (false !== strpos($ip, ':')) {
list($ip, $port) = explode(':', $ip);
}
if (empty($ip)) {
$ip = '127.0.0.1'; | php | {
"resource": ""
} |
q268217 | Mail.renderView | test | protected function renderView($view, array $parameters = array())
{
if ($this->_oContainer->has('templating')) {
return $this->_oContainer->get('templating')->render($view, $parameters);
}
if (!$this->_oContainer->has('twig')) {
throw new \LogicException('You | php | {
"resource": ""
} |
q268218 | EventStoreRepository.publishStream | test | protected function publishStream(StreamInterface $stream): EventStoreRepository
{
foreach ($stream as $domainEventMessage) { | php | {
"resource": ""
} |
q268219 | LinkedResourceFetcher.onResourceMaterialize | test | public function onResourceMaterialize(ResourceMaterializeEvent $e)
{
/** @var $resource MaterializedResource */
$resource = $e->getResource();
// Only scan resources with .css extension.
if (preg_match('/\.css$/i', $resource->getPath())) {
$this->scanner->scan($resource, $resource->getContent());
$collection = $this->scanner->getQueue()->flush();
// TODO Aggregate collection scans and materialize post hoc.
// Materialize non-existing resources.
foreach ($collection as $linkedResource) {
| php | {
"resource": ""
} |
q268220 | Message.params | test | public function params( /*...*/ ) {
$args = func_get_args();
if ( isset( $args[0] ) && is_array( $args[0] ) ) {
$args = $args[0];
}
$values = array_values( | php | {
"resource": ""
} |
q268221 | Message.fetchMessage | test | protected function fetchMessage() {
if ( $this->message === null ) {
$this->message = $this->ctx->getMessageCache()->get(
| php | {
"resource": ""
} |
q268222 | SodiumCrypt.encrypt | test | public function encrypt(string $message, string $key = null): string
{
$key = $key ?? $this->getKey();
$nonce = random_bytes(
SODIUM_CRYPTO_SECRETBOX_NONCEBYTES
);
$cipher = base64_encode(
$nonce .
sodium_crypto_secretbox(
$message,
| php | {
"resource": ""
} |
q268223 | SodiumCrypt.decrypt | test | public function decrypt(string $encrypted, string $key = null): string
{
$key = $key ?? $this->getKey();
$decoded = base64_decode($encrypted, true);
if ($decoded === false) {
throw new CryptException('The encoding failed');
}
if (mb_strlen($decoded, '8bit') < (SODIUM_CRYPTO_SECRETBOX_NONCEBYTES + SODIUM_CRYPTO_SECRETBOX_MACBYTES)) {
| php | {
"resource": ""
} |
q268224 | SodiumCrypt.decryptArray | test | public function decryptArray(string $encrypted, string $key = null): array | php | {
"resource": ""
} |
q268225 | SodiumCrypt.encryptObject | test | public function encryptObject(object $object, string $key = null): | php | {
"resource": ""
} |
q268226 | SodiumCrypt.decryptObject | test | public function decryptObject(string $encrypted, string $key = null): | php | {
"resource": ""
} |
q268227 | Zend_Cache_Backend_Static.getOption | test | public function getOption($name)
{
$name = strtolower($name);
if ($name | php | {
"resource": ""
} |
q268228 | AbstractPackageDependent.init | test | protected function init()
{
$clsname = get_called_class();
if (property_exists($clsname, 'defaults')) {
foreach($clsname::$defaults as $name=>$value) {
| php | {
"resource": ""
} |
q268229 | AbstractComponent.replaceMagicFields | test | public function replaceMagicFields($html)
{
$html = str_replace('%id%', $this->getId(), $html);
$html = str_replace('%class%', implode(' ', $this->classes), $html);
$html = str_replace('%style%', $this->getStyle(), $html);
$html = str_replace('%name%', $this->getName(), $html);
$html = str_replace('%label%', $this->getLabel(), $html);
| php | {
"resource": ""
} |
q268230 | PsiToOrmQueryBuilderConverter.convert | test | public function convert(Query $query): QueryBuilder
{
$queryBuilder = $this->entityManager
->getRepository($query->getClassFqn())
->createQueryBuilder(self::FROM_ALIAS);
$this->buildSelects($queryBuilder, $query);
| php | {
"resource": ""
} |
q268231 | RichText.asText | test | public static function asText($richText)
{
$result = '';
foreach ($richText as $block) {
| php | {
"resource": ""
} |
q268232 | RichText.asHtml | test | public static function asHtml(array $richText, LinkResolver $linkResolver = null)
{
$groups = [];
if(is_array($richText) && key_exists('dimensions', $richText)) {
return self::asImageBlock($richText);
}
foreach ($richText as $block) {
$block = (object) $block;
$count = count($groups);
// Check if block is image
if(empty($block->type)) {
var_dump($richText);
die();
}
if ($count > 0) {
$lastOne = $groups[$count - 1];
if ('ul' == $lastOne->getTag() && $block->type === 'list-item') {
$lastOne->addBlock($block);
} elseif ('ol' == $lastOne->getTag() && $block->type === 'o-list-item') {
$lastOne->addBlock($block);
} elseif ($block->type === 'list-item') {
$newBlockGroup = new BlockGroup('ul', array());
$newBlockGroup->addBlock($block);
array_push($groups, $newBlockGroup);
} else {
if ($block->type === 'o-list-item') {
$newBlockGroup = new BlockGroup('ol', array());
$newBlockGroup->addBlock($block);
array_push($groups, $newBlockGroup);
} else {
$newBlockGroup = new BlockGroup(null, array());
$newBlockGroup->addBlock($block);
array_push($groups, $newBlockGroup);
}
}
} else {
| php | {
"resource": ""
} |
q268233 | RichText.asHtmlBlock | test | private static function asHtmlBlock(\stdClass $block, $linkResolver = null, $htmlSerializer = null)
{
$content = '';
if ($block->type === 'heading1' ||
$block->type === 'heading2' ||
$block->type === 'heading3' ||
$block->type === 'heading4' ||
$block->type === 'heading5' ||
$block->type === 'heading6' ||
$block->type === 'paragraph' ||
$block->type === 'list-item' ||
$block->type === 'o-list-item' ||
| php | {
"resource": ""
} |
q268234 | NativeResponse.withoutCookie | test | public function withoutCookie(Cookie $cookie)
{
$cookie->setValue();
$cookie->setExpire();
return $this->withAddedHeader(
| php | {
"resource": ""
} |
q268235 | NativeResponse.send | test | public function send(): Response
{
$http_line = sprintf(
'HTTP/%s %s %s',
$this->getProtocolVersion(),
$this->getStatusCode(),
$this->getReasonPhrase()
);
header($http_line, true, $this->getStatusCode());
foreach ($this->getHeaders() as $name => $values) {
/** @var array $values */
foreach ($values as $value) {
header("$name: $value", false);
} | php | {
"resource": ""
} |
q268236 | NativeResponse.validateStatusCode | test | protected function validateStatusCode(int $code): int
{
if (StatusCode::MIN > $code || $code > StatusCode::MAX) {
throw new InvalidStatusCode(
sprintf(
'Invalid status code | php | {
"resource": ""
} |