_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q13600
CacheableRepository.serializeCriteria
train
protected function serializeCriteria() { try { return serialize($this->getCriteria()); } catch (Exception $e) { return serialize($this->getCriteria()->map(function ($criterion)
php
{ "resource": "" }
q13601
CacheableRepository.serializeCriterion
train
protected function serializeCriterion($criterion) { try { serialize($criterion); return $criterion; } catch (Exception $e) { // We want to take care of the closure serialization errors, // other than that we
php
{ "resource": "" }
q13602
ComparesVersionsTrait.versionCompare
train
public function versionCompare($frameworkVersion, $compareVersion, $operator = null) { // Lumen (5.5.2) (Laravel Components 5.5.*) $lumenPattern = '/Lumen \((\d\.\d\.[\d|\*])\)( \(Laravel Components (\d\.\d\.[\d|\*])\))?/';
php
{ "resource": "" }
q13603
ValidatorGenerator.getRules
train
public function getRules() { if (!$this->rules) { return '[]'; } $results = '[' . PHP_EOL; foreach ($this->getSchemaParser()->toArray() as $column => $value) {
php
{ "resource": "" }
q13604
ControllerGenerator.getValidator
train
public function getValidator() { $validatorGenerator = new ValidatorGenerator([ 'name' => $this->name, ]);
php
{ "resource": "" }
q13605
ControllerGenerator.getRepository
train
public function getRepository() { $repositoryGenerator = new RepositoryInterfaceGenerator([ 'name' => $this->name, ]); $repository = $repositoryGenerator->getRootNamespace() . '\\' . $repositoryGenerator->getName();
php
{ "resource": "" }
q13606
BindingsGenerator.getEloquentRepository
train
public function getEloquentRepository() { $repositoryGenerator = new RepositoryEloquentGenerator([ 'name' => $this->name, ]); $repository = $repositoryGenerator->getRootNamespace() . '\\' . $repositoryGenerator->getName();
php
{ "resource": "" }
q13607
BaseRepository.validator
train
public function validator() { if (isset($this->rules) && !is_null($this->rules) && is_array($this->rules) && !empty($this->rules)) { if (class_exists('Prettus\Validator\LaravelValidator')) { $validator = app('Prettus\Validator\LaravelValidator');
php
{ "resource": "" }
q13608
BaseRepository.first
train
public function first($columns = ['*']) { $this->applyCriteria(); $this->applyScope(); $results = $this->model->first($columns);
php
{ "resource": "" }
q13609
BaseRepository.find
train
public function find($id, $columns = ['*']) { $this->applyCriteria(); $this->applyScope();
php
{ "resource": "" }
q13610
BaseRepository.findWhereIn
train
public function findWhereIn($field, array $values, $columns = ['*']) { $this->applyCriteria(); $this->applyScope();
php
{ "resource": "" }
q13611
BaseRepository.findWhereNotIn
train
public function findWhereNotIn($field, array $values, $columns = ['*']) { $this->applyCriteria(); $this->applyScope();
php
{ "resource": "" }
q13612
BaseRepository.whereHas
train
public function whereHas($relation, $closure) { $this->model =
php
{ "resource": "" }
q13613
BaseRepository.pushCriteria
train
public function pushCriteria($criteria) { if (is_string($criteria)) { $criteria = new $criteria; } if (!$criteria instanceof CriteriaInterface) { throw new RepositoryException("Class " .
php
{ "resource": "" }
q13614
BaseRepository.applyConditions
train
protected function applyConditions(array $where) { foreach ($where as $field => $value) { if (is_array($value)) { list($field, $condition, $val) = $value;
php
{ "resource": "" }
q13615
BaseRepository.parserResult
train
public function parserResult($result) { if ($this->presenter instanceof PresenterInterface) { if ($result instanceof Collection || $result instanceof LengthAwarePaginator) { $result->each(function ($model) { if ($model instanceof Presentable) { $model->setPresenter($this->presenter); } return $model;
php
{ "resource": "" }
q13616
Generator.getName
train
public function getName() { $name = $this->name; if (str_contains($this->name, '\\')) { $name = str_replace('\\', '/', $this->name); } if (str_contains($this->name, '/')) { $name = str_replace('/',
php
{ "resource": "" }
q13617
Generator.getConfigGeneratorClassPath
train
public function getConfigGeneratorClassPath($class, $directoryPath = false) { switch ($class) { case ('models' === $class): $path = config('repository.generator.paths.models', 'Entities'); break; case ('repositories' === $class): $path = config('repository.generator.paths.repositories', 'Repositories'); break; case ('interfaces' === $class): $path = config('repository.generator.paths.interfaces', 'Repositories'); break; case ('presenters' === $class): $path = config('repository.generator.paths.presenters', 'Presenters'); break; case ('transformers' === $class): $path = config('repository.generator.paths.transformers', 'Transformers'); break; case ('validators' === $class): $path = config('repository.generator.paths.validators', 'Validators'); break; case ('controllers' === $class):
php
{ "resource": "" }
q13618
BackupJob.dumpDatabases
train
protected function dumpDatabases(): array { return $this->dbDumpers->map(function (DbDumper $dbDumper, $key) { consoleOutput()->info("Dumping database {$dbDumper->getDbName()}..."); $dbType = mb_strtolower(basename(str_replace('\\', '/', get_class($dbDumper)))); $dbName = $dbDumper->getDbName(); if ($dbDumper instanceof Sqlite) { $dbName = $key.'-database'; } $fileName = "{$dbType}-{$dbName}.{$this->getExtension($dbDumper)}"; if (config('backup.backup.gzip_database_dump')) { $dbDumper->useCompressor(new GzipCompressor()); $fileName .= '.'.$dbDumper->getCompressorExtension(); }
php
{ "resource": "" }
q13619
FileSelection.excludeFilesFrom
train
public function excludeFilesFrom($excludeFilesAndDirectories): self { $this->excludeFilesAndDirectories
php
{ "resource": "" }
q13620
AMQPWriter.write_bits
train
public function write_bits($bits) { $value = 0; foreach ($bits as $n => $bit) { $bit = $bit ? 1 : 0; $value |= ($bit <<
php
{ "resource": "" }
q13621
AMQPWriter.write_octet
train
public function write_octet($n) { if ($n < 0 || $n > 255) { throw new AMQPInvalidArgumentException('Octet out of range: ' . $n);
php
{ "resource": "" }
q13622
AMQPWriter.write_short
train
public function write_short($n) { if ($n < 0 || $n > 65535) { throw new AMQPInvalidArgumentException('Short out of range: ' . $n);
php
{ "resource": "" }
q13623
AMQPWriter.write_long
train
public function write_long($n) { if (($n < 0) || ($n > 4294967295)) { throw new AMQPInvalidArgumentException('Long out of range: ' . $n);
php
{ "resource": "" }
q13624
AMQPWriter.write_longlong
train
public function write_longlong($n) { if ($n < 0) { throw new AMQPInvalidArgumentException('Longlong out of range: ' . $n); } // if PHP_INT_MAX is big enough for that // direct $n<=PHP_INT_MAX check is unreliable on 64bit (values close to max) due to limited float precision if (bcadd($n, -PHP_INT_MAX, 0) <= 0) { // trick explained in http://www.php.net/manual/fr/function.pack.php#109328 if ($this->is64bits) { list($hi, $lo) = $this->splitIntoQuads($n); } else { $hi = 0;
php
{ "resource": "" }
q13625
AMQPWriter.write_shortstr
train
public function write_shortstr($s) { $len = mb_strlen($s, 'ASCII'); if ($len > 255) { throw new AMQPInvalidArgumentException('String too long');
php
{ "resource": "" }
q13626
AbstractChannel.prepare_method_frame
train
protected function prepare_method_frame($method_sig, $args = '', $pkt = null) {
php
{ "resource": "" }
q13627
AbstractChannel.wait
train
public function wait($allowed_methods = null, $non_blocking = false, $timeout = 0) { $this->debug->debug_allowed_methods($allowed_methods); $deferred = $this->process_deferred_methods($allowed_methods); if ($deferred['dispatch'] === true) { return $this->dispatch_deferred_method($deferred['queued_method']); } // timeouts must be deactivated for non-blocking actions if (true === $non_blocking) { $timeout = null; } // No deferred methods? wait for new ones while (true) { try { list($frame_type, $payload) = $this->next_frame($timeout); } catch (AMQPNoDataException $e) { // no data ready for non-blocking actions - stop and exit break; } catch (AMQPConnectionClosedException $exception) { if ($this instanceof AMQPChannel) { $this->do_close(); } throw $exception; } $this->validate_method_frame($frame_type);
php
{ "resource": "" }
q13628
GenericContent.has
train
public function has($name) { return isset($this->properties[$name])
php
{ "resource": "" }
q13629
GenericContent.get
train
public function get($name) { if (isset($this->properties[$name])) { return $this->properties[$name]; } if (isset($this->delivery_info[$name])) {
php
{ "resource": "" }
q13630
AbstractIO.write_heartbeat
train
protected function write_heartbeat() { $pkt = new AMQPWriter(); $pkt->write_octet(8); $pkt->write_short(0); $pkt->write_long(0);
php
{ "resource": "" }
q13631
AbstractIO.cleanup_error_handler
train
protected function cleanup_error_handler() { restore_error_handler(); if ($this->last_error !== null) { throw new \ErrorException( $this->last_error['errstr'], 0,
php
{ "resource": "" }
q13632
AbstractIO.error_handler
train
public function error_handler($errno, $errstr, $errfile, $errline, $errcontext = null) { // throwing an exception in an error handler will halt execution //
php
{ "resource": "" }
q13633
AMQPReader.reuse
train
public function reuse($str) { $this->str = $str; $this->str_length = mb_strlen($this->str, 'ASCII');
php
{ "resource": "" }
q13634
AMQPReader.wait
train
protected function wait() { $timeout = $this->getTimeout(); if (null === $timeout) { // timeout=null just poll state and return instantly $sec = 0; $usec = 0; } elseif ($timeout > 0) { list($sec, $usec) = MiscHelper::splitSecondsMicroseconds($this->getTimeout()); } else { // wait indefinitely for data if timeout=0 $sec = null; $usec = 0; } $result = $this->io->select($sec, $usec); if ($result === false) { throw new AMQPIOWaitException('A network
php
{ "resource": "" }
q13635
AMQPReader.read_longlong
train
public function read_longlong() { $this->bitcount = $this->bits = 0; list(, $hi, $lo) = unpack('N2', $this->rawread(8)); $msb = self::getLongMSB($hi); if (empty($this->is64bits)) { if ($msb) { $hi = sprintf('%u', $hi); } if (self::getLongMSB($lo)) {
php
{ "resource": "" }
q13636
AMQPReader.read_array
train
public function read_array($returnObject = false) { $this->bitcount = $this->bits = 0; // Determine array length and its end position $arrayLength = $this->read_php_int(); $endOffset = $this->offset + $arrayLength; $result = $returnObject ? new AMQPArray() : array(); // Read values until we reach the end of the array while ($this->offset < $endOffset)
php
{ "resource": "" }
q13637
AMQPReader.read_value
train
public function read_value($fieldType, $collectionsAsObjects = false) { $this->bitcount = $this->bits = 0; switch ($fieldType) { case AMQPAbstractCollection::T_INT_SHORTSHORT: //according to AMQP091 spec, 'b' is not bit, it is short-short-int, also valid for rabbit/qpid //$val=$this->read_bit(); $val = $this->read_signed_octet(); break; case AMQPAbstractCollection::T_INT_SHORTSHORT_U: $val = $this->read_octet(); break; case AMQPAbstractCollection::T_INT_SHORT: $val = $this->read_signed_short(); break; case AMQPAbstractCollection::T_INT_SHORT_U: $val = $this->read_short(); break; case AMQPAbstractCollection::T_INT_LONG: $val = $this->read_signed_long(); break; case AMQPAbstractCollection::T_INT_LONG_U: $val = $this->read_long(); break; case AMQPAbstractCollection::T_INT_LONGLONG: $val = $this->read_signed_longlong(); break; case AMQPAbstractCollection::T_INT_LONGLONG_U: $val = $this->read_longlong(); break; case AMQPAbstractCollection::T_DECIMAL: $e = $this->read_octet(); $n = $this->read_signed_long(); $val = new AMQPDecimal($n, $e); break; case AMQPAbstractCollection::T_TIMESTAMP: $val = $this->read_timestamp(); break; case AMQPAbstractCollection::T_BOOL: $val = $this->read_octet(); break; case AMQPAbstractCollection::T_STRING_SHORT:
php
{ "resource": "" }
q13638
AbstractConnection.connect
train
protected function connect() { try { // Loop until we connect while (!$this->isConnected()) { // Assume we will connect, until we dont $this->setIsConnected(true); // Connect the socket $this->io->connect(); $this->channels = array(); // The connection object itself is treated as channel 0 parent::__construct($this, 0); $this->input = new AMQPReader(null, $this->io); $this->write($this->amqp_protocol_header); $this->wait(array($this->waitHelper->get_wait('connection.start')),false,$this->connection_timeout); $this->x_start_ok( $this->getLibraryProperties(), $this->login_method, $this->login_response, $this->locale ); $this->wait_tune_ok = true; while ($this->wait_tune_ok) { $this->wait(array( $this->waitHelper->get_wait('connection.secure'), $this->waitHelper->get_wait('connection.tune') )); } $host = $this->x_open($this->vhost, '', $this->insist); if (!$host) { //Reconnected
php
{ "resource": "" }
q13639
AbstractConnection.reconnect
train
public function reconnect() { // Try to close the AMQP connection $this->safeClose(); // Reconnect the socket/stream then AMQP $this->io->close();
php
{ "resource": "" }
q13640
AbstractConnection.safeClose
train
protected function safeClose() { try { if (isset($this->input) && $this->input) { $this->close(); }
php
{ "resource": "" }
q13641
AbstractConnection.wait_frame
train
protected function wait_frame($timeout = 0) { if (is_null($this->input)) { $this->setIsConnected(false); throw new AMQPConnectionClosedException('Broken pipe or closed connection'); } $currentTimeout = $this->input->getTimeout(); $this->input->setTimeout($timeout); try { // frame_type + channel_id + size $this->wait_frame_reader->reuse( $this->input->read(AMQPReader::OCTET + AMQPReader::SHORT + AMQPReader::LONG) ); $frame_type = $this->wait_frame_reader->read_octet(); $class = self::$PROTOCOL_CONSTANTS_CLASS; if (!array_key_exists($frame_type, $class::$FRAME_TYPES)) { throw new AMQPInvalidFrameException('Invalid frame type ' . $frame_type); } $channel = $this->wait_frame_reader->read_short(); $size = $this->wait_frame_reader->read_long(); // payload + ch $this->wait_frame_reader->reuse($this->input->read(AMQPReader::OCTET + (int) $size)); $payload = $this->wait_frame_reader->read($size); $ch = $this->wait_frame_reader->read_octet(); } catch (AMQPTimeoutException $e) { $this->input->setTimeout($currentTimeout);
php
{ "resource": "" }
q13642
AbstractConnection.wait_channel
train
protected function wait_channel($channel_id, $timeout = 0) { // Keeping the original timeout unchanged. $_timeout = $timeout; while (true) { $now = time(); try { list($frame_type, $frame_channel, $payload) = $this->wait_frame($_timeout); } catch (AMQPTimeoutException $e) { if ( $this->heartbeat && microtime(true) - ($this->heartbeat*2) > $this->last_frame ) { $this->debug->debug_msg("missed server heartbeat (at threshold * 2)"); $this->setIsConnected(false); throw new AMQPHeartbeatMissedException("Missed server heartbeat"); } throw $e; } $this->last_frame = microtime(true); if ($frame_channel === 0 && $frame_type === 8) { // skip heartbeat frames and reduce the timeout by the time passed $this->debug->debug_msg("received server heartbeat"); if($_timeout > 0) { $_timeout -= time() - $now; if($_timeout <= 0) { // If timeout has been reached, throw the exception without calling wait_frame throw new AMQPTimeoutException("Timeout waiting on channel"); } } continue; } else { if ($frame_channel == $channel_id) { return array($frame_type, $payload); }
php
{ "resource": "" }
q13643
AbstractConnection.close
train
public function close($reply_code = 0, $reply_text = '', $method_sig = array(0, 0)) { $result = null; $this->io->disableHeartbeat(); if (empty($this->protocolWriter) || !$this->isConnected()) { return $result; } try { $this->closeChannels(); list($class_id, $method_id, $args) = $this->protocolWriter->connectionClose(
php
{ "resource": "" }
q13644
AbstractConnection.connection_open_ok
train
protected function connection_open_ok($args) { $this->known_hosts = $args->read_shortstr();
php
{ "resource": "" }
q13645
AbstractConnection.connection_redirect
train
protected function connection_redirect($args) { $host = $args->read_shortstr(); $this->known_hosts = $args->read_shortstr(); $this->debug->debug_msg(sprintf(
php
{ "resource": "" }
q13646
AbstractConnection.x_secure_ok
train
protected function x_secure_ok($response) { $args = new AMQPWriter();
php
{ "resource": "" }
q13647
AbstractConnection.connection_start
train
protected function connection_start($args) { $this->version_major = $args->read_octet(); $this->version_minor = $args->read_octet(); $this->server_properties = $args->read_table(); $this->mechanisms = explode(' ', $args->read_longstr()); $this->locales = explode(' ', $args->read_longstr()); $this->debug->debug_connection_start(
php
{ "resource": "" }
q13648
AbstractConnection.connection_tune
train
protected function connection_tune($args) { $v = $args->read_short(); if ($v) { $this->channel_max = $v; } $v = $args->read_long(); if ($v) { $this->frame_max = $v; } // use
php
{ "resource": "" }
q13649
AbstractConnection.x_tune_ok
train
protected function x_tune_ok($channel_max, $frame_max, $heartbeat) { $args = new AMQPWriter(); $args->write_short($channel_max); $args->write_long($frame_max); $args->write_short($heartbeat);
php
{ "resource": "" }
q13650
AbstractConnection.closeChannels
train
protected function closeChannels() { foreach ($this->channels as $key => $channel) { // channels[0] is this connection object, so don't close it yet if ($key === 0) { continue; } try {
php
{ "resource": "" }
q13651
AMQPChannel.channel_alert
train
protected function channel_alert($reader) { $reply_code = $reader->read_short(); $reply_text =
php
{ "resource": "" }
q13652
AMQPChannel.close
train
public function close($reply_code = 0, $reply_text = '', $method_sig = array(0, 0)) { $this->callbacks = array(); if ($this->is_open === false || $this->connection === null) { $this->do_close(); return null; // already closed } list($class_id, $method_id, $args) = $this->protocolWriter->channelClose( $reply_code, $reply_text, $method_sig[0], $method_sig[1] ); try {
php
{ "resource": "" }
q13653
AMQPChannel.access_request
train
public function access_request( $realm, $exclusive = false, $passive = false, $active = false, $write = false, $read = false ) { list($class_id, $method_id, $args) = $this->protocolWriter->accessRequest( $realm, $exclusive, $passive, $active, $write,
php
{ "resource": "" }
q13654
AMQPChannel.exchange_delete
train
public function exchange_delete( $exchange, $if_unused = false, $nowait = false, $ticket = null ) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->exchangeDelete( $ticket, $exchange, $if_unused, $nowait ); $this->send_method_frame(array($class_id, $method_id), $args);
php
{ "resource": "" }
q13655
AMQPChannel.exchange_bind
train
public function exchange_bind( $destination, $source, $routing_key = '', $nowait = false, $arguments = array(), $ticket = null ) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->exchangeBind( $ticket, $destination, $source, $routing_key, $nowait,
php
{ "resource": "" }
q13656
AMQPChannel.queue_bind
train
public function queue_bind( $queue, $exchange, $routing_key = '', $nowait = false, $arguments = array(), $ticket = null ) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->queueBind( $ticket, $queue, $exchange, $routing_key, $nowait,
php
{ "resource": "" }
q13657
AMQPChannel.queue_unbind
train
public function queue_unbind( $queue, $exchange, $routing_key = '', $arguments = array(), $ticket = null ) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->queueUnbind( $ticket, $queue, $exchange, $routing_key, $arguments
php
{ "resource": "" }
q13658
AMQPChannel.queue_declare_ok
train
protected function queue_declare_ok($reader) { $queue = $reader->read_shortstr(); $message_count = $reader->read_long();
php
{ "resource": "" }
q13659
AMQPChannel.queue_delete
train
public function queue_delete($queue = '', $if_unused = false, $if_empty = false, $nowait = false, $ticket = null) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->queueDelete( $ticket, $queue, $if_unused, $if_empty, $nowait ); $this->send_method_frame(array($class_id,
php
{ "resource": "" }
q13660
AMQPChannel.queue_purge
train
public function queue_purge($queue = '', $nowait = false, $ticket = null) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->queuePurge($ticket, $queue, $nowait); $this->send_method_frame(array($class_id, $method_id), $args); if ($nowait) {
php
{ "resource": "" }
q13661
AMQPChannel.basic_ack
train
public function basic_ack($delivery_tag, $multiple = false) { list($class_id, $method_id,
php
{ "resource": "" }
q13662
AMQPChannel.basic_ack_from_server
train
protected function basic_ack_from_server(AMQPReader $reader) { $delivery_tag = $reader->read_longlong(); $multiple = (bool) $reader->read_bit(); if (!isset($this->published_messages[$delivery_tag])) { throw new AMQPRuntimeException(sprintf( 'Server ack\'ed unknown delivery_tag
php
{ "resource": "" }
q13663
AMQPChannel.basic_nack_from_server
train
protected function basic_nack_from_server($reader) { $delivery_tag = $reader->read_longlong(); $multiple = (bool) $reader->read_bit(); if (!isset($this->published_messages[$delivery_tag])) { throw new AMQPRuntimeException(sprintf( 'Server nack\'ed unknown delivery_tag
php
{ "resource": "" }
q13664
AMQPChannel.basic_nack
train
public function basic_nack($delivery_tag, $multiple = false, $requeue = false) { list($class_id, $method_id, $args) = $this->protocolWriter->basicNack($delivery_tag, $multiple,
php
{ "resource": "" }
q13665
AMQPChannel.basic_cancel
train
public function basic_cancel($consumer_tag, $nowait = false, $noreturn = false) { list($class_id, $method_id, $args) = $this->protocolWriter->basicCancel($consumer_tag, $nowait); $this->send_method_frame(array($class_id, $method_id), $args); if ($nowait || $noreturn) { unset($this->callbacks[$consumer_tag]);
php
{ "resource": "" }
q13666
AMQPChannel.basic_consume
train
public function basic_consume( $queue = '', $consumer_tag = '', $no_local = false, $no_ack = false, $exclusive = false, $nowait = false, $callback = null, $ticket = null, $arguments = array() ) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->basicConsume(
php
{ "resource": "" }
q13667
AMQPChannel.basic_deliver
train
protected function basic_deliver($reader, $message) { $consumer_tag = $reader->read_shortstr(); $delivery_tag = $reader->read_longlong(); $redelivered = $reader->read_bit(); $exchange = $reader->read_shortstr(); $routing_key = $reader->read_shortstr(); $message->delivery_info = array( 'channel' => $this, 'consumer_tag' => $consumer_tag, 'delivery_tag' => $delivery_tag, 'redelivered' => $redelivered,
php
{ "resource": "" }
q13668
AMQPChannel.basic_get
train
public function basic_get($queue = '', $no_ack = false, $ticket = null) { $ticket = $this->getTicket($ticket); list($class_id, $method_id, $args) = $this->protocolWriter->basicGet($ticket, $queue, $no_ack); $this->send_method_frame(array($class_id, $method_id), $args); return $this->wait(array(
php
{ "resource": "" }
q13669
AMQPChannel.basic_get_ok
train
protected function basic_get_ok($reader, $message) { $delivery_tag = $reader->read_longlong(); $redelivered = $reader->read_bit(); $exchange = $reader->read_shortstr(); $routing_key = $reader->read_shortstr(); $message_count = $reader->read_long(); $message->delivery_info = array( 'delivery_tag'
php
{ "resource": "" }
q13670
AMQPChannel.basic_publish
train
public function basic_publish( $msg, $exchange = '', $routing_key = '', $mandatory = false, $immediate = false, $ticket = null ) { $pkt = new AMQPWriter(); $pkt->write($this->pre_publish($exchange, $routing_key, $mandatory, $immediate, $ticket)); try { $this->connection->send_content(
php
{ "resource": "" }
q13671
AMQPChannel.basic_recover
train
public function basic_recover($requeue = false) { list($class_id, $method_id, $args) = $this->protocolWriter->basicRecover($requeue); $this->send_method_frame(array($class_id, $method_id), $args);
php
{ "resource": "" }
q13672
AMQPChannel.basic_reject
train
public function basic_reject($delivery_tag, $requeue) { list($class_id, $method_id, $args)
php
{ "resource": "" }
q13673
AMQPChannel.basic_return
train
protected function basic_return($reader, $message) { $callback = $this->basic_return_callback; if (!is_callable($callback)) { $this->debug->debug_msg('Skipping unhandled basic_return message'); return null; } $reply_code = $reader->read_short(); $reply_text = $reader->read_shortstr();
php
{ "resource": "" }
q13674
AMQPChannel.tx_rollback
train
public function tx_rollback() { $this->send_method_frame(array(90, 30));
php
{ "resource": "" }
q13675
AMQPChannel.confirm_select
train
public function confirm_select($nowait = false) { list($class_id, $method_id, $args) = $this->protocolWriter->confirmSelect($nowait); $this->send_method_frame(array($class_id, $method_id), $args); if ($nowait) { return null;
php
{ "resource": "" }
q13676
AMQPChannel.wait_for_pending_acks
train
public function wait_for_pending_acks($timeout = 0) { $functions = array( $this->waitHelper->get_wait('basic.ack'), $this->waitHelper->get_wait('basic.nack'), ); while (count($this->published_messages) !== 0) { if
php
{ "resource": "" }
q13677
AMQPChannel.tx_select
train
public function tx_select() { $this->send_method_frame(array(90, 10));
php
{ "resource": "" }
q13678
AMQPChannel.set_return_listener
train
public function set_return_listener($callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException(sprintf( 'Given callback "%s" should be callable. %s type was given.',
php
{ "resource": "" }
q13679
AMQPChannel.set_nack_handler
train
public function set_nack_handler($callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException(sprintf( 'Given callback "%s" should be callable. %s type was given.',
php
{ "resource": "" }
q13680
AMQPChannel.set_ack_handler
train
public function set_ack_handler($callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException(sprintf( 'Given callback "%s" should be callable. %s type was given.',
php
{ "resource": "" }
q13681
Consumer.start
train
public function start() { if ($this->restart) { echo 'Restarting consumer.' . PHP_EOL; $this->restart = false; } else { echo 'Starting consumer.' . PHP_EOL; } $exchange = 'router'; $queue = 'msgs'; $this->channel = $this->connection->channel(); $this->channel->queue_declare($queue, false, true, false, false); $this->channel->exchange_declare($exchange, AMQPExchangeType::DIRECT, false, true, false); $this->channel->queue_bind($queue, $exchange); $this->channel->basic_consume( $queue, $this->consumerTag, false,
php
{ "resource": "" }
q13682
MiscHelper.hexdump
train
public static function hexdump($data, $htmloutput = true, $uppercase = false, $return = false) { // Init $hexi = ''; $ascii = ''; $dump = $htmloutput ? '<pre>' : ''; $offset = 0; $len = mb_strlen($data, 'ASCII'); // Upper or lower case hexidecimal $hexFormat = $uppercase ? 'X' : 'x'; // Iterate string for ($i = $j = 0; $i < $len; $i++) { // Convert to hexidecimal // We must use concatenation here because the $hexFormat value // is needed for sprintf() to parse the format $hexi .= sprintf('%02' . $hexFormat . ' ', ord($data[$i])); // Replace non-viewable bytes with '.' if (ord($data[$i]) >= 32) {
php
{ "resource": "" }
q13683
Discussion.getApiDocument
train
protected function getApiDocument(User $actor, array $params) { $response = $this->api->send('Flarum\Api\Controller\ShowDiscussionController', $actor, $params); $statusCode = $response->getStatusCode();
php
{ "resource": "" }
q13684
Application.url
train
public function url($path = null) { $config = $this->make('flarum.config'); $url = array_get($config, 'url', array_get($_SERVER, 'REQUEST_URI')); if (is_array($url)) { if (isset($url[$path])) { return $url[$path];
php
{ "resource": "" }
q13685
NotificationServiceProvider.registerNotificationTypes
train
public function registerNotificationTypes() { $blueprints = [ DiscussionRenamedBlueprint::class => ['alert'] ]; $this->app->make('events')->fire( new ConfigureNotificationTypes($blueprints) ); foreach ($blueprints as $blueprint => $enabled) { Notification::setSubjectModel( $type = $blueprint::getType(), $blueprint::getSubjectModel() ); User::addPreference( User::getNotificationPreferenceKey($type, 'alert'),
php
{ "resource": "" }
q13686
RevisionCompiler.getFilenameForRevision
train
protected function getFilenameForRevision(string $revision): string { $ext = pathinfo($this->filename, PATHINFO_EXTENSION);
php
{ "resource": "" }
q13687
NotificationRepository.findByUser
train
public function findByUser(User $user, $limit = null, $offset = 0) { $primaries = Notification::select( app('flarum.db')->raw('MAX(id) AS id'), app('flarum.db')->raw('SUM(read_at IS NULL) AS unread_count') ) ->where('user_id', $user->id) ->whereIn('type', $user->getAlertableNotificationTypes()) ->where('is_deleted', false) ->whereSubjectVisibleTo($user) ->groupBy('type', 'subject_id') ->orderByRaw('MAX(created_at) DESC') ->skip($offset)
php
{ "resource": "" }
q13688
NotificationRepository.markAllAsRead
train
public function markAllAsRead(User $user) { Notification::where('user_id',
php
{ "resource": "" }
q13689
AccessToken.generate
train
public static function generate($userId, $lifetime = 3600) { $token = new static; $token->token = str_random(40); $token->user_id = $userId;
php
{ "resource": "" }
q13690
RouteCollectionUrlGenerator.route
train
public function route($name, $parameters = []) { $path = $this->routes->getPath($name, $parameters);
php
{ "resource": "" }
q13691
AbstractValidator.assertValid
train
public function assertValid(array $attributes) { $validator = $this->makeValidator($attributes); if ($validator->fails()) {
php
{ "resource": "" }
q13692
AbstractValidator.makeValidator
train
protected function makeValidator(array $attributes) { $rules = array_only($this->getRules(), array_keys($attributes));
php
{ "resource": "" }
q13693
Index.getApiDocument
train
private function getApiDocument(User $actor, array $params) {
php
{ "resource": "" }
q13694
ApiServiceProvider.registerNotificationSerializers
train
protected function registerNotificationSerializers() { $blueprints = []; $serializers = [ 'discussionRenamed' => BasicDiscussionSerializer::class ]; $this->app->make('events')->fire( new ConfigureNotificationTypes($blueprints, $serializers) );
php
{ "resource": "" }
q13695
ApiServiceProvider.populateRoutes
train
protected function populateRoutes(RouteCollection $routes) { $factory = $this->app->make(RouteHandlerFactory::class); $callback = include __DIR__.'/routes.php'; $callback($routes,
php
{ "resource": "" }
q13696
User.rename
train
public function rename($username) { if ($username !== $this->username) { $oldUsername = $this->username; $this->username = $username;
php
{ "resource": "" }
q13697
User.changeEmail
train
public function changeEmail($email) { if ($email !== $this->email) { $this->email = $email;
php
{ "resource": "" }
q13698
User.requestEmailChange
train
public function requestEmailChange($email) { if ($email !== $this->email) {
php
{ "resource": "" }
q13699
User.changeAvatarPath
train
public function changeAvatarPath($path) { $this->avatar_url = $path;
php
{ "resource": "" }