_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q250600
FinalCallback.finalize
validation
protected function finalize($function) { $response = $this->container->get(self::RESPONSE); if (is_string($function) === true) { $stream = $response->getBody(); $stream->write((string) $function);
php
{ "resource": "" }
q250601
CallbackHandler.middleware
validation
protected function middleware(FinalCallback $callback, ServerRequestInterface $request) { $response = $this->container->get(self::RESPONSE); if (interface_exists(Application::MIDDLEWARE) === true) { $middleware = new Dispatcher($this->middlewares, $response); $delegate = ne...
php
{ "resource": "" }
q250602
Complex.norm
validation
public function norm() { if ($this->original) { return $this->original->rho; }
php
{ "resource": "" }
q250603
Complex.argument
validation
public function argument() { if ($this->original) { return $this->original->theta; }
php
{ "resource": "" }
q250604
Complex.add
validation
public function add($z) { if (is_numeric($z)) { $z = new self($z, 0); }
php
{ "resource": "" }
q250605
Complex.substract
validation
public function substract($z) { if (is_numeric($z)) { $z = new self($z, 0);
php
{ "resource": "" }
q250606
Complex.multiply
validation
public function multiply($z) { if (is_numeric($z)) { $z = new self($z, 0); } return new self(
php
{ "resource": "" }
q250607
Complex.divide
validation
public function divide($z) { if (is_numeric($z)) { $z = new self($z, 0); } if ($z->is_zero) { throw new \InvalidArgumentException('Cannot divide by zero!'); } $divisor = pow($z->re, 2) + pow($z->im, 2); $r =
php
{ "resource": "" }
q250608
Complex.equal
validation
public function equal($z) { if (is_numeric($z)) { $z = new self($z, 0); }
php
{ "resource": "" }
q250609
HttpIntegration.globals
validation
protected function globals(Configuration $config) { $cookies = $config->get('app.http.cookies', array()); $files = $config->get('app.http.files', array());
php
{ "resource": "" }
q250610
HttpIntegration.resolve
validation
protected function resolve(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response) { if (class_exists('Zend\Diactoros\ServerRequestFactory')) { $response = new ZendResponse; $request = ServerRequestFactory::fromGlobals();
php
{ "resource": "" }
q250611
Application.handle
validation
public function handle(ServerRequestInterface $request) { $callback = new CallbackHandler(self::$container); if (static::$container->has(self::MIDDLEWARE)) { $middleware = static::$container->get(self::MIDDLEWARE); $delegate = new Delegate($callback);
php
{ "resource": "" }
q250612
Application.integrate
validation
public function integrate($integrations, ConfigurationInterface $config = null) { list($config, $container) = array($config ?: $this->config, static::$container); foreach ((array) $integrations as $item) { $integration = is_string($item) ? new $item : $item;
php
{ "resource": "" }
q250613
Application.run
validation
public function run() { // NOTE: To be removed in v1.0.0. Use "ErrorHandlerIntegration" instead. if (static::$container->has(self::ERROR_HANDLER)) { $debugger = static::$container->get(self::ERROR_HANDLER); $debugger->display();
php
{ "resource": "" }
q250614
WhoopsErrorHandler.display
validation
public function display() { $handler = new PrettyPageHandler; error_reporting(E_ALL);
php
{ "resource": "" }
q250615
MiddlewareIntegration.dispatcher
validation
protected function dispatcher(ResponseInterface $response, $stack) { $dispatcher = new Dispatcher($stack, $response); if (class_exists('Zend\Stratigility\MiddlewarePipe')) { $pipe = new MiddlewarePipe;
php
{ "resource": "" }
q250616
Renderer.render
validation
public function render($template, array $data = array()) { list($file, $name) = array(null, str_replace('.', '/', $template)); foreach ((array) $this->paths as $key => $path) { $files = (array) $this->files($path); $item = $this->check($files, $path, $key, $name . '.php'); ...
php
{ "resource": "" }
q250617
Renderer.check
validation
protected function check(array $files, $path, $source, $template) { $file = null; foreach ((array) $files as $key => $value) { $filepath = (string) str_replace($path, $source, $value); $filepath = str_replace('\\', '/', (string) $filepath); $filepath = (string)...
php
{ "resource": "" }
q250618
Renderer.extract
validation
protected function extract($filepath, array $data) { extract($data); ob_start(); include $filepath;
php
{ "resource": "" }
q250619
Renderer.files
validation
protected function files($path) { $directory = new \RecursiveDirectoryIterator($path); $iterator = new \RecursiveIteratorIterator($directory);
php
{ "resource": "" }
q250620
Dispatcher.parse
validation
protected function parse($httpMethod, $uri, $route) { $matched = preg_match($route[4], $uri, $parameters); if ($matched && ($httpMethod == $route[0]
php
{ "resource": "" }
q250621
Dispatcher.retrieve
validation
protected function retrieve(array $routes, $uri) { $routes = array_values(array_filter($routes)); if (empty($routes)) { $message = 'Route "' . $uri . '" not found'; throw new \UnexpectedValueException($message); }
php
{ "resource": "" }
q250622
LeagueContainer.set
validation
public function set($id, $concrete, $share = false) {
php
{ "resource": "" }
q250623
FontAwesomeBackend.getTag
validation
public function getTag($classNames, $color = null) { return ArrayData::create([ 'ClassNames' => $classNames,
php
{ "resource": "" }
q250624
FontAwesomeBackend.getClassName
validation
public function getClassName($identifier, $args = []) { if (isset($this->classes[$identifier])) {
php
{ "resource": "" }
q250625
FontAwesomeBackend.getIcons
validation
public function getIcons() { // Initialise: $icons = []; // Iterate Grouped Icons: foreach ($this->getGroupedIcons() as $name => $group) { foreach ($group as $id => $icon) { if (!isset($icons[$id])) ...
php
{ "resource": "" }
q250626
FontAwesomeBackend.getGroupedIcons
validation
public function getGroupedIcons() { // Answer Cached Icons (if available): if ($icons = self::cache()->get($this->getCacheKey())) { return $icons; } // Initialise: $icons = []; // Parse Icon Source Data: ...
php
{ "resource": "" }
q250627
Router.retrieve
validation
public function retrieve($httpMethod, $uri) { $route = array($httpMethod, $uri); $routes = array_map(function ($route) { return array($route[0], $route[1]); }, $this->routes); $key
php
{ "resource": "" }
q250628
Router.restful
validation
public function restful($route, $class, $middlewares = array()) { $middlewares = (is_string($middlewares)) ? array($middlewares) : $middlewares; $this->add('GET', '/' . $route, $class . '@index', $middlewares); $this->add('POST', '/' . $route, $class . '@store', $middlewares); $thi...
php
{ "resource": "" }
q250629
Router.prefix
validation
public function prefix($prefix = '', $namespace = '') { $namespace === '' && $namespace = (string) $this->namespace; $prefix && $prefix[0] !== '/'
php
{ "resource": "" }
q250630
Router.parse
validation
protected function parse($route) { $route[0] = strtoupper($route[0]); $route[1] = str_replace('//', '/', $this->prefix . $route[1]); is_string($route[2]) && $route[2] = explode('@', $route[2]);
php
{ "resource": "" }
q250631
Sortable.getSortValBeforeAll
validation
public function getSortValBeforeAll($groupingId = null) { if ($groupingId === null && $this->grpColumn) { throw new SortableException( 'groupingId may be omitted only when grpColumn is not configured.' ); } $query = (new Query()) ->select(...
php
{ "resource": "" }
q250632
Sortable.getSortValAfterAll
validation
public function getSortValAfterAll($groupingId = null) { if (!$groupingId === null && $this->grpColumn) { throw new SortableException( 'groupingId may be omitted only when grpColumn is not configured.' ); } $query = (new Query()) ->select(...
php
{ "resource": "" }
q250633
Sortable.skipRowsClause
validation
protected function skipRowsClause() { $skipClause = []; foreach ($this->skipRows as $cl => $val) { $skipClause[] = ['<>', $cl, $val]; } if
php
{ "resource": "" }
q250634
Response.withStatus
validation
public function withStatus($code, $reason = '') { // TODO: Add \InvalidArgumentException
php
{ "resource": "" }
q250635
Growl.execute
validation
public function execute() { if ($this->escape !== false) { $this->options = $this->escape($this->options);
php
{ "resource": "" }
q250636
Growl.buildCommand
validation
public function buildCommand() { if ($this->escape !== false) { $this->options = $this->escape($this->options);
php
{ "resource": "" }
q250637
Growl.setSafe
validation
public function setSafe($options) { if (is_string($options)) { $this->safe[] = $options; return $this; } if (is_array($options)) {
php
{ "resource": "" }
q250638
Growl.escape
validation
protected function escape(array $options) { $results = []; foreach ($options as $key => $value) { if (!in_array($key, $this->safe)) {
php
{ "resource": "" }
q250639
Growl.selectBuilder
validation
protected function selectBuilder() { if (PHP_OS === 'Darwin') { if (exec('which growlnotify')) { return new GrowlNotifyBuilder; } if (exec('which terminal-notifier')) { return new TerminalNotifierBuilder; } } if ...
php
{ "resource": "" }
q250640
Factorial.compute
validation
protected function compute($n) { $int_fact = 1; for ($i = 1; $i <= $n ; $i++) {
php
{ "resource": "" }
q250641
SentryTarget.export
validation
public function export() { foreach ($this->messages as $message) { list($msg, $level, $catagory, $timestamp, $traces) = $message; $errStr = ''; $options = [ 'level' => yii\log\Logger::getLevelName($level), 'extra' => [], ]; ...
php
{ "resource": "" }
q250642
Collection.setHttp
validation
public function setHttp(ServerRequestInterface $request, ResponseInterface $response) { $this->set('Psr\Http\Message\ServerRequestInterface', $request);
php
{ "resource": "" }
q250643
GrowlNotifyBuilder.build
validation
public function build($options) { $command = $this->path; if (isset($options['title'])) { $command .= " -t {$options['title']}"; } if (isset($options['message'])) { $command .= " -m {$options['message']}"; } if (isset($options['image'])) { ...
php
{ "resource": "" }
q250644
Collector.get
validation
public static function get(ContainerInterface $container, array $components = array(), &$globals = null) { $configuration = new Configuration; $collection = new Collection; foreach ((array) $components as $component) { $instance = self::prepare($collection, $component); ...
php
{ "resource": "" }
q250645
Collector.prepare
validation
protected static function prepare(Collection &$collection, $component) { $instance = new $component; $type = $instance->type(); if (empty($type) === false) { $parameters = array($instance->get()); $type === 'http' && $parameters = $instance->get();
php
{ "resource": "" }
q250646
Dispatcher.push
validation
public function push($middleware) { if (is_array($middleware)) { $this->stack = array_merge($this->stack, $middleware); return $this;
php
{ "resource": "" }
q250647
Dispatcher.approach
validation
protected function approach($middleware) { if ($middleware instanceof \Closure) { $object = new \ReflectionFunction($middleware); return count($object->getParameters()) === 2; } $class
php
{ "resource": "" }
q250648
Dispatcher.callback
validation
protected function callback($middleware, ResponseInterface $response) { $middleware = is_string($middleware) ? new $middleware : $middleware; $callback = function ($request, $next = null) use ($middleware) { return $middleware($request, $next); }; if ($this->approach($m...
php
{ "resource": "" }
q250649
Dispatcher.resolve
validation
protected function resolve($index) { $callback = null; $stack = $this->stack; if (isset($this->stack[$index])) { $item = $stack[$index]; $next = $this->resolve($index + 1); $callback = function ($request) use
php
{ "resource": "" }
q250650
Dispatcher.transform
validation
protected function transform($middleware, $wrappable = true) { if (is_a($middleware, Application::MIDDLEWARE) === false) { $approach = (boolean) $this->approach($middleware); $response = $approach === self::SINGLE_PASS ? $this->response : null; $wrapper
php
{ "resource": "" }
q250651
PhrouteDispatcher.collect
validation
protected function collect() { $collector = new RouteCollector; foreach ($this->router->routes() as
php
{ "resource": "" }
q250652
PhrouteDispatcher.exceptions
validation
protected function exceptions(\Exception $exception, $uri) { $interface = 'Phroute\Phroute\Exception\HttpRouteNotFoundException'; $message = (string) $exception->getMessage();
php
{ "resource": "" }
q250653
Uri.getAuthority
validation
public function getAuthority() { $authority = $this->host; if ($this->host !== '' && $this->user !== null)
php
{ "resource": "" }
q250654
Uri.instance
validation
public static function instance(array $server) { $secure = isset($server['HTTPS']) ? $server['HTTPS'] : 'off'; $http = $secure ===
php
{ "resource": "" }
q250655
NormalDistribution.variance
validation
public function variance() { $float_variance = pow($this->float_sigma, 2); if ($this->int_precision) { return round($float_variance,
php
{ "resource": "" }
q250656
NormalDistribution.precision
validation
public function precision($n) { if (!is_numeric($n) || $n < 0) { throw new \InvalidArgumentException('Precision must be
php
{ "resource": "" }
q250657
NormalDistribution.max
validation
public function max() { $float_max = 1 / ($this->float_sigma * sqrt(2 * pi())); if ($this->int_precision) {
php
{ "resource": "" }
q250658
NormalDistribution.fwhm
validation
public function fwhm() { $float_fwhm = 2 * sqrt(2 * log(2)) * $this->float_sigma; if ($this->int_precision) {
php
{ "resource": "" }
q250659
NormalDistribution.f
validation
public function f($x) { if (!is_numeric($x)) { throw new \InvalidArgumentException('x variable must be numeric value.'); } $float_fx = exp(-0.5 * pow(($x - $this->float_mu) / $this->float_sigma, 2)) / ($this->float_sigma * sqrt(2 * pi()));
php
{ "resource": "" }
q250660
NormalDistribution.samples
validation
public function samples($amount) { if (!is_numeric($amount) || $amount < 1) { throw new \InvalidArgumentException('Amount of samples must be greater or equal to one'); } $arr = array(); for ($i = 1; $i <= $amount; $i++) { $r
php
{ "resource": "" }
q250661
FontIconField.search
validation
public function search(HTTPRequest $request) { // Detect Ajax: if (!$request->isAjax()) { return; } // Initialise: $data = []; // Filter Icons: if ($term = $request->getVar('term')) { ...
php
{ "resource": "" }
q250662
Stream.getContents
validation
public function getContents() { if (is_null($this->stream) || ! $this->isReadable()) { $message = 'Could not get contents of stream';
php
{ "resource": "" }
q250663
Stream.getMetadata
validation
public function getMetadata($key = null) { isset($this->stream) && $this->meta = stream_get_meta_data($this->stream);
php
{ "resource": "" }
q250664
Stream.getSize
validation
public function getSize() { if (is_null($this->size) === true) { $stats = fstat($this->stream);
php
{ "resource": "" }
q250665
Stream.write
validation
public function write($string) { if (! $this->isWritable()) { $message = 'Stream is not writable'; throw new \RuntimeException($message);
php
{ "resource": "" }
q250666
Stats.f
validation
public function f() { if(is_null($this->arr_f)){ $arr = $this->frequency(); array_walk( $arr, function(&$v, $k, $n){ $v = $v / $n; },
php
{ "resource": "" }
q250667
TerminalNotifierBuilder.build
validation
public function build($options) { $command = $this->path; if (isset($options['title'])) { $command .= " -title {$options['title']}"; } if (isset($options['subtitle'])) { $command .= " -subtitle {$options['subtitle']}"; } if (isset($options['me...
php
{ "resource": "" }
q250668
TwigRenderer.render
validation
public function render($template, array $data = array(), $extension = 'twig') { $file = $template . '.'
php
{ "resource": "" }
q250669
FontIconExtension.updateCMSFields
validation
public function updateCMSFields(FieldList $fields) { // Insert Icon Tab: $fields->insertAfter( Tab::create( 'Icon', $this->owner->fieldLabel('Icon') ), 'Main' ); // Create Icon Fields: ...
php
{ "resource": "" }
q250670
FontIconExtension.getFontIconClassNames
validation
public function getFontIconClassNames() { $classes = []; if ($this->owner->FontIcon) { if ($this->owner->FontIconListItem) { $classes[] = $this->backend->getClassName('list-item');
php
{ "resource": "" }
q250671
FontIconExtension.getFontIconTag
validation
public function getFontIconTag() { if ($this->owner->hasFontIcon()) { return $this->backend->getTag( $this->owner->FontIconClass,
php
{ "resource": "" }
q250672
FastRouteRouter.routes
validation
public function routes() { $routes = array_merge($this->routes, $this->collector->getData()); return function (RouteCollector $collector) use ($routes) { foreach (array_filter($routes) as $route) {
php
{ "resource": "" }
q250673
RandomComplex.random
validation
protected static function random($float_min, $float_max) { if ($float_max >= 0) { $r = new Random(); while (true) { $float_prov = $float_max * $r->get(); if ($float_prov >= $float_min) { return $float_prov; } ...
php
{ "resource": "" }
q250674
RandomComplex.checkOrder
validation
protected static function checkOrder($float_min, $float_max) { if (!is_numeric($float_min) && !is_numeric($float_max)) { throw new \InvalidArgumentException('Min and max values must be valid numbers.'); }
php
{ "resource": "" }
q250675
RandomComplex.rho
validation
public function rho($float_min, $float_max) { self::checkOrder($float_min, $float_max); if ($float_min < 0 || $float_max < 0) { throw new \InvalidArgumentException('Rho value must be a positive number!'); } if ($this->r || $this->i) {
php
{ "resource": "" }
q250676
RandomComplex.theta
validation
public function theta($float_min, $float_max) { self::checkOrder($float_min, $float_max); if ($this->r || $this->i) { throw new \RuntimeException('You cannot set
php
{ "resource": "" }
q250677
RandomComplex.get
validation
public function get() { if ($this->r || $this->i) { if (!is_object($this->i)) { return new Complex( self::random($this->r->min, $this->r->max), 0 ); } if (!is_object($this->r)) { retu...
php
{ "resource": "" }
q250678
RandomComplex.getMany
validation
public function getMany($n) { if (!is_integer($n) || $n < 2) { throw new \InvalidArgumentException('You must take 2 or more items in this case.'); } $arr_out = array();
php
{ "resource": "" }
q250679
RandomComplex.reset
validation
public function reset() { $this->rho = null; $this->theta =
php
{ "resource": "" }
q250680
Container.alias
validation
public function alias($id, $original) {
php
{ "resource": "" }
q250681
Container.value
validation
protected function value($name) { $object = isset($this->instances[$name]) ? $this->get($name) : null; $exists = ! $object && $this->extra->has($name) ===
php
{ "resource": "" }
q250682
Random.get
validation
public function get() { if ($this->range->as_integer) { return mt_rand($this->range->min, $this->range->max); } else {
php
{ "resource": "" }
q250683
Random.getManyWithoutReplacement
validation
public function getManyWithoutReplacement($n) { if (!is_integer($n) || $n < 2) { throw new \InvalidArgumentException('You must take 2 or more items in this case.'); } if ($this->range->as_integer) { $arr_range = range($this->range->min, $this->range->max); ...
php
{ "resource": "" }
q250684
JetPackTrait.setPackOptions
validation
public function setPackOptions(Container $app) { foreach ($this->packOptions as $key => &$value) { $key = $this->_ns($key);
php
{ "resource": "" }
q250685
JetPackTrait.getName
validation
public function getName() { static $names = []; $me = get_class($this); if (empty($names[$me])) { $names[$me] = $this->getReflector()->getShortName(); $suffix = defined('static::PACK_SUFFIX') ? static::PACK_SUFFIX : 'Pack';
php
{ "resource": "" }
q250686
JetPackTrait.getEntityMappings
validation
public function getEntityMappings(Container $app) { static $mappings = []; $me = get_class($this); if (empty($mappings[$me])) { $subns = $this->packOptions['entity_subnamespace']; $subns = trim($subns, '\\'); $simple = $this->packOptions['entity_use_simple...
php
{ "resource": "" }
q250687
JetPackTrait.getConfigsPath
validation
public function getConfigsPath(Container $app) { static $paths = []; $me = get_class($this); if (empty($paths[$me])) { $subpath = $this->packOptions['configs_subpath'];
php
{ "resource": "" }
q250688
JetPackTrait.getSymlinks
validation
public function getSymlinks(Container $app) { $symlinks = []; if ($this->getPublicPath($app)) {
php
{ "resource": "" }
q250689
JetPackTrait.getPackPath
validation
public function getPackPath(Container $app) { static $paths = []; $me = get_class($this); if (empty($paths[$me])) {
php
{ "resource": "" }
q250690
AbstractDispatcher.allowed
validation
protected function allowed($method) { if (in_array($method, $this->allowed) === false) {
php
{ "resource": "" }
q250691
Rule.pathExtract
validation
protected function pathExtract(): array { $regExp = []; $path = $this->path; if (\is_array($this->path)) { $regExp = \array_pop($this->path);
php
{ "resource": "" }
q250692
Dlstats.logDLStatDetails
validation
protected function logDLStatDetails() { //Host / Page ID ermitteln $pageId = $GLOBALS['objPage']->id; // ID der grad aufgerufenden Seite. $pageHost = \Environment::get('host'); // Host der grad aufgerufenden Seite. if (isset($GLOBALS['TL_CONFIG']['dlstatdets']) && (bool) $GLOBALS...
php
{ "resource": "" }
q250693
SearchAbstract.query
validation
public function query($index, array $filters = null, array $queries = null, array $fieldWeights = null, $limit = 20, $offset = 0 ) { $sphinxClient = $this->getSphinxClient(); $sphinxClient->SetLimits($offset, $limit); if (null !== $filters) { foreach ($filters as ...
php
{ "resource": "" }
q250694
SearchAbstract.getCollection
validation
public function getCollection($index, array $filters = null, array $queries = null, array $fieldWeights = null, $limit = 20, $offset = 0, $countableAttributes = null ) { $result = $this->query($index, $filters, $queries, $fieldWeights, $limit, $offset); if (is_array($res...
php
{ "resource": "" }
q250695
Parser.doParse
validation
protected function doParse(StringReader $string) { $val = null; // May be : or ; as a terminator, depending on what the data // type is. $type = substr($string->read(2), 0, 1); switch ($type) { case 'a': // Associative array: a:length:{[index][v...
php
{ "resource": "" }
q250696
QueryAbstract.getQueries
validation
public function getQueries() { $array = []; foreach ($this->getKeywords() as $keyword) { $value = $keyword->getData();
php
{ "resource": "" }
q250697
QueryAbstract.getOffSet
validation
public function getOffSet() { if ($this->getPaginator()) { return $this->getPaginator()->getOffset(); } else { $offset = $this->get('offset');
php
{ "resource": "" }
q250698
QueryAbstract.addCountableAttribute
validation
public function addCountableAttribute($attribute) { if (empty($attribute)) { return false; } if (in_array($attribute, $this->getCountableAttributes(), true)) {
php
{ "resource": "" }
q250699
RouteServiceProvider.mapAdminRoutes
validation
private function mapAdminRoutes() { $this->adminGroup(function () { $this->name('foundation.')->group(function () {
php
{ "resource": "" }