_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q246600
InputGeneratorTrait.createUrlStatements
validation
protected function createUrlStatements(Operation $operation, $queryParamVariable) { $urlVariable = new Expr\Variable('url'); // url = /path $statements = [ new Expr\Assign($urlVariable, new Scalar\String_($operation->getPath())) ]; if ($operation->getOperation()-...
php
{ "resource": "" }
q246601
InputGeneratorTrait.createBodyStatements
validation
protected function createBodyStatements(Operation $operation, $queryParamVariable, Context $context) { $bodyParameter = null; $bodyVariable = new Expr\Variable('body'); $parameterKey = 0; if ($operation->getOperation()->getParameters()) { foreach ($operation->getOperatio...
php
{ "resource": "" }
q246602
InputGeneratorTrait.createHeaderStatements
validation
protected function createHeaderStatements(Operation $operation, $queryParamVariable) { $headerVariable = new Expr\Variable('headers'); $headers = [ new Expr\ArrayItem( new Scalar\String_($operation->getHost()), new Scalar\String_('Host') ), ...
php
{ "resource": "" }
q246603
JaneOpenApi.createContext
validation
public function createContext(Registry $registry, $name) { $schemas = array_values($registry->getSchemas()); /** @var Schema $schema */ foreach ($schemas as $schema) { $openApiSpec = $this->schemaParser->parseSchema($schema->getOrigin()); $this->chainGuesser->guessCl...
php
{ "resource": "" }
q246604
JaneOpenApi.generate
validation
public function generate(Registry $registry) { /** @var OpenApi $openApi */ $context = $this->createContext($registry, 'Client'); $files = []; foreach ($registry->getSchemas() as $schema) { $context->setCurrentSchema($schema); $files = array_merge($files,...
php
{ "resource": "" }
q246605
JaneOpenApi.fix
validation
protected function fix($directory) { if (!class_exists('PhpCsFixer\Config')) { return; } /** @var Config $fixerConfig */ $fixerConfig = $this->fixerConfig; if (null === $fixerConfig) { $fixerConfig = Config::create() ->setRiskyAllowed...
php
{ "resource": "" }
q246606
Recorder.paintPass
validation
public function paintPass($message) { parent::paintPass($message); $this->results[] = new SimpleResultOfPass(parent::getTestList(), $message); }
php
{ "resource": "" }
q246607
Recorder.paintFail
validation
public function paintFail($message) { parent::paintFail($message); $this->results[] = new SimpleResultOfFail(parent::getTestList(), $message); }
php
{ "resource": "" }
q246608
Recorder.paintException
validation
public function paintException($message) { parent::paintException($message); $this->results[] = new SimpleResultOfException(parent::getTestList(), $message); }
php
{ "resource": "" }
q246609
SimpleAttachment.asMime
validation
public function asMime() { $part = 'Content-Disposition: form-data; '; $part .= 'name="' . $this->key . '"; '; $part .= 'filename="' . $this->filename . '"'; $part .= "\r\nContent-Type: " . $this->deduceMimeType(); $part .= "\r\n\r\n" . $this->content; return $part; ...
php
{ "resource": "" }
q246610
SimpleAttachment.isOnlyAscii
validation
protected function isOnlyAscii($ascii) { for ($i = 0, $length = strlen($ascii); $i < $length; $i++) { if (ord($ascii[$i]) > 127) { return false; } } return true; }
php
{ "resource": "" }
q246611
SimpleEncoding.add
validation
public function add($key, $value) { if ($value === false) { return; } if (is_array($value)) { foreach ($value as $item) { $this->addPair($key, $item); } } else { $this->addPair($key, $value); } }
php
{ "resource": "" }
q246612
SimpleEncoding.attach
validation
public function attach($key, $content, $filename) { $this->request[] = new SimpleAttachment($key, $content, $filename); }
php
{ "resource": "" }
q246613
SimpleEncoding.merge
validation
public function merge($query) { if (is_object($query)) { $this->request = array_merge($this->request, $query->getAll()); } elseif (is_array($query)) { foreach ($query as $key => $value) { $this->add($key, $value); } } }
php
{ "resource": "" }
q246614
SimpleEncoding.getValue
validation
public function getValue($key) { $values = array(); foreach ($this->request as $pair) { if ($pair->isKey($key)) { $values[] = $pair->getValue(); } } if (count($values) == 0) { return false; } elseif (count($values) == 1) { ...
php
{ "resource": "" }
q246615
SimpleTagBuilder.createTag
validation
public function createTag($name, $attributes) { static $map = array( 'a' => 'SimpleAnchorTag', 'title' => 'SimpleTitleTag', 'base' => 'SimpleBaseTag', 'button' => 'SimpleButtonTag', 'textarea' => 'SimpleTextAreaTag', 'op...
php
{ "resource": "" }
q246616
SimpleTagBuilder.createInputTag
validation
protected function createInputTag($attributes) { if (! isset($attributes['type'])) { return new SimpleTextTag($attributes); } $type = strtolower(trim($attributes['type'])); $map = array( 'submit' => 'SimpleSubmitTag', 'image' => 'SimpleImageS...
php
{ "resource": "" }
q246617
SimpleTagBuilder.keysToLowerCase
validation
protected function keysToLowerCase($map) { $lower = array(); foreach ($map as $key => $value) { $lower[strtolower($key)] = $value; } return $lower; }
php
{ "resource": "" }
q246618
SimpleTag.getAttribute
validation
public function getAttribute($label) { $label = strtolower($label); if (! isset($this->attributes[$label])) { return false; } return (string) $this->attributes[$label]; }
php
{ "resource": "" }
q246619
SimpleTextAreaTag.wrapIsEnabled
validation
public function wrapIsEnabled() { if ($this->getAttribute('cols')) { $wrap = $this->getAttribute('wrap'); if (($wrap === 'physical') || ($wrap === 'hard')) { return true; } } return false; }
php
{ "resource": "" }
q246620
SimpleTextAreaTag.wrap
validation
protected function wrap($text) { $text = str_replace("\r\r\n", "\r\n", str_replace("\n", "\r\n", $text)); $text = str_replace("\r\n\n", "\r\n", str_replace("\r", "\r\n", $text)); if (strncmp($text, "\r\n", strlen("\r\n")) == 0) { $text = substr($text, strlen("\r\n")); } ...
php
{ "resource": "" }
q246621
SimpleSelectionTag.setValue
validation
public function setValue($value) { for ($i = 0, $count = count($this->options); $i < $count; $i++) { if ($this->options[$i]->isValue($value)) { $this->choice = $i; return true; } } return false; }
php
{ "resource": "" }
q246622
SimpleSelectionTag.getValue
validation
public function getValue() { if ($this->choice === false) { return $this->getDefault(); } return $this->options[$this->choice]->getValue(); }
php
{ "resource": "" }
q246623
MultipleSelectionTag.setValue
validation
public function setValue($desired) { $achieved = array(); foreach ($desired as $value) { $success = false; for ($i = 0, $count = count($this->options); $i < $count; $i++) { if ($this->options[$i]->isValue($value)) { $achieved[] = $this->opt...
php
{ "resource": "" }
q246624
SimpleOptionTag.isValue
validation
public function isValue($compare) { $compare = trim($compare); if (trim($this->getValue()) == $compare) { return true; } return trim(strip_tags($this->getContent())) == $compare; }
php
{ "resource": "" }
q246625
SimpleRadioButtonTag.setValue
validation
public function setValue($value) { if ($value === false) { return parent::setValue($value); } if ($value != $this->getAttribute('value')) { return false; } return parent::setValue($value); }
php
{ "resource": "" }
q246626
SimpleTagGroup.isId
validation
public function isId($id) { for ($i = 0, $count = count($this->widgets); $i < $count; $i++) { if ($this->widgets[$i]->isId($id)) { return true; } } return false; }
php
{ "resource": "" }
q246627
SimpleTagGroup.isLabel
validation
public function isLabel($label) { for ($i = 0, $count = count($this->widgets); $i < $count; $i++) { if ($this->widgets[$i]->isLabel($label)) { return true; } } return false; }
php
{ "resource": "" }
q246628
SimpleCheckboxGroup.setValue
validation
public function setValue($values) { $values = $this->makeArray($values); if (! $this->valuesArePossible($values)) { return false; } $widgets = $this->getWidgets(); for ($i = 0, $count = count($widgets); $i < $count; $i++) { $possible = $widgets[$i]->ge...
php
{ "resource": "" }
q246629
SimpleCheckboxGroup.valuesArePossible
validation
protected function valuesArePossible($values) { $matches = array(); $widgets = &$this->getWidgets(); for ($i = 0, $count = count($widgets); $i < $count; $i++) { $possible = $widgets[$i]->getAttribute('value'); if (in_array($possible, $values)) { $match...
php
{ "resource": "" }
q246630
SimpleRadioGroup.setValue
validation
public function setValue($value) { if (! $this->valueIsPossible($value)) { return false; } $index = false; $widgets = $this->getWidgets(); for ($i = 0, $count = count($widgets); $i < $count; $i++) { if (! $widgets[$i]->setValue($value)) { ...
php
{ "resource": "" }
q246631
SimpleRadioGroup.valueIsPossible
validation
protected function valueIsPossible($value) { $widgets = $this->getWidgets(); for ($i = 0, $count = count($widgets); $i < $count; $i++) { if ($widgets[$i]->getAttribute('value') == $value) { return true; } } return false; }
php
{ "resource": "" }
q246632
SimpleRadioGroup.getValue
validation
public function getValue() { $widgets = $this->getWidgets(); for ($i = 0, $count = count($widgets); $i < $count; $i++) { if ($widgets[$i]->getValue() !== false) { return $widgets[$i]->getValue(); } } return false; }
php
{ "resource": "" }
q246633
XmlReporter.paintPass
validation
public function paintPass($message) { parent::paintPass($message); print $this->getIndent(1); print '<' . $this->namespace . 'pass>'; print $this->toParsedXml($message); print '</' . $this->namespace . "pass>\n"; }
php
{ "resource": "" }
q246634
XmlReporter.paintFail
validation
public function paintFail($message) { parent::paintFail($message); print $this->getIndent(1); print '<' . $this->namespace . 'fail>'; print $this->toParsedXml($message); print '</' . $this->namespace . "fail>\n"; }
php
{ "resource": "" }
q246635
XmlReporter.paintError
validation
public function paintError($message) { parent::paintError($message); print $this->getIndent(1); print '<' . $this->namespace . 'exception>'; print $this->toParsedXml($message); print '</' . $this->namespace . "exception>\n"; }
php
{ "resource": "" }
q246636
XmlReporter.paintException
validation
public function paintException($exception) { parent::paintException($exception); print $this->getIndent(1); print '<' . $this->namespace . 'exception>'; $message = 'Unexpected exception of type [' . get_class($exception) . '] with message [' . $exception->getMessage()...
php
{ "resource": "" }
q246637
XmlReporter.paintSkip
validation
public function paintSkip($message) { parent::paintSkip($message); print $this->getIndent(1); print '<' . $this->namespace . 'skip>'; print $this->toParsedXml($message); print '</' . $this->namespace . "skip>\n"; }
php
{ "resource": "" }
q246638
XmlReporter.paintMessage
validation
public function paintMessage($message) { parent::paintMessage($message); print $this->getIndent(1); print '<' . $this->namespace . 'message>'; print $this->toParsedXml($message); print '</' . $this->namespace . "message>\n"; }
php
{ "resource": "" }
q246639
XmlReporter.paintSignal
validation
public function paintSignal($type, $payload) { parent::paintSignal($type, $payload); print $this->getIndent(1); print '<' . $this->namespace . "signal type=\"$type\">"; print '<![CDATA[' . serialize($payload) . ']]>'; print '</' . $this->namespace . "signal>\n"; }
php
{ "resource": "" }
q246640
SimpleCookie.setHost
validation
public function setHost($host) { if ($host = $this->truncateHost($host)) { $this->host = $host; return true; } return false; }
php
{ "resource": "" }
q246641
SimpleCookie.truncateHost
validation
protected function truncateHost($host) { $tlds = SimpleUrl::getAllTopLevelDomains(); if (preg_match('/[a-z\-]+\.(' . $tlds . ')$/i', $host, $matches)) { return $matches[0]; } elseif (preg_match('/[a-z\-]+\.[a-z\-]+\.[a-z\-]+$/i', $host, $matches)) { return $matches[0]...
php
{ "resource": "" }
q246642
SimpleCookie.isValidPath
validation
public function isValidPath($path) { return (strncmp($this->fixPath($path), $this->getPath(), strlen($this->getPath())) == 0); }
php
{ "resource": "" }
q246643
SimpleCookie.isExpired
validation
public function isExpired($now) { if (! $this->expiry) { return true; } if (is_string($now)) { $now = strtotime($now); } return ($this->expiry < $now); }
php
{ "resource": "" }
q246644
SimpleCookie.fixPath
validation
protected function fixPath($path) { if (substr($path, 0, 1) != '/') { $path = '/' . $path; } if (substr($path, -1, 1) != '/') { $path .= '/'; } return $path; }
php
{ "resource": "" }
q246645
SimpleCookieJar.restartSession
validation
public function restartSession($date = false) { $surviving_cookies = array(); for ($i = 0; $i < count($this->cookies); $i++) { if (! $this->cookies[$i]->getValue()) { continue; } if (! $this->cookies[$i]->getExpiry()) { continue; ...
php
{ "resource": "" }
q246646
SimpleCookieJar.agePrematurely
validation
public function agePrematurely($interval) { for ($i = 0; $i < count($this->cookies); $i++) { $this->cookies[$i]->agePrematurely($interval); } }
php
{ "resource": "" }
q246647
SimpleCookieJar.findFirstMatch
validation
protected function findFirstMatch($cookie) { for ($i = 0; $i < count($this->cookies); $i++) { $is_match = $this->isMatch( $cookie, $this->cookies[$i]->getHost(), $this->cookies[$i]->getPath(), $this->cookies[$i]->get...
php
{ "resource": "" }
q246648
SimpleCookieJar.getCookieValue
validation
public function getCookieValue($host, $path, $name) { $longest_path = ''; foreach ($this->cookies as $cookie) { if ($this->isMatch($cookie, $host, $path, $name)) { if (strlen($cookie->getPath()) > strlen($longest_path)) { $value = $cookie->getVa...
php
{ "resource": "" }
q246649
SimpleCookieJar.isMatch
validation
protected function isMatch($cookie, $host, $path, $name) { if ($cookie->getName() != $name) { return false; } if ($host && $cookie->getHost() && ! $cookie->isValidHost($host)) { return false; } if (! $cookie->isValidPath($path)) { return fa...
php
{ "resource": "" }
q246650
SimpleCookieJar.selectAsPairs
validation
public function selectAsPairs($url) { $pairs = array(); foreach ($this->cookies as $cookie) { if ($this->isMatch($cookie, $url->getHost(), $url->getPath(), $cookie->getName())) { $pairs[] = $cookie->getName() . '=' . $cookie->getValue(); } } r...
php
{ "resource": "" }
q246651
SimpleFileSocket.close
validation
public function close() { if (!$this->is_open) { return false; } $this->is_open = false; return fclose($this->handle); }
php
{ "resource": "" }
q246652
SimpleSocket.write
validation
public function write($message) { if ($this->isError() || ! $this->isOpen()) { return false; } $count = fwrite($this->handle, $message); if (! $count) { if ($count === false) { $this->setError('Cannot write to socket'); $this->c...
php
{ "resource": "" }
q246653
SimpleSocket.read
validation
public function read() { if ($this->isError() || ! $this->isOpen()) { return false; } $raw = @fread($this->handle, $this->block_size); if ($raw === false) { $this->setError('Cannot read from socket'); $this->close(); } return $raw;...
php
{ "resource": "" }
q246654
SimpleRoute.createSocket
validation
protected function createSocket($scheme, $host, $port, $timeout) { if (in_array($scheme, array('file'))) { return new SimpleFileSocket($this->url); } elseif (in_array($scheme, array('https'))) { return new SimpleSecureSocket($host, $port, $timeout); } else { ...
php
{ "resource": "" }
q246655
SimpleProxyRoute.getRequestLine
validation
public function getRequestLine($method) { $url = $this->getUrl(); $scheme = $url->getScheme() ? $url->getScheme() : 'http'; $port = $url->getPort() ? ':' . $url->getPort() : ''; return $method . ' ' . $scheme . '://' . $url->getHost() . $port . $url->getPath() ....
php
{ "resource": "" }
q246656
SimpleHttpRequest.fetch
validation
public function fetch($timeout) { $socket = $this->route->createConnection($this->encoding->getMethod(), $timeout); if (! $socket->isError()) { $this->dispatchRequest($socket, $this->encoding); } return $this->createResponse($socket); }
php
{ "resource": "" }
q246657
SimpleHttpRequest.dispatchRequest
validation
protected function dispatchRequest($socket, $encoding) { foreach ($this->headers as $header_line) { $socket->write($header_line . "\r\n"); } if (count($this->cookies) > 0) { $socket->write('Cookie: ' . implode(';', $this->cookies) . "\r\n"); } $encodin...
php
{ "resource": "" }
q246658
SimpleHttpRequest.createResponse
validation
protected function createResponse($socket) { $response = new SimpleHttpResponse( $socket, $this->route->getUrl(), $this->encoding); $socket->close(); return $response; }
php
{ "resource": "" }
q246659
SimpleHttpHeaders.writeCookiesToJar
validation
public function writeCookiesToJar($jar, $url) { foreach ($this->cookies as $cookie) { $jar->setCookie( $cookie->getName(), $cookie->getValue(), $url->getHost(), $cookie->getPath(), $cookie->getExp...
php
{ "resource": "" }
q246660
SimpleHttpHeaders.parseHeaderLine
validation
protected function parseHeaderLine($header_line) { if (preg_match('/HTTP\/(\d+\.\d+)\s+(\d+)/i', $header_line, $matches)) { $this->http_version = $matches[1]; $this->response_code = $matches[2]; } if (preg_match('/Content-type:\s*(.*)/i', $header_line, $matches)) { ...
php
{ "resource": "" }
q246661
SimpleHttpHeaders.parseCookie
validation
protected function parseCookie($cookie_line) { $parts = explode(';', $cookie_line); $cookie = array(); preg_match('/\s*(.*?)\s*=(.*)/', array_shift($parts), $cookie); foreach ($parts as $part) { if (preg_match('/\s*(.*?)\s*=(.*)/', $part, $matches)) { $co...
php
{ "resource": "" }
q246662
SimpleHttpResponse.parse
validation
protected function parse($raw) { if (! $raw) { $this->setError('Nothing fetched'); $this->headers = new SimpleHttpHeaders(''); } elseif ('file' === $this->url->getScheme()) { $this->headers = new SimpleHttpHeaders(''); $this->content = $raw; } ...
php
{ "resource": "" }
q246663
SimpleHttpResponse.readAll
validation
protected function readAll($socket) { $all = ''; while (! $this->isLastPacket($next = $socket->read())) { $all .= $next; } return $all; }
php
{ "resource": "" }
q246664
SimpleExceptionTrappingInvoker.invoke
validation
public function invoke($method) { $trap = SimpleTest::getContext()->get('SimpleExceptionTrap'); $trap->clear(); try { $has_thrown = false; parent::invoke($method); } catch (Exception $exception) { $has_thrown = true; if (! $trap->isExpe...
php
{ "resource": "" }
q246665
SimpleExceptionTrap.expectException
validation
public function expectException($expected = false, $message = '%s') { $this->expected = $this->forceToExpectation($expected); $this->message = $message; }
php
{ "resource": "" }
q246666
SimpleExceptionTrap.isExpected
validation
public function isExpected($test, $exception) { if ($this->expected) { return $test->assert($this->expected, $exception, $this->message); } foreach ($this->ignored as $ignored) { if ($ignored->test($exception)) { return true; } } ...
php
{ "resource": "" }
q246667
SimpleExceptionTrap.forceToExpectation
validation
private function forceToExpectation($exception) { if ($exception === false) { return new AnythingExpectation(); } if (! SimpleExpectation::isExpectation($exception)) { return new ExceptionExpectation($exception); } return $exception; }
php
{ "resource": "" }
q246668
SimpleReflection.getInterfaces
validation
public function getInterfaces() { $reflection = new ReflectionClass($this->interface); if ($reflection->isInterface()) { return array($this->interface); } return $this->onlyParents($reflection->getInterfaces()); }
php
{ "resource": "" }
q246669
SimpleReflection.getInterfaceMethods
validation
public function getInterfaceMethods() { $methods = array(); $interfaces = $this->getInterfaces(); foreach ($interfaces as $interface) { $methods = array_merge($methods, get_class_methods($interface)); } return array_unique($methods); }
php
{ "resource": "" }
q246670
SimpleReflection.getParent
validation
public function getParent() { $reflection = new ReflectionClass($this->interface); $parent = $reflection->getParentClass(); if ($parent) { return $parent->getName(); } return false; }
php
{ "resource": "" }
q246671
SimpleReflection.hasFinal
validation
public function hasFinal() { $reflection = new ReflectionClass($this->interface); $methods = $reflection->getMethods(); foreach ($methods as $method) { if ($method->isFinal()) { return true; } } return false; }
php
{ "resource": "" }
q246672
SimpleReflection.onlyParents
validation
protected function onlyParents($interfaces) { $parents = array(); $blacklist = array(); foreach ($interfaces as $interface) { foreach ($interfaces as $possible_parent) { if ($interface->getName() == $possible_parent->getName()) { continue; ...
php
{ "resource": "" }
q246673
SimpleReflection.isAbstractMethod
validation
protected function isAbstractMethod($name) { $interface = new ReflectionClass($this->interface); if (! $interface->hasMethod($name)) { return false; } return $interface->getMethod($name)->isAbstract(); }
php
{ "resource": "" }
q246674
SimpleReflection.isAbstractMethodInParents
validation
public function isAbstractMethodInParents($name) { $interface = new ReflectionClass($this->interface); $parent = $interface->getParentClass(); while ($parent) { if (! $parent->hasMethod($name)) { return false; } if ($parent->getMethod($n...
php
{ "resource": "" }
q246675
SimpleReflection.isStaticMethod
validation
protected function isStaticMethod($name) { $interface = new ReflectionClass($this->interface); if (! $interface->hasMethod($name)) { return false; } return $interface->getMethod($name)->isStatic(); }
php
{ "resource": "" }
q246676
SimpleReflection.getSignature
validation
public function getSignature($name) { $interface = new ReflectionClass($this->interface); $method = $interface->getMethod($name); $abstract = ($method->isAbstract() && ! $interface->isInterface() && ! $this->isAbstractMethodInParents($name)) ? 'abstract ' : ''; if ($method->isPubli...
php
{ "resource": "" }
q246677
SimpleReflection.getParameterSignatures
validation
protected function getParameterSignatures($method) { $signatures = []; $parameters = $method->getParameters(); foreach ($parameters as $parameter) { $signature = ''; $signature .= $this->getParameterTypeHint($parameter); if ($parameter->isPassedByReference...
php
{ "resource": "" }
q246678
ParallelRegex.addPattern
validation
public function addPattern($pattern, $label = true) { $count = count($this->patterns); $this->patterns[$count] = $pattern; $this->labels[$count] = $label; $this->regex = null; }
php
{ "resource": "" }
q246679
ParallelRegex.match
validation
public function match($subject, &$match) { if (count($this->patterns) === 0) { return false; } if (! preg_match($this->getCompoundedRegex(), $subject, $matches)) { $match = ''; return false; } $match = $matches[0]; for ($i = 1; $i ...
php
{ "resource": "" }
q246680
SimpleLexer.addPattern
validation
public function addPattern($pattern, $mode = 'accept') { if (! isset($this->regexes[$mode])) { $this->regexes[$mode] = new ParallelRegex($this->case); } $this->regexes[$mode]->addPattern($pattern); if (! isset($this->mode_handlers[$mode])) { $this->mode_handle...
php
{ "resource": "" }
q246681
SimpleLexer.addEntryPattern
validation
public function addEntryPattern($pattern, $mode, $new_mode) { if (! isset($this->regexes[$mode])) { $this->regexes[$mode] = new ParallelRegex($this->case); } $this->regexes[$mode]->addPattern($pattern, $new_mode); if (! isset($this->mode_handlers[$new_mode])) { ...
php
{ "resource": "" }
q246682
SimpleLexer.parse
validation
public function parse($raw) { if (! isset($this->parser)) { return false; } $length = strlen($raw); while (is_array($parsed = $this->reduce($raw))) { list($raw, $unmatched, $matched, $mode) = $parsed; if (! $this->dispatchTokens($unmatched, $matche...
php
{ "resource": "" }
q246683
SimpleLexer.dispatchTokens
validation
protected function dispatchTokens($unmatched, $matched, $mode = false) { if (! $this->invokeParser($unmatched, LEXER_UNMATCHED)) { return false; } if (is_bool($mode)) { return $this->invokeParser($matched, LEXER_MATCHED); } if ($this->isModeEnd($mode))...
php
{ "resource": "" }
q246684
SimpleLexer.invokeParser
validation
protected function invokeParser($content, $is_match) { if (($content === '') || ($content === false)) { return true; } $handler = $this->mode_handlers[$this->mode->getCurrent()]; return $this->parser->$handler($content, $is_match); }
php
{ "resource": "" }
q246685
SimpleLexer.reduce
validation
protected function reduce($raw) { if ($action = $this->regexes[$this->mode->getCurrent()]->match($raw, $match)) { $unparsed_character_count = strpos($raw, $match); $unparsed = substr($raw, 0, $unparsed_character_count); $raw = substr($...
php
{ "resource": "" }
q246686
SimpleHtmlLexer.addSkipping
validation
protected function addSkipping() { $this->mapHandler('css', 'ignore'); $this->addEntryPattern('<style', 'text', 'css'); $this->addExitPattern('</style>', 'css'); $this->mapHandler('js', 'ignore'); $this->addEntryPattern('<script', 'text', 'js'); $this->addExitPattern(...
php
{ "resource": "" }
q246687
SimpleHtmlLexer.addInTagTokens
validation
protected function addInTagTokens() { $this->mapHandler('tag', 'acceptStartToken'); $this->addSpecialPattern('\s+', 'tag', 'ignore'); $this->addAttributeTokens(); $this->addExitPattern('/>', 'tag'); $this->addExitPattern('>', 'tag'); }
php
{ "resource": "" }
q246688
SimpleHtmlLexer.addAttributeTokens
validation
protected function addAttributeTokens() { $this->mapHandler('dq_attribute', 'acceptAttributeToken'); $this->addEntryPattern('=\s*"', 'tag', 'dq_attribute'); $this->addPattern('\\\\"', 'dq_attribute'); $this->addExitPattern('"', 'dq_attribute'); $this->mapHandler('sq_attribute...
php
{ "resource": "" }
q246689
SimpleHtmlSaxParser.acceptStartToken
validation
public function acceptStartToken($token, $event) { if ($event == LEXER_ENTER) { $this->tag = strtolower(substr($token, 1)); return true; } if ($event == LEXER_EXIT) { $success = $this->listener->startElement( $this->tag, ...
php
{ "resource": "" }
q246690
SimpleHtmlSaxParser.acceptEndToken
validation
public function acceptEndToken($token, $event) { if (! preg_match('/<\/(.*)>/', $token, $matches)) { return false; } return $this->listener->endElement(strtolower($matches[1])); }
php
{ "resource": "" }
q246691
SimpleHtmlSaxParser.acceptAttributeToken
validation
public function acceptAttributeToken($token, $event) { if ($this->current_attribute) { if ($event == LEXER_UNMATCHED) { $this->attributes[$this->current_attribute] .= html_entity_decode($token, ENT_QUOTES); } if ($event == LEXER_SPE...
php
{ "resource": "" }
q246692
SimplePhpPageBuilder.parse
validation
public function parse($response) { $this->tags = array(); $this->page = $this->createPage($response); $parser = $this->createParser($this); $parser->parse($response->getContent()); $this->acceptPageEnd(); $page = $this->page; $this->free(); return...
php
{ "resource": "" }
q246693
SimplePhpPageBuilder.startElement
validation
public function startElement($name, $attributes) { $factory = new SimpleTagBuilder(); $tag = $factory->createTag($name, $attributes); if (! $tag) { return true; } if ($tag->getTagName() === 'label') { $this->acceptLabelStart($tag); $thi...
php
{ "resource": "" }
q246694
SimplePhpPageBuilder.endElement
validation
public function endElement($name) { if ($name === 'label') { $this->acceptLabelEnd(); return true; } if ($name === 'form') { $this->acceptFormEnd(); return true; } if ($name === 'frameset') { $this->acceptFramesetE...
php
{ "resource": "" }
q246695
SimplePhpPageBuilder.hasNamedTagOnOpenTagStack
validation
protected function hasNamedTagOnOpenTagStack($name) { return isset($this->tags[$name]) && (count($this->tags[$name]) > 0); }
php
{ "resource": "" }
q246696
SimplePhpPageBuilder.addContent
validation
public function addContent($text) { if (isset($this->private_content_tag)) { $this->private_content_tag->addContent($text); } else { $this->addContentToAllOpenTags($text); } return true; }
php
{ "resource": "" }
q246697
SimplePhpPageBuilder.addContentToAllOpenTags
validation
protected function addContentToAllOpenTags($text) { foreach (array_keys($this->tags) as $name) { for ($i = 0, $count = count($this->tags[$name]); $i < $count; $i++) { $this->tags[$name][$i]->addContent($text); } } }
php
{ "resource": "" }
q246698
SimplePhpPageBuilder.addContentTagToOpenTags
validation
protected function addContentTagToOpenTags(&$tag) { if ($tag->getTagName() != 'option') { return; } foreach (array_keys($this->tags) as $name) { for ($i = 0, $count = count($this->tags[$name]); $i < $count; $i++) { $this->tags[$name][$i]->addTag($tag);...
php
{ "resource": "" }
q246699
SimplePhpPageBuilder.openTag
validation
protected function openTag($tag) { $name = $tag->getTagName(); if (! in_array($name, array_keys($this->tags))) { $this->tags[$name] = array(); } $this->tags[$name][] = $tag; }
php
{ "resource": "" }