_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 ($method_id === 'Closure::fromcallable') { return true; } $original_method_id = $method_id; $method_id = $codebase_methods->getDeclaringMethodId($method_id); if (!$method_id) { throw new \LogicException('Declaring method for ' . $original_method_id . ' should not be null'); } $storage = $codebase_methods->getStorage($method_id); if (!$storage->is_static) { if ($self_call) { if (!$is_context_dynamic) { if (IssueBuffer::accepts( new NonStaticSelfCall( 'Method ' . $codebase_methods->getCasedMethodId($method_id) . ' is not static, but is called ' . 'using self::', $code_location ), $suppressed_issues )) {
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($possibilities)) { $unique_clause->possibilities[$var_id] = array_unique($possibilities); } } $cloned_clauses[$clause->getHash()] = $unique_clause; } // remove impossible types foreach ($cloned_clauses as $clause_a) { if (count($clause_a->possibilities) !== 1 || count(array_values($clause_a->possibilities)[0]) !== 1) { continue; } if (!$clause_a->reconcilable || $clause_a->wedge) { continue; } $clause_var = array_keys($clause_a->possibilities)[0]; $only_type = array_pop(array_values($clause_a->possibilities)[0]); $negated_clause_type = self::negateType($only_type); foreach ($cloned_clauses as $clause_b) { if ($clause_a === $clause_b || !$clause_b->reconcilable || $clause_b->wedge) { continue; } if (isset($clause_b->possibilities[$clause_var]) && in_array($negated_clause_type, $clause_b->possibilities[$clause_var], true) ) { $clause_b->possibilities[$clause_var] = array_filter( $clause_b->possibilities[$clause_var], /** * @param string $possible_type * * @return bool */ function ($possible_type) use ($negated_clause_type) { return $possible_type !== $negated_clause_type; }
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; } foreach ($clause->possibilities as $var => $possible_types) { // if there's only one possible type, return it if (count($clause->possibilities) === 1 && count($possible_types) === 1) { if (isset($truths[$var])) { $truths[$var][] = [array_pop($possible_types)]; } else { $truths[$var] = [[array_pop($possible_types)]]; } } elseif (count($clause->possibilities) === 1) { // if there's only one active clause, return all the non-negation clause members ORed together $things_that_can_be_said = array_filter( $possible_types, /** * @param string $possible_type * * @return bool * * @psalm-suppress MixedOperand */
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('/^\\\\/', '', $property_id); list($fq_class_name, $property_name) = explode('::$', $property_id); if ($this->property_existence_provider->has($fq_class_name)) { $property_exists = $this->property_existence_provider->doesPropertyExist( $fq_class_name, $property_name, $read_mode, $source, $context, $code_location ); if ($property_exists !== null) { return $property_exists; } } $class_storage = $this->classlike_storage_provider->get($fq_class_name); if (isset($class_storage->declaring_property_ids[$property_name])) { $declaring_property_class = $class_storage->declaring_property_ids[$property_name];
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 type negation if (in_array($var_id, $vars_to_update, true)) { // if we're leaving, we're effectively deleting the possibility of the if types $new_type = !$has_leaving_statements && $end_context->hasVariable($var_id) ? $end_context->vars_in_scope[$var_id] : null; $existing_type = isset($this->vars_in_scope[$var_id]) ? $this->vars_in_scope[$var_id] : null; if (!$existing_type) { if ($new_type) { $this->vars_in_scope[$var_id] = clone $new_type; $updated_vars[$var_id] = true; }
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 ' . $path . '. Have you run \'psalm --init\' ?' .
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 { $maybe_path
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, $file_contents);
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; } $j = $i; while ($j < $c && $diff[$j]->type === DiffElem::TYPE_REMOVE) { $j++; } $k = $j; while ($k < $c && $diff[$k]->type === DiffElem::TYPE_ADD) { $k++; } if ($j - $i === $k - $j) { $len = $j - $i; for ($n = 0; $n < $len; $n++) { $newDiff[] = new DiffElem(
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) $fragments['path']); if (strpos($filepath,
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) { try { if ($element->isDisplayed()) {
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, $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( $visibility_of_element_located->getApply(), $driver );
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; } ); } else { if ($element_or_by instanceof WebDriverBy) { return new static( function (WebDriver $driver) use ($element_or_by, $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'); $zip = new ZipArchive(); if ($zip->open($temp_zip, ZipArchive::CREATE) !== true) { return false; } $info = pathinfo($local_file); $file_name = $info['basename']; $zip->addFile($local_file, $file_name); $zip->close();
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_capabilities = null ) { $selenium_server_url = preg_replace('#/+$#', '', $selenium_server_url); $desired_capabilities = self::castToDesiredCapabilitiesObject($desired_capabilities); $executor = new HttpCommandExecutor($selenium_server_url, $http_proxy, $http_proxy_port); if ($connection_timeout_in_ms !== null) { $executor->setConnectionTimeout($connection_timeout_in_ms);
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: throw new NoStringException($message, $results); case 4: throw new NoStringLengthException($message, $results); case 5: throw new NoStringWrapperException($message, $results); case 6: throw new NoSuchDriverException($message, $results); case 7: throw new NoSuchElementException($message, $results); case 8: throw new NoSuchFrameException($message, $results); case 9: throw new UnknownCommandException($message, $results); case 10: throw new StaleElementReferenceException($message, $results); case 11: throw new ElementNotVisibleException($message, $results); case 12: throw new InvalidElementStateException($message, $results); case 13: throw new UnknownServerException($message, $results); case 14: throw new ExpectedException($message, $results); case 15: throw new ElementNotSelectableException($message, $results); case 16: throw new NoSuchDocumentException($message, $results); case 17: throw new UnexpectedJavascriptException($message, $results); case 18: throw new NoScriptResultException($message, $results); case 19: throw new XPathLookupException($message, $results); case 20: throw new NoSuchCollectionException($message, $results); case 21: throw new TimeOutException($message, $results); case 22: throw new NullPointerException($message, $results); case 23:
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['HTTP_USER_AGENT'] = ''; foreach ($ctx['headers'] as $key => $value) {
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; } if (UPLOAD_ERR_OK === $f['error']) { $stream = $this->streamFactory->createStreamFromFile($f['tmpName']); } else { $stream = $this->streamFactory->createStream(); }
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); } // no context for the termination. $header = null;
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) { throw new RoadRunnerException("invalid task context, JSON payload is expected"); } // PID negotiation (socket connections only) if (!empty($p['pid'])) { $this->relay->send(
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['privacy'])) { $privacyClass = $fieldObject->config['privacy']; // If privacy given as a closure if(is_callable($privacyClass) && call_user_func($privacyClass, self::$args) === false) { $selectable = null; } // If Privacy class given elseif(is_string($privacyClass)) { if(array_has(self::$privacyValidations, $privacyClass)) {
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(',', $always); }
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['operations'], true); if (isset($result['operationName'])) { $result['operation'] = $result['operationName']; unset($result['operationName']); } foreach ($map as $fileKey => $locations) { foreach ($locations as $location) {
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' ); } if (!is_array($bodyParams)) { throw new RequestError( 'GraphQL Server expects JSON object or array, but got ' . Utils::printSafeJson($bodyParams)
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'); $queryComplexity->setMaxQueryComplexity($maxQueryComplexity); } $maxQueryDepth = config('graphql.security.query_max_depth'); if ($maxQueryDepth !== null) { /** @var QueryDepth $queryDepth */ $queryDepth = DocumentValidator::getRule('QueryDepth'); $queryDepth->setMaxQueryDepth($maxQueryDepth); }
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'), 'featured_image' => request('featured_image'), 'featured_image_caption' => request('featured_image_caption', ''), 'publish_date' => request('publish_date', ''), 'meta' => request('meta', (object) []), ]; validator($data, [ 'publish_date' => 'required|date', 'author_id' => 'required',
php
{ "resource": "" }