_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q251600
ErrorHandler.formatBacktrace
validation
protected static function formatBacktrace(array $backtrace) : array { if (is_array($backtrace) === false || count($backtrace) === 0) { return $backtrace; } /** * Remove unnecessary info from backtrace */ if ($backtrace[0]['function'] == '{closure}') { ...
php
{ "resource": "" }
q251601
ErrorHandler.fatal
validation
public static function fatal() { $e = error_get_last(); if ($e !== null && (error_reporting() & $e['type']) !== 0) { ErrorHandler::exception(new \ErrorException($e['message'], $e['type'], 0, $e['file'], $e['line'])); exit(1); } }
php
{ "resource": "" }
q251602
ErrorHandler.writeLogs
validation
public static function writeLogs(string $message) : bool { return (bool) file_put_contents(rtrim(LOGS_PATH, '/') . '/' . gmdate('Y_m_d') . '.log', '[' . gmdate('d-M-Y H:i:s') . '] ' . $message . PHP_EOL, FILE_APPEND); }
php
{ "resource": "" }
q251603
ErrorHandler.exception
validation
public static function exception($exception) { try { // Empty output buffers while(ob_get_level() > 0) ob_end_clean(); // Get exception info $error['code'] = $exception->getCode(); $error['message'] = $exception->getMessage(); $err...
php
{ "resource": "" }
q251604
NodeList.__isset
validation
public function __isset( $childName ) { // Iterate over all nodes and check if a child with the requested name // exists. foreach ( $this->nodes as $node ) { if ( isset( $node->$childName ) ) { // We found something, so that we can immediatly e...
php
{ "resource": "" }
q251605
NodeList.offsetSet
validation
public function offsetSet( $item, $node ) { // We only allow to append nodes to node list, so that we bail out on // all other array keys then null. if ( $item !== null ) { throw new ValueException( $item, 'null' ); } return $this->nodes[] = $node; }
php
{ "resource": "" }
q251606
AuthController.login
validation
public function login(LoginRequest $request) { $this->bus->pipeThrough($this->pipesOf('login'))->dispatchFrom(LoginJob::class, $request); return redirect()->route(config('_auth.login.redirect')); }
php
{ "resource": "" }
q251607
AuthController.logout
validation
public function logout() { $this->bus->pipeThrough($this->pipesOf('logout'))->dispatchNow(new LogoutJob); return redirect()->route(config('_auth.logout.redirect')); }
php
{ "resource": "" }
q251608
AuthController.register
validation
public function register(RegisterRequest $request) { $this->bus->pipeThrough($this->pipesOf('register'))->dispatchFrom(RegisterJob::class, $request); return redirect()->route(config('_auth.register.redirect'))->withSuccess(trans('auth::register.success')); }
php
{ "resource": "" }
q251609
AuthController.recover
validation
public function recover(RecoverRequest $request) { $this->bus->pipeThrough($this->pipesOf('recover'))->dispatchFrom(RecoverJob::class, $request); return back()->withSuccess(trans('auth::recover.success')); }
php
{ "resource": "" }
q251610
AuthController.reset
validation
public function reset(ResetRequest $request, $token) { $this->bus->pipeThrough($this->pipesOf('reset'))->dispatchFrom(ResetJob::class, $request, compact('token')); return redirect()->route('login.index')->withSuccess(trans('auth::reset.success')); }
php
{ "resource": "" }
q251611
WP_Register.add
validation
public static function add( $type, $data = [] ) { $is_admin = is_admin(); if ( self::validate( $type, $data, $is_admin ) ) { $hook = $is_admin ? 'admin_enqueue_scripts' : 'wp_enqueue_scripts'; $method = __CLASS__ . "::add_{$type}s"; if ( has_action( $hook, $method ) === false ) { add_action( $hook...
php
{ "resource": "" }
q251612
WP_Register.add_scripts
validation
public static function add_scripts() { self::look_if_process_files( 'script' ); foreach ( self::$data['script'] as $data ) { $params = [ 'plugin_url' => defined( 'WP_PLUGIN_URL' ) ? WP_PLUGIN_URL . '/' : '', 'nonce' => wp_create_nonce( $data['name'] ), ]; $data['params'] = array_merge( $da...
php
{ "resource": "" }
q251613
WP_Register.add_styles
validation
public static function add_styles() { self::look_if_process_files( 'style' ); foreach ( self::$data['style'] as $data ) { wp_register_style( $data['name'], $data['url'], $data['deps'], $data['version'], $data['media'] ); wp_enqueue_style( $data['name'] ); } }
php
{ "resource": "" }
q251614
WP_Register.unify
validation
public static function unify( $id, $params, $minify = '' ) { self::$id = $id; self::$unify = $params; self::$minify = $minify; return true; }
php
{ "resource": "" }
q251615
WP_Register.remove
validation
public static function remove( $type, $name ) { if ( isset( self::$data[ $type ][ $name ] ) ) { unset( self::$data[ $type ][ $name ] ); } return true; }
php
{ "resource": "" }
q251616
WP_Register.validate
validation
protected static function validate( $type, $data, $admin ) { $place = ( isset( $data['place'] ) ) ? $data['place'] : 'front'; $place = $admin && 'admin' == $place || ! $admin && 'front' == $place; if ( ! $place || self::set_params( $type, $data ) === false ) { return false; } return true; }
php
{ "resource": "" }
q251617
WP_Register.look_if_process_files
validation
protected static function look_if_process_files( $type ) { if ( is_string( self::$unify ) || isset( self::$unify[ "{$type}s" ] ) ) { return self::unify_files( self::prepare_files( $type ) ); } }
php
{ "resource": "" }
q251618
WP_Register.prepare_files
validation
protected static function prepare_files( $type ) { $params['type'] = $type; $params['routes'] = self::get_routes_to_folder( $type ); self::get_processed_files(); foreach ( self::$data[ $type ] as $id => $file ) { $path = self::get_path_from_url( $file['url'] ); $params['files'][ $id ] = basename( $...
php
{ "resource": "" }
q251619
WP_Register.get_routes_to_folder
validation
protected static function get_routes_to_folder( $type ) { $url = isset( self::$unify[ "{$type}s" ] ) ? self::$unify[ "{$type}s" ] : self::$unify; return [ 'url' => $url, 'path' => self::get_path_from_url( $url ), ]; }
php
{ "resource": "" }
q251620
WP_Register.is_modified_file
validation
protected static function is_modified_file( $filepath ) { $actual = filemtime( $filepath ); $last = isset( self::$files[ $filepath ] ) ? self::$files[ $filepath ] : 0; if ( $actual !== $last ) { self::$files[ $filepath ] = $actual; self::$changes = true; return self::$changes; } return false; ...
php
{ "resource": "" }
q251621
WP_Register.is_modified_hash
validation
protected static function is_modified_hash( $url, $path ) { if ( self::is_external_url( $url ) ) { if ( sha1_file( $url ) !== sha1_file( $path ) ) { self::$changes = true; return self::$changes; } } return false; }
php
{ "resource": "" }
q251622
WP_Register.unify_files
validation
protected static function unify_files( $params, $data = '' ) { $type = $params['type']; $routes = $params['routes']; $extension = ( 'style' == $type ) ? '.css' : '.js'; $hash = sha1( implode( '', $params['files'] ) ); $min_file = $routes['path'] . $hash . $extension; if ( ! is_file( $min_fil...
php
{ "resource": "" }
q251623
WP_Register.save_external_file
validation
protected static function save_external_file( $url, $path ) { $data = file_get_contents( $url ); return ( $data && self::save_file( $path, $data ) ) ? $data : ''; }
php
{ "resource": "" }
q251624
WP_Register.compress_files
validation
protected static function compress_files( $content ) { $var = array( "\r\n", "\r", "\n", "\t", ' ', ' ', ' ' ); $content = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $content ); $content = str_replace( $var, '', $content ); $content = str_replace( '{ ', '{', $content ); $content = str_replac...
php
{ "resource": "" }
q251625
WP_Register.set_new_params
validation
protected static function set_new_params( $type, $hash, $url, $extension ) { $data = [ 'name' => self::$id, 'url' => $url . $hash . $extension, 'deps' => self::unify_params( $type, 'deps' ), 'version' => self::unify_params( $type, 'version', '1.0.0' ), ]; switch ( $type ) { case 'style...
php
{ "resource": "" }
q251626
WP_Register.unify_params
validation
protected static function unify_params( $type, $field, $default = '' ) { $data = array_column( self::$data[ $type ], $field ); switch ( $field ) { case 'media': case 'footer': case 'version': foreach ( $data as $key => $value ) { if ( $data[0] !== $value ) { return $default; } } ...
php
{ "resource": "" }
q251627
OriginalInitCommand.createInitializer
validation
protected function createInitializer() { $initializer = new Initializer(); $initializer->addTemplate('Common', new CommonTemplate()); $initializer->addTemplate('Laravel', new LaravelTemplate()); $initializer->addTemplate('Symfony', new SymfonyTemplate()); $initializer->addTe...
php
{ "resource": "" }
q251628
Calgamo.newApp
validation
public function newApp() : ApplicationInterface { $app = new CalgamoApplication($this->filesystem); $app->requireModule(CalgamoLogExceptionHandlerModule::class); $app->requireModule(CalgamoRouterModule::class); $app->requireModule(CalgamoDiModule::class); $app->requireModule(...
php
{ "resource": "" }
q251629
ValueTrait.handleTtl
validation
protected function handleTtl($key, $expireSetTs, $expireSec) { $ttl = $expireSetTs + $expireSec - time(); if ($ttl <= 0) { $this->getClient()->delete($key); throw new KeyNotFoundException(); } return $ttl; }
php
{ "resource": "" }
q251630
Document.loadFile
validation
public static function loadFile( $xmlFile ) { // Check if user exists at all if ( !is_file( $xmlFile ) || !is_readable( $xmlFile ) ) { throw new NoSuchFileException( $xmlFile ); } return self::parseXml( $xmlFile ); }
php
{ "resource": "" }
q251631
Document.loadString
validation
public static function loadString( $xmlString ) { $xmlFile = tempnam( self::getSysTempDir(), 'xml_' ); file_put_contents( $xmlFile, $xmlString ); $xml = self::parseXml( $xmlFile ); unlink( $xmlFile ); return $xml; }
php
{ "resource": "" }
q251632
Document.getSysTempDir
validation
protected static function getSysTempDir() { if ( function_exists( 'sys_get_temp_dir' ) ) { return sys_get_temp_dir(); } else if ( $tmp = getenv( 'TMP' ) ) { return $tmp; } else if ( $tmp = getenv( 'TEMP' ) ) { return...
php
{ "resource": "" }
q251633
Document.parseXml
validation
protected static function parseXml( $xmlFile ) { $reader = new \XMLReader(); // Use custom error handling to suppress warnings and errors during // parsing. $libXmlErrors = libxml_use_internal_errors( true ); // Try to open configuration file, and throw parsing exception if...
php
{ "resource": "" }
q251634
SyncStorage.isValidOperation
validation
private function isValidOperation($operationType) { $operationType = strtoupper($operationType); return in_array( $operationType, [ ActionTypes::CREATE, ActionTypes::UPDATE, ActionTypes::DELETE, ] ); }
php
{ "resource": "" }
q251635
ModifyEventListener.transform
validation
protected function transform(DocumentInterface $document, $entity, $skip = null) { $entityMethods = get_class_methods($entity); $documentMethods = get_class_methods($document); if ($skip === null) { $skip = $this->getCopySkipFields(); } foreach ($entityMethods as...
php
{ "resource": "" }
q251636
AbstractExtractor.getShopIds
validation
protected function getShopIds() { $shopIds = []; try { $shops = $this->container->getParameter('ongr_connections.shops'); } catch (InvalidArgumentException $e) { $shops = []; } foreach ($shops as $shop) { $shopIds[] = $shop['shop_id']; ...
php
{ "resource": "" }
q251637
LoadClassMetadataListener.loadClassMetadata
validation
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs) { if (empty($this->replacements)) { return; } /** @var ClassMetadataInfo $metadata */ $metadata = $eventArgs->getClassMetadata(); // Handle table name. $tableName = $metadata->getTa...
php
{ "resource": "" }
q251638
LoadClassMetadataListener.processDiscriminatorMap
validation
protected function processDiscriminatorMap(ClassMetadataInfo $metadata) { $newMap = []; foreach ($metadata->discriminatorMap as $mapId => $mappedEntityName) { $newKey = $this->doReplacement($mapId); $newMap[$newKey] = $mappedEntityName; } $metadata->discrimi...
php
{ "resource": "" }
q251639
LoadClassMetadataListener.doReplacement
validation
protected function doReplacement($inputString) { if (is_string($inputString)) { $inputString = str_replace( array_keys($this->replacements), array_values($this->replacements), $inputString ); } return $inputString; ...
php
{ "resource": "" }
q251640
AbstractStartServiceCommand.start
validation
protected function start(InputInterface $input, OutputInterface $output, $serviceClass, $prefix) { $benchmark = new CommandBenchmark($output); $benchmark->start(); /** @var PipelineStarter $service */ $service = $this->getContainer()->get($serviceClass); $factory = $service-...
php
{ "resource": "" }
q251641
ItemSkipper.skip
validation
public static function skip(ItemPipelineEvent $event, $reason = '') { $itemSkip = new ItemSkip(); $itemSkip->setReason($reason); $event->setItemSkip($itemSkip); $event->stopPropagation(); }
php
{ "resource": "" }
q251642
Pipeline.countSourceItems
validation
private function countSourceItems($sources) { $count = 0; foreach ($sources as $source) { $count += count($source); } return $count; }
php
{ "resource": "" }
q251643
DefaultApplicationFactory.createApplication
validation
public function createApplication(string $app_type, FileSystemInterface $filesystem) : ApplicationInterface { switch($app_type) { case ApplicationType::SHELL: return (new Calgamo($filesystem)) ->newApp() ->requireModule(CalgamoShell...
php
{ "resource": "" }
q251644
AbstractConsumeEventListener.onConsume
validation
public function onConsume(ItemPipelineEvent $event) { if ($event->getItemSkip()) { $this->skip($event); } else { $this->consume($event); } }
php
{ "resource": "" }
q251645
PairStorage.get
validation
public function get($key) { $pair = $this->repository->find($key); return $pair ? $pair->getValue() : null; }
php
{ "resource": "" }
q251646
PairStorage.set
validation
public function set($key, $value) { $pair = $this->repository->find($key); if ($pair === null) { $pair = new Pair(); $pair->setId($key); } $pair->setValue($value); $this->save($pair); return $pair; }
php
{ "resource": "" }
q251647
PairStorage.remove
validation
public function remove($key) { $pair = $this->repository->find($key); if ($pair !== null) { $this->repository->remove($pair->getId()); $this->manager->flush(); $this->manager->refresh(); } }
php
{ "resource": "" }
q251648
PairStorage.save
validation
private function save(Pair $pair) { $this->manager->persist($pair); $this->manager->commit(); $this->manager->refresh(); }
php
{ "resource": "" }
q251649
UrlInvalidatorService.addDocumentParameter
validation
public function addDocumentParameter($field, $value) { $this->documentParamCache[md5($value . $field)] = [$field, $value]; }
php
{ "resource": "" }
q251650
UrlInvalidatorService.getUrlsByDocumentParameter
validation
protected function getUrlsByDocumentParameter() { if (count($this->documentParamCache) < 1) { return []; } $urls = []; $query = new Query(); $queryTerms = []; foreach ($this->documentParamCache as $param) { $queryTerms[$param[0]][] = $param[1...
php
{ "resource": "" }
q251651
UrlInvalidatorService.createUrlsTempFile
validation
public function createUrlsTempFile() { $hash = md5(microtime(true)); $links = array_merge($this->getUrls(), $this->getUrlsByDocumentParameter()); $urlsFile = "/tmp/urls_{$hash}.txt"; $urls = []; foreach ($links as $url) { $separator = ($url[0] !== '/') ? '/' : ''...
php
{ "resource": "" }
q251652
UrlInvalidatorService.invalidate
validation
public function invalidate() { $script = escapeshellcmd($this->rootDir . "/../{$this->cacheScript}"); $urlsFile = escapeshellarg($this->createUrlsTempFile()); $curlTimeout = escapeshellarg($this->curlTimeout); // Execute in background. $process = new Process(sprintf('%s %s %s...
php
{ "resource": "" }
q251653
UrlInvalidatorService.loadUrlsFromDocument
validation
public function loadUrlsFromDocument($type, SeoAwareInterface $document) { if ($this->invalidateSeoUrls) { // Default behavior. $urls = $document->getUrls(); if (is_array($urls) || $urls instanceof \Traversable) { /** @var UrlObject $url */ ...
php
{ "resource": "" }
q251654
UrlInvalidatorService.loadUrlsByType
validation
public function loadUrlsByType($type) { foreach ($this->urlCollectors as $collector) { $this->addUrls($collector->getUrlsByType($type, $this->router)); } }
php
{ "resource": "" }
q251655
TableManager.createTable
validation
public function createTable($connection = null) { $connection = $connection ? : $this->connection; $schemaManager = $connection->getSchemaManager(); if ($schemaManager->tablesExist([$this->tableName])) { return null; } $table = new Table($this->tableName); ...
php
{ "resource": "" }
q251656
TableManager.updateTable
validation
public function updateTable($connection = null) { $connection = $connection ? : $this->connection; $schemaManager = $connection->getSchemaManager(); if (!$schemaManager->tablesExist([$this->tableName])) { return false; } $table = new Table($this->tableName); ...
php
{ "resource": "" }
q251657
TableManager.addStatusField
validation
protected function addStatusField(Table $table) { if (empty($this->shops)) { $table->addColumn('status', 'boolean', ['default' => 0])->setComment('0-new,1-done'); $table->addIndex(['status']); } else { foreach ($this->shops as $shop) { $fieldName =...
php
{ "resource": "" }
q251658
PipelineStarter.startPipeline
validation
public function startPipeline($prefix, $target) { if ($target === null) { $target = 'default'; } $this->getPipelineFactory()->create($prefix . $target)->start(); }
php
{ "resource": "" }
q251659
YamlExtractor.extract
validation
public static function extract($yamlArray, $key, $needed = false) { if (!empty($yamlArray) && array_key_exists($key, $yamlArray)) return $yamlArray[$key]; if ($needed) { throw new \Deployer\Exception\Exception( 'Cannot find the setting: ' . $key . '. This key...
php
{ "resource": "" }
q251660
YamlExtractor.parse
validation
public static function parse($path) { if (!file_exists($path)) { throw new Exception('The give file ' . $path . ' doesn\'t exist.'); } return Yaml::parse(file_get_contents($path)); }
php
{ "resource": "" }
q251661
PipelineFactory.create
validation
public function create($pipelineName, $listeners = []) { $listeners = array_merge( [ 'sources' => [], 'modifiers' => [], 'consumers' => [], ], $listeners ); $className = $this->getClassName(); /** @v...
php
{ "resource": "" }
q251662
ExtractionDescriptor.addToUpdateFields
validation
public function addToUpdateFields($updateField, $updateType = null) { $this->updateFields[$updateField] = ['priority' => isset($updateType) ? $updateType : $this->defaultJobType]; }
php
{ "resource": "" }
q251663
ExtractionDescriptor.addToInsertList
validation
public function addToInsertList($key, $value, $isString = true) { $this->sqlInsertList[$key] = [ 'value' => $value, 'string' => $isString, ]; }
php
{ "resource": "" }
q251664
ExtractionDescriptor.setTriggerType
validation
public function setTriggerType($type) { if (!array_key_exists($type, $this->validTypes)) { throw new \InvalidArgumentException('The type MUST be one of:' . implode(',', $this->validTypes)); } $this->type = $this->validTypes[$type]; $this->typeAlias = $type; }
php
{ "resource": "" }
q251665
NcipService.parseXml
validation
public function parseXml($xml) { if (is_null($xml)) { return null; } $xml = new QuiteSimpleXMLElement($xml); $xml->registerXPathNamespaces($this->namespaces); return $xml; }
php
{ "resource": "" }
q251666
Emitter.headers
validation
private function headers(ResponseInterface $response): void { if (!headers_sent()) { foreach ($response->getHeaders() as $name => $values) { $cookie = stripos($name, 'Set-Cookie') === 0 ? false : true; foreach ($values as $valu...
php
{ "resource": "" }
q251667
Emitter.body
validation
private function body(ResponseInterface $response): ResponseInterface { if (!in_array($response->getStatusCode(), $this->responseIsEmpty)) { $stream = $response->getBody(); if ($stream->isSeekable()) { $stream->rewind(); ...
php
{ "resource": "" }
q251668
ONGRConnectionsExtension.initShops
validation
private function initShops(ContainerBuilder $container, array $config) { $activeShop = !empty($config['active_shop']) ? $config['active_shop'] : null; if ($activeShop !== null && !isset($config['shops'][$activeShop])) { throw new LogicException( "Parameter 'ongr_connectio...
php
{ "resource": "" }
q251669
ONGRConnectionsExtension.initSyncStorage
validation
private function initSyncStorage(ContainerBuilder $container, array $config) { $availableStorages = array_keys($config['sync']['sync_storage']); $syncStorageStorage = current($availableStorages); if (empty($syncStorageStorage)) { throw new LogicException('Data synchronization sto...
php
{ "resource": "" }
q251670
ONGRConnectionsExtension.initSyncStorageForMysql
validation
private function initSyncStorageForMysql(ContainerBuilder $container, array $config) { // Initiate MySQL storage manager. $doctrineConnection = sprintf('doctrine.dbal.%s_connection', $config['connection']); $definition = $container->getDefinition( 'ongr_connections.sync.storage_m...
php
{ "resource": "" }
q251671
ONGRConnectionsExtension.createPipelines
validation
protected function createPipelines(ContainerBuilder $container, array $config) { foreach ($config['pipelines'] as $pipelineName => $pipelineConfig) { if (!isset($pipelineConfig['shop'])) { $pipelineConfig['shop'] = $container->getParameter('ongr_connections.active_shop'); ...
php
{ "resource": "" }
q251672
ONGRConnectionsExtension.getShopId
validation
protected function getShopId(ContainerBuilder $container, $shop, $name) { $shops = $container->getParameter('ongr_connections.shops'); if (!isset($shops[$shop])) { throw new \InvalidArgumentException('Non existing shop provided for pipeline ' . $name); } return $shops[$s...
php
{ "resource": "" }
q251673
ONGRConnectionsExtension.createServices
validation
protected function createServices(ContainerBuilder $container, $classes, $config, $tag, $method) { if (!is_array($tag)) { $tag = [$tag]; } foreach ($classes as $class) { $methods = $this->getMethods($class); $definition = new Definition($class); ...
php
{ "resource": "" }
q251674
ONGRConnectionsExtension.prepareServiceConfigs
validation
protected function prepareServiceConfigs(ContainerBuilder $container, $pipelineConfig, $pipelineName) { return array_merge( $pipelineConfig['config'], [ 'doctrineManager' => $pipelineConfig['doctrineManager'], 'elasticsearchManager' => $pipelineConfig[...
php
{ "resource": "" }
q251675
ONGRConnectionsExtension.prepareTypeServiceConfigs
validation
protected function prepareTypeServiceConfigs($serviceConfig, $typeConfig, $type) { return array_merge( $serviceConfig, $typeConfig['config'], [ 'entity_class' => $typeConfig['entity_class'], 'document_class' => $typeConfig['document_class']...
php
{ "resource": "" }
q251676
NcipConnector.post
validation
public function post($request) { if ($request instanceof Request) { $request = $request->xml(); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->url); if ($this->user_agent != null) { curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent); } curl_setopt($ch, CURLOPT_HEADER, 0); // no head...
php
{ "resource": "" }
q251677
CalgamoLoggerAdapter.channel
validation
public function channel(string $channel_id) : LoggerChannelInterface { $logger = $this->log_manager->get($channel_id); if (!$logger){ return new NullLoggerChannel(); } return new CalgamoLoggerChannelAdapter($logger); }
php
{ "resource": "" }
q251678
com_meego_planet_injector.inject_template
validation
public function inject_template(midgardmvc_core_request $request) { // Replace the default MeeGo sidebar with our own $route = $request->get_route(); $route->template_aliases['content-sidebar'] = 'cmp-show-sidebar'; $route->template_aliases['main-menu'] = 'cmp-show-main_menu'; ...
php
{ "resource": "" }
q251679
Node.offsetSet
validation
public function offsetSet( $attributeName, $attribute ) { if ( !is_string( $attributeName ) || !is_string( $attribute ) ) { // We only accept strings for name AND content throw new ValueException( $attribute, 'string' ); } $this->attributes[$attr...
php
{ "resource": "" }
q251680
BinlogParser.nextBufferLine
validation
protected function nextBufferLine() { $query = $this->parseQuery(); if (!empty($query)) { $this->buffer[$this->key][self::PARAM_QUERY] = $query; } else { $this->buffer[$this->key] = false; } }
php
{ "resource": "" }
q251681
BinlogParser.parseQuery
validation
protected function parseQuery() { if (empty($this->lastLine) || $this->lastLineType != self::LINE_TYPE_QUERY) { $this->getNextLine(self::LINE_TYPE_QUERY); if (empty($this->lastLine)) { return false; } } $buffer = $this->handleStart($this-...
php
{ "resource": "" }
q251682
BinlogParser.getLineType
validation
protected function getLineType($line) { if (preg_match('/^###\s+@[0-9]+=.*$/', $line)) { return self::LINE_TYPE_PARAM; } elseif (preg_match('/^###/', $line)) { return self::LINE_TYPE_QUERY; } elseif (preg_match('/^#[0-9]/', $line)) { return self::LINE_TYPE...
php
{ "resource": "" }
q251683
BinlogParser.getNewPipe
validation
protected function getNewPipe() { $cmd = 'mysqlbinlog ' . escapeshellarg($this->logDir . '/' . $this->baseName) . '.[0-9]*'; if ($this->from !== null) { if ($this->startType == self::START_TYPE_DATE) { $cmd .= ' --start-datetime=' . escapeshellarg($this->from->format('Y-...
php
{ "resource": "" }
q251684
BinlogParser.handleStart
validation
protected function handleStart($line) { if (preg_match('/^(INSERT INTO|UPDATE|DELETE FROM)\s+`?(.*?)`?\.`?(.*?)`?$/', $line, $part)) { return [ 'type' => $this->detectQueryType($part[1]), 'table' => $part[3], ]; } throw new \Unexpected...
php
{ "resource": "" }
q251685
BinlogParser.handleStatement
validation
protected function handleStatement($line, $type) { if (!preg_match("/^{$type}$/", $line)) { throw new \UnexpectedValueException("Expected a {$type} statement, got {$line}"); } $params = []; $param = $this->handleParam(); while ($param !== null) { $pa...
php
{ "resource": "" }
q251686
BinlogParser.handleParam
validation
protected function handleParam() { if (preg_match('/^@([0-9]+)=(.*)$/', $this->getNextLine(self::LINE_TYPE_ANY), $part)) { $paramValue = trim($part[2], "'"); return [$part[1] => $paramValue]; } return null; }
php
{ "resource": "" }
q251687
BinlogParser.detectQueryType
validation
protected function detectQueryType($type) { switch ($type) { case 'INSERT INTO': return ActionTypes::CREATE; case 'UPDATE': return ActionTypes::UPDATE; case 'DELETE FROM': return ActionTypes::DELETE; default: ...
php
{ "resource": "" }
q251688
Webhook.post
validation
public function post(Payload $payload, $endpoint) { if (! Type::isValidWebhookType($payload->getAction())) { throw new \Exception(sprintf('Webhook "%s" isn\'t valid', $payload->getAction())); } $requestContent = [ 'headers' => ['Content-Type' => 'application/json'], ...
php
{ "resource": "" }
q251689
AbstractPipe.callIfExistsAndEnabled
validation
private function callIfExistsAndEnabled($method, array $parameters = []) { if( ! $this->isEnabled()) return; if(method_exists($this, $method) && $this->{"{$method}IsEnabled"}()) { $this->container->call([$this, $method], $parameters); } }
php
{ "resource": "" }
q251690
DefaultConfigurator.load
validation
public function load($config) { if (is_string($config) and file_exists($config)) { $config = include $config; } if ( ! is_array($config)) { $msg = 'Failed to load configuration data'; throw new ConfigurationException($msg); } ...
php
{ "resource": "" }
q251691
KeyTrait.delete
validation
public function delete($key) { try { $this->get($key); } catch (KeyNotFoundException $e) { return false; } return $this->getClient()->delete($key); }
php
{ "resource": "" }
q251692
KeyTrait.getTtl
validation
public function getTtl($key) { $getResult = $this->getValue($key); $unserialized = @unserialize($getResult); if (!Util::hasInternalExpireTime($unserialized)) { throw new \Exception('Cannot retrieve ttl'); } return $this->handleTtl($key, $unserialized['ts'], $uns...
php
{ "resource": "" }
q251693
WithDefault.format
validation
public function format(string $question, string $default = null): string { if($default != '') { $default = sprintf('[%s]', $default); } return trim($question . $default) . sprintf('%s ', $this->getDelimiter()); }
php
{ "resource": "" }
q251694
EloquentUserRepository.assignResetToken
validation
public function assignResetToken($token, $email) { $user = $this->user->whereEmail($email)->first(); $user->reset_token = $token; $user->save(); }
php
{ "resource": "" }
q251695
EloquentUserRepository.resetPassword
validation
public function resetPassword($user, $password) { $user->password = $password; $user->reset_token = null; $user->save(); }
php
{ "resource": "" }
q251696
AbstractImportConsumeEventListener.consume
validation
public function consume(ItemPipelineEvent $event) { if (!$this->setItem($event)) { return; } $this->log( sprintf( 'Start update single document of type %s id: %s', get_class($this->getItem()->getDocument()), $this->getI...
php
{ "resource": "" }
q251697
AbstractImportConsumeEventListener.setItem
validation
protected function setItem(ItemPipelineEvent $event) { /** @var AbstractImportItem $tempItem */ $tempItem = $event->getItem(); if (!$tempItem instanceof $this->importItemClass) { $this->log("Item provided is not an {$this->importItemClass}", LogLevel::ERROR); return...
php
{ "resource": "" }
q251698
AbstractQuantity.to
validation
public function to(Uom $uom) { // Get the conversion factor as a Fraction $conversionFactor = Uom::getConversionFactor( $this->getUom(), $uom ); // Multiply the amount by the conversion factor and create a new // Weight with the new Unit retur...
php
{ "resource": "" }
q251699
NotEmpty.validate
validation
public function validate(string $answer): string { if(trim((string) $answer) === '') { throw new \RuntimeException(sprintf('%s Given value: "%s"', $this->getErrorMessage(), $answer)); } return $answer; }
php
{ "resource": "" }