_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q14200 | PostsController.collectTags | train | private function collectTags($incomingTags)
{
$allTags = WinkTag::all();
return collect($incomingTags)->map(function ($incomingTag) use ($allTags) {
$tag = $allTags->where('slug', Str::slug($incomingTag['name']))->first();
if (! $tag) {
$tag = WinkTag::creat... | php | {
"resource": ""
} |
q14201 | TeamController.delete | train | public function delete($id)
{
$entry = WinkAuthor::findOrFail($id);
if ($entry->posts()->count()) {
return response()->json(['message' => 'Please remove the author\'s posts first.'], 402);
}
if ($entry->id == auth('wink')->user()->id) {
return response()->js... | php | {
"resource": ""
} |
q14202 | WinkServiceProvider.registerRoutes | train | private function registerRoutes()
{
$path = config('wink.path');
$middlewareGroup = config('wink.middleware_group');
Route::namespace('Wink\Http\Controllers')
->middleware($middlewareGroup)
->as('wink.')
->prefix($path)
->group(function () {
... | php | {
"resource": ""
} |
q14203 | ForgotPasswordController.sendResetLinkEmail | train | public function sendResetLinkEmail()
{
validator(request()->all(), [
'email' => 'required|email',
])->validate();
if ($author = WinkAuthor::whereEmail(request('email'))->first()) {
cache(['password.reset.'.$author->id => $token = Str::random()],
now()... | php | {
"resource": ""
} |
q14204 | ForgotPasswordController.showNewPassword | train | public function showNewPassword($token)
{
try {
$token = decrypt($token);
[$authorId, $token] = explode('|', $token);
$author = WinkAuthor::findOrFail($authorId);
} catch (Throwable $e) {
return redirect()->route('wink.password.forgot')->with('invali... | php | {
"resource": ""
} |
q14205 | PagesController.index | train | public function index()
{
$entries = WinkPage::when(request()->has('search'), function ($q) {
$q->where('title', 'LIKE', '%'.request('search').'%');
})
->orderBy('created_at', 'DESC')
->paginate(30);
return PagesResource::collection($entries);
} | php | {
"resource": ""
} |
q14206 | Response.makeFromExisting | train | public static function makeFromExisting(IlluminateResponse $old)
{
$new = static::create($old->getOriginalContent(), $old->getStatusCode());
$new->headers = $old->headers;
return $new;
} | php | {
"resource": ""
} |
q14207 | Response.withHeader | train | public function withHeader($key, $value, $replace = true)
{
return $this->header($key, $value, $replace);
} | php | {
"resource": ""
} |
q14208 | Request.createFromIlluminate | train | public function createFromIlluminate(IlluminateRequest $old)
{
$new = new static(
$old->query->all(), $old->request->all(), $old->attributes->all(),
$old->cookies->all(), $old->files->all(), $old->server->all(), $old->content
);
if ($session = $old->getSession()) {
... | php | {
"resource": ""
} |
q14209 | Laravel.getRoutes | train | public function getRoutes($version = null)
{
if (! is_null($version)) {
return $this->routes[$version];
}
return $this->routes;
} | php | {
"resource": ""
} |
q14210 | Laravel.gatherRouteMiddlewares | train | public function gatherRouteMiddlewares($route)
{
if (method_exists($this->router, 'gatherRouteMiddleware')) {
return $this->router->gatherRouteMiddleware($route);
}
return $this->router->gatherRouteMiddlewares($route);
} | php | {
"resource": ""
} |
q14211 | Fractal.shouldEagerLoad | train | protected function shouldEagerLoad($response)
{
if ($response instanceof IlluminatePaginator) {
$response = $response->getCollection();
}
return $response instanceof EloquentCollection && $this->eagerLoading;
} | php | {
"resource": ""
} |
q14212 | Fractal.parseFractalIncludes | train | public function parseFractalIncludes(Request $request)
{
$includes = $request->input($this->includeKey);
if (! is_array($includes)) {
$includes = array_map('trim', array_filter(explode($this->includeSeparator, $includes)));
}
$this->fractal->parseIncludes($includes);
... | php | {
"resource": ""
} |
q14213 | Fractal.mergeEagerLoads | train | protected function mergeEagerLoads($transformer, $requestedIncludes)
{
$includes = array_merge($requestedIncludes, $transformer->getDefaultIncludes());
$eagerLoads = [];
foreach ($includes as $key => $value) {
$eagerLoads[] = is_string($key) ? $key : $value;
}
... | php | {
"resource": ""
} |
q14214 | Factory.item | train | public function item($item, $transformer, $parameters = [], Closure $after = null)
{
$class = get_class($item);
if ($parameters instanceof \Closure) {
$after = $parameters;
$parameters = [];
}
$binding = $this->transformer->register($class, $transformer, $pa... | php | {
"resource": ""
} |
q14215 | Binding.resolveTransformer | train | public function resolveTransformer()
{
if (is_string($this->resolver)) {
return $this->container->make($this->resolver);
} elseif (is_callable($this->resolver)) {
return call_user_func($this->resolver, $this->container);
} elseif (is_object($this->resolver)) {
... | php | {
"resource": ""
} |
q14216 | RouteCollection.addLookups | train | protected function addLookups(Route $route)
{
$action = $route->getAction();
if (isset($action['as'])) {
$this->names[$action['as']] = $route;
}
if (isset($action['controller'])) {
$this->actions[$action['controller']] = $route;
}
} | php | {
"resource": ""
} |
q14217 | RouteCollection.getByName | train | public function getByName($name)
{
return isset($this->names[$name]) ? $this->names[$name] : null;
} | php | {
"resource": ""
} |
q14218 | RouteCollection.getByAction | train | public function getByAction($action)
{
return isset($this->actions[$action]) ? $this->actions[$action] : null;
} | php | {
"resource": ""
} |
q14219 | Routes.routeRateLimit | train | protected function routeRateLimit($route)
{
list($limit, $expires) = [$route->getRateLimit(), $route->getRateLimitExpiration()];
if ($limit && $expires) {
return sprintf('%s req/s', round($limit / ($expires * 60), 2));
}
} | php | {
"resource": ""
} |
q14220 | Routes.filterByVersions | train | protected function filterByVersions(array $route)
{
foreach ($this->option('versions') as $version) {
if (Str::contains($route['versions'], $version)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q14221 | Routes.filterByScopes | train | protected function filterByScopes(array $route)
{
foreach ($this->option('scopes') as $scope) {
if (Str::contains($route['scopes'], $scope)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q14222 | Factory.register | train | public function register($class, $resolver, array $parameters = [], Closure $after = null)
{
return $this->bindings[$class] = $this->createBinding($resolver, $parameters, $after);
} | php | {
"resource": ""
} |
q14223 | Factory.transform | train | public function transform($response)
{
$binding = $this->getBinding($response);
return $this->adapter->transform($response, $binding->resolveTransformer(), $binding, $this->getRequest());
} | php | {
"resource": ""
} |
q14224 | Factory.getBinding | train | protected function getBinding($class)
{
if ($this->isCollection($class) && ! $class->isEmpty()) {
return $this->getBindingFromCollection($class);
}
$class = is_object($class) ? get_class($class) : $class;
if (! $this->hasBinding($class)) {
throw new RuntimeE... | php | {
"resource": ""
} |
q14225 | Factory.createBinding | train | protected function createBinding($resolver, array $parameters = [], Closure $callback = null)
{
return new Binding($this->container, $resolver, $parameters, $callback);
} | php | {
"resource": ""
} |
q14226 | Factory.hasBinding | train | protected function hasBinding($class)
{
if ($this->isCollection($class) && ! $class->isEmpty()) {
$class = $class->first();
}
$class = is_object($class) ? get_class($class) : $class;
return isset($this->bindings[$class]);
} | php | {
"resource": ""
} |
q14227 | Factory.getRequest | train | public function getRequest()
{
$request = $this->container['request'];
if ($request instanceof IlluminateRequest && ! $request instanceof Request) {
$request = (new Request())->createFromIlluminate($request);
}
return $request;
} | php | {
"resource": ""
} |
q14228 | Lumen.normalizeRequestUri | train | protected function normalizeRequestUri(Request $request)
{
$query = $request->server->get('QUERY_STRING');
$uri = '/'.trim(str_replace('?'.$query, '', $request->server->get('REQUEST_URI')), '/').($query ? '?'.$query : '');
$request->server->set('REQUEST_URI', $uri);
} | php | {
"resource": ""
} |
q14229 | Lumen.breakUriSegments | train | protected function breakUriSegments($uri)
{
if (! Str::contains($uri, '?}')) {
return (array) $uri;
}
$segments = preg_split(
'/\/(\{.*?\})/',
preg_replace('/\{(.*?)\?\}/', '{$1}', $uri),
-1,
PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_N... | php | {
"resource": ""
} |
q14230 | Lumen.removeMiddlewareFromApp | train | protected function removeMiddlewareFromApp()
{
if ($this->middlewareRemoved) {
return;
}
$this->middlewareRemoved = true;
$reflection = new ReflectionClass($this->app);
$property = $reflection->getProperty('middleware');
$property->setAccessible(true);
... | php | {
"resource": ""
} |
q14231 | Lumen.getIterableRoutes | train | public function getIterableRoutes($version = null)
{
$iterable = [];
foreach ($this->getRoutes($version) as $version => $collector) {
$routeData = $collector->getData();
// The first element in the array are the static routes that do not have any parameters.
for... | php | {
"resource": ""
} |
q14232 | Request.terminate | train | public function terminate($request, $response)
{
if (! ($request = $this->app['request']) instanceof HttpRequest) {
return;
}
// Laravel's route middlewares can be terminated just like application
// middleware, so we'll gather all the route middleware here.
// O... | php | {
"resource": ""
} |
q14233 | Route.setupRouteProperties | train | protected function setupRouteProperties(Request $request, $route)
{
list($this->uri, $this->methods, $this->action) = $this->adapter->getRouteProperties($route, $request);
$this->versions = Arr::pull($this->action, 'version');
$this->conditionalRequest = Arr::pull($this->action, 'conditiona... | php | {
"resource": ""
} |
q14234 | Route.mergeControllerProperties | train | protected function mergeControllerProperties()
{
if (isset($this->action['uses']) && is_string($this->action['uses']) && Str::contains($this->action['uses'],
'@')) {
$this->action['controller'] = $this->action['uses'];
$this->makeControllerInstance();
}
... | php | {
"resource": ""
} |
q14235 | Route.findControllerPropertyOptions | train | protected function findControllerPropertyOptions($name)
{
$properties = [];
foreach ($this->getControllerInstance()->{'get'.ucfirst($name)}() as $property) {
if (isset($property['options']) && ! $this->optionsApplyToControllerMethod($property['options'])) {
continue;
... | php | {
"resource": ""
} |
q14236 | Route.optionsApplyToControllerMethod | train | protected function optionsApplyToControllerMethod(array $options)
{
if (empty($options)) {
return true;
} elseif (isset($options['only']) && in_array($this->controllerMethod,
$this->explodeOnPipes($options['only']))) {
return true;
} elseif (isset($opt... | php | {
"resource": ""
} |
q14237 | Route.controllerUsesHelpersTrait | train | protected function controllerUsesHelpersTrait()
{
if (! $controller = $this->getControllerInstance()) {
return false;
}
$traits = [];
do {
$traits = array_merge(class_uses($controller, false), $traits);
} while ($controller = get_parent_class($contro... | php | {
"resource": ""
} |
q14238 | Route.makeControllerInstance | train | protected function makeControllerInstance()
{
list($this->controllerClass, $this->controllerMethod) = explode('@', $this->action['uses']);
$this->container->instance($this->controllerClass,
$this->controller = $this->container->make($this->controllerClass));
return $this->contr... | php | {
"resource": ""
} |
q14239 | Route.isProtected | train | public function isProtected()
{
if (isset($this->middleware['api.auth']) || in_array('api.auth', $this->middleware)) {
if ($this->controller && isset($this->middleware['api.auth'])) {
return $this->optionsApplyToControllerMethod($this->middleware['api.auth']);
}
... | php | {
"resource": ""
} |
q14240 | JWT.getToken | train | protected function getToken(Request $request)
{
try {
$this->validateAuthorizationHeader($request);
$token = $this->parseAuthorizationHeader($request);
} catch (Exception $exception) {
if (! $token = $request->query('token', false)) {
throw $excep... | php | {
"resource": ""
} |
q14241 | JsonOptionalFormatting.isCustomIndentStyleRequired | train | protected function isCustomIndentStyleRequired()
{
return $this->isJsonPrettyPrintEnabled() &&
isset($this->options['indent_style']) &&
in_array($this->options['indent_style'], $this->indentStyles);
} | php | {
"resource": ""
} |
q14242 | JsonOptionalFormatting.performJsonEncoding | train | protected function performJsonEncoding($content, array $jsonEncodeOptions = [])
{
$jsonEncodeOptions = $this->filterJsonEncodeOptions($jsonEncodeOptions);
$optionsBitmask = $this->calucateJsonEncodeOptionsBitmask($jsonEncodeOptions);
if (($encodedString = json_encode($content, $optionsBitm... | php | {
"resource": ""
} |
q14243 | JsonOptionalFormatting.indentPrettyPrintedJson | train | protected function indentPrettyPrintedJson($jsonString, $indentStyle, $defaultIndentSize = 2)
{
$indentChar = $this->getIndentCharForIndentStyle($indentStyle);
$indentSize = $this->getPrettyPrintIndentSize() ?: $defaultIndentSize;
// If the given indentation style is allowed to have various... | php | {
"resource": ""
} |
q14244 | JsonOptionalFormatting.peformIndentation | train | protected function peformIndentation($jsonString, $indentChar = "\t", $indentSize = 1, $defaultSpaces = 4)
{
$pattern = '/(^|\G) {'.$defaultSpaces.'}/m';
$replacement = str_repeat($indentChar, $indentSize).'$1';
return preg_replace($pattern, $replacement, $jsonString);
} | php | {
"resource": ""
} |
q14245 | ServiceProvider.config | train | protected function config($item, $instantiate = true)
{
$value = $this->app['config']->get('api.'.$item);
if (is_array($value)) {
return $instantiate ? $this->instantiateConfigValues($item, $value) : $value;
}
return $instantiate ? $this->instantiateConfigValue($item, $... | php | {
"resource": ""
} |
q14246 | ServiceProvider.instantiateConfigValues | train | protected function instantiateConfigValues($item, array $values)
{
foreach ($values as $key => $value) {
$values[$key] = $this->instantiateConfigValue($item, $value);
}
return $values;
} | php | {
"resource": ""
} |
q14247 | Accept.validate | train | public function validate(Request $request)
{
try {
$this->accept->parse($request, $this->strict);
} catch (BadRequestHttpException $exception) {
if ($request->getMethod() === 'OPTIONS') {
return true;
}
throw $exception;
}
... | php | {
"resource": ""
} |
q14248 | LaravelServiceProvider.updateRouterBindings | train | protected function updateRouterBindings()
{
foreach ($this->getRouterBindings() as $key => $binding) {
$this->app['api.router.adapter']->getRouter()->bind($key, $binding);
}
} | php | {
"resource": ""
} |
q14249 | Router.version | train | public function version($version, $second, $third = null)
{
if (func_num_args() == 2) {
list($version, $callback, $attributes) = array_merge(func_get_args(), [[]]);
} else {
list($version, $attributes, $callback) = func_get_args();
}
$attributes = array_merge... | php | {
"resource": ""
} |
q14250 | Router.resource | train | public function resource($name, $controller, array $options = [])
{
if ($this->container->bound(ResourceRegistrar::class)) {
$registrar = $this->container->make(ResourceRegistrar::class);
} else {
$registrar = new ResourceRegistrar($this);
}
$registrar->regis... | php | {
"resource": ""
} |
q14251 | Router.mergeLastGroupAttributes | train | protected function mergeLastGroupAttributes(array $attributes)
{
if (empty($this->groupStack)) {
return $this->mergeGroup($attributes, []);
}
return $this->mergeGroup($attributes, end($this->groupStack));
} | php | {
"resource": ""
} |
q14252 | Router.dispatch | train | public function dispatch(Request $request)
{
$this->currentRoute = null;
$this->container->instance(Request::class, $request);
$this->routesDispatched++;
try {
$response = $this->adapter->dispatch($request, $request->version());
} catch (Exception $exception) {... | php | {
"resource": ""
} |
q14253 | Router.createRoute | train | public function createRoute($route)
{
return new Route($this->adapter, $this->container, $this->container['request'], $route);
} | php | {
"resource": ""
} |
q14254 | Router.getRoutes | train | public function getRoutes($version = null)
{
$routes = $this->adapter->getIterableRoutes($version);
if (! is_null($version)) {
$routes = [$version => $routes];
}
$collections = [];
foreach ($routes as $key => $value) {
$collections[$key] = new Route... | php | {
"resource": ""
} |
q14255 | Router.setAdapterRoutes | train | public function setAdapterRoutes(array $routes)
{
$this->adapter->setRoutes($routes);
$this->container->instance('api.routes', $this->getRoutes());
} | php | {
"resource": ""
} |
q14256 | Auth.filterProviders | train | protected function filterProviders(array $providers)
{
if (empty($providers)) {
return $this->providers;
}
return array_intersect_key($this->providers, array_flip($providers));
} | php | {
"resource": ""
} |
q14257 | Auth.extend | train | public function extend($key, $provider)
{
if (is_callable($provider)) {
$provider = call_user_func($provider, $this->container);
}
$this->providers[$key] = $provider;
} | php | {
"resource": ""
} |
q14258 | RateLimit.handle | train | public function handle($request, Closure $next)
{
if ($request instanceof InternalRequest) {
return $next($request);
}
$route = $this->router->getCurrentRoute();
if ($route->hasThrottle()) {
$this->handler->setThrottle($route->getThrottle());
}
... | php | {
"resource": ""
} |
q14259 | RateLimit.responseWithHeaders | train | protected function responseWithHeaders($response)
{
foreach ($this->getHeaders() as $key => $value) {
$response->headers->set($key, $value);
}
return $response;
} | php | {
"resource": ""
} |
q14260 | RateLimit.getHeaders | train | protected function getHeaders()
{
return [
'X-RateLimit-Limit' => $this->handler->getThrottleLimit(),
'X-RateLimit-Remaining' => $this->handler->getRemainingLimit(),
'X-RateLimit-Reset' => $this->handler->getRateLimitReset(),
];
} | php | {
"resource": ""
} |
q14261 | Docs.getDocName | train | protected function getDocName()
{
$name = $this->option('name') ?: $this->name;
if (! $name) {
$this->comment('A name for the documentation was not supplied. Use the --name option or set a default in the configuration.');
exit;
}
return $name;
} | php | {
"resource": ""
} |
q14262 | Docs.getVersion | train | protected function getVersion()
{
$version = $this->option('use-version') ?: $this->version;
if (! $version) {
$this->comment('A version for the documentation was not supplied. Use the --use-version option or set a default in the configuration.');
exit;
}
r... | php | {
"resource": ""
} |
q14263 | Docs.getControllers | train | protected function getControllers()
{
$controllers = new Collection;
if ($controller = $this->option('use-controller')) {
$this->addControllerIfNotExists($controllers, app($controller));
return $controllers;
}
foreach ($this->router->getRoutes() as $collect... | php | {
"resource": ""
} |
q14264 | Docs.addControllerIfNotExists | train | protected function addControllerIfNotExists(Collection $controllers, $controller)
{
$class = get_class($controller);
if ($controllers->has($class)) {
return;
}
$reflection = new ReflectionClass($controller);
$interface = Arr::first($reflection->getInterfaces(),... | php | {
"resource": ""
} |
q14265 | Dispatcher.attach | train | public function attach(array $files)
{
foreach ($files as $key => $file) {
if (is_array($file)) {
$file = new UploadedFile($file['path'], basename($file['path']), $file['mime'], $file['size']);
} elseif (is_string($file)) {
$finfo = finfo_open(FILEINFO... | php | {
"resource": ""
} |
q14266 | Dispatcher.json | train | public function json($content)
{
if (is_array($content)) {
$content = json_encode($content);
}
$this->content = $content;
return $this->header('Content-Type', 'application/json');
} | php | {
"resource": ""
} |
q14267 | Dispatcher.with | train | public function with($parameters)
{
$this->parameters = array_merge($this->parameters, is_array($parameters) ? $parameters : func_get_args());
return $this;
} | php | {
"resource": ""
} |
q14268 | Dispatcher.queueRequest | train | protected function queueRequest($verb, $uri, $parameters, $content = '')
{
if (! empty($content)) {
$this->content = $content;
}
// Sometimes after setting the initial request another request might be made prior to
// internally dispatching an API request. We need to cap... | php | {
"resource": ""
} |
q14269 | Dispatcher.dispatch | train | protected function dispatch(InternalRequest $request)
{
$this->routeStack[] = $this->router->getCurrentRoute();
$this->clearCachedFacadeInstance();
try {
$this->container->instance('request', $request);
$response = $this->router->dispatch($request);
if... | php | {
"resource": ""
} |
q14270 | Json.formatEloquentModel | train | public function formatEloquentModel($model)
{
$key = Str::singular($model->getTable());
if (! $model::$snakeAttributes) {
$key = Str::camel($key);
}
return $this->encode([$key => $model->toArray()]);
} | php | {
"resource": ""
} |
q14271 | Json.formatEloquentCollection | train | public function formatEloquentCollection($collection)
{
if ($collection->isEmpty()) {
return $this->encode([]);
}
$model = $collection->first();
$key = Str::plural($model->getTable());
if (! $model::$snakeAttributes) {
$key = Str::camel($key);
... | php | {
"resource": ""
} |
q14272 | Json.encode | train | protected function encode($content)
{
$jsonEncodeOptions = [];
// Here is a place, where any available JSON encoding options, that
// deal with users' requirements to JSON response formatting and
// structure, can be conveniently applied to tweak the output.
if ($this->isJs... | php | {
"resource": ""
} |
q14273 | Handler.rateLimitRequest | train | public function rateLimitRequest(Request $request, $limit = 0, $expires = 0)
{
$this->request = $request;
// If the throttle instance is already set then we'll just carry on as
// per usual.
if ($this->throttle instanceof Throttle) {
// If the developer specified a cert... | php | {
"resource": ""
} |
q14274 | Handler.prepareCacheStore | train | protected function prepareCacheStore()
{
if ($this->retrieve('expires') != $this->throttle->getExpires()) {
$this->forget('requests');
$this->forget('expires');
$this->forget('reset');
}
} | php | {
"resource": ""
} |
q14275 | Handler.cache | train | protected function cache($key, $value, $minutes)
{
$this->cache->add($this->key($key), $value, Carbon::now()->addMinutes($minutes));
} | php | {
"resource": ""
} |
q14276 | Handler.extend | train | public function extend($throttle)
{
if (is_callable($throttle)) {
$throttle = call_user_func($throttle, $this->container);
}
$this->throttles->push($throttle);
} | php | {
"resource": ""
} |
q14277 | Autoloader.loadPlugins | train | public function loadPlugins()
{
$this->checkCache();
$this->validatePlugins();
$this->countPlugins();
array_map(static function () {
include_once WPMU_PLUGIN_DIR . '/' . func_get_args()[0];
}, array_keys(self::$cache['plugins']));
$this->pluginHooks();
... | php | {
"resource": ""
} |
q14278 | Autoloader.checkCache | train | private function checkCache()
{
$cache = get_site_option('bedrock_autoloader');
if ($cache === false || (isset($cache['plugins'], $cache['count']) && count($cache['plugins']) !== $cache['count'])) {
$this->updateCache();
return;
}
self::$cache = $cache;
... | php | {
"resource": ""
} |
q14279 | Autoloader.validatePlugins | train | private function validatePlugins()
{
foreach (self::$cache['plugins'] as $plugin_file => $plugin_info) {
if (!file_exists(WPMU_PLUGIN_DIR . '/' . $plugin_file)) {
$this->updateCache();
break;
}
}
} | php | {
"resource": ""
} |
q14280 | Autoloader.countPlugins | train | private function countPlugins()
{
if (isset(self::$count)) {
return self::$count;
}
$count = count(glob(WPMU_PLUGIN_DIR . '/*/', GLOB_ONLYDIR | GLOB_NOSORT));
if (!isset(self::$cache['count']) || $count !== self::$cache['count']) {
self::$count = $count;
... | php | {
"resource": ""
} |
q14281 | Serialization.serialize | train | public static function serialize($filename, $instance, $force = false)
{
if ($filename == '') {
throw new \danog\MadelineProto\Exception('Empty filename');
}
if ($instance->API->asyncInitPromise) {
return $instance->call(static function () use ($filename, $instance, $... | php | {
"resource": ""
} |
q14282 | ObfuscatedStream.bufferReadAsync | train | public function bufferReadAsync(int $length): \Generator
{
return @$this->decrypt->encrypt(yield $this->read_buffer->bufferRead($length));
} | php | {
"resource": ""
} |
q14283 | ObfuscatedStream.setExtra | train | public function setExtra($extra)
{
if (isset($extra['secret']) && strlen($extra['secret']) > 17) {
$extra['secret'] = hex2bin($extra['secret']);
}
if (isset($extra['secret']) && strlen($extra['secret']) == 17) {
$extra['secret'] = substr($extra['secret'], 0, 16);
... | php | {
"resource": ""
} |
q14284 | DefaultStream.read | train | public function read(): Promise
{
return $this->stream ? $this->stream->read() : new \Amp\Success(null);
} | php | {
"resource": ""
} |
q14285 | HttpStream.setExtra | train | public function setExtra($extra)
{
if (isset($extra['user']) && isset($extra['password'])) {
$this->header = \base64_encode($extra['user'].':'.$extra['password'])."\r\n";
}
} | php | {
"resource": ""
} |
q14286 | MyTelegramOrgWrapper.get_headers | train | private function get_headers($httpType, $cookies)
{
// Common header flags.
$headers = [];
$headers[] = 'Dnt: 1';
$headers[] = 'Connection: keep-alive';
$headers[] = 'Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4';
$headers[] = 'User-Agent: Mozilla/5.0 (Windows... | php | {
"resource": ""
} |
q14287 | ConnectionContext.setUri | train | public function setUri($uri): self
{
$this->uri = $uri instanceof Uri ? $uri : new Uri($uri);
return $this;
} | php | {
"resource": ""
} |
q14288 | ConnectionContext.getIntDc | train | public function getIntDc()
{
$dc = intval($this->dc);
if ($this->test) {
$dc += 10000;
}
if (strpos($this->dc, '_media')) {
$dc = -$dc;
}
return $dc;
} | php | {
"resource": ""
} |
q14289 | ConnectionContext.addStream | train | public function addStream(string $streamName, $extra = null): self
{
$this->nextStreams[] = [$streamName, $extra];
$this->key = count($this->nextStreams) - 1;
return $this;
} | php | {
"resource": ""
} |
q14290 | ConnectionContext.getStreamAsync | train | public function getStreamAsync(string $buffer = ''): \Generator
{
list($clazz, $extra) = $this->nextStreams[$this->key--];
$obj = new $clazz();
if ($obj instanceof ProxyStreamInterface) {
$obj->setExtra($extra);
}
yield $obj->connect($this, $buffer);
retu... | php | {
"resource": ""
} |
q14291 | ConnectionContext.getName | train | public function getName(): string
{
$string = $this->getStringUri();
if ($this->isSecure()) {
$string .= ' (TLS)';
}
$string .= ' DC ';
$string .= $this->getDc();
$string .= ', via ';
$string .= $this->getIpv6() ? 'ipv6' : 'ipv4';
$string .... | php | {
"resource": ""
} |
q14292 | AnnotationsBuilder.setProperties | train | private function setProperties()
{
\danog\MadelineProto\Logger::log('Generating properties...', \danog\MadelineProto\Logger::NOTICE);
$fixture = DocBlockFactory::createInstance();
$class = new \ReflectionClass(APIFactory::class);
$content = file_get_contents($filename = $class->getFi... | php | {
"resource": ""
} |
q14293 | HashedBufferedStream.getReadHash | train | public function getReadHash(): string
{
$hash = hash_final($this->read_hash, true);
if ($this->rev) {
$hash = strrev($hash);
}
$this->read_hash = null;
$this->read_check_after = 0;
$this->read_check_pos = 0;
return $hash;
} | php | {
"resource": ""
} |
q14294 | HashedBufferedStream.getWriteHash | train | public function getWriteHash(): string
{
$hash = hash_final($this->write_hash, true);
if ($this->rev) {
$hash = strrev($hash);
}
$this->write_hash = null;
$this->write_check_after = 0;
$this->write_check_pos = 0;
return $hash;
} | php | {
"resource": ""
} |
q14295 | HashedBufferedStream.bufferReadAsync | train | public function bufferReadAsync(int $length): \Generator
{
if ($this->read_check_after && $length + $this->read_check_pos >= $this->read_check_after) {
if ($length + $this->read_check_pos > $this->read_check_after) {
throw new \danog\MadelineProto\Exception('Tried to read too muc... | php | {
"resource": ""
} |
q14296 | HashedBufferedStream.setExtra | train | public function setExtra($hash)
{
$rev = strpos($hash, '_rev');
$this->rev = false;
if ($rev !== false) {
$hash = substr($hash, 0, $rev);
$this->rev = true;
}
$this->hash_name = $hash;
} | php | {
"resource": ""
} |
q14297 | FullStream.connect | train | public function connect(ConnectionContext $ctx, string $header = ''): Promise
{
$this->in_seq_no = -1;
$this->out_seq_no = -1;
$this->stream = new HashedBufferedStream();
$this->stream->setExtra('crc32b_rev');
return $this->stream->connect($ctx, $header);
} | php | {
"resource": ""
} |
q14298 | BufferedRawStream.bufferWrite | train | public function bufferWrite(string $data): Promise
{
if ($this->append_after) {
$this->append_after -= strlen($data);
if ($this->append_after === 0) {
$data .= $this->append;
$this->append = '';
} elseif ($this->append_after < 0) {
... | php | {
"resource": ""
} |
q14299 | Connection.connectAsync | train | public function connectAsync(ConnectionContext $ctx): \Generator
{
$this->API->logger->logger("Trying connection via $ctx", \danog\MadelineProto\Logger::WARNING);
$this->ctx = $ctx->getCtx();
$this->datacenter = $ctx->getDc();
$this->stream = yield $ctx->getStream();
if (iss... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.