_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q250800
HandlerResolver.resolve
validation
public function resolve($handler) { if (!is_string($handler)) { return $handler; } $handler = $this->container->resolve($handler); if (!is_callable($handler) && !$handler instanceof ErrorHandlerInterface) {
php
{ "resource": "" }
q250801
Modal.renderCloseButton
validation
protected function renderCloseButton() { if (($closeButton = $this->closeButton) !== false) { $tag = ArrayHelper::remove($closeButton, 'tag', 'button'); $label = ArrayHelper::remove($closeButton, 'label', 'Close'); if ($tag === 'button' && !isset($closeButton['type'])) { ...
php
{ "resource": "" }
q250802
ErrorHandlerManager.makeResponse
validation
protected function makeResponse($response, Exception $exception) { if (!$response instanceof Response) { $response = new Response($response); } if (!$response->isClientError() && !$response->isServerError() &&
php
{ "resource": "" }
q250803
ErrorHandlerManager.matchesTypehint
validation
protected function matchesTypehint($handler, Exception $exception) { if ($handler instanceof ErrorHandlerInterface) { return true; } if (is_array($handler)) { $reflection = (new ReflectionMethod($handler[0], $handler[1])); } else { $reflection = (new ReflectionFunction($handler)); } $params = $r...
php
{ "resource": "" }
q250804
ErrorHandlerManager.callHandler
validation
protected function callHandler($handler, Exception $exception) { if ($handler instanceof ErrorHandlerInterface) {
php
{ "resource": "" }
q250805
ErrorHandlerManager.makeFatalErrorException
validation
protected function makeFatalErrorException() { $error = error_get_last(); if ($error !== null) { return new FatalErrorException($error['message'],
php
{ "resource": "" }
q250806
Route.addBeforeHook
validation
public function addBeforeHook($hook) { if (!isset($this->options['before'])) {
php
{ "resource": "" }
q250807
Route.addAfterHook
validation
public function addAfterHook($hook) { if (!isset($this->options['after'])) {
php
{ "resource": "" }
q250808
Application.config
validation
public function config($configurator) { if ($this->booted) { $this->invokeConfigurator($configurator); } else
php
{ "resource": "" }
q250809
Application.invokeConfigurator
validation
protected function invokeConfigurator($configurator) { if (is_callable($configurator)) { call_user_func($configurator, $this); return; } if (is_string($configurator)) {
php
{ "resource": "" }
q250810
Application.setContainer
validation
public function setContainer(ContainerInterface $container) { $this->container = $container; $container->instance('Autarky\Application', $this);
php
{ "resource": "" }
q250811
Application.addMiddleware
validation
public function addMiddleware($middleware, $priority = null) {
php
{ "resource": "" }
q250812
Application.bootConsole
validation
public function bootConsole() { $this->console = new ConsoleApplication('Autarky', static::VERSION);
php
{ "resource": "" }
q250813
Application.boot
validation
public function boot() { if ($this->booted) return; $this->booting = true; $this->registerProviders(); foreach ($this->configurators as $configurator) {
php
{ "resource": "" }
q250814
Application.registerProviders
validation
protected function registerProviders() { $dependants = []; foreach ($this->providers as $provider) { if (is_string($provider)) { $provider = new $provider(); } $this->registerProvider($provider); if ($provider instanceof DependantProviderInterface) {
php
{ "resource": "" }
q250815
Application.registerProvider
validation
protected function registerProvider(ProviderInterface $provider) { if ($provider instanceof AbstractProvider) { $provider->setApplication($this); } $provider->register();
php
{ "resource": "" }
q250816
Application.resolveStack
validation
protected function resolveStack() { if ($this->stack !== null) { return $this->stack; } $this->stack = new StackBuilder; foreach ($this->middlewares as $middleware)
php
{ "resource": "" }
q250817
Application.resolveKernel
validation
protected function resolveKernel() { if ($this->kernel !== null) { return $this->kernel; } $class = 'Symfony\Component\EventDispatcher\EventDispatcherInterface'; $eventDispatcher = $this->container->isBound($class) ? $this->container->resolve($class) : null; $kernel = new Kernel(
php
{ "resource": "" }
q250818
BaseWidgetTrait.registerMaterializePlugin
validation
protected function registerMaterializePlugin($name) { $view = $this->getView(); if ($this->materializeAsset) { MaterializeAsset::register($view); } if ($this->customAsset) { MaterializeCustomAsset::register($view); } $id = $this->options['id']...
php
{ "resource": "" }
q250819
BaseWidgetTrait.registerPlugin
validation
protected function registerPlugin($name) { $view = $this->getView(); if ($this->materializeAsset) { MaterializeAsset::register($view); } if ($this->customAsset) { MaterializeCustomAsset::register($view); } $id = $this->options['id']; ...
php
{ "resource": "" }
q250820
ChannelManager.setChannel
validation
public function setChannel($channel, LoggerInterface $logger) { if (isset($this->channels[$channel]))
php
{ "resource": "" }
q250821
ChannelManager.setDeferredChannel
validation
public function setDeferredChannel($channel, callable $callback) { if (isset($this->channels[$channel])) { throw new InvalidArgumentException("Channel $channel is
php
{ "resource": "" }
q250822
ChannelManager.getChannel
validation
public function getChannel($channel = null) { $channel = $channel ?: $this->defaultChannel; if (isset($this->deferredChannels[$channel])) { $this->setChannel($channel, $this->deferredChannels[$channel]()); unset($this->deferredChannels[$channel]); }
php
{ "resource": "" }
q250823
Moo_EditableFieldNumeric.getFieldValidationOptions
validation
public function getFieldValidationOptions() { $min = ($this->getSetting('MinValue')) ? $this->getSetting('MinValue') : ''; $max = ($this->getSetting('MaxValue')) ? $this->getSetting('MaxValue') : ''; return [
php
{ "resource": "" }
q250824
Router.addCachedRoute
validation
public function addCachedRoute(Route $route) { $this->routes->attach($route); if ($name
php
{ "resource": "" }
q250825
Router.getRouteForRequest
validation
public function getRouteForRequest(Request $request) { $method = $request->getMethod(); $path = $request->getPathInfo() ?: '/'; $result = $this->getDispatcher() ->dispatch($method, $path); if ($result[0] == \FastRoute\Dispatcher::NOT_FOUND) { throw new NotFoundHttpException("No route match for path $pa...
php
{ "resource": "" }
q250826
ExternalURL.Nice
validation
public function Nice() { if ($this->value && $parts = parse_url($this->URL())) { $remove = array('scheme', 'user', 'pass', 'port', 'query', 'fragment'); foreach ($remove as $part) {
php
{ "resource": "" }
q250827
ExternalURL.scaffoldFormField
validation
public function scaffoldFormField($title = null, $params = null) { $field = new ExternalURLField($this->name, $title);
php
{ "resource": "" }
q250828
Xml.getAttribute
validation
protected function getAttribute(SimpleXmlElement $node, $name)
php
{ "resource": "" }
q250829
Xml.isAttributeSet
validation
protected function isAttributeSet(SimpleXmlElement $node, $name)
php
{ "resource": "" }
q250830
ActiveField.dropDownListDefault
validation
public function dropDownListDefault($items, $options = []) {
php
{ "resource": "" }
q250831
ActiveField.radioWithGap
validation
public function radioWithGap($options = [], $enclosedByLabel = true) {
php
{ "resource": "" }
q250832
ActiveField.radioListWithGap
validation
public function radioListWithGap($items, $options = []) { $this->addListInputCssClass($options,
php
{ "resource": "" }
q250833
ActiveField.checkboxFilled
validation
public function checkboxFilled($options = [], $enclosedByLabel = true) { Html::addCssClass($options, $this->checkboxFilledCssClass);
php
{ "resource": "" }
q250834
ActiveField.checkboxListFilled
validation
public function checkboxListFilled($items, $options = []) { $this->addListInputCssClass($options,
php
{ "resource": "" }
q250835
SessionProvider.makeSessionHandler
validation
public function makeSessionHandler() { $handler = $this->dic->resolve('Autarky\Http\SessionHandlerFactory') ->makeHandler($this->config->get('session.handler')); if
php
{ "resource": "" }
q250836
SessionProvider.makeSessionStorage
validation
public function makeSessionStorage() { $storage = $this->config->get('session.storage'); if ($storage == 'mock_array') { return new MockArraySessionStorage; } if ($storage == 'mock_file') { return new MockFileSessionStorage; } $handler = $this->dic->resolve('SessionHandlerInterface');
php
{ "resource": "" }
q250837
SessionProvider.makeSession
validation
public function makeSession() { $session = new Session( $this->dic->resolve('Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface'), $this->dic->resolve('Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface'),
php
{ "resource": "" }
q250838
ControllerTrait.flashMessages
validation
protected function flashMessages($messages) { $flashBag = $this->getSession() ->getFlashBag(); foreach ((array)
php
{ "resource": "" }
q250839
ControllerTrait.flashInput
validation
protected function flashInput(Request $request = null) { if ($request === null) { $request = $this->container ->resolve('Symfony\Component\HttpFoundation\RequestStack')
php
{ "resource": "" }
q250840
ControllerTrait.redirect
validation
protected function redirect($name, array $params = array(), $statusCode
php
{ "resource": "" }
q250841
Vector.length
validation
public function length() { $sumOfSquares = 0; foreach ($this->components() as
php
{ "resource": "" }
q250842
Vector.add
validation
public function add(self $b) { $this->_checkVectorSpace($b); $bComponents = $b->components();
php
{ "resource": "" }
q250843
Vector.dotProduct
validation
public function dotProduct(self $b) { $this->_checkVectorSpace($b); $bComponents = $b->components();
php
{ "resource": "" }
q250844
Vector.crossProduct
validation
public function crossProduct(self $b) { $this->_checkVectorSpace($b); if ($this->dimension() !== 3) { throw new Exception('Both vectors must be 3-dimensional'); } $tc = $this->components(); $bc = $b->components(); list($k0, $k1, $k2) = array_keys($tc); ...
php
{ "resource": "" }
q250845
Vector.scalarTripleProduct
validation
public function scalarTripleProduct(self $b, self $c)
php
{ "resource": "" }
q250846
Vector.vectorTripleProduct
validation
public function vectorTripleProduct(self $b, self $c)
php
{ "resource": "" }
q250847
Vector.multiplyByScalar
validation
public function multiplyByScalar($scalar) { $result = []; foreach ($this->components() as $i => $component) { $result[$i]
php
{ "resource": "" }
q250848
Vector.projectOnto
validation
public function projectOnto(self $b) { $bUnit = $b->normalize(); return
php
{ "resource": "" }
q250849
Vector.angleBetween
validation
public function angleBetween(self $b) { $denominator = $this->length() * $b->length(); if ($denominator == 0) { throw
php
{ "resource": "" }
q250850
Vector._checkVectorSpace
validation
protected function _checkVectorSpace(self $b) { if (!$this->isSameDimension($b)) { throw new Exception('The vectors must be of the same dimension'); }
php
{ "resource": "" }
q250851
UrlGenerator.getRouteUrl
validation
public function getRouteUrl($name, array $params = array(), $relative = false) { $route = $this->router->getRoute($name); $routeParams = []; $query = []; foreach ($params as $key => $value) { if (is_int($key)) { $routeParams[] = $value; } else { $query[$key] = $value; } } $path = $this->...
php
{ "resource": "" }
q250852
UrlGenerator.getAssetUrl
validation
public function getAssetUrl($path, $relative = false) { if (substr($path, 0, 1) !== '/') { $path = '/'.$path; } if ($this->assetRoot !== null) { $base = $this->assetRoot; } else if ($relative) {
php
{ "resource": "" }
q250853
UrlGenerator.getRootUrl
validation
public function getRootUrl() { $request = $this->requests->getCurrentRequest(); $host = $request->getHttpHost(); $base =
php
{ "resource": "" }
q250854
GuzzleServiceProvider.register
validation
public function register(Container $app) { $app['guzzle.handler_stack'] = function () { $stack = HandlerStack::create(); return $stack; }; $app['guzzle'] = function () use ($app) {
php
{ "resource": "" }
q250855
ApiKeyAuthenticationProvider.authenticate
validation
public function authenticate(TokenInterface $token) { $user = $this->userProvider->loadUserByApiKey($this->encoder->encodePassword($token->getCredentials())); if (!$user || !($user instanceof UserInterface)) { throw new AuthenticationException('Bad credentials'); }
php
{ "resource": "" }
q250856
AgnosticReader.addManagerRegistry
validation
public function addManagerRegistry(ManagerRegistry $registry) { if (!in_array($registry,
php
{ "resource": "" }
q250857
Application.registerCommands
validation
public function registerCommands(array $commands, callable $handler) { foreach ($commands as $command) { $handler_id = "app.handler." . join('',
php
{ "resource": "" }
q250858
Application.registerSubscriber
validation
public function registerSubscriber($class, callable $callback) { $service_id = "event." . strtolower(str_replace("\\", ".", $class));
php
{ "resource": "" }
q250859
Application.registerStackMiddleware
validation
public function registerStackMiddleware($class) { if (func_num_args() === 0) { throw new \InvalidArgumentException("Missing argument(s) when calling registerStackMiddlerware"); } if (! class_exists($class) && ! is_callable($class)) {
php
{ "resource": "" }
q250860
Recaptcha.checkAnswer
validation
public function checkAnswer($extraParams = array()) { $remoteIp = $_SERVER["REMOTE_ADDR"]; $challenge = $_POST["recaptcha_challenge_field"]; $response = $_POST["recaptcha_response_field"]; if ( ! $this->getPrivateKey()) { throw new \Exception("To use reCAPTCHA you mu...
php
{ "resource": "" }
q250861
Recaptcha.httpPost
validation
protected function httpPost($host, $path, array $data, $port = 80) { $req = $this->qsencode($data); $http_request = "POST {$path} HTTP/1.0\r\n"; $http_request .= "Host: {$host}\r\n"; $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; $http_request .= "Cont...
php
{ "resource": "" }
q250862
Recaptcha.qsencode
validation
protected function qsencode(array $data = array()) { $req = ''; if ($data) { foreach ($data as $key => $value) { $req .= $key . '=' . urlencode(stripslashes($value)) . '&';
php
{ "resource": "" }
q250863
ConnectionManager.getPdo
validation
public function getPdo($connection = null) { if ($connection === null) { $connection = $this->defaultConnection; } if (isset($this->instances[$connection])) { return $this->instances[$connection]; }
php
{ "resource": "" }
q250864
ConnectionManager.getConnectionConfig
validation
public function getConnectionConfig($connection = null) { if ($connection === null) { $connection = $this->defaultConnection; } $config = $this->config->get("database.connections.$connection"); if (!$config) { if (!is_string($connection)) { $connection =
php
{ "resource": "" }
q250865
SessionHandlerFactory.makeHandler
validation
public function makeHandler($ident) { if (!isset($this->factories[$ident])) {
php
{ "resource": "" }
q250866
AbstractSuperHeroApi.getById
validation
public function getById($characterId) { try { $result = $this->client->get($this->slug . '/' . $characterId); } catch (RequestException $e) { $return['request'] = $e->getRequest() . "\n"; if ($e->hasResponse()) {
php
{ "resource": "" }
q250867
AbstractSuperHeroApi.getAll
validation
public function getAll(array $filterAttributes = []) { $filters = ['query' => [$filterAttributes]]; try { $result = $this->client->get($this->slug, $filters); } catch (RequestException $e) { $return['request'] = $e->getRequest() . "\n";
php
{ "resource": "" }
q250868
AbstractRouter.matchParams
validation
protected function matchParams(Route $route, array $params) : bool { $matchers = $route->getMatchers(); foreach ($params as $name => $value) { if (!isset($matchers[$name])) { continue; } $valueMatchers = $matchers[$name]; foreach ($va...
php
{ "resource": "" }
q250869
AbstractRouter.validateParams
validation
protected function validateParams(Route $route, array $params, array $requiredParams) { $identifier = $this->getRouteIdentifier($route); $givenParams = array_keys($params); $missingParams = array_diff($requiredParams, $givenParams); if (count($missingParams) > 0) { thro...
php
{ "resource": "" }
q250870
AbstractRouter.getRouteIdentifier
validation
protected function getRouteIdentifier(Route $route) : string {
php
{ "resource": "" }
q250871
Ftp.verifyAndMoveUploadedFile
validation
public function verifyAndMoveUploadedFile( $originSize, $tmpDestination, $publicDestination ) { $remoteTempSize = $this->getSize($tmpDestination); $this->logger->debug('Temp size: ' . $remoteTempSize); $this->logger->debug('Origin size: ' . $originSize); if ($...
php
{ "resource": "" }
q250872
Moo_EditableField.setSetting
validation
public function setSetting($key, $value) { $settings = $this->getSettings();
php
{ "resource": "" }
q250873
Moo_EditableField.getSetting
validation
public function getSetting($setting) { $settings = $this->getSettings(); if (isset($settings) && count($settings) > 0) { if
php
{ "resource": "" }
q250874
Moo_EditableField.onBeforeWrite
validation
public function onBeforeWrite() { $return = parent::onBeforeWrite(); // Field name must be unique $exists = self::get()->filter('Name', $this->Name)->exclude('ID', $this->ID); if ($exists->count()) { throw new ValidationException( _t('Moo_EditableField.UN...
php
{ "resource": "" }
q250875
Moo_EditableField.getFormField
validation
public function getFormField() { if (null === $this->field) {
php
{ "resource": "" }
q250876
LockingFilesystem.read
validation
public function read($path, $blocking = false) { $size = filesize($path); if ($size === 0) { return ''; } $flockFlags = $blocking ? LOCK_SH : LOCK_SH | LOCK_NB; $file = fopen($path, 'r'); if (!flock($file, $flockFlags)) { fclose($file); throw
php
{ "resource": "" }
q250877
LockingFilesystem.write
validation
public function write($path, $contents, $blocking = false) { $flockFlags = $blocking ? LOCK_EX : LOCK_EX | LOCK_NB; $file = fopen($path, 'c'); if (!flock($file, $flockFlags)) { fclose($file); throw new IOException("Could not aquire file lock for file:
php
{ "resource": "" }
q250878
ApiKeyAuthenticationListener.handle
validation
public function handle(GetResponseEvent $event) { $apiKey = $this->getApiKeyFromQueryOrHeader($event->getRequest()); if (false === $apiKey) { return; } try { $token = $this->authenticationManager->authenticate(new ApiKeyToken($apiKey)); $this->to...
php
{ "resource": "" }
q250879
ExternalURLField.getAttributes
validation
public function getAttributes() { $attributes = array( 'placeholder' => $this->config['defaultparts']['scheme'] . "://example.com" //example url ); if ($this->config['html5validation']) { $attributes += array( 'type' => 'url', //html5
php
{ "resource": "" }
q250880
ExternalURLField.setValue
validation
public function setValue($url) { if ($url) {
php
{ "resource": "" }
q250881
ExternalURLField.rebuildURL
validation
protected function rebuildURL($url) { $defaults = $this->config['defaultparts']; if (!preg_match('#^[a-zA-Z]+://#', $url)) { $url = $defaults['scheme'] . "://" . $url; } $parts = parse_url($url); if (!$parts) { //can't parse url, abort retu...
php
{ "resource": "" }
q250882
ExternalURLField.validate
validation
public function validate($validator) { $this->value = trim($this->value); $regex = $this->config['validregex']; if ($this->value && $regex && !preg_match($regex, $this->value)) { $validator->validationError( $this->name,
php
{ "resource": "" }
q250883
PathResolver.resolve
validation
public function resolve($path) { $paths = []; foreach ($this->paths as $configuredPath) { $paths[] = $configuredPath.'/'.$path; } $parts = explode('/', $path); // this doesn't change behaviour but will save some performance if (count($parts) == 1) { return $paths; } $current = ''; $mountPat...
php
{ "resource": "" }
q250884
DriverFactory.getDriver
validation
public static function getDriver(MappingDriver $originalDriver, $namespace) { /*if (\Doctrine\Common\Version::compare('2.3.0') > -1) { throw new \Exception('The DMR library requires Doctrine 2.3.0 or higher.'); }*/ if ($originalDriver instanceof MappingDriverChain) { ...
php
{ "resource": "" }
q250885
Psr7Router.mapParams
validation
protected function mapParams(array $params) : array { unset($params[0]); foreach ($params as $name => $value) { if (!is_string($name)) { unset($params[$name]);
php
{ "resource": "" }
q250886
ConnectionFactory.makePdo
validation
public function makePdo(array $config, $connection = null) { if (!isset($config['driver']) && !isset($config['dsn'])) { throw new InvalidArgumentException('DSN or driver must be set'); } $options = isset($config['pdo_options']) ? $config['pdo_options'] : []; unset($config['pdo_options']); $options = arra...
php
{ "resource": "" }
q250887
RouteBuilder.build
validation
public function build() : Route { return new $this->routeClass($this->methods,
php
{ "resource": "" }
q250888
RouteBuilder.whateverMatches
validation
public function whateverMatches(string $param) : RouteBuilder { if (array_key_exists($param, $this->matchers)) {
php
{ "resource": "" }
q250889
ConstantSetMatcher.getConstantValues
validation
protected function getConstantValues(string $classIdentifier, string $regex) : array { $reflectionClass = new \ReflectionClass($classIdentifier); $constants =
php
{ "resource": "" }
q250890
File.getMapping
validation
public function getMapping($className) { // Try loading mapping from original driver first $mapping = null; if (null != $this->originalDriver) { if ($this->originalDriver instanceof FileDriver) {
php
{ "resource": "" }
q250891
Moo_EditableFieldMultipleOption.delete
validation
public function delete() { $options = $this->Options(); if ($options) {
php
{ "resource": "" }
q250892
Moo_EditableFieldMultipleOption.duplicate
validation
public function duplicate($doWrite = true) { $clonedNode = parent::duplicate($doWrite); if ($this->Options()) { foreach ($this->Options() as $field) { $newField = $field->duplicate();
php
{ "resource": "" }
q250893
Moo_EditableFieldMultipleOption.initFormField
validation
protected function initFormField() { $options = $this->Options()->map('EscapedTitle', 'Title');
php
{ "resource": "" }
q250894
LoaderFactory.addLoader
validation
public function addLoader($extensions, $loaderClass) { foreach ((array) $extensions as $extension) { $this->extensions[] = $extension; if (is_string($loaderClass)) { $this->loaderClasses[$extension] = $loaderClass; } elseif
php
{ "resource": "" }
q250895
LoaderFactory.getForPath
validation
public function getForPath($path) { $extension = $this->getExtension($path); if (!isset($this->loaders[$extension])) {
php
{ "resource": "" }
q250896
Configuration.override
validation
public function override($name, array $routeData) { if (!isset($this->routes[$name])) {
php
{ "resource": "" }
q250897
Configuration.merge
validation
public function merge(array $routes) { foreach ($routes as $name => $route) {
php
{ "resource": "" }
q250898
Configuration.mount
validation
public function mount($prefix = null) { if ($prefix) { $this->router->group(['prefix'
php
{ "resource": "" }
q250899
IOFactory.createWriter
validation
public static function createWriter(Spreadsheet $spreadsheet, $writerType) { if (!isset(self::$writers[$writerType])) { throw new Writer\Exception("No writer
php
{ "resource": "" }