_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q14100
MethodAnalyzer.checkStatic
train
public static function checkStatic( $method_id, $self_call, $is_context_dynamic, Codebase $codebase, CodeLocation $code_location, array $suppressed_issues, &$is_dynamic_this_method = false ) { $codebase_methods = $codebase->methods; if ($metho...
php
{ "resource": "" }
q14101
Algebra.simplifyCNF
train
public static function simplifyCNF(array $clauses) { $cloned_clauses = []; // avoid strict duplicates foreach ($clauses as $clause) { $unique_clause = clone $clause; foreach ($unique_clause->possibilities as $var_id => $possibilities) { if (count($pos...
php
{ "resource": "" }
q14102
Algebra.getTruthsFromFormula
train
public static function getTruthsFromFormula( array $clauses, array &$cond_referenced_var_ids = [] ) { $truths = []; if (empty($clauses)) { return []; } foreach ($clauses as $clause) { if (!$clause->reconcilable) { continue; ...
php
{ "resource": "" }
q14103
TextDocument.publishDiagnostics
train
public function publishDiagnostics(string $uri, array $diagnostics): Promise { return $this->handler->notify('textDocument/publishDiagnostics', [
php
{ "resource": "" }
q14104
TextDocument.xcontent
train
public function xcontent(TextDocumentIdentifier $textDocument): Promise { return call( /** * @return \Generator<int, mixed, mixed, TextDocumentItem> */ function () use ($textDocument) {
php
{ "resource": "" }
q14105
StatementsAnalyzer.getFirstAppearance
train
public function getFirstAppearance($var_id) { return
php
{ "resource": "" }
q14106
Properties.propertyExists
train
public function propertyExists( string $property_id, bool $read_mode, StatementsSource $source = null, Context $context = null, CodeLocation $code_location = null ) { // remove trailing backslash if it exists $property_id = preg_replace('/^\\\\/', '', $propert...
php
{ "resource": "" }
q14107
Context.update
train
public function update( Context $start_context, Context $end_context, $has_leaving_statements, array $vars_to_update, array &$updated_vars ) { foreach ($start_context->vars_in_scope as $var_id => $old_type) { // this is only true if there was some sort of ...
php
{ "resource": "" }
q14108
Config.getConfigForPath
train
public static function getConfigForPath($path, $base_dir, $output_format) { $config_path = self::locateConfigFile($path); if (!$config_path) { if ($output_format === ProjectAnalyzer::TYPE_CONSOLE) { exit( 'Could not locate a config XML file in path ' ...
php
{ "resource": "" }
q14109
Config.locateConfigFile
train
public static function locateConfigFile(string $path) { $dir_path = realpath($path); if ($dir_path === false) { throw new ConfigException('Config not found for path ' . $path); } if (!is_dir($dir_path)) { $dir_path = dirname($dir_path); } do...
php
{ "resource": "" }
q14110
Config.loadFromXMLFile
train
public static function loadFromXMLFile($file_path, $base_dir) { $file_contents = file_get_contents($file_path); if ($file_contents === false) { throw new \InvalidArgumentException('Cannot open ' . $file_path); } try { $config = self::loadFromXML($base_dir, $...
php
{ "resource": "" }
q14111
FileDiffer.coalesceReplacements
train
private static function coalesceReplacements(array $diff) { $newDiff = []; $c = \count($diff); for ($i = 0; $i < $c; $i++) { $diffType = $diff[$i]->type; if ($diffType !== DiffElem::TYPE_REMOVE) { $newDiff[] = $diff[$i]; continue; ...
php
{ "resource": "" }
q14112
Codebase.scanFiles
train
public function scanFiles(int $threads = 1) { $has_changes = $this->scanner->scanFiles($this->classlikes, $threads);
php
{ "resource": "" }
q14113
Codebase.isTypeContainedByType
train
public function isTypeContainedByType( Type\Union $input_type, Type\Union $container_type
php
{ "resource": "" }
q14114
Codebase.canTypeBeContainedByType
train
public function canTypeBeContainedByType( Type\Union $input_type, Type\Union $container_type
php
{ "resource": "" }
q14115
FunctionDocblockManipulator.setReturnType
train
public function setReturnType($php_type, $new_type, $phpdoc_type, $is_php_compatible, $description) { $new_type = str_replace(['<mixed, mixed>', '<array-key, mixed>', '<empty, empty>'], '', $new_type);
php
{ "resource": "" }
q14116
FunctionDocblockManipulator.setParamType
train
public function setParamType($param_name, $php_type, $new_type, $phpdoc_type, $is_php_compatible) { $new_type = str_replace(['<mixed, mixed>', '<array-key, mixed>', '<empty, empty>'], '', $new_type); if ($php_type) { $this->new_php_param_types[$param_name] = $php_type; }
php
{ "resource": "" }
q14117
LanguageServer.pathToUri
train
public static function pathToUri(string $filepath): string { $filepath = trim(str_replace('\\', '/', $filepath), '/'); $parts = explode('/', $filepath); // Don't %-encode the colon after a Windows drive letter $first = array_shift($parts); if (substr($first, -1) !== ':') { ...
php
{ "resource": "" }
q14118
LanguageServer.uriToPath
train
public static function uriToPath(string $uri) { $fragments = parse_url($uri); if ($fragments === false || !isset($fragments['scheme']) || $fragments['scheme'] !== 'file') { throw new \InvalidArgumentException("Not a valid file URI: $uri"); } $filepath = urldecode((string)...
php
{ "resource": "" }
q14119
FunctionLikeAnalyzer.addReturnTypes
train
public function addReturnTypes(Context $context) { if ($this->return_vars_in_scope !== null) { $this->return_vars_in_scope = TypeAnalyzer::combineKeyedTypes( $context->vars_in_scope, $this->return_vars_in_scope ); } else {
php
{ "resource": "" }
q14120
ClientHandler.notify
train
public function notify(string $method, $params): Promise { return $this->protocolWriter->write(
php
{ "resource": "" }
q14121
WebDriverActions.moveByOffset
train
public function moveByOffset($x_offset, $y_offset) { $this->action->addAction(
php
{ "resource": "" }
q14122
Cookie.setDomain
train
public function setDomain($domain) { if (mb_strpos($domain, ':') !== false) { throw
php
{ "resource": "" }
q14123
RemoteKeyboard.sendKeys
train
public function sendKeys($keys) { $this->executor->execute(DriverCommand::SEND_KEYS_TO_ACTIVE_ELEMENT, [
php
{ "resource": "" }
q14124
RemoteKeyboard.pressKey
train
public function pressKey($key) { $this->executor->execute(DriverCommand::SEND_KEYS_TO_ACTIVE_ELEMENT, [
php
{ "resource": "" }
q14125
RemoteKeyboard.releaseKey
train
public function releaseKey($key) { $this->executor->execute(DriverCommand::SEND_KEYS_TO_ACTIVE_ELEMENT, [
php
{ "resource": "" }
q14126
WebDriverExpectedCondition.titleContains
train
public static function titleContains($title) { return new static( function (WebDriver $driver) use ($title) {
php
{ "resource": "" }
q14127
WebDriverExpectedCondition.titleMatches
train
public static function titleMatches($titleRegexp) { return new static( function (WebDriver $driver) use ($titleRegexp) {
php
{ "resource": "" }
q14128
WebDriverExpectedCondition.urlContains
train
public static function urlContains($url) { return new static( function (WebDriver $driver) use ($url) {
php
{ "resource": "" }
q14129
WebDriverExpectedCondition.urlMatches
train
public static function urlMatches($urlRegexp) { return new static( function (WebDriver $driver) use ($urlRegexp) {
php
{ "resource": "" }
q14130
WebDriverExpectedCondition.presenceOfAllElementsLocatedBy
train
public static function presenceOfAllElementsLocatedBy(WebDriverBy $by) { return new static( function (WebDriver $driver) use ($by) {
php
{ "resource": "" }
q14131
WebDriverExpectedCondition.visibilityOfElementLocated
train
public static function visibilityOfElementLocated(WebDriverBy $by) { return new static( function (WebDriver $driver) use ($by) { try { $element = $driver->findElement($by);
php
{ "resource": "" }
q14132
WebDriverExpectedCondition.visibilityOfAnyElementLocated
train
public static function visibilityOfAnyElementLocated(WebDriverBy $by) { return new static( function (WebDriver $driver) use ($by) { $elements = $driver->findElements($by); $visibleElements = []; foreach ($elements as $element) { ...
php
{ "resource": "" }
q14133
WebDriverExpectedCondition.elementTextMatches
train
public static function elementTextMatches(WebDriverBy $by, $regexp) { return new static( function (WebDriver $driver) use ($by, $regexp) { try { return (bool) preg_match($regexp, $driver->findElement($by)->getText());
php
{ "resource": "" }
q14134
WebDriverExpectedCondition.elementValueContains
train
public static function elementValueContains(WebDriverBy $by, $text) { return new static( function (WebDriver $driver) use ($by, $text) { try { $element_text = $driver->findElement($by)->getAttribute('value'); return mb_strpos($element_text...
php
{ "resource": "" }
q14135
WebDriverExpectedCondition.frameToBeAvailableAndSwitchToIt
train
public static function frameToBeAvailableAndSwitchToIt($frame_locator) { return new static( function (WebDriver $driver) use ($frame_locator) { try {
php
{ "resource": "" }
q14136
WebDriverExpectedCondition.invisibilityOfElementLocated
train
public static function invisibilityOfElementLocated(WebDriverBy $by) { return new static( function (WebDriver $driver) use ($by) { try { return !$driver->findElement($by)->isDisplayed(); } catch (NoSuchElementException $e) {
php
{ "resource": "" }
q14137
WebDriverExpectedCondition.invisibilityOfElementWithText
train
public static function invisibilityOfElementWithText(WebDriverBy $by, $text) { return new static( function (WebDriver $driver) use ($by, $text) { try { return !($driver->findElement($by)->getText() === $text); } catch (NoSuchElementException $e...
php
{ "resource": "" }
q14138
WebDriverExpectedCondition.elementToBeClickable
train
public static function elementToBeClickable(WebDriverBy $by) { $visibility_of_element_located = self::visibilityOfElementLocated($by); return new static( function (WebDriver $driver) use ($visibility_of_element_located) { $element = call_user_func( ...
php
{ "resource": "" }
q14139
WebDriverExpectedCondition.stalenessOf
train
public static function stalenessOf(WebDriverElement $element) { return new static( function () use ($element) { try {
php
{ "resource": "" }
q14140
WebDriverExpectedCondition.refreshed
train
public static function refreshed(self $condition) { return new static( function (WebDriver $driver) use ($condition) { try { return call_user_func($condition->getApply(), $driver);
php
{ "resource": "" }
q14141
WebDriverExpectedCondition.elementSelectionStateToBe
train
public static function elementSelectionStateToBe($element_or_by, $selected) { if ($element_or_by instanceof WebDriverElement) { return new static( function () use ($element_or_by, $selected) { return $element_or_by->isSelected() === $selected; ...
php
{ "resource": "" }
q14142
WebDriverExpectedCondition.not
train
public static function not(self $condition) { return new static( function (WebDriver $driver) use ($condition) {
php
{ "resource": "" }
q14143
AbstractWebDriverCheckboxOrRadio.byIndex
train
protected function byIndex($index, $select = true) { $elements = $this->getRelatedElements(); if (!isset($elements[$index])) { throw new NoSuchElementException(sprintf('Cannot locate %s with index: %d', $this->type, $index));
php
{ "resource": "" }
q14144
RemoteTargetLocator.defaultContent
train
public function defaultContent() { $params = ['id' => null];
php
{ "resource": "" }
q14145
RemoteTargetLocator.frame
train
public function frame($frame) { if ($frame instanceof WebDriverElement) { $id = ['ELEMENT' => $frame->getID()]; } else { $id = (string) $frame; }
php
{ "resource": "" }
q14146
RemoteTargetLocator.window
train
public function window($handle) { $params = ['name' => (string) $handle];
php
{ "resource": "" }
q14147
RemoteTargetLocator.activeElement
train
public function activeElement() { $response = $this->driver->execute(DriverCommand::GET_ACTIVE_ELEMENT, []);
php
{ "resource": "" }
q14148
RemoteWebElement.findElement
train
public function findElement(WebDriverBy $by) { $params = [ 'using' => $by->getMechanism(), 'value' => $by->getValue(), ':id' => $this->id, ]; $raw_element = $this->executor->execute(
php
{ "resource": "" }
q14149
RemoteWebElement.findElements
train
public function findElements(WebDriverBy $by) { $params = [ 'using' => $by->getMechanism(), 'value' => $by->getValue(), ':id' => $this->id, ]; $raw_elements = $this->executor->execute( DriverCommand::FIND_CHILD_ELEMENTS, $params ...
php
{ "resource": "" }
q14150
RemoteWebElement.getAttribute
train
public function getAttribute($attribute_name) { $params = [ ':name' => $attribute_name,
php
{ "resource": "" }
q14151
RemoteWebElement.getCSSValue
train
public function getCSSValue($css_property_name) { $params = [ ':propertyName' => $css_property_name, ':id' => $this->id, ]; return $this->executor->execute(
php
{ "resource": "" }
q14152
RemoteWebElement.getLocation
train
public function getLocation() { $location = $this->executor->execute( DriverCommand::GET_ELEMENT_LOCATION, [':id' => $this->id]
php
{ "resource": "" }
q14153
RemoteWebElement.getLocationOnScreenOnceScrolledIntoView
train
public function getLocationOnScreenOnceScrolledIntoView() { $location = $this->executor->execute(
php
{ "resource": "" }
q14154
RemoteWebElement.getSize
train
public function getSize() { $size = $this->executor->execute( DriverCommand::GET_ELEMENT_SIZE, [':id' => $this->id]
php
{ "resource": "" }
q14155
RemoteWebElement.sendKeys
train
public function sendKeys($value) { $local_file = $this->fileDetector->getLocalFile($value); if ($local_file === null) { $params = [ 'value' => WebDriverKeys::encode($value), ':id' => $this->id, ];
php
{ "resource": "" }
q14156
RemoteWebElement.upload
train
protected function upload($local_file) { if (!is_file($local_file)) { throw new WebDriverException('You may only upload files: ' . $local_file); } // Create a temporary file in the system temp directory. $temp_zip = tempnam(sys_get_temp_dir(), 'WebDriverZip'); $z...
php
{ "resource": "" }
q14157
WebDriverWindow.getPosition
train
public function getPosition() { $position = $this->executor->execute( DriverCommand::GET_WINDOW_POSITION,
php
{ "resource": "" }
q14158
WebDriverWindow.getSize
train
public function getSize() { $size = $this->executor->execute( DriverCommand::GET_WINDOW_SIZE,
php
{ "resource": "" }
q14159
WebDriverWindow.setSize
train
public function setSize(WebDriverDimension $size) { $params = [ 'width' => $size->getWidth(), 'height' => $size->getHeight(), ':windowHandle' => 'current', ];
php
{ "resource": "" }
q14160
WebDriverWindow.setPosition
train
public function setPosition(WebDriverPoint $position) { $params = [ 'x' => $position->getX(), 'y' => $position->getY(), ':windowHandle' => 'current', ];
php
{ "resource": "" }
q14161
WebDriverWindow.setScreenOrientation
train
public function setScreenOrientation($orientation) { $orientation = mb_strtoupper($orientation); if (!in_array($orientation, ['PORTRAIT', 'LANDSCAPE'])) { throw new IndexOutOfBoundsException( 'Orientation must be either PORTRAIT, or LANDSCAPE'
php
{ "resource": "" }
q14162
DesiredCapabilities.setJavascriptEnabled
train
public function setJavascriptEnabled($enabled) { $browser = $this->getBrowserName(); if ($browser && $browser !== WebDriverBrowserType::HTMLUNIT) { throw new Exception( 'isJavascriptEnabled() is a htmlunit-only option. ' . 'See
php
{ "resource": "" }
q14163
RemoteWebDriver.create
train
public static function create( $selenium_server_url = 'http://localhost:4444/wd/hub', $desired_capabilities = null, $connection_timeout_in_ms = null, $request_timeout_in_ms = null, $http_proxy = null, $http_proxy_port = null, DesiredCapabilities $required_capabili...
php
{ "resource": "" }
q14164
RemoteWebDriver.findElement
train
public function findElement(WebDriverBy $by) { $params = ['using' => $by->getMechanism(), 'value' => $by->getValue()]; $raw_element = $this->execute(
php
{ "resource": "" }
q14165
RemoteWebDriver.findElements
train
public function findElements(WebDriverBy $by) { $params = ['using' => $by->getMechanism(), 'value' => $by->getValue()]; $raw_elements = $this->execute( DriverCommand::FIND_ELEMENTS, $params );
php
{ "resource": "" }
q14166
RemoteWebDriver.get
train
public function get($url) { $params = ['url' => (string) $url];
php
{ "resource": "" }
q14167
RemoteWebDriver.executeScript
train
public function executeScript($script, array $arguments = []) { $params = [ 'script' => $script, 'args' => $this->prepareScriptArguments($arguments),
php
{ "resource": "" }
q14168
RemoteWebDriver.executeAsyncScript
train
public function executeAsyncScript($script, array $arguments = []) { $params = [ 'script' => $script,
php
{ "resource": "" }
q14169
RemoteWebDriver.takeScreenshot
train
public function takeScreenshot($save_as = null) { $screenshot = base64_decode( $this->execute(DriverCommand::SCREENSHOT)
php
{ "resource": "" }
q14170
RemoteWebDriver.getAllSessions
train
public static function getAllSessions($selenium_server_url = 'http://localhost:4444/wd/hub', $timeout_in_ms = 30000) { $executor = new HttpCommandExecutor($selenium_server_url); $executor->setConnectionTimeout($timeout_in_ms); $command = new WebDriverCommand( null,
php
{ "resource": "" }
q14171
RemoteWebDriver.prepareScriptArguments
train
protected function prepareScriptArguments(array $arguments) { $args = []; foreach ($arguments as $key => $value) { if ($value instanceof WebDriverElement) {
php
{ "resource": "" }
q14172
WebDriverPoint.move
train
public function move($new_x, $new_y) { $this->x = $new_x;
php
{ "resource": "" }
q14173
WebDriverPoint.moveBy
train
public function moveBy($x_offset, $y_offset) { $this->x += $x_offset;
php
{ "resource": "" }
q14174
WebDriverPoint.equals
train
public function equals(self $point) { return
php
{ "resource": "" }
q14175
WebDriverDimension.equals
train
public function equals(self $dimension) { return $this->height === $dimension->getHeight() &&
php
{ "resource": "" }
q14176
WebDriverOptions.addCookie
train
public function addCookie($cookie) { if (is_array($cookie)) { $cookie = Cookie::createFromArray($cookie); } if (!$cookie instanceof Cookie) { throw new InvalidArgumentException('Cookie must be set from instance of Cookie class or from array.'); }
php
{ "resource": "" }
q14177
WebDriverOptions.getCookieNamed
train
public function getCookieNamed($name) { $cookies = $this->getCookies(); foreach ($cookies as $cookie) { if ($cookie['name'] ===
php
{ "resource": "" }
q14178
WebDriverOptions.getCookies
train
public function getCookies() { $cookieArrays = $this->executor->execute(DriverCommand::GET_ALL_COOKIES);
php
{ "resource": "" }
q14179
WebDriverException.throwException
train
public static function throwException($status_code, $message, $results) { switch ($status_code) { case 1: throw new IndexOutOfBoundsException($message, $results); case 2: throw new NoCollectionException($message, $results); case 3: ...
php
{ "resource": "" }
q14180
WebDriverNavigation.to
train
public function to($url) { $params = ['url' => (string) $url];
php
{ "resource": "" }
q14181
HtmlBuilder.nestedListing
train
protected function nestedListing($key, $type, $value) { if (is_int($key)) { return $this->listing($type, $value); } else {
php
{ "resource": "" }
q14182
FormBuilder.tel
train
public function tel($name, $value = null, $options = [])
php
{ "resource": "" }
q14183
FormBuilder.month
train
public function month($name, $value = null, $options = []) { if ($value instanceof DateTime) { $value = $value->format('Y-m');
php
{ "resource": "" }
q14184
PolicyCommands.rsyncValidate
train
public function rsyncValidate(CommandData $commandData) { if (preg_match("/^@prod/", $commandData->input()->getArgument('target'))) { throw new
php
{ "resource": "" }
q14185
PSR7Client.configureServer
train
protected function configureServer(array $ctx): array { $server = $this->originalServer; $server['REQUEST_TIME'] = time(); $server['REQUEST_TIME_FLOAT'] = microtime(true); $server['REMOTE_ADDR'] = $ctx['attributes']['ipAddress'] ?? $ctx['remoteAddr'] ?? '127.0.0.1'; $server[...
php
{ "resource": "" }
q14186
PSR7Client.wrapUploads
train
private function wrapUploads($files): array { if (empty($files)) { return []; } $result = []; foreach ($files as $index => $f) { if (!isset($f['name'])) { $result[$index] = $this->wrapUploads($f); continue; } ...
php
{ "resource": "" }
q14187
PSR7Client.fetchProtocolVersion
train
private static function fetchProtocolVersion(string $version): string { $v = substr($version, 5); if ($v === '2.0') { return '2'; } // Fallback for values outside of valid protocol versions
php
{ "resource": "" }
q14188
Worker.receive
train
public function receive(&$header) { $body = $this->relay->receiveSync($flags); if ($flags & Relay::PAYLOAD_CONTROL) { if ($this->handleControl($body, $header, $flags)) { // wait for the next command return $this->receive($header); } ...
php
{ "resource": "" }
q14189
Worker.send
train
public function send(string $payload = null, string $header = null) { if (is_null($header)) { $this->relay->send($header, Relay::PAYLOAD_CONTROL | Relay::PAYLOAD_NONE); } else {
php
{ "resource": "" }
q14190
Worker.error
train
public function error(string $message) { $this->relay->send( $message,
php
{ "resource": "" }
q14191
Worker.handleControl
train
private function handleControl(string $body = null, &$header = null, int $flags = 0): bool { $header = $body; if (is_null($body) || $flags & Relay::PAYLOAD_RAW) { // empty or raw prefix return true; } $p = json_decode($body, true); if ($p === false) {...
php
{ "resource": "" }
q14192
SelectFields.validateField
train
protected static function validateField($fieldObject) { $selectable = true; // If not a selectable field if(isset($fieldObject->config['selectable']) && $fieldObject->config['selectable'] === false) { $selectable = false; } if(isset($fieldObject->config[...
php
{ "resource": "" }
q14193
SelectFields.addAlwaysFields
train
protected static function addAlwaysFields($fieldObject, array &$select, $parentTable, $forRelation = false) { if(isset($fieldObject->config['always'])) { $always = $fieldObject->config['always']; if(is_string($always)) { $always = explode(',', $al...
php
{ "resource": "" }
q14194
GraphQLUploadMiddleware.processRequest
train
public function processRequest(Request $request) { $contentType = $request->header('content-type') ?: ''; if (mb_stripos($contentType, 'multipart/form-data')
php
{ "resource": "" }
q14195
GraphQLUploadMiddleware.parseUploadedFiles
train
private function parseUploadedFiles(Request $request) { $bodyParams = $request->all(); if (!isset($bodyParams['map'])) { throw new RequestError('The request must define a `map`'); } $map = json_decode($bodyParams['map'], true); $result = json_decode($bodyParams['...
php
{ "resource": "" }
q14196
GraphQLUploadMiddleware.validateParsedBody
train
private function validateParsedBody(Request $request) { $bodyParams = $request->all(); if (null === $bodyParams) { throw new InvariantViolation( 'Request is expected to provide parsed body for "multipart/form-data" requests but got null' ); } ...
php
{ "resource": "" }
q14197
GraphQLServiceProvider.bootSchemas
train
protected function bootSchemas() { $configSchemas = config('graphql.schemas'); foreach ($configSchemas as $name => $schema) {
php
{ "resource": "" }
q14198
GraphQLServiceProvider.applySecurityRules
train
protected function applySecurityRules() { $maxQueryComplexity = config('graphql.security.query_max_complexity'); if ($maxQueryComplexity !== null) { /** @var QueryComplexity $queryComplexity */ $queryComplexity = DocumentValidator::getRule('QueryComplexity'); $que...
php
{ "resource": "" }
q14199
PostsController.store
train
public function store($id) { $data = [ 'title' => request('title'), 'excerpt' => request('excerpt', ''), 'slug' => request('slug'), 'body' => request('body', ''), 'published' => request('published'), 'author_id' => request('author_id'),...
php
{ "resource": "" }