_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q257500
Rediska_Key.setBit
test
public function setBit($offset, $bit) {
php
{ "resource": "" }
q257501
Rediska_Key.getOrSetValue
test
public function getOrSetValue($object = null, $expire = null, $expireIsTimestamp =
php
{ "resource": "" }
q257502
UserController.followersAction
test
public function followersAction() { $userId = $this->_getParam('userId'); $user = new User($userId); $this->view->user = $user->getValue(); $followers = new Followers($userId);
php
{ "resource": "" }
q257503
UserController.followingAction
test
public function followingAction() { $userId = $this->_getParam('userId'); $following = new Following($userId);
php
{ "resource": "" }
q257504
UserController.followAction
test
public function followAction() { $auth = Zend_Auth::getInstance(); if (!$auth->hasIdentity()) { throw new Zend_Auth_Exception("You're not authorized to see this page"); } $userId = $this->_getParam('userId');
php
{ "resource": "" }
q257505
Rediska_Key_Abstract.moveToDb
test
public function moveToDb($dbIndex) { $result = $this->_getRediskaOn()->moveToDb($this->getName(), $dbIndex); if (!is_null($this->getExpire()) && $result) {
php
{ "resource": "" }
q257506
Rediska_Key_Abstract.setExpire
test
public function setExpire($secondsOrTimestamp, $isTimestamp = false) { if ($secondsOrTimestamp !== null) { trigger_error('Expire option is deprecated, because expire
php
{ "resource": "" }
q257507
Rediska_Key_Abstract._getRediskaOn
test
protected function _getRediskaOn() { $rediska = $this->getRediska(); if (!is_null($this->getServerAlias())) {
php
{ "resource": "" }
q257508
Rediska_Profiler_Stream.setMode
test
public function setMode($mode) { if (is_resource($this->_stream) && $this->_mode != $mode) { $meta = stream_get_meta_data($this->_stream);
php
{ "resource": "" }
q257509
Rediska_Manager.add
test
public static function add($rediska) { if ($rediska instanceof Rediska) { if (!self::has($rediska->getName())) { foreach(self::$_instances as $name => $instance) { if ($instance === $rediska && $name != $rediska->getName()) { unset(self...
php
{ "resource": "" }
q257510
Rediska_Manager.getAll
test
public static function getAll() { foreach(self::$_instances as $name => $instanceOrOptions) {
php
{ "resource": "" }
q257511
Rediska_Manager._instanceFromOptions
test
protected static function _instanceFromOptions($name) { if (!is_object(self::$_instances[$name])) { $options = self::$_instances[$name];
php
{ "resource": "" }
q257512
Ratelimit.increment
test
public function increment($subject) { $bucket = $this->_getBucketName(); $transaction = $this->_getTransaction();
php
{ "resource": "" }
q257513
Ratelimit.reset
test
public function reset($subject) { $keyName = $this->_getKeyName($subject);
php
{ "resource": "" }
q257514
Ratelimit._getBucketName
test
protected function _getBucketName($time = null) { $time = $time ? : time(); return (int) floor(($time %
php
{ "resource": "" }
q257515
Ratelimit._setMultiIncrementTransactionPart
test
protected function _setMultiIncrementTransactionPart(Rediska_Transaction $transaction, $subject, $bucket) { $keyName = $this->_getKeyName($subject); $transaction->incrementinhash($keyName, $bucket, 1) ->deletefromhash($keyName, ($bucket +
php
{ "resource": "" }
q257516
Ratelimit._setMulitExecGetCountPart
test
protected function _setMulitExecGetCountPart(Rediska_Transaction $transaction, $subject, $bucket, $count) { $keyName = $this->_getKeyName($subject); // Get the counts from the previous `$count` buckets $transaction->getfromhash($keyName, $bucket); for ($i = $count; $i > 0;
php
{ "resource": "" }
q257517
Rediska_Connection_Socket._createSocketConnection
test
protected function _createSocketConnection() { $socket = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp')); socket_set_option($socket, SOL_SOCKET, TCP_NODELAY, 1); @socket_set_nonblock($socket); $result = @socket_connect($socket, $this->getHost(), $this->getPort()); ...
php
{ "resource": "" }
q257518
Rediska_Connection_Socket._getReadBuffer
test
protected function _getReadBuffer() { if ($this->_readBuffer === null) {
php
{ "resource": "" }
q257519
Rediska_Connection.read
test
public function read($length) { if (!$this->isConnected()) { throw new Rediska_Connection_Exception("Can't read without connection to Redis server. Do connect or write first."); } if ($length > 0) {
php
{ "resource": "" }
q257520
Rediska_Connection.readLine
test
public function readLine() { if (!$this->isConnected()) { throw new Rediska_Connection_Exception("Can't read without connection to Redis server. Do connect or write first."); } $reply = @fgets($this->_socket); if ($reply === false || $reply === '') { ...
php
{ "resource": "" }
q257521
Rediska_Connection.setReadTimeout
test
public function setReadTimeout($timeout) { $this->_options['readTimeout'] = $timeout; if ($this->isConnected()) { $seconds = floor($this->_options['readTimeout']); $microseconds = ($this->_options['readTimeout'] - $seconds)
php
{ "resource": "" }
q257522
Rediska_Connection.getStreamContext
test
public function getStreamContext() { if ($this->_options['streamContext'] !== null) { if (is_resource($this->_options['streamContext'])) { return $this->_options['streamContext']; } if
php
{ "resource": "" }
q257523
Rediska_Connection._readAndThrowException
test
protected function _readAndThrowException($length) { $data = @stream_get_contents($this->_socket, $length); $info = stream_get_meta_data($this->_socket); if ($info['timed_out']) { throw new Rediska_Connection_TimeoutException("Connection read timed out."); }
php
{ "resource": "" }
q257524
WpNonce.validate
test
public function validate(NonceContextInterface $context = null) { $context or $context = new RequestGlobalsContext(); $value = $context->offsetExists($this->action) ? $context[$this->action] : ''; if (!$value || !is_string($value)) { return false; }
php
{ "resource": "" }
q257525
PeclAmqpDriver.declareAndBindQueue
test
public function declareAndBindQueue($exchange, $queueName, $routingKey = '') { $this->declareSimpleQueue($queueName);
php
{ "resource": "" }
q257526
PeclAmqpDriver.ack
test
public function ack(Message $message) { $queue = $this->getQueue($message->getQueue());
php
{ "resource": "" }
q257527
PeclAmqpDriver.nack
test
public function nack(Message $message, $requeue = true) { $queue = $this->getQueue($message->getQueue());
php
{ "resource": "" }
q257528
PeclAmqpDriver.getMessageProperties
test
private static function getMessageProperties(Message $message) { $properties = [ self::DELIVERY_MODE => 2, self::CONTENT_TYPE => 'text/plain', self::APPLICATION_HEADERS => $message->getHeaders() ]; if ($message->getCorrelationId() !== null) {...
php
{ "resource": "" }
q257529
QueueHandlingDaemon.start
test
public function start() { $this->eventEmitter->emit(new DaemonStarted()); $this->logger->info('Starting daemon...'); $options = $this->handler->options(new ConsumeOptions()); $this->driver->consume( $this->queueName, function (Message $message) { ...
php
{ "resource": "" }
q257530
QueueHandlingDaemon.stop
test
public function stop() { $this->logger->info('Closing daemon...'); $this->driver->close();
php
{ "resource": "" }
q257531
TimeoutException.build
test
public static function build(\Exception $e, $timeout) { return new self( sprintf('The connection timed out after %d sec while awaiting incoming
php
{ "resource": "" }
q257532
HandlerBuilder.build
test
public function build(QueueConsumer $consumer) { Assertion::notNull($this->sync, 'You must specify if the handler must be sync or async'); // Sync $handler = $this->sync ? new SyncConsumerHandler($consumer, $this->driver) : new AsyncConsumerHandler($consumer); ...
php
{ "resource": "" }
q257533
SyncConsumerHandler.handleSyncMessage
test
private function handleSyncMessage(Message $message, $returnValue) { self::checkMessageIsSync($message); $this->logger->debug( 'Send return value back!', [ 'returnValue' => $returnValue, 'correlationId' => $message->getCorrelationId(), ...
php
{ "resource": "" }
q257534
DriverFactory.getDriver
test
public static function getDriver($connection) { if (is_array($connection) && isset($connection['host'], $connection['port'], $connection['user'], $connection['pwd']) ) { $connection = self::getConnectionFromArray($connection); } if ($connection instanceof Abs...
php
{ "resource": "" }
q257535
PhpAmqpLibDriver.nack
test
public function nack(Message $message, $requeue = true) {
php
{ "resource": "" }
q257536
PhpAmqpLibDriver.close
test
public function close() { $this->stop = true;
php
{ "resource": "" }
q257537
SerializingConsumer.consume
test
public function consume($message, array $headers = []) { return $this->serializer->serialize( $this->consumer->consume(
php
{ "resource": "" }
q257538
DataTablesEditorCommand.replaceModel
test
protected function replaceModel(&$stub) { $model = explode('\\', $this->getModel()); $model = array_pop($model);
php
{ "resource": "" }
q257539
DataTablesEditorCommand.qualifyClass
test
protected function qualifyClass($name) { $rootNamespace = $this->laravel->getNamespace(); if (Str::startsWith($name, $rootNamespace)) { return $name; } if (Str::contains($name, '/')) { $name = str_replace('/', '\\', $name); }
php
{ "resource": "" }
q257540
DataTablesEditor.process
test
public function process(Request $request) { $action = $request->get('action'); if (! in_array($action, $this->actions))
php
{ "resource": "" }
q257541
DataTablesEditor.create
test
public function create(Request $request) { $instance = $this->resolveModel(); $connection = $instance->getConnection(); $affected = []; $errors = []; $connection->beginTransaction(); foreach ($request->get('data') as $data) { $validator = $this->g...
php
{ "resource": "" }
q257542
DataTablesEditor.toJson
test
protected function toJson(array $data, array $errors = []) { $response = ['data' => $data]; if ($errors) {
php
{ "resource": "" }
q257543
DataTablesEditor.edit
test
public function edit(Request $request) { $instance = $this->resolveModel(); $connection = $instance->getConnection(); $affected = []; $errors = []; $connection->beginTransaction(); foreach ($request->get('data') as $key => $data) { $model = $i...
php
{ "resource": "" }
q257544
DataTablesEditor.remove
test
public function remove(Request $request) { $instance = $this->resolveModel(); $connection = $instance->getConnection(); $affected = []; $errors = []; $connection->beginTransaction(); foreach ($request->get('data') as $key => $data) { $model = ...
php
{ "resource": "" }
q257545
BlacklistVoter.voteOnAttribute
test
protected function voteOnAttribute($attribute, $subject, TokenInterface $token) { /** @var $subject Query */
php
{ "resource": "" }
q257546
HtmlReport.render
test
public function render(DocumentInterface $document, $parameters = []) { $html = $this->twig->render($this->template, [ 'doc' => $document,
php
{ "resource": "" }
q257547
ByteBuffer.getString
test
public function getString() { $zeroByteIndex = strpos($this->byteArray, "\0", $this->position); if($zeroByteIndex === false) { return ''; } else {
php
{ "resource": "" }
q257548
GameAchievement.getGlobalPercentages
test
public static function getGlobalPercentages($appId) { $params = ['gameid' => $appId]; $data = WebApi::getJSONObject('ISteamUserStats', 'GetGlobalAchievementPercentagesForApp', 2, $params); $percentages = [];
php
{ "resource": "" }
q257549
SteamSocket.close
test
public function close() { if(!empty($this->socket) && $this->socket->isOpen()) {
php
{ "resource": "" }
q257550
SteamSocket.receivePacket
test
public function receivePacket($bufferLength = 0) { if(!$this->socket->select(self::$timeout)) { throw new TimeoutException(); } if($bufferLength == 0) { $this->buffer->clear(); } else { $this->buffer = ByteBuffer::allocate($bufferLength);
php
{ "resource": "" }
q257551
SteamSocket.send
test
public function send(SteamPacket $dataPacket) { $this->logger->debug("Sending packet of type \"" . get_class($dataPacket) . "\"...");
php
{ "resource": "" }
q257552
MasterServerSocket.getReply
test
public function getReply() { $this->receivePacket(1500); if($this->buffer->getLong() != -1) { throw new PacketFormatException("Master query response has wrong packet header."); }
php
{ "resource": "" }
q257553
GoldSrcSocket.rconExec
test
public function rconExec($password, $command) { if($this->rconChallenge == -1 || $this->isHLTV) { $this->rconGetChallenge(); } $this->rconSend("rcon {$this->rconChallenge} $password $command"); if($this->isHLTV) { try { $response = $this->getReply...
php
{ "resource": "" }
q257554
GoldSrcSocket.rconGetChallenge
test
public function rconGetChallenge() { $this->rconSend('challenge rcon'); $response = trim($this->getReply()->getResponse());
php
{ "resource": "" }
q257555
GoldSrcSocket.rconSend
test
public function rconSend($command) { $this->send(new
php
{ "resource": "" }
q257556
TCPSocket.connect
test
public function connect($ipAddress, $portNumber, $timeout) { $this->ipAddress = $ipAddress; $this->portNumber = $portNumber; if($this->socketsEnabled) { if (!$this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) { throw new SocketException(socket_last_error($...
php
{ "resource": "" }
q257557
MasterServer.getServers
test
public function getServers($regionCode = MasterServer::REGION_ALL , $filter = '', $force = false) { $failCount = 0; $finished = false; $portNumber = 0; $hostName = '0.0.0.0'; $serverArray = []; while(true) { $failCount = 0; try { ...
php
{ "resource": "" }
q257558
GameItemSchema.internalFetch
test
public function internalFetch() { $params = ['language' => $this->language]; $data = WebApi::getJSONData("IEconItems_{$this->appId}", 'GetSchema', 1, $params); $this->attributes = []; foreach ($data->attributes as $attribute) { $this->attributes[$attribute->defindex] = $attr...
php
{ "resource": "" }
q257559
SteamId.convertCommunityIdToSteamId
test
public static function convertCommunityIdToSteamId($communityId) { $steamId1 = bcmod($communityId, 2); $steamId2 = bcsub($communityId, 76561197960265728);
php
{ "resource": "" }
q257560
SteamId.convertSteamIdToCommunityId
test
public static function convertSteamIdToCommunityId($steamId) { if($steamId == 'STEAM_ID_LAN' || $steamId == 'BOT') { throw new SteamCondenserException("Cannot convert SteamID \"$steamId\" to a community ID."); } if (preg_match('/^STEAM_[0-1]:[0-1]:[0-9]+$/', $steamId)) { ...
php
{ "resource": "" }
q257561
SteamId.resolveVanityUrl
test
public static function resolveVanityUrl($vanityUrl) { $params = ['vanityurl' => $vanityUrl]; $result = WebApi::getJSONObject('ISteamUser', 'ResolveVanityURL', 1, $params); $result = $result->response;
php
{ "resource": "" }
q257562
SteamId.fetchFriends
test
public function fetchFriends() { $friendsData = $this->getData($this->getBaseUrl() . '/friends?xml=1'); $this->friends = []; foreach($friendsData->friends->friend as $friend) {
php
{ "resource": "" }
q257563
SteamId.fetchGames
test
public function fetchGames() { $params = [ 'steamid' => $this->getSteamId64(), 'include_appinfo' => 1, 'include_played_free_games' => 1 ]; $gamesData = WebApi::getJSONObject('IPlayerService', 'GetOwnedGames', 1, $params); foreach ($gamesDa...
php
{ "resource": "" }
q257564
SteamId.fetchGroups
test
public function fetchGroups() { $params = ['steamid' => $this->getSteamId64()]; $result = WebApi::getJSONObject('ISteamUser', 'GetUserGroupList', 1, $params);
php
{ "resource": "" }
q257565
SteamId.getSteamId64
test
public function getSteamId64() { if (empty($this->steamId64)) {
php
{ "resource": "" }
q257566
SteamId.getRecentPlaytime
test
public function getRecentPlaytime($appId) { if (empty($this->playtimes)) { $this->fetchGames();
php
{ "resource": "" }
q257567
SteamId.getTotalPlaytime
test
public function getTotalPlaytime($appId) { if (empty($this->playtimes)) { $this->fetchGames();
php
{ "resource": "" }
q257568
SteamId.internalFetch
test
protected function internalFetch() { $profile = $this->getData($this->getBaseUrl() . '?xml=1'); if(!empty($profile->error)) { throw new SteamCondenserException((string) $profile->error); } if(!empty($profile->privacyMessage)) { throw new SteamCondenserException(...
php
{ "resource": "" }
q257569
Server.rotateIp
test
public function rotateIp() { if(sizeof($this->ipAddresses) == 1) { return true; } $this->ipIndex = ($this->ipIndex + 1) % sizeof($this->ipAddresses); $this->ipAddress =
php
{ "resource": "" }
q257570
SourceServer.initSocket
test
public function initSocket() { $this->rconSocket = new Sockets\RCONSocket($this->ipAddress, $this->port);
php
{ "resource": "" }
q257571
SourceServer.rconAuth
test
public function rconAuth($password) { $this->rconRequestId = $this->generateRconRequestId(); $this->rconSocket->send(new Packets\RCON\RCONAuthRequest($this->rconRequestId, $password)); $reply = $this->rconSocket->getReply(); if ($reply == null) { throw new
php
{ "resource": "" }
q257572
UDPSocket.connect
test
public function connect($ipAddress, $portNumber, $timeout) { $this->ipAddress = $ipAddress; $this->portNumber = $portNumber; if($this->socketsEnabled) { if(!$this->socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP)) { throw new SocketException(socket_last_error($th...
php
{ "resource": "" }
q257573
Cacheable.create
test
public static function create() { $args = func_get_args(); $className = empty(self::$className) ? get_class() : self::$className; $class = new \ReflectionClass($className); $constructor = $class->getConstructor(); $arity = $constructor->getNumberOfParameters(); if (sizeo...
php
{ "resource": "" }
q257574
Cacheable.cachedInstance
test
protected function cachedInstance() { $findInstance = function($id, $cache) use (&$findInstance) { self::selectIds($id, $ids); if (array_key_exists($id, $cache)) { return (empty($ids)) ? $cache[$id] : $findInstance($id, $cache[$id]); }...
php
{ "resource": "" }
q257575
Cacheable.isCached
test
public static function isCached($id) { $findId = function($id, $cache) use (&$findId) { self::selectIds($id, $ids); if (array_key_exists($id, $cache)) {
php
{ "resource": "" }
q257576
Cacheable.cache
test
protected function cache() { $cacheInstance = function($id, &$cache) use (&$cacheInstance) { self::selectIds($id, $ids); if (empty($ids)) {
php
{ "resource": "" }
q257577
Cacheable.cacheIds
test
protected function cacheIds() { $values = function($id) use (&$values) { return is_array($id) ? array_map($values, $id) : $this->{$id};
php
{ "resource": "" }
q257578
GoldSrcServer.initSocket
test
public function initSocket() { $this->socket =
php
{ "resource": "" }
q257579
GoldSrcServer.rconAuth
test
public function rconAuth($password) { $this->rconPassword = $password; try { $this->rconAuthenticated = true;
php
{ "resource": "" }
q257580
Socket.close
test
public function close() { if(!empty($this->socket)) { if($this->socketsEnabled) { socket_close($this->socket); } else {
php
{ "resource": "" }
q257581
Socket.recv
test
public function recv($length = 128) { if($this->socketsEnabled) { $data = socket_read($this->socket, $length); if ($data === false) { $errorCode = socket_last_error($this->socket); if (defined('SOCKET_ECONNRESET') && $errorCode == ...
php
{ "resource": "" }
q257582
Socket.select
test
public function select($timeout = 0) { $read = [$this->socket]; $write = null; $except = null; $sec = floor($timeout / 1000); $usec = $timeout % 1000; if($this->socketsEnabled) { $select = socket_select($read, $write, $except, $sec, $usec);
php
{ "resource": "" }
q257583
Socket.send
test
public function send($data) { if($this->socketsEnabled) { $sendResult = socket_send($this->socket, $data, strlen($data), 0); if ($sendResult === false) { throw new SocketException(socket_last_error($this->socket)); } } else {
php
{ "resource": "" }
q257584
AppNews.getNewsForApp
test
public static function getNewsForApp($appId, $count = 5, $maxLength = null) { $params = ['appid' => $appId, 'count' => $count, 'maxlength' => $maxLength]; $data = WebApi::getJSONObject('ISteamNews', 'GetNewsForApp', 2, $params); $newsItems = [];
php
{ "resource": "" }
q257585
TF2Item.getClassesEquipped
test
public function getClassesEquipped() { $classesEquipped = []; foreach($this->equipped as $classId => $equipped)
php
{ "resource": "" }
q257586
SteamGroup.getMemberCount
test
public function getMemberCount() { if(empty($this->memberCount)) { $totalPages = $this->fetchPage(1);
php
{ "resource": "" }
q257587
SteamGroup.getMembers
test
public function getMembers() { if(sizeof($this->members) != $this->memberCount) {
php
{ "resource": "" }
q257588
SteamGroup.fetchPage
test
private function fetchPage($page) { $url = "{$this->getBaseUrl()}/memberslistxml?p=$page"; $memberData = $this->getData($url); if($page == 1) { preg_match('/\/([0-9a-f]+)\.jpg$/', (string) $memberData->groupDetails->avatarIcon, $matches); $this->avatarHash = $matches[1];...
php
{ "resource": "" }
q257589
SteamGroup.internalFetch
test
protected function internalFetch() { if(empty($this->memberCount) || sizeof($this->members) == $this->memberCount) { $page = 0; } else { $page = 1;
php
{ "resource": "" }
q257590
GameInventory.getItemSchema
test
public function getItemSchema() { if ($this->itemSchema == null) { $this->itemSchema = GameItemSchema::create($this->appId,
php
{ "resource": "" }
q257591
GameInventory.internalFetch
test
protected function internalFetch() { $params = ['SteamID' => $this->steamId64]; $result = WebApi::getJSONData("IEconItems_{$this->getAppId()}", 'GetPlayerItems', 1, $params); $this->items = []; $this->preliminaryItems = []; foreach ($result->items as $itemData) { if ...
php
{ "resource": "" }
q257592
Portal2Item.getBotsEquipped
test
public function getBotsEquipped() { $botsEquipped = []; foreach($this->equipped as $botId => $equipped)
php
{ "resource": "" }
q257593
TF2GoldenWrench.getGoldenWrenches
test
public static function getGoldenWrenches() { if(self::$goldenWrenches == null) { self::$goldenWrenches = []; $data = WebApi::getJSONObject('ITFItems_440', 'GetGoldenWrenches', 2);
php
{ "resource": "" }
q257594
WebApi.setApiKey
test
public static function setApiKey($apiKey) { if($apiKey != null && !preg_match('/^[0-9A-F]{32}$/', $apiKey))
php
{ "resource": "" }
q257595
WebApi.request
test
protected function request($url) { $this->logger->debug("Querying Steam Web API: " . str_replace(self::$apiKey, 'SECRET', $url)); $data = file_get_contents($url); if(empty($data)) { preg_match('/^.* (\d{3}) (.*)$/', $http_response_header[0], $http_status); if($http_sta...
php
{ "resource": "" }
q257596
RCONSocket.send
test
public function send(SteamPacket $dataPacket) { if(empty($this->socket) || !$this->socket->isOpen()) { $this->socket = new TCPSocket(); $this->socket->connect($this->ipAddress,
php
{ "resource": "" }
q257597
GameServer.getPlayers
test
public function getPlayers($rconPassword = null) { if($this->playerHash ==
php
{ "resource": "" }
q257598
GameServer.handleResponseForRequest
test
protected function handleResponseForRequest($requestType, $repeatOnFailure = true) { switch($requestType) { case self::REQUEST_CHALLENGE: $expectedResponse = '\SteamCondenser\Servers\Packets\S2CCHALLENGEPacket'; $requestPacket = new A2SPLAYERPacket(); ...
php
{ "resource": "" }
q257599
GameServer.updatePing
test
public function updatePing() { $this->socket->send(new A2SINFOPacket()); $startTime = microtime(true); $this->socket->getReply(); $endTime
php
{ "resource": "" }