_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q266600 | DatabaseOptions.setDataColumn | test | public function setDataColumn($dataColumn)
{
$dataColumn = (string) $dataColumn;
/** @noinspection IsEmptyFunctionUsageInspection */
if (empty($dataColumn)) {
throw new Exception\InvalidArgumentException('Data column must be a non-empty string.');
}
$this->dataColumn = $dataColumn;
return $this;
} | php | {
"resource": ""
} |
q266601 | DatabaseOptions.setLifetimeColumn | test | public function setLifetimeColumn($lifetimeColumn)
{
$lifetimeColumn = (string) $lifetimeColumn;
/** @noinspection IsEmptyFunctionUsageInspection */
if (empty($lifetimeColumn)) {
throw new Exception\InvalidArgumentException('Lifetime column must be a non-empty string.');
}
$this->lifetimeColumn = $lifetimeColumn;
return $this;
} | php | {
"resource": ""
} |
q266602 | DatabaseOptions.setModifiedColumn | test | public function setModifiedColumn($modifiedColumn)
{
$modifiedColumn = (string) $modifiedColumn;
/** @noinspection IsEmptyFunctionUsageInspection */
if (empty($modifiedColumn)) {
throw new Exception\InvalidArgumentException('Modified column must be a non-empty string.');
}
$this->modifiedColumn = $modifiedColumn;
return $this;
} | php | {
"resource": ""
} |
q266603 | DatabaseOptions.setCreatedColumn | test | public function setCreatedColumn($createdColumn)
{
$createdColumn = (string) $createdColumn;
/** @noinspection IsEmptyFunctionUsageInspection */
if (empty($createdColumn)) {
throw new Exception\InvalidArgumentException('Created column must be a non-empty string.');
}
$this->createdColumn = $createdColumn;
return $this;
} | php | {
"resource": ""
} |
q266604 | Social.providers | test | public static function providers()
{
return collect(Settings::first()->fillable)->filter(function ($value) {
return strpos($value, '_client_id') !== false;
})->map(function ($value) {
return str_replace('_client_id', '', $value);
})->toArray();
} | php | {
"resource": ""
} |
q266605 | Social.availableProviders | test | public static function availableProviders()
{
$settings = Settings::first();
return collect(static::providers())->filter(function ($value) use ($settings) {
$ci = $value.'_client_id';
$cs = $value.'_client_secret';
return $settings->$ci && $settings->$cs;
})->toArray();
} | php | {
"resource": ""
} |
q266606 | ContentNegotiationServiceProvider.boot | test | public function boot(Application $app)
{
$app->before(array($this, "setRequestFormat"), Application::EARLY_EVENT);
$app->before(array($this, "validateRequestContentType"), Application::EARLY_EVENT);
} | php | {
"resource": ""
} |
q266607 | ContentNegotiationServiceProvider.register | test | public function register(Container $app)
{
$app["conneg.responseFormats"] = array("html");
$app["conneg.requestFormats"] = array("form");
$app["conneg.defaultFormat"] = "html";
$app["conneg"] = function (Container $app) {
if ($app->offsetExists("serializer")) {
if ($app["serializer"] instanceof JMS\Serializer) {
if (!$app->offsetExists("conneg.serializationContext")) {
$app["conneg.serializationContext"] = null;
}
if (!$app->offsetExists("conneg.deserializationContext")) {
$app["conneg.deserializationContext"] = null;
}
return new JmsSerializerContentNegotiation($app);
} elseif ($app["serializer"] instanceof SymfonySerializer\Serializer) {
if (!$app->offsetExists("conneg.serializationContext")) {
$app["conneg.serializationContext"] = array();
}
if (!$app->offsetExists("conneg.deserializationContext")) {
$app["conneg.deserializationContext"] = array();
}
return new SymfonySerializerContentNegotiation($app);
}
}
throw new ServiceUnavailableHttpException(null, "No supported serializer found");
};
} | php | {
"resource": ""
} |
q266608 | ContentNegotiationServiceProvider.setRequestFormat | test | public function setRequestFormat(Request $request, Application $app)
{
// If there is no Accept header, do nothing
if (!$request->headers->get("Accept")) {
return;
}
// Check the Accept header for acceptable formats
foreach ($request->getAcceptableContentTypes() as $contentType) {
// If any format is acceptable, do nothing
if ($contentType === "*/*") {
return;
}
$format = $request->getFormat($contentType);
if (in_array($format, $app["conneg.responseFormats"])) {
// An acceptable format was found. Set it as the requestFormat
// where it can be referenced later.
$request->setRequestFormat($format);
return;
}
}
// No acceptable formats were found
throw new NotAcceptableHttpException();
} | php | {
"resource": ""
} |
q266609 | ContentNegotiationServiceProvider.validateRequestContentType | test | public function validateRequestContentType(Request $request, Application $app)
{
// Define the "form" format so we can use it for validation
$request->setFormat("form", array("application/x-www-form-urlencoded", "multipart/form-data"));
$format = $request->getContentType();
if (strlen($request->getContent()) > 0 && !in_array($format, $app["conneg.requestFormats"])) {
// The request has a body but it is not a supported media type
throw new UnsupportedMediaTypeHttpException();
}
} | php | {
"resource": ""
} |
q266610 | ReturnPromise.execute | test | public function execute(array $args, FunctionProphecy $function)
{
$value = array_shift($this->returnValues);
if (!count($this->returnValues)) {
$this->returnValues[] = $value;
}
return $value;
} | php | {
"resource": ""
} |
q266611 | PEAR_Downloader.discover | test | function discover($channel)
{
$this->log(1, 'Attempting to discover channel "' . $channel . '"...');
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$callback = $this->ui ? array(&$this, '_downloadCallback') : null;
if (!class_exists('System')) {
require_once 'System.php';
}
$tmpdir = $this->config->get('temp_dir');
$tmp = System::mktemp('-d -t "' . $tmpdir . '"');
$a = $this->downloadHttp('http://' . $channel . '/channel.xml', $this->ui, $tmp, $callback, false);
PEAR::popErrorHandling();
if (PEAR::isError($a)) {
// Attempt to fallback to https automatically.
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$this->log(1, 'Attempting fallback to https instead of http on channel "' . $channel . '"...');
$a = $this->downloadHttp('https://' . $channel . '/channel.xml', $this->ui, $tmp, $callback, false);
PEAR::popErrorHandling();
if (PEAR::isError($a)) {
return false;
}
}
list($a, $lastmodified) = $a;
if (!class_exists('PEAR_ChannelFile')) {
require_once 'PEAR/ChannelFile.php';
}
$b = new PEAR_ChannelFile;
if ($b->fromXmlFile($a)) {
unlink($a);
if ($this->config->get('auto_discover')) {
$this->_registry->addChannel($b, $lastmodified);
$alias = $b->getName();
if ($b->getName() == $this->_registry->channelName($b->getAlias())) {
$alias = $b->getAlias();
}
$this->log(1, 'Auto-discovered channel "' . $channel .
'", alias "' . $alias . '", adding to registry');
}
return true;
}
unlink($a);
return false;
} | php | {
"resource": ""
} |
q266612 | PEAR_Downloader.& | test | function &getDependency2Object(&$c, $i, $p, $s)
{
if (!class_exists('PEAR_Dependency2')) {
require_once 'PEAR/Dependency2.php';
}
$z = &new PEAR_Dependency2($c, $i, $p, $s);
return $z;
} | php | {
"resource": ""
} |
q266613 | PEAR_Downloader.getDownloadDir | test | function getDownloadDir()
{
if (isset($this->_downloadDir)) {
return $this->_downloadDir;
}
$downloaddir = $this->config->get('download_dir');
if (empty($downloaddir) || (is_dir($downloaddir) && !is_writable($downloaddir))) {
if (is_dir($downloaddir) && !is_writable($downloaddir)) {
$this->log(0, 'WARNING: configuration download directory "' . $downloaddir .
'" is not writeable. Change download_dir config variable to ' .
'a writeable dir to avoid this warning');
}
if (!class_exists('System')) {
require_once 'System.php';
}
if (PEAR::isError($downloaddir = System::mktemp('-d'))) {
return $downloaddir;
}
$this->log(3, '+ tmp dir created at ' . $downloaddir);
}
if (!is_writable($downloaddir)) {
if (PEAR::isError(System::mkdir(array('-p', $downloaddir))) ||
!is_writable($downloaddir)) {
return PEAR::raiseError('download directory "' . $downloaddir .
'" is not writeable. Change download_dir config variable to ' .
'a writeable dir');
}
}
return $this->_downloadDir = $downloaddir;
} | php | {
"resource": ""
} |
q266614 | PEAR_Downloader._detectDepCycle | test | function _detectDepCycle(&$deplinks)
{
do {
$keepgoing = false;
foreach ($deplinks as $dep => $parents) {
foreach ($parents as $parent => $unused) {
// reset the parent cycle detector
$this->_testCycle(null, null, null);
if ($this->_testCycle($dep, $deplinks, $parent)) {
$keepgoing = true;
unset($deplinks[$dep][$parent]);
if (count($deplinks[$dep]) == 0) {
unset($deplinks[$dep]);
}
continue 3;
}
}
}
} while ($keepgoing);
} | php | {
"resource": ""
} |
q266615 | PEAR_Downloader._setupGraph | test | function _setupGraph($t, $reg, &$deplinks, &$nodes, $package)
{
foreach ($t as $dep) {
$depchannel = !isset($dep['channel']) ? '__uri': $dep['channel'];
$dname = $reg->parsedPackageNameToString(
array(
'channel' => $depchannel,
'package' => strtolower($dep['name']),
));
if (isset($nodes[$dname])) {
if (!isset($deplinks[$dname])) {
$deplinks[$dname] = array();
}
$deplinks[$dname][$package] = 1;
}
}
} | php | {
"resource": ""
} |
q266616 | Request.getUrlArg | test | public function getUrlArg($param = null, $default = false)
{
$routes = CarteBlanche::getContainer()->get('router')->getRouteParsed();
if (!empty($routes)) {
if ($param=='args') {
if (isset($routes['args']))
return $routes['args'];
} else {
if (isset($routes[$param]))
return $routes[$param];
if (isset($routes['args'][$param]))
return $routes['args'][$param];
}
}
return $default;
} | php | {
"resource": ""
} |
q266617 | Console.outputLine | test | public function outputLine($string = '', $translate = true)
{
if ($translate) {
\cli\line($this->getLang()->__($string));
} else {
\cli\line($string);
}
} | php | {
"resource": ""
} |
q266618 | Console.getArgs | test | public function getArgs($strict = false, $force = false)
{
if (is_null($this->args) || $force) {
$this->args = new \cli\Arguments($strict);
$this->args->addFlag(array(
'verbose',
'v'
), 'Turn on verbose output');
$this->args->addFlag('version', 'Display the version');
$this->args->addFlag(array(
'help',
'h'
), 'Show this help screen');
}
return $this->args;
} | php | {
"resource": ""
} |
q266619 | NoCaptchaServiceProvider.registerNoCaptcha | test | private function registerNoCaptcha()
{
$this->singleton(Contracts\NoCaptcha::class, function($app) {
/** @var \Illuminate\Config\Repository $config */
$config = $app['config'];
return new NoCaptcha(
$config->get('no-captcha.secret'),
$config->get('no-captcha.sitekey'),
$config->get('no-captcha.lang'),
$config->get('no-captcha.attributes', [])
);
});
$this->singleton('arcanedev.no-captcha', Contracts\NoCaptcha::class);
} | php | {
"resource": ""
} |
q266620 | NoCaptchaServiceProvider.registerValidatorRules | test | private function registerValidatorRules($app)
{
$app['validator']->extend('captcha', function($attribute, $value) use ($app) {
unset($attribute);
$ip = $app['request']->getClientIp();
return $app[Contracts\NoCaptcha::class]->verify($value, $ip);
});
} | php | {
"resource": ""
} |
q266621 | NoCaptchaServiceProvider.registerFormMacros | test | private function registerFormMacros($app)
{
if ($app->bound('form')) {
$app['form']->macro('captcha', function($name = null, array $attributes = []) use ($app) {
return $app[Contracts\NoCaptcha::class]->display($name, $attributes);
});
}
} | php | {
"resource": ""
} |
q266622 | PEAR_ChannelFile.fromXmlFile | test | function fromXmlFile($descfile)
{
if (!file_exists($descfile) || !is_file($descfile) || !is_readable($descfile) ||
(!$fp = fopen($descfile, 'r'))) {
require_once 'PEAR.php';
return PEAR::raiseError("Unable to open $descfile");
}
// read the whole thing so we only get one cdata callback
// for each block of cdata
fclose($fp);
$data = file_get_contents($descfile);
return $this->fromXmlString($data);
} | php | {
"resource": ""
} |
q266623 | PEAR_ChannelFile.fromAny | test | function fromAny($info)
{
if (is_string($info) && file_exists($info) && strlen($info) < 255) {
$tmp = substr($info, -4);
if ($tmp == '.xml') {
$info = $this->fromXmlFile($info);
} else {
$fp = fopen($info, "r");
$test = fread($fp, 5);
fclose($fp);
if ($test == "<?xml") {
$info = $this->fromXmlFile($info);
}
}
if (PEAR::isError($info)) {
require_once 'PEAR.php';
return PEAR::raiseError($info);
}
}
if (is_string($info)) {
$info = $this->fromXmlString($info);
}
return $info;
} | php | {
"resource": ""
} |
q266624 | PEAR_ChannelFile.toXml | test | function toXml()
{
if (!$this->_isValid && !$this->validate()) {
$this->_validateError(PEAR_CHANNELFILE_ERROR_INVALID);
return false;
}
if (!isset($this->_channelInfo['attribs']['version'])) {
$this->_channelInfo['attribs']['version'] = '1.0';
}
$channelInfo = $this->_channelInfo;
$ret = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
$ret .= "<channel version=\"" .
$channelInfo['attribs']['version'] . "\" xmlns=\"http://pear.php.net/channel-1.0\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://pear.php.net/dtd/channel-"
. $channelInfo['attribs']['version'] . " http://pear.php.net/dtd/channel-" .
$channelInfo['attribs']['version'] . ".xsd\">
<name>$channelInfo[name]</name>
<summary>" . htmlspecialchars($channelInfo['summary'])."</summary>
";
if (isset($channelInfo['suggestedalias'])) {
$ret .= ' <suggestedalias>' . $channelInfo['suggestedalias'] . "</suggestedalias>\n";
}
if (isset($channelInfo['validatepackage'])) {
$ret .= ' <validatepackage version="' .
$channelInfo['validatepackage']['attribs']['version']. '">' .
htmlspecialchars($channelInfo['validatepackage']['_content']) .
"</validatepackage>\n";
}
$ret .= " <servers>\n";
$ret .= ' <primary';
if (isset($channelInfo['servers']['primary']['attribs']['ssl'])) {
$ret .= ' ssl="' . $channelInfo['servers']['primary']['attribs']['ssl'] . '"';
}
if (isset($channelInfo['servers']['primary']['attribs']['port'])) {
$ret .= ' port="' . $channelInfo['servers']['primary']['attribs']['port'] . '"';
}
$ret .= ">\n";
if (isset($channelInfo['servers']['primary']['rest'])) {
$ret .= $this->_makeRestXml($channelInfo['servers']['primary']['rest'], ' ');
}
$ret .= " </primary>\n";
if (isset($channelInfo['servers']['mirror'])) {
$ret .= $this->_makeMirrorsXml($channelInfo);
}
$ret .= " </servers>\n";
$ret .= "</channel>";
return str_replace("\r", "\n", str_replace("\r\n", "\n", $ret));
} | php | {
"resource": ""
} |
q266625 | PEAR_ChannelFile._validateError | test | function _validateError($code, $params = array())
{
$this->_stack->push($code, 'error', $params);
$this->_isValid = false;
} | php | {
"resource": ""
} |
q266626 | PEAR_ChannelFile.getBaseURL | test | function getBaseURL($resourceType, $mirror = false)
{
if ($mirror == $this->_channelInfo['name']) {
$mirror = false;
}
if ($mirror) {
$mir = $this->getMirror($mirror);
if (!$mir) {
return false;
}
$rest = $mir['rest'];
} else {
$rest = $this->_channelInfo['servers']['primary']['rest'];
}
if (!isset($rest['baseurl'][0])) {
$rest['baseurl'] = array($rest['baseurl']);
}
foreach ($rest['baseurl'] as $baseurl) {
if (strtolower($baseurl['attribs']['type']) == strtolower($resourceType)) {
return $baseurl['_content'];
}
}
return false;
} | php | {
"resource": ""
} |
q266627 | PEAR_ChannelFile.resetFunctions | test | function resetFunctions($type, $mirror = false)
{
if ($mirror) {
if (isset($this->_channelInfo['servers']['mirror'])) {
$mirrors = $this->_channelInfo['servers']['mirror'];
if (!isset($mirrors[0])) {
$mirrors = array($mirrors);
}
foreach ($mirrors as $i => $mir) {
if ($mir['attribs']['host'] == $mirror) {
if (isset($this->_channelInfo['servers']['mirror'][$i][$type])) {
unset($this->_channelInfo['servers']['mirror'][$i][$type]);
}
return true;
}
}
return false;
}
return false;
}
if (isset($this->_channelInfo['servers']['primary'][$type])) {
unset($this->_channelInfo['servers']['primary'][$type]);
}
return true;
} | php | {
"resource": ""
} |
q266628 | PEAR_ChannelFile.setDefaultPEARProtocols | test | function setDefaultPEARProtocols($version = '1.0', $mirror = false)
{
switch ($version) {
case '1.0' :
$this->resetREST($mirror);
if (!isset($this->_channelInfo['servers'])) {
$this->_channelInfo['servers'] = array('primary' =>
array('rest' => array()));
} elseif (!isset($this->_channelInfo['servers']['primary'])) {
$this->_channelInfo['servers']['primary'] = array('rest' => array());
}
return true;
break;
default :
return false;
break;
}
} | php | {
"resource": ""
} |
q266629 | PEAR_ChannelFile.getMirror | test | function getMirror($server)
{
foreach ($this->getMirrors() as $mirror) {
if ($mirror['attribs']['host'] == $server) {
return $mirror;
}
}
return false;
} | php | {
"resource": ""
} |
q266630 | PEAR_ChannelFile.setValidationPackage | test | function setValidationPackage($validateclass, $version)
{
if (empty($validateclass)) {
unset($this->_channelInfo['validatepackage']);
}
$this->_channelInfo['validatepackage'] = array('_content' => $validateclass);
$this->_channelInfo['validatepackage']['attribs'] = array('version' => $version);
} | php | {
"resource": ""
} |
q266631 | PEAR_ChannelFile.addFunction | test | function addFunction($type, $version, $name = '', $mirror = false)
{
if ($mirror) {
return $this->addMirrorFunction($mirror, $type, $version, $name);
}
$set = array('attribs' => array('version' => $version), '_content' => $name);
if (!isset($this->_channelInfo['servers']['primary'][$type]['function'])) {
if (!isset($this->_channelInfo['servers'])) {
$this->_channelInfo['servers'] = array('primary' =>
array($type => array()));
} elseif (!isset($this->_channelInfo['servers']['primary'])) {
$this->_channelInfo['servers']['primary'] = array($type => array());
}
$this->_channelInfo['servers']['primary'][$type]['function'] = $set;
$this->_isValid = false;
return true;
} elseif (!isset($this->_channelInfo['servers']['primary'][$type]['function'][0])) {
$this->_channelInfo['servers']['primary'][$type]['function'] = array(
$this->_channelInfo['servers']['primary'][$type]['function']);
}
$this->_channelInfo['servers']['primary'][$type]['function'][] = $set;
return true;
} | php | {
"resource": ""
} |
q266632 | PEAR_ChannelFile.addMirrorFunction | test | function addMirrorFunction($mirror, $type, $version, $name = '')
{
if (!isset($this->_channelInfo['servers']['mirror'])) {
$this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
array('mirror' => $mirror));
return false;
}
$setmirror = false;
if (isset($this->_channelInfo['servers']['mirror'][0])) {
foreach ($this->_channelInfo['servers']['mirror'] as $i => $mir) {
if ($mirror == $mir['attribs']['host']) {
$setmirror = &$this->_channelInfo['servers']['mirror'][$i];
break;
}
}
} else {
if ($this->_channelInfo['servers']['mirror']['attribs']['host'] == $mirror) {
$setmirror = &$this->_channelInfo['servers']['mirror'];
}
}
if (!$setmirror) {
$this->_validateError(PEAR_CHANNELFILE_ERROR_MIRROR_NOT_FOUND,
array('mirror' => $mirror));
return false;
}
$set = array('attribs' => array('version' => $version), '_content' => $name);
if (!isset($setmirror[$type]['function'])) {
$setmirror[$type]['function'] = $set;
$this->_isValid = false;
return true;
} elseif (!isset($setmirror[$type]['function'][0])) {
$setmirror[$type]['function'] = array($setmirror[$type]['function']);
}
$setmirror[$type]['function'][] = $set;
$this->_isValid = false;
return true;
} | php | {
"resource": ""
} |
q266633 | PEAR_ChannelFile.getValidationPackage | test | function getValidationPackage()
{
if (!$this->_isValid && !$this->validate()) {
return false;
}
if (!isset($this->_channelInfo['validatepackage'])) {
return array('attribs' => array('version' => 'default'),
'_content' => 'PEAR_Validate');
}
return $this->_channelInfo['validatepackage'];
} | php | {
"resource": ""
} |
q266634 | PEAR_ChannelFile.& | test | function &getValidationObject($package = false)
{
if (!class_exists('PEAR_Validate')) {
require_once 'PEAR/Validate.php';
}
if (!$this->_isValid) {
if (!$this->validate()) {
$a = false;
return $a;
}
}
if (isset($this->_channelInfo['validatepackage'])) {
if ($package == $this->_channelInfo['validatepackage']) {
// channel validation packages are always validated by PEAR_Validate
$val = &new PEAR_Validate;
return $val;
}
if (!class_exists(str_replace('.', '_',
$this->_channelInfo['validatepackage']['_content']))) {
if ($this->isIncludeable(str_replace('_', '/',
$this->_channelInfo['validatepackage']['_content']) . '.php')) {
include_once str_replace('_', '/',
$this->_channelInfo['validatepackage']['_content']) . '.php';
$vclass = str_replace('.', '_',
$this->_channelInfo['validatepackage']['_content']);
$val = &new $vclass;
} else {
$a = false;
return $a;
}
} else {
$vclass = str_replace('.', '_',
$this->_channelInfo['validatepackage']['_content']);
$val = &new $vclass;
}
} else {
$val = &new PEAR_Validate;
}
return $val;
} | php | {
"resource": ""
} |
q266635 | BaseObject.canGetProperty | test | public function canGetProperty($name, $checkVars = true)
{
$getter = static::_GETTER_PREFIX . $name;
return method_exists($this, $getter) || $checkVars && property_exists($this, $name);
} | php | {
"resource": ""
} |
q266636 | BaseObject.canSetProperty | test | public function canSetProperty($name, $checkVars = true)
{
$setter = static::_GETTER_PREFIX . $name;
return method_exists($this, $setter) || $checkVars && property_exists($this, $name);
} | php | {
"resource": ""
} |
q266637 | Container.getCacheFile | test | public function getCacheFile(callable $encoder = null): string
{
if (\is_null($encoder)) {
$encoder = function ($value): string {
return var_export($value, true);
};
}
$this->loadCacheParameters();
ksort($this->entries);
$encoded = $encoder($this->entries);
return <<<TEMPLATE
<?php return new class extends \Simply\Container\Container {
protected \$entries = $encoded;
};
TEMPLATE;
} | php | {
"resource": ""
} |
q266638 | Container.loadCacheParameters | test | private function loadCacheParameters(): void
{
foreach ($this->entryCache as $id => $entry) {
$parameters = $entry->getCacheParameters();
if (!$this->isConstantValue($parameters)) {
throw new ContainerException("Unable to cache entry '$id', the cache parameters are not static");
}
$this->entries[$id] = [\get_class($entry), $parameters];
}
} | php | {
"resource": ""
} |
q266639 | Container.addEntry | test | public function addEntry(string $id, EntryInterface $type): void
{
if (isset($this[$id])) {
throw new ContainerException("Entry for identifier '$id' already exists");
}
$this->entryCache[$id] = $type;
} | php | {
"resource": ""
} |
q266640 | Container.get | test | public function get($id)
{
if (array_key_exists($id, $this->valueCache)) {
return $this->valueCache[$id];
}
$entry = $this->getEntry($id);
$value = $entry->getValue($this->delegate);
if ($entry->isFactory()) {
$this->entryCache[$id] = $entry;
} else {
$this->valueCache[$id] = $value;
}
return $value;
} | php | {
"resource": ""
} |
q266641 | Container.getEntry | test | private function getEntry(string $id): EntryInterface
{
if (isset($this->entryCache[$id])) {
return $this->entryCache[$id];
}
if (!isset($this->entries[$id])) {
throw new NotFoundException("No entry was found for the identifier '$id'");
}
/** @var EntryInterface $class */
[$class, $parameters] = $this->entries[$id];
return $class::createFromCacheParameters($parameters);
} | php | {
"resource": ""
} |
q266642 | Container.has | test | public function has($id): bool
{
return isset($this->entries[$id]) || isset($this->entryCache[$id]);
} | php | {
"resource": ""
} |
q266643 | Container.offsetUnset | test | public function offsetUnset($offset): void
{
unset(
$this->entries[$offset],
$this->entryCache[$offset],
$this->valueCache[$offset]
);
} | php | {
"resource": ""
} |
q266644 | SiteAttribute.applySiteConditions | test | protected function applySiteConditions()
{
if ($this->siteId !== null) {
$this->andWhere(Db::parseParam('siteId', $this->siteId));
} else {
$this->andWhere(Db::parseParam('siteId', Craft::$app->getSites()->currentSite->id));
}
} | php | {
"resource": ""
} |
q266645 | AssignByKey.assign | test | function assign(array $keys, $value)
{
foreach ($keys as $key) {
$arr = &$this->array[$key];
}
$arr = $value;
return $this->array;
} | php | {
"resource": ""
} |
q266646 | PEAR_PackageFile._extractErrors | test | function _extractErrors($err = null)
{
static $errors = array();
if ($err === null) {
$e = $errors;
$errors = array();
return $e;
}
$errors[] = $err->getMessage();
} | php | {
"resource": ""
} |
q266647 | ZeroConfDriver.getModelsConfigFile | test | public function getModelsConfigFile()
{
$o = $this->params;
$file = $o['path'] . DIRECTORY_SEPARATOR . 'normalist_zeroconf_cache_' . $o['alias'] . '_' . $o['version'] . '.php';
return $file;
} | php | {
"resource": ""
} |
q266648 | ZeroConfDriver.getModelsDefinition | test | public function getModelsDefinition()
{
$file = $this->getModelsConfigFile();
if (!file_exists($file) || !is_readable($file)) {
throw new Exception\ModelFileNotFoundException(__METHOD__ . " Model configuration file '$file' does not exists or not readable");
}
if (defined('HHVM_VERSION')) {
// As an 'evil' workaround, waiting for hhvm to comply
// see https://github.com/facebook/hhvm/issues/1447
$definition = false;
$file_content = file_get_contents($file);
$file_content = trim(str_replace('<?php', '', $file_content));
$file_content = trim(str_replace('return array(', '$definition = array(', $file_content));
eval($file_content);
} else {
$definition = include $file;
}
if (!$definition) {
throw new Exception\ModelFileCorruptedException(__METHOD__ . " Model configuration file '$file' cannot be included");
}
if (!is_array($definition)) {
throw new Exception\ModelFileCorruptedException(__METHOD__ . " Model configuration file '$file' was included but is not a valid array");
}
return $definition;
} | php | {
"resource": ""
} |
q266649 | ZeroConfDriver.saveModelsDefinition | test | protected function saveModelsDefinition(array $models_definition)
{
$file = $this->getModelsConfigFile();
if (file_exists($file) && !is_writable($file)) {
throw new Exception\ModelFileNotWritableException(__METHOD__ . "Model configuration file '$file' cannot be overwritten, not writable.");
}
//$config = new Config($models_defintion, true);
$writer = new Writer\PhpArray();
$models_definition['normalist'] = ['model_version' => Metadata\NormalistModels::VERSION];
$writer->toFile($file, $models_definition, $exclusiveLock = true);
$perms = $this->params['permissions'];
if ($perms != '') {
if (decoct(octdec($perms)) == $perms) {
$perms = octdec($perms);
}
chmod($file, $perms);
}
return $this;
} | php | {
"resource": ""
} |
q266650 | ZeroConfDriver.getMetadata | test | public function getMetadata()
{
$cache_key = md5(serialize($this->params));
if (!array_key_exists($cache_key, self::$metadataCache)) {
if ($this->metadata === null) {
self::$metadataCache[$cache_key] = $this->getDefaultMetadata();
} else {
self::$metadataCache[$cache_key] = $this->metadata;
}
}
return self::$metadataCache[$cache_key];
} | php | {
"resource": ""
} |
q266651 | BankAbstract.setName | test | public function setName($name)
{
$name = (string) $name;
if ($this->exists() && $this->name !== $name) {
$this->updated['name'] = true;
}
$this->name = $name;
return $this;
} | php | {
"resource": ""
} |
q266652 | BankAbstract.setColor | test | public function setColor($color)
{
$color = (string) $color;
if ($this->exists() && $this->color !== $color) {
$this->updated['color'] = true;
}
$this->color = $color;
return $this;
} | php | {
"resource": ""
} |
q266653 | BankAbstract.setParser | test | public function setParser($parser)
{
$parser = (string) $parser;
if ($this->exists() && $this->parser !== $parser) {
$this->updated['parser'] = true;
}
$this->parser = $parser;
return $this;
} | php | {
"resource": ""
} |
q266654 | Aggregator.aggregate | test | public function aggregate($collection)
{
// Ensure the collection is materialized.
$collection = $this->mirror->materializeCollection($collection);
// Create aggregate collection to accumulate style sheets.
$aggregate = new StyleAggregate();
foreach ($collection as $resource) {
if ($resource instanceof MaterializedResource) {
$internalResource = $resource->getResource();
$mediaType = 'all';
if ($internalResource instanceof CssResource) {
$mediaType = $internalResource->getMediaType();
}
$aggregate->addStyle($resource, $mediaType);
}
}
// Create resource with the aggregate style sheet.
$data = $aggregate->getAggregateStyle();
$hash = sha1($data);
$file = $this->prefix.$hash.'.css';
$resource = new LocalResource($file, $data);
return $resource;
} | php | {
"resource": ""
} |
q266655 | NoAPI.curl | test | public static function curl($url)
{
$req = curl_init();
$opt = [
CURLOPT_AUTOREFERER => true,
CURLOPT_COOKIEJAR => tempnam(sys_get_temp_dir(), 'curl'),
CURLOPT_FAILONERROR => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HEADER => true,
CURLOPT_HTTPHEADER => ['DNT: 1', 'Accept-Language: en-us,en;q=0.5'],
CURLOPT_MAXREDIRS => 5,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url,
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0',
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_TIMEOUT => 10,
];
curl_setopt_array($req, $opt);
if (! $res = curl_exec($req)) return false;
curl_close($req);
// mb_convert_encoding is used to avoid encoding issues related to DOMDocument::loadHTML
// see https://secure.php.net/manual/en/domdocument.loadhtml.php#52251
return mb_convert_encoding($res, 'HTML-ENTITIES', 'UTF-8');
} | php | {
"resource": ""
} |
q266656 | NoAPI.imageProxy | test | public static function imageProxy($url, $filename, $directory, $overwrite = null)
{
$allowedmimetype = [ 'image/gif', 'image/jpeg', 'image/png', 'image/x-icon' ];
$localpath = $directory . '/noapi_' . $filename;
if (! $overwrite && file_exists($localpath)) return $localpath;
$image = file_get_contents($url);
$finfo = new \finfo(FILEINFO_MIME_TYPE);
$mimetype = $finfo->buffer($image);
if (! in_array($mimetype, $allowedmimetype)) return false;
if (file_put_contents($localpath, $image) === false) return false;
return $localpath;
} | php | {
"resource": ""
} |
q266657 | Validator.createValidator | test | public static function createValidator($type, $model, $attributes, $params = [])
{
$params['attributes'] = $attributes;
if ($type instanceof \Closure || ($model->hasMethod($type) && !isset(static::$builtInValidators[$type]))) {
// method-based validator
$params['class'] = __NAMESPACE__ . '\InlineValidator';
$params['method'] = $type;
} else {
if (isset(static::$builtInValidators[$type])) {
$type = static::$builtInValidators[$type];
}
if (is_array($type)) {
$params = array_merge($type, $params);
} else {
$params['class'] = $type;
}
}
return Reaction::create($params);
} | php | {
"resource": ""
} |
q266658 | Validator.validateAttribute | test | public function validateAttribute($model, $attribute)
{
$result = $this->validateValue($model->$attribute);
if ($result instanceof ExtendedPromiseInterface) {
return $result->then(function($_result) use ($model, $attribute) {
if (!empty($_result)) {
$this->addError($model, $attribute, $_result[0], $_result[1]);
}
});
}
if (!empty($result)) {
$this->addError($model, $attribute, $result[0], $result[1]);
}
return null;
} | php | {
"resource": ""
} |
q266659 | Validator.validate | test | public function validate($value, &$error = null)
{
$result = $this->validateValue($value);
if (empty($result)) {
return true;
}
list($message, $params) = $result;
$params['attribute'] = Reaction::t('rct', 'the input value');
if (is_array($value)) {
$params['value'] = 'array()';
} elseif (is_object($value)) {
$params['value'] = 'object';
} else {
$params['value'] = $value;
}
$error = $this->formatMessage($message, $params);
return false;
} | php | {
"resource": ""
} |
q266660 | App.run | test | public function run($namespace)
{
$this->namespace = $namespace;
$this->_initRegister();
date_default_timezone_set($this->config['timezone']);
if (false === IS_CLI) {
$this->route = Route::instance()->init();
$this->controller = Controller::create($this->route);
}
} | php | {
"resource": ""
} |
q266661 | App.shutdown | test | public static function shutdown()
{
$error = error_get_last();
if ($error !== null) {
if (App::app()->config['debug'] == false) {
Log::log()->fatal('Fatal Error: ' .$error['message'] . ' in '. $error['file']. ' on '.$error['line']);
}
}
} | php | {
"resource": ""
} |
q266662 | App.url | test | public function url($controller, $action, $param)
{
$path = url();
if (empty($param)) {
// return PATH_APP_REL.'/'.$controller.'/'.$action;
return $path . '/' . $controller.'/'.$action;
} else {
// return PATH_APP_REL.'/'.$controller.'/'.$action.'?'.http_build_query($param);
return $path . '/' . $controller.'/'.$action.'?'.http_build_query($param);
}
} | php | {
"resource": ""
} |
q266663 | UrlHelper.canonical | test | public function canonical()
{
$routePath = $this->getCurrentPath(true);
if ($routePath === null) {
return null;
}
$params = $this->app->getRoute()->getRouteParams();
$params[0] = $routePath;
return $this->getUrlManager()->createAbsoluteUrl($params);
} | php | {
"resource": ""
} |
q266664 | UrlHelper.normalizeRoutePath | test | protected function normalizeRoutePath($routePath)
{
$routePath = Reaction::$app->getAlias((string) $routePath);
if (strncmp($routePath, '/', 1) === 0) {
// absolute route
return $routePath;
}
$route = $this->app->getRoute();
// relative route
if ($route === null || $route->controller === null) {
throw new InvalidArgumentException("Unable to resolve the relative route: $routePath. No active controller is available.");
}
return $routePath === '' ? $route->getRoutePath(true) : $route->controller->group() . '/' . $routePath;
} | php | {
"resource": ""
} |
q266665 | Application.isWorking | test | public function isWorking()
{
if (null != $this->exception) {
return false;
}
foreach ($this->getTests() as $test) {
if ($test->hasFailed()) {
$this->exception = new \Exception('Tests failed');
return false;
}
}
return true;
} | php | {
"resource": ""
} |
q266666 | ViewFinderTrait.getViewNames | test | public function getViewNames($schema = '', $refresh = false)
{
if (!isset($this->_viewNames[$schema]) || $refresh) {
return $this->findViewNames($schema)->then(
function($names) use($schema) {
$this->_viewNames[$schema] = $names;
return $names;
}
);
}
return resolve($this->_viewNames[$schema]);
} | php | {
"resource": ""
} |
q266667 | Psr16Manager.get | test | public function get(string $key, $default = null)
{
$value = static::$handler->get($this->normalized($key));
// If we could not find the cache value, we will get
// the default value for this cache value. This default could be a callback
// so we will execute the value function which will resolve it if needed.
if (is_null($value)) {
$value = is_callable($default) ? $default() : $default;
}
if (static::hasMacro()) {
$value = $this->runMacro('getAfter', [$value, $key, false]);
}
return $value;
} | php | {
"resource": ""
} |
q266668 | Psr16Manager.set | test | public function set(string $key, $value, int $ttl = null)
{
$keyNormalized = $this->normalized($key);
$result = static::$handler->set($keyNormalized, $value, $ttl ?? $this->ttl);
if ($result) {
if ($this->assistant) {
$this->assistant->add($keyNormalized);
$this->assistant->save();
}
}
return $result;
} | php | {
"resource": ""
} |
q266669 | Psr16Manager.setMultiple | test | public function setMultiple(array $values, int $ttl = null)
{
$valuesNormalized = [];
foreach ($values as $key => $value) {
$valuesNormalized[$this->normalized($key)] = $value;
}
$result = static::$handler->setMultiple(
$valuesNormalized,
$ttl ?? $this->ttl
);
if ($result) {
if ($this->assistant) {
foreach (array_keys($valuesNormalized) as $key) {
$this->assistant->add($key);
}
$this->assistant->save();
}
}
return $result;
} | php | {
"resource": ""
} |
q266670 | Psr16Manager.pull | test | public function pull(string $key, $default = null)
{
$result = $this->get($key, $default);
$this->delete($key);
return $result;
} | php | {
"resource": ""
} |
q266671 | Psr16Manager.add | test | public function add(string $key, $value, int $ttl = null)
{
// If the store has an "add" method we will call the method on the store so it
// has a chance to override this logic. Some drivers better support the way
// this operation should work with a total "atomic" implementation of it.
if (method_exists(static::$handler, 'add')) {
return static::$handler->add(
$this->normalized($key),
$value,
$ttl ?? $this->ttl
);
}
// If the value did not exist in the cache, we will put the value in the cache
// so it exists for subsequent requests. Then, we will return true so it is
// easy to know if the value gets added. Otherwise, we will return false.
if (is_null($this->get($key))) {
return $this->set($key, $value, $ttl ?? $this->ttl);
}
return false;
} | php | {
"resource": ""
} |
q266672 | Psr16Manager.remember | test | public function remember(string $key, \Closure $callback, $ttl = null)
{
$value = $this->get($key);
// If the item exists in the cache we will just return this immediately and if
// not we will execute the given Closure and cache the result of that for a
// given number of seconds so it's available for all subsequent requests.
if (!is_null($value)) {
return $value;
}
$this->set($key, $value = $callback(), $ttl ?? $this->ttl);
return $value;
} | php | {
"resource": ""
} |
q266673 | Psr16Manager.delete | test | public function delete(string $key)
{
$keyNormalized = $this->normalized($key);
$result = static::$handler->delete($keyNormalized);
if ($result) {
if ($this->assistant) {
$this->assistant->remove($keyNormalized);
$this->assistant->save();
}
}
return $result;
} | php | {
"resource": ""
} |
q266674 | Phone.filter | test | public function filter($str)
{
$str = preg_replace("|[\D+]|", "", $str);
if (strlen($str) == 11 && in_array(substr($str, 0, 1), array("7", "8"))) {
$str = substr($str, 1);
}
$len2 = strlen($str);
return $len2 == 10 ? $str : "";
} | php | {
"resource": ""
} |
q266675 | ConfigTrait.configDefaultOptions | test | protected function configDefaultOptions(Command $command)
{
$defaultConfPath = getcwd() . '/' . $this->confDir;
$command->addArgument('working-directory', InputOption::VALUE_REQUIRED, 'Working directory', getcwd());
$command
->addOption('app-type', null, InputOption::VALUE_REQUIRED, 'Application type', StaticApplicationInterface::APP_TYPE_WEB)
->addOption('app-host', null, InputOption::VALUE_REQUIRED, 'Host to run', '127.0.0.1')
->addOption('app-port', null, InputOption::VALUE_REQUIRED, 'Port to run', 4000)
->addOption('app-debug', null, InputOption::VALUE_REQUIRED, 'Enable debug', true)
->addOption('app-config', null, InputOption::VALUE_REQUIRED, 'Configs dir path', $defaultConfPath);
} | php | {
"resource": ""
} |
q266676 | ConfigTrait.optionOrConfigValue | test | protected function optionOrConfigValue(InputInterface $input, $config, $optionName, $configName = null)
{
$optionNameRaw = $this->normalizeConfigArrayPath($optionName);
if ($input->hasParameterOption('--' . $optionNameRaw)) {
return $this->getOptionWithTypeCast($input, $optionName);
}
if (!isset($configName)) {
$configName = $optionNameRaw;
}
$configValue = ArrayHelper::getValue($config, $configName, null);
return isset($configValue) ? $configValue : $input->getOption($optionName);
} | php | {
"resource": ""
} |
q266677 | ConfigTrait.getOptionWithTypeCast | test | protected function getOptionWithTypeCast(InputInterface $input, $optionName)
{
$optionNameExp = explode(':', $optionName);
if (count($optionNameExp) > 1) {
$optionName = $optionNameExp[0];
$optionType = $optionNameExp[1];
}
$optionValue = $input->getOption($optionName);
if (isset($optionType) && function_exists($optionType . 'val')) {
$typeCastFunc = $optionType . 'val';
$optionValue = $typeCastFunc($optionValue);
}
return $optionValue;
} | php | {
"resource": ""
} |
q266678 | ConfigTrait.loadConfigFromFile | test | protected function loadConfigFromFile($path, $appType = StaticApplicationInterface::APP_TYPE_WEB)
{
if (!isset($this->_reader)) {
$reader = new ConfigReader([
'path' => $path,
'appType' => $appType,
]);
$this->_reader = $reader;
}
return $this->_reader->data;
} | php | {
"resource": ""
} |
q266679 | ConfigTrait.loadConfig | test | protected function loadConfig(InputInterface $input, OutputInterface $output, $saveConfig = true)
{
$configsPath = $this->getConfigPath($input);
$appType = $input->getOption('app-type');
$config = $this->loadConfigFromFile($configsPath, $appType);
/**
* Array format
* [ 'OPTION_NAME:TYPE' => 'CONFIG_ARRAY_PATH', ]
*/
$configOptions = [
'app-host' => 'appStatic.hostname',
'app-port:int' => 'appStatic.port',
'app-debug:bool' => 'appStatic.debug',
];
foreach ($configOptions as $optionName => $configName) {
$value = $this->optionOrConfigValue($input, $config, $optionName, $configName);
ArrayHelper::setValue($config, $configName, $value);
}
if ($saveConfig) {
$this->_reader->data = $config;
\Reaction::$config = $this->_reader;
}
return $config;
} | php | {
"resource": ""
} |
q266680 | ConfigTrait.renderConfig | test | protected function renderConfig(OutputInterface $output, array $config)
{
$table = new Table($output);
$rows = $this->renderConfigRows($config);
$table->addRows($rows);
$table->render();
} | php | {
"resource": ""
} |
q266681 | ConfigTrait.renderValue | test | private function renderValue($value)
{
$type = gettype($value);
$valueStr = null;
switch ($type) {
case 'object':
$valueStr = 'object(' . get_class($value) . ')';
break;
case 'array':
$valueStr = 'array(' . count($value) . ')';
break;
case 'boolean':
$valueStr = $value ? 'TRUE' : 'FALSE';
break;
case 'string':
$valueStr = '"' . $value . '"';
break;
default: $valueStr = $value;
}
return $valueStr;
} | php | {
"resource": ""
} |
q266682 | ConfigTrait.normalizeConfigArrayPath | test | private function normalizeConfigArrayPath($configPath)
{
if (!strpos($configPath, ':')) {
return $configPath;
}
$configPathExp = explode(':', $configPath);
return reset($configPathExp);
} | php | {
"resource": ""
} |
q266683 | PEAR_PackageFile_v2_rw._setPackageVersion2_1 | test | function _setPackageVersion2_1()
{
$info = array(
'version' => '2.1',
'xmlns' => 'http://pear.php.net/dtd/package-2.1',
'xmlns:tasks' => 'http://pear.php.net/dtd/tasks-1.0',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation' => 'http://pear.php.net/dtd/tasks-1.0
http://pear.php.net/dtd/tasks-1.0.xsd
http://pear.php.net/dtd/package-2.1
http://pear.php.net/dtd/package-2.1.xsd',
);
if (!isset($this->_packageInfo['attribs'])) {
$this->_packageInfo = array_merge(array('attribs' => $info), $this->_packageInfo);
} else {
$this->_packageInfo['attribs'] = $info;
}
} | php | {
"resource": ""
} |
q266684 | PEAR_PackageFile_v2_rw.clearContents | test | function clearContents($baseinstall = false)
{
$this->_filesValid = false;
$this->_isValid = 0;
if (!isset($this->_packageInfo['contents'])) {
$this->_packageInfo = $this->_insertBefore($this->_packageInfo,
array('compatible',
'dependencies', 'providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease',
'extbinrelease', 'zendextsrcrelease', 'zendextbinrelease',
'bundle', 'changelog'), array(), 'contents');
}
if ($this->getPackageType() != 'bundle') {
$this->_packageInfo['contents'] =
array('dir' => array('attribs' => array('name' => '/')));
if ($baseinstall) {
$this->_packageInfo['contents']['dir']['attribs']['baseinstalldir'] = $baseinstall;
}
} else {
$this->_packageInfo['contents'] = array('bundledpackage' => array());
}
} | php | {
"resource": ""
} |
q266685 | PEAR_PackageFile_v2_rw.clearDeps | test | function clearDeps()
{
if (!isset($this->_packageInfo['dependencies'])) {
$this->_packageInfo = $this->_mergeTag($this->_packageInfo, array(),
array(
'dependencies' => array('providesextension', 'usesrole', 'usestask',
'srcpackage', 'srcuri', 'phprelease', 'extsrcrelease', 'extbinrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle', 'changelog')));
}
$this->_packageInfo['dependencies'] = array();
} | php | {
"resource": ""
} |
q266686 | PEAR_PackageFile_v2_rw.setPackageType | test | function setPackageType($type)
{
$this->_isValid = 0;
if (!in_array($type, array('php', 'extbin', 'extsrc', 'zendextsrc',
'zendextbin', 'bundle'))) {
return false;
}
if (in_array($type, array('zendextsrc', 'zendextbin'))) {
$this->_setPackageVersion2_1();
}
if ($type != 'bundle') {
$type .= 'release';
}
foreach (array('phprelease', 'extbinrelease', 'extsrcrelease',
'zendextsrcrelease', 'zendextbinrelease', 'bundle') as $test) {
unset($this->_packageInfo[$test]);
}
if (!isset($this->_packageInfo[$type])) {
// ensure that the release tag is set up
$this->_packageInfo = $this->_insertBefore($this->_packageInfo, array('changelog'),
array(), $type);
}
$this->_packageInfo[$type] = array();
return true;
} | php | {
"resource": ""
} |
q266687 | PEAR_PackageFile_v2_rw.& | test | function &_getCurrentRelease($strict = true)
{
if ($p = $this->getPackageType()) {
if ($strict) {
if ($p == 'extsrc' || $p == 'zendextsrc') {
$a = null;
return $a;
}
}
if ($p != 'bundle') {
$p .= 'release';
}
if (isset($this->_packageInfo[$p][0])) {
return $this->_packageInfo[$p][count($this->_packageInfo[$p]) - 1];
} else {
return $this->_packageInfo[$p];
}
} else {
$a = null;
return $a;
}
} | php | {
"resource": ""
} |
q266688 | PEAR_PackageFile_v2_rw.addInstallAs | test | function addInstallAs($path, $as)
{
$r = &$this->_getCurrentRelease();
if ($r === null) {
return false;
}
$this->_isValid = 0;
$r = $this->_mergeTag($r, array('attribs' => array('name' => $path, 'as' => $as)),
array(
'filelist' => array(),
'install' => array('ignore')
));
} | php | {
"resource": ""
} |
q266689 | PEAR_PackageFile_v2_rw.addIgnore | test | function addIgnore($path)
{
$r = &$this->_getCurrentRelease();
if ($r === null) {
return false;
}
$this->_isValid = 0;
$r = $this->_mergeTag($r, array('attribs' => array('name' => $path)),
array(
'filelist' => array(),
'ignore' => array()
));
} | php | {
"resource": ""
} |
q266690 | PEAR_PackageFile_v2_rw.addBinarypackage | test | function addBinarypackage($package)
{
if ($this->getPackageType() != 'extsrc' && $this->getPackageType() != 'zendextsrc') {
return false;
}
$r = &$this->_getCurrentRelease(false);
if ($r === null) {
return false;
}
$this->_isValid = 0;
$r = $this->_mergeTag($r, $package,
array(
'binarypackage' => array('filelist'),
));
} | php | {
"resource": ""
} |
q266691 | PEAR_PackageFile_v2_rw.addConfigureOption | test | function addConfigureOption($name, $prompt, $default = null)
{
if ($this->getPackageType() != 'extsrc' && $this->getPackageType() != 'zendextsrc') {
return false;
}
$r = &$this->_getCurrentRelease(false);
if ($r === null) {
return false;
}
$opt = array('attribs' => array('name' => $name, 'prompt' => $prompt));
if ($default !== null) {
$opt['attribs']['default'] = $default;
}
$this->_isValid = 0;
$r = $this->_mergeTag($r, $opt,
array(
'configureoption' => array('binarypackage', 'filelist'),
));
} | php | {
"resource": ""
} |
q266692 | PEAR_PackageFile_v2_rw.setPhpInstallCondition | test | function setPhpInstallCondition($min, $max, $exclude = false)
{
$r = &$this->_getCurrentRelease();
if ($r === null) {
return false;
}
$this->_isValid = 0;
if (isset($r['installconditions']['php'])) {
unset($r['installconditions']['php']);
}
$dep = array('min' => $min, 'max' => $max);
if ($exclude) {
if (is_array($exclude) && count($exclude) == 1) {
$exclude = $exclude[0];
}
$dep['exclude'] = $exclude;
}
if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
$r = $this->_mergeTag($r, $dep,
array(
'installconditions' => array('configureoption', 'binarypackage',
'filelist'),
'php' => array('extension', 'os', 'arch')
));
} else {
$r = $this->_mergeTag($r, $dep,
array(
'installconditions' => array('filelist'),
'php' => array('extension', 'os', 'arch')
));
}
} | php | {
"resource": ""
} |
q266693 | PEAR_PackageFile_v2_rw.setOsInstallCondition | test | function setOsInstallCondition($name, $conflicts = false)
{
$r = &$this->_getCurrentRelease();
if ($r === null) {
return false;
}
$this->_isValid = 0;
if (isset($r['installconditions']['os'])) {
unset($r['installconditions']['os']);
}
$dep = array('name' => $name);
if ($conflicts) {
$dep['conflicts'] = '';
}
if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
$r = $this->_mergeTag($r, $dep,
array(
'installconditions' => array('configureoption', 'binarypackage',
'filelist'),
'os' => array('arch')
));
} else {
$r = $this->_mergeTag($r, $dep,
array(
'installconditions' => array('filelist'),
'os' => array('arch')
));
}
} | php | {
"resource": ""
} |
q266694 | PEAR_PackageFile_v2_rw.setArchInstallCondition | test | function setArchInstallCondition($pattern, $conflicts = false)
{
$r = &$this->_getCurrentRelease();
if ($r === null) {
return false;
}
$this->_isValid = 0;
if (isset($r['installconditions']['arch'])) {
unset($r['installconditions']['arch']);
}
$dep = array('pattern' => $pattern);
if ($conflicts) {
$dep['conflicts'] = '';
}
if ($this->getPackageType() == 'extsrc' || $this->getPackageType() == 'zendextsrc') {
$r = $this->_mergeTag($r, $dep,
array(
'installconditions' => array('configureoption', 'binarypackage',
'filelist'),
'arch' => array()
));
} else {
$r = $this->_mergeTag($r, $dep,
array(
'installconditions' => array('filelist'),
'arch' => array()
));
}
} | php | {
"resource": ""
} |
q266695 | PEAR_PackageFile_v2_rw.generateChangeLogEntry | test | function generateChangeLogEntry($notes = false)
{
return array(
'version' =>
array(
'release' => $this->getVersion('release'),
'api' => $this->getVersion('api'),
),
'stability' =>
$this->getStability(),
'date' => $this->getDate(),
'license' => $this->getLicense(true),
'notes' => $notes ? $notes : $this->getNotes()
);
} | php | {
"resource": ""
} |
q266696 | VideoModel.isVideo | test | public function isVideo()
{
return $this->pathExists() && $this->exists() &&
in_array(strtolower(end(explode('.', $this->filename))), self::$allowed_extensions);
} | php | {
"resource": ""
} |
q266697 | VideoModel.getVideoInfos | test | public function getVideoInfos()
{
if (!$this->exists()) return false;
$data = finfo_file($this->getPath().$this->filename);
return $data;
} | php | {
"resource": ""
} |
q266698 | TransactionAbstract.setDate | test | public function setDate($date)
{
$date = (string) $date;
if ($this->exists() && $this->date !== $date) {
$this->updated['date'] = true;
}
$this->date = $date;
return $this;
} | php | {
"resource": ""
} |
q266699 | TransactionAbstract.setAmount | test | public function setAmount($amount)
{
$amount = (float) $amount;
if ($this->exists() && $this->amount !== $amount) {
$this->updated['amount'] = true;
}
$this->amount = $amount;
return $this;
} | php | {
"resource": ""
} |
Subsets and Splits