_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q248600
PriceTransformer.getDefaultPriceMapLoader
validation
public static function getDefaultPriceMapLoader() { if (null === self::$defaultPriceMapLoader) { $currencyDir = realpath(__DIR__ . '/../../../data/prices'); self::$defaultPriceMapLoader = new PhpFileLoader(array($currencyDir)); } return self::$defaultPriceMapLoader; }
php
{ "resource": "" }
q248601
SaleItemNormalizer.getInStock
validation
private function getInStock(SaleItemInterface $item) { if (null === $subject = $this->subjectHelper->resolve($item, false)) { return INF; } if (!$subject instanceof StockSubjectInterface) { return INF; } if ($subject->isStockCompound()) { return INF; } if ($subject->getStockMode() === StockSubjectModes::MODE_DISABLED) { return INF; } return $subject->getInStock(); }
php
{ "resource": "" }
q248602
SaleUpdater.updateWeightTotal
validation
protected function updateWeightTotal(SaleInterface $sale) { $weightTotal = $this->weightCalculator->calculateSale($sale); if ($sale->getWeightTotal() != $weightTotal) { $sale->setWeightTotal($weightTotal); return true; } return false; }
php
{ "resource": "" }
q248603
SaleUpdater.updateAmountsTotal
validation
protected function updateAmountsTotal(SaleInterface $sale) { $changed = false; $currency = $sale->getCurrency()->getCode(); $sale->clearResults(); $result = $this->amountCalculator->calculateSale($sale); if (0 != Money::compare($result->getBase(), $sale->getNetTotal(), $currency)) { $sale->setNetTotal($result->getBase()); $changed = true; } if (0 != Money::compare($result->getTotal(), $sale->getGrandTotal(), $currency)) { $sale->setGrandTotal($result->getTotal()); $changed = true; } return $changed; }
php
{ "resource": "" }
q248604
SaleUpdater.updatePaymentTotal
validation
protected function updatePaymentTotal(SaleInterface $sale) { $changed = false; $currency = $sale->getCurrency()->getCode(); // Update paid total if needed $paid = $this->paymentCalculator->calculatePaidTotal($sale); if (0 != Money::compare($paid, $sale->getPaidTotal(), $currency)) { $sale->setPaidTotal($paid); $changed = true; } // Update pending total total if needed $pending = $this->paymentCalculator->calculateOfflinePendingTotal($sale); if (0 != Money::compare($pending, $sale->getPendingTotal(), $currency)) { $sale->setPendingTotal($pending); $changed = true; } // Update accepted outstanding total if needed $acceptedOutstanding = $this->paymentCalculator->calculateOutstandingAcceptedTotal($sale); if (0 != Money::compare($acceptedOutstanding, $sale->getOutstandingAccepted(), $currency)) { $sale->setOutstandingAccepted($acceptedOutstanding); $changed = true; } // Update expired outstanding total if needed $expiredOutstanding = $this->paymentCalculator->calculateOutstandingExpiredTotal($sale); if (0 != Money::compare($expiredOutstanding, $sale->getOutstandingExpired(), $currency)) { $sale->setOutstandingExpired($expiredOutstanding); $changed = true; } // If payment totals has changed and fund has been released if ($changed && $this->outstandingReleaser->releaseFund($sale)) { // Re-update the outstanding totals //$sale->setPaidTotal($this->paymentCalculator->calculatePaidTotal($sale)); //$sale->setPendingTotal($this->paymentCalculator->calculateOfflinePendingTotal($sale)); $sale->setOutstandingAccepted($this->paymentCalculator->calculateOutstandingAcceptedTotal($sale)); $sale->setOutstandingExpired($this->paymentCalculator->calculateOutstandingExpiredTotal($sale)); } return $changed; }
php
{ "resource": "" }
q248605
SaleUpdater.updateInvoiceTotal
validation
protected function updateInvoiceTotal(SaleInterface $sale) { if (!$sale instanceof InvoiceSubjectInterface) { return false; } $changed = false; $invoice = $this->invoiceCalculator->calculateInvoiceTotal($sale); if (0 != Money::compare($invoice, $sale->getInvoiceTotal(), $sale->getCurrency()->getCode())) { $sale->setInvoiceTotal($invoice); $changed = true; } $credit = $this->invoiceCalculator->calculateCreditTotal($sale); if (0 != Money::compare($credit, $sale->getCreditTotal(), $sale->getCurrency()->getCode())) { $sale->setCreditTotal($credit); $changed = true; } return $changed; }
php
{ "resource": "" }
q248606
SaleUpdater.resolveOutstandingDate
validation
protected function resolveOutstandingDate(SaleInterface $sale) { if (!$sale instanceof InvoiceSubjectInterface) { return null; } if (!$sale instanceof ShipmentSubjectInterface) { return null; } if (null === $term = $sale->getPaymentTerm()) { return null; } if (!$this->saleHasOutstandingPayments($sale)) { return null; } $from = null; switch ($term->getTrigger()) { case PaymentTermTriggers::TRIGGER_SHIPPED: $from = $sale->getShippedAt(); break; case PaymentTermTriggers::TRIGGER_FULLY_SHIPPED: if ($sale->getShipmentState() === ShipmentStates::STATE_COMPLETED) { $from = $sale->getShippedAt(true); } break; case PaymentTermTriggers::TRIGGER_INVOICED: $from = $sale->getInvoicedAt(); break; case PaymentTermTriggers::TRIGGER_FULLY_INVOICED: if ($sale->getInvoiceState() === InvoiceStates::STATE_COMPLETED) { $from = $sale->getInvoicedAt(true); } break; } if (null === $from) { return null; } // Calculate outstanding date $date = clone $from; $date->setTime(23, 59, 59); $date->modify(sprintf('+%s days', $term->getDays())); if ($term->getEndOfMonth()) { $date->modify('last day of this month'); } return $date; }
php
{ "resource": "" }
q248607
SaleItemValidator.checkPrivacyIntegrity
validation
protected function checkPrivacyIntegrity(SaleItemInterface $item, SaleItem $constraint) { $parent = $item->getParent(); if ($item->isPrivate()) { if (null === $parent) { // Level zero items must be public $this ->context ->buildViolation($constraint->root_item_cant_be_private) ->atPath('private') ->addViolation(); throw new ValidationFailedException(); } elseif ($item->getTaxGroup() !== $parent->getTaxGroup()) { // Tax group must match parent's one $this ->context ->buildViolation($constraint->tax_group_integrity) ->atPath('taxGroup') ->addViolation(); throw new ValidationFailedException(); } } elseif (null !== $parent && $parent->isPrivate()) { // Item with private parent must be private $this ->context ->buildViolation($constraint->privacy_integrity) ->atPath('private') ->addViolation(); throw new ValidationFailedException(); } }
php
{ "resource": "" }
q248608
SaleItemValidator.checkInvoiceIntegrity
validation
protected function checkInvoiceIntegrity(SaleItemInterface $item, SaleItem $constraint) { $sale = $item->getSale(); if (!$sale instanceof Invoice\InvoiceSubjectInterface) { return; } if (empty($sale->getInvoices()->toArray())) { return; } $min = $this->invoiceCalculator->calculateInvoicedQuantity($item); $qty = $item->getTotalQuantity(); // TODO Use packaging format if (1 === bccomp($min, 0, 3) && 1 === bccomp($min, $qty, 3)) { $this ->context ->buildViolation($constraint->quantity_is_lower_than_invoiced, [ '%min%' => $min, ]) ->atPath('quantity') ->addViolation(); throw new ValidationFailedException(); } }
php
{ "resource": "" }
q248609
SaleItemValidator.checkShipmentIntegrity
validation
protected function checkShipmentIntegrity(SaleItemInterface $item, SaleItem $constraint) { $sale = $item->getSale(); if (!$sale instanceof Shipment\ShipmentSubjectInterface) { return; } if (empty($sale->getShipments()->toArray())) { return; } $min = $this->shipmentCalculator->calculateShippedQuantity($item); // TODO Use packaging format //if (0 < $min && $item->getTotalQuantity() < $min) { if (1 === bccomp($min, 0, 3) && 1 === bccomp($min, $item->getTotalQuantity(), 3)) { $this ->context ->buildViolation($constraint->quantity_is_lower_than_shipped, [ '%min%' => $min, ]) ->setInvalidValue($item->getQuantity()) ->atPath('quantity') ->addViolation(); throw new ValidationFailedException(); } }
php
{ "resource": "" }
q248610
StockUnitLinker.updatePrice
validation
private function updatePrice(StockUnitInterface $stockUnit) { $price = null; if (null !== $item = $stockUnit->getSupplierOrderItem()) { if (null === $order = $item->getOrder()) { throw new StockLogicException("Supplier order item's order must be set at this point."); } $currency = $order->getCurrency()->getCode(); $date = $order->getPaymentDate(); if ($date > new \DateTime()) { $date = null; } $price = $this->currencyConverter->convert($item->getNetPrice(), $currency, null, $date); } if (0 !== Money::compare($stockUnit->getNetPrice(), $price, $this->currencyConverter->getDefaultCurrency())) { $stockUnit->setNetPrice($price); return true; } return false; }
php
{ "resource": "" }
q248611
SaleView.setTranslations
validation
public function setTranslations(array $translations) { foreach ($translations as $key => $string) { if (!(is_string($string) && !empty($string))) { throw new \InvalidArgumentException("Invalid translation for key '$key'."); } } $this->translations = array_replace($this->getDefaultTranslations(), $translations); }
php
{ "resource": "" }
q248612
ProfileController.editAction
validation
public function editAction() { $user = $this->getUser(); $form = $this->createForm(ProfileType::class, $user); return array( 'form' => $form->createView(), ); }
php
{ "resource": "" }
q248613
ProfileController.updateAction
validation
public function updateAction(Request $request) { $user = $this->getUser(); $form = $this->createForm(ProfileType::class, $user); $form->bind($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); try { $em->persist($user); $em->flush(); $this->get('session')->getFlashBag()->set('success', 'Your changes have been saved.'); return new JsonReloadResponse(); } catch (\Exception $e) { $form->addError(new FormError('Could not save changes. If the problem persists, please contact support.')); } } return new JsonErrorResponse($form); }
php
{ "resource": "" }
q248614
ProfileController.updatePasswordAction
validation
public function updatePasswordAction(Request $request) { $user = $this->getUser(); $form = $this->createForm(ChangePasswordType::class); $form->bind($request); $data = $form->getData(); /** @var $factory \Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface */ $factory = $this->get('security.encoder_factory'); $encoder = $factory->getEncoder($user); $current = $encoder->encodePassword($data['current'], $user->getSalt()); if ($current !== $user->getPassword()) { $form->get('current')->addError(new FormError('Current password is not correct')); } if ($form->isValid()) { $user->setPassword($encoder->encodePassword($data['password'], $user->getSalt())); $em = $this->getDoctrine()->getManager(); $em->persist($user); $em->flush(); $this->get('session')->getFlashBag()->set('success', 'Your password has been changed.'); return new JsonReloadResponse(); } return new JsonErrorResponse($form); }
php
{ "resource": "" }
q248615
SessionBag.has
validation
public function has(string $key): bool { return isset($_SESSION) ? array_key_exists($key, $_SESSION) : false; }
php
{ "resource": "" }
q248616
UnlimitedPool.clear
validation
public function clear() { while (!$this->queue->isEmpty()) { $this->queue->pop(); } $this->queue = null; }
php
{ "resource": "" }
q248617
ValueBag.fetch
validation
public function fetch(string $key, $default = null) { $val = $this->bag[$key] ?? $default; if (!is_array($val)) { return trim($val); } else { return $val; } }
php
{ "resource": "" }
q248618
ValueBag.fetchFloat
validation
public function fetchFloat(string $key, float $default = 0.0, int $precision = 2): float { return round(floatval($this->fetch($key, $default)), $precision); }
php
{ "resource": "" }
q248619
ValueBag.fetchBool
validation
public function fetchBool(string $key, bool $default = false): bool { return $this->fetchFilter($key, $default, FILTER_VALIDATE_BOOLEAN); }
php
{ "resource": "" }
q248620
ValueBag.fetchFilter
validation
public function fetchFilter(string $key, $default = null, $filter = FILTER_DEFAULT, $options = []) { $value = $this->fetch($key, $default); if (!is_array($options) && $options) { $options = ['flags' => $options]; } if (is_array($value) && !isset($options['flags'])) { $options['flags'] = FILTER_REQUIRE_ARRAY; } return filter_var($value, $filter, $options); }
php
{ "resource": "" }
q248621
ValueBag.fetchEscape
validation
public function fetchEscape(string $key, \mysqli $db, string $default = ''): string { return $db->real_escape_string($this->fetch($key, $default)); }
php
{ "resource": "" }
q248622
Request.route
validation
public function route(bool $dropIndex = false): string { if ($dropIndex) { if ('index' == $this->route) { return ''; } } return $this->route; }
php
{ "resource": "" }
q248623
SqlStatement.toInsert
validation
public static function toInsert($input, array $include = []) { if (is_object($input)) { if (method_exists($input, 'toArray')) { $input = $input->toArray(); } elseif ($input instanceof \Traversable) { $input = iterator_to_array($input); } else { $input = (array)$input; } } elseif (!is_array($input)) { throw new InvalidArgumentException('input must be an associative array or traversable object'); } if (count($include)) { $arr = []; foreach ($include as $i) { if (isset($input[$i])) { $arr[$i] &= $input[$i]; } } } else { $arr = &$input; } $sqlStrs = []; foreach ($arr as $k => &$v) { $kEq = '`' . $k . '` = '; switch (gettype($v)) { case 'bool': case 'boolean': $sqlStrs[] = $kEq . ($v ? '1' : '0'); break; case 'int': case 'integer': case 'float': case 'double': $sqlStrs[] = $kEq . $v; break; case 'string': // if $v is a string that contains the text 'NULL' then if ($v === 'NULL') { $sqlStrs[] = $kEq . 'NULL'; } // elseif ($v === '') { // // This condition is required with bin2hex() as we can't use only '0x'. // $sqlStrs[] = $kEq . '""'; // } else { $sqlStrs[] = $kEq . '"' . addslashes($v) . '"'; // $sqlStrs[] = $kEq . '0x' . bin2hex($v); } break; case 'null': case 'NULL': // if $v is a NULL $sqlStrs[] = $kEq . 'NULL'; break; case 'object': if ($v instanceof DateTime) { $sqlStrs[] = $kEq . '"' . $v . '"'; break; } // other objects fall through case 'array': $sqlStrs[] = $kEq . '"' . addslashes(json_encode($v)) . '"'; // $sqlStrs[] = $kEq . '0x' . bin2hex(json_encode($v)); $jsonLastErr = json_last_error(); if ($jsonLastErr !== JSON_ERROR_NONE) { throw new UnexpectedValueException(json_last_error_msg(), $jsonLastErr); } break; // resource, just ignore these default: break; } } return implode(",\n", $sqlStrs); }
php
{ "resource": "" }
q248624
SqlStatement.toValues
validation
public static function toValues($input, array $include = []) { if (!is_array($input) && !is_object($input)) { throw new InvalidArgumentException('input must be an associative array or traversable object'); } $sqlStrs = []; if (count($include)) { foreach ($include as $i) { if (array_key_exists($i, $input)) { $sqlStrs[] = '`' . $i . '` = VALUES(`' . $i . '`)'; } } } else { foreach ($input as $k => &$v) { $sqlStrs[] = '`' . $k . '` = VALUES(`' . $k . '`)'; } } return implode(",\n", $sqlStrs); }
php
{ "resource": "" }
q248625
Randstring.generateString
validation
private function generateString() { $this->generateNumbers(); $this->adjective = $this->adjectives[$this->first]; $this->animal = $this->animals[$this->second]; switch ($this->case) { case 'ucfirst': $this->string = ucfirst($this->adjective . $this->animal . $this->number); break; case 'ucwords': case 'sentence': $this->string = ucfirst($this->adjective) . ucfirst($this->animal) . ucfirst($this->number); break; case 'camel': $this->string = $this->adjective . ucfirst($this->animal) . $this->number; break; default: $this->string = $this->adjective . $this->animal . $this->number; break; } }
php
{ "resource": "" }
q248626
Upload.uploadAction
validation
public function uploadAction() { if ($this->request->hasFiles() == true) { $this->initializeScaffolding(); $form = $this->scaffolding->getForm(); $name = key($_FILES); /** @var \Vegas\Forms\Element\Upload $uploadElement */ $uploadElement = $form->get($name); $model = $uploadElement->getModel(); $path = $uploadElement->getPath(); $maxFileSize = $uploadElement->getMaxFileSize(); $minFileSize = $uploadElement->getMinFileSize(); foreach ($this->request->getUploadedFiles() as $file) { $fileName = $file->getName(); $fileSize = $file->getSize(); $fileType = $file->getRealType(); $fileExtensions = pathinfo($fileName, PATHINFO_EXTENSION); $allowed = $uploadElement->getAllowedExtensions(); if (!empty($allowed)) { if (!in_array($fileExtensions, $allowed)) { throw new ForbiddenFileExtensionException(); } } $forbidden = $uploadElement->getForbiddenExtensions(); if (!empty($forbidden)) { if (in_array($fileExtensions, $forbidden)) { throw new ForbiddenFileExtensionException(); } } $allowedMime = $uploadElement->getAllowedMimeTypes(); if (!empty($allowedMime)) { if (!in_array($fileType, $allowedMime)) { throw new ForbiddenFileMimeTypeException(); } } $forbiddenMime = $uploadElement->getForbiddenMimeTypes(); if (!empty($forbiddenMime)) { if (in_array($fileType, $forbiddenMime)) { throw new ForbiddenFileMimeTypeException(); } } if (!empty($maxFileSize)) { if ($fileSize > $this->convertFileSizeToBytes($maxFileSize)) { throw new \Exception('s'); } } if (!empty($minFileSize)) { if ($fileSize < $this->convertFileSizeToBytes($minFileSize)) { throw new \Exception('s'); } } if (empty($path)) { $path = 'files/'; } $model->name = $fileName; $model->mime_type = $fileType; $model->path = $path; $model->save(); $file->moveTo($path . $model->_id); return $this->response->setJsonContent((string) $model->_id); } } $this->view->setRenderLevel(View::LEVEL_NO_RENDER); }
php
{ "resource": "" }
q248627
Helper.moveFile
validation
public static final function moveFile($file) { try { if($file->is_temp) { rename( $file->temp_destination . '/' . $file->temp_name, $file->original_destination . '/' . $file->temp_name ); if(!file_exists($file->original_destination . '/' . $file->temp_name)) { throw new CannotSaveFileInHardDriveException(); } $file->is_temp = false; $file->expire = null; $file->save(); } } catch (\Exception $exception) { throw new FileException($exception->getMessage()); } }
php
{ "resource": "" }
q248628
Helper.generateThumbnailsFrom
validation
public static final function generateThumbnailsFrom($files, array $size) { foreach($files as $file) { self::generateThumbnail($file->getRecord(), $size); } }
php
{ "resource": "" }
q248629
ServerBag.fetch
validation
public function fetch(string $key, $default = null) { if (isset($_SERVER[$key])) { return $_SERVER[$key]; } else { $key = 'HTTP_' . $key; return $_SERVER[$key] ?? $default; } }
php
{ "resource": "" }
q248630
Application.getResponse
validation
public function getResponse(array $packageList, array $languageList, array $customRouteList, string $url = ''): Response { $request = new Request($languageList, $packageList, $url); $this->packageRoot .= 'package/' . $request->package() . '/'; try { /** * Process request. */ if (isset($customRouteList[$request->package()])) { /** * Path to custom router class. */ $path = $this->packageRoot . 'CustomRoute.php'; if (file_exists($path)) { require $path; $route = $request->package() . '\\CustomRoute'; /** * @var IRoute $route */ $route = new $route(); $this->response = $route->getResponse($this->packageRoot, $request); if ($this->response->is404()) { $this->set404(); } return $this->response; } else { throw new RouteException(sprintf('The file "%s" does not exist', $path)); } } else { $this->response = (new DefaultRoute())->getResponse($this->packageRoot, $request); if ($this->response->is404()) { $this->set404(); } return $this->response; } } catch (RouteException $e) { if (Wrap::isEnabled()) { throw $e; } else { $this->response = new Response(); $this->set404(); return $this->response; } } }
php
{ "resource": "" }
q248631
Application.set404
validation
private function set404() { $this->response->setStatusCode(404); $content = '404 Not Found'; if (file_exists($this->packageRoot . '/view/404.html.php')) { $content = (new Native($this->packageRoot))->getContent('404.html.php'); } $this->response->setContent($content); }
php
{ "resource": "" }
q248632
TypedClass.assign
validation
public function assign($in) { $this->_massageBlockInput($in); if (empty($in)) { foreach ($this->_publicNames as $publicName) { $this->__unset($publicName); } } elseif (is_object($in)) { foreach ($this->_publicNames as $publicName) { if (isset($in->{$publicName})) { $this->_setByName($publicName, $in->{$publicName}); } else { $this->__unset($publicName); } } } else { foreach ($this->_publicNames as $publicName) { if (isset($in[$publicName])) { $this->_setByName($publicName, $in[$publicName]); } else { $this->__unset($publicName); } } } $this->_checkRelatedProperties(); }
php
{ "resource": "" }
q248633
TypedClass.serialize
validation
public function serialize(): string { $toSerialize = [ '_arrayOptions' => $this->_arrayOptions, '_jsonOptions' => $this->_jsonOptions, ]; foreach ($this->_publicNames as $k) { $toSerialize[$k] = $this->{$k}; } return serialize($toSerialize); }
php
{ "resource": "" }
q248634
TypedClass.unserialize
validation
public function unserialize($serialized): void { $this->_initMetaData(); $data = unserialize($serialized); foreach ($data as $k => $v) { $this->{$k} = $v; } }
php
{ "resource": "" }
q248635
TypedClass.replace
validation
public function replace($in): void { $this->_massageBlockInput($in); if (empty($in)) { return; } foreach ($in as $k => $v) { if ($this->_keyExists($k)) { if ($this->{$k} instanceof TypedAbstract) { $this->{$k}->replace($v); } else { $this->_setByName($k, $v); } } } $this->_checkRelatedProperties(); }
php
{ "resource": "" }
q248636
TypedClass._getByName
validation
protected function _getByName($propName) { if (array_key_exists($propName, $this->_map)) { $propName = $this->_map[$propName]; } if ($this->{$propName} instanceof AtomicInterface) { return $this->{$propName}->get(); } $getter = '_get_' . $propName; if (method_exists($this->_calledClass, $getter)) { return $this->{$getter}(); } return $this->{$propName}; }
php
{ "resource": "" }
q248637
LatitudeLongitudeWorker.execute
validation
public function execute() { $addresses = $this->addressRepository->createQueryBuilder('a') ->where('a.latitude IS NULL') ->orWhere('a.longitude IS NULL') ->setMaxResults(500) ->getQuery() ->getResult(); foreach ($addresses as $address) { try { $this->updateLatLong($address); } catch (\RuntimeException $e) { echo "Stopping work -- over the API query limit.\n"; break; } $this->entityManager->persist($address); usleep(self::MILLISECONDS_PAUSE_BETWEEN_QUERIES); } $this->entityManager->flush(); }
php
{ "resource": "" }
q248638
Response.header
validation
public function header(string $name, string $value): bool { if (!empty($name) && !empty($value) && !headers_sent()) { header($name . ': ' . $value); return true; } return false; }
php
{ "resource": "" }
q248639
Response.setStatusCode
validation
public function setStatusCode(int $statusCode, string $version = '1.1', string $statusText = ''): bool { if (!headers_sent()) { $statusCode = intval($statusCode); if ('' == $statusText) { $statusTexts = [ 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', // RFC2518 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-Status', // RFC4918 208 => 'Already Reported', // RFC5842 226 => 'IM Used', // RFC3229 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect', 308 => 'Permanent Redirect', // RFC7238 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Payload Too Large', 414 => 'URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Range Not Satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', // RFC2324 422 => 'Unprocessable Entity', // RFC4918 423 => 'Locked', // RFC4918 424 => 'Failed Dependency', // RFC4918 425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817 426 => 'Upgrade Required', // RFC2817 428 => 'Precondition Required', // RFC6585 429 => 'Too Many Requests', // RFC6585 431 => 'Request Header Fields Too Large', // RFC6585 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported', 506 => 'Variant Also Negotiates (Experimental)', // RFC2295 507 => 'Insufficient Storage', // RFC4918 508 => 'Loop Detected', // RFC5842 510 => 'Not Extended', // RFC2774 511 => 'Network Authentication Required', // RFC6585 ]; $statusText = $statusTexts[$statusCode]; } header(sprintf('HTTP/%s %s %s', $version, $statusCode, $statusText), true, $statusCode); return true; } return false; }
php
{ "resource": "" }
q248640
Response.redirect
validation
public function redirect(string $url = '', int $statusCode = 302) { $this->is404 = false; $server = filter_input_array(INPUT_SERVER); if ('' == $url && isset($server['REQUEST_URI'])) { $url = '/' . trim($server['REQUEST_URI'], '/'); preg_match('/^[\\a-zA-Z0-9-\._~:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=%]*$/iD', $url, $match); $url = $match[1] ?? ''; } if (!headers_sent()) { header('Location: ' . $url, true, $statusCode); } echo sprintf('<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta http-equiv="refresh" content="0;url=%1$s" /> <title>Redirecting to %1$s</title> </head> <body> <script type="text/javascript"> window.location.href = "%1$s"; </script> Redirecting to <a href="%1$s">%1$s</a>. </body> </html>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8')); }
php
{ "resource": "" }
q248641
JsonErrorResponse.getFormErrorData
validation
private function getFormErrorData(Form $form) { if ($form->isValid()) { // A JsonErrorResponse was created with a valid form-- no errors will be found return $this->getResponseData('An error occurred while processing the submitted information'); } $errors = $this->getErrors($form); $message = $this->getMainErrorMessage($form); return $this->getResponseData($message, $errors); }
php
{ "resource": "" }
q248642
JsonErrorResponse.getErrors
validation
private function getErrors(Form $form) { $errors = array(); if ($form->isSubmitted() && $form->isValid()) { return $errors; } $id = $form->createView()->vars['id']; foreach ($form->getErrors() as $error) { if (!isset($errors[$id])) { $errors[$id] = array(); } $errors[$id][] = $error->getMessage(); } foreach ($form->all() as $child) { $errors = array_merge($this->getErrors($child), $errors); } return $errors; }
php
{ "resource": "" }
q248643
config.Get
validation
public function Get($name = null,$value = null,...$param){ if(!isset($name)) return self::$config; return isset($value)? self::$config[$name][$value] :(isset(self::$config[$name])?self::$config[$name]:null); }
php
{ "resource": "" }
q248644
config.reload
validation
public static function reload($file,$rangePath = null){ if(!empty($rangePath)){ self::$rangePath = $rangePath; } if (PHP_SAPI === 'cli'){ $cilpath = realpath(dirname(dirname(dirname(dirname(__FILE__))))).'/config/'; $file = $cilpath.$file.'.'.self::$format; }else{ $file = self::$rangePath.$file.'.'.self::$format; } $name = strtolower($file); $type = pathinfo($file, PATHINFO_EXTENSION); if(self::$format == $type) return self::set(include $file); }
php
{ "resource": "" }
q248645
FileBag.convertFileInformation
validation
private function convertFileInformation($file) { if ($file instanceof FileUpload) { return $file; } $file = $this->fixPhpFilesArray($file); if (is_array($file)) { $keys = array_keys($file); sort($keys); if ($keys == ['error', 'name', 'size', 'tmp_name', 'type']) { if (UPLOAD_ERR_NO_FILE == $file['error']) { $file = null; } else { $file = new FileUpload($file['tmp_name'], $file['name'], $file['size'], $file['type'], $file['error']); } } else { $file = array_map([$this, 'convertFileInformation'], $file); } } return $file; }
php
{ "resource": "" }
q248646
TypedArray.assign
validation
public function assign($in) { $this->_massageBlockInput($in); $this->_container = []; // initialize array or remove all current values foreach ($in as $k => $v) { $this->offsetSet($k, $v); } }
php
{ "resource": "" }
q248647
TypedArray.replace
validation
public function replace($in) { $this->_massageBlockInput($in); foreach ($in as $k => $v) { $this->offsetSet($k, $v); } }
php
{ "resource": "" }
q248648
TypedArray.serialize
validation
public function serialize(): string { return serialize([ '_type' => $this->_type, '_arrayOptions' => $this->_arrayOptions, '_jsonOptions' => $this->_jsonOptions, '_container' => $this->_container, ]); }
php
{ "resource": "" }
q248649
TypedArray.merge
validation
public function merge($ta): self { $this->_massageBlockInput($in); $ret = clone $this; foreach ($ta as $k => $v) { if (is_int($k)) { $ret[] = $v; } else { $ret[$k] = $v; } } return $ret; }
php
{ "resource": "" }
q248650
TypedArray.&
validation
public function &offsetGet($offset) { if (!$this->offsetExists($offset)) { // Be sure offset exists before accessing it. $this->offsetSet($offset, null); // Returns new offset created by ::offsetSet(). if (null === $offset) { end($this->_container); $offset = key($this->_container); } } return $this->_container[$offset]; }
php
{ "resource": "" }
q248651
TypedArray.offsetSet
validation
public function offsetSet($k, $v) { if (null === $k || !array_key_exists($k, $this->_container)) { $v = (is_object($v) && get_class($v) === $this->_type) ? $v : new $this->_type($v); if (null === $k) { $this->_container[] = $v; } else { $this->_container[$k] = $v; } return; } if (is_a($this->_type, AtomicInterface::class, true)) { $this->_container[$k]->set($v); return; } if (is_a($this->_type, TypedAbstract::class, true)) { $this->_container[$k]->replace($v); return; } $this->_container[$k] = new $this->_type($v); }
php
{ "resource": "" }
q248652
TypedArray.combine
validation
public function combine(array $keys): self { if (count($keys) !== count($this->_container)) { throw new LengthException('array counts do not match'); } $this->_container = array_combine($keys, $this->_container); return $this; }
php
{ "resource": "" }
q248653
File.customChmod
validation
protected function customChmod(string $target, $mode = 0666) { if (false === @chmod($target, $mode & ~umask())) { throw new FileException(sprintf('Unable to change mode of the "%s"', $target)); } }
php
{ "resource": "" }
q248654
DefaultRoute.getResponse
validation
public function getResponse(string &$packageRoot, Request &$request): Response { $packageRoot = rtrim($packageRoot, '/'); $route = preg_replace('/\/\d+/u', '/D', $request->route()); $path = $packageRoot . '/Route/' . $route . '/' . $request->method() . '.php'; if (file_exists($path)) { require $path; $controllerClass = $request->package() . '\\Route_' . str_replace('/', '_', $route) . '\\' . $request->method(); /** * @var BaseController $controller */ if (class_exists($controllerClass)) { $controller = new $controllerClass($packageRoot, $request); } else { throw new RouteException(sprintf('Route: the class "%s" does not exist', $controllerClass)); } /** * Call handler. */ $handler = filter_input_array(INPUT_POST)['handler'] ?? filter_input_array(INPUT_GET)['handler'] ?? 'index'; if (method_exists($controllerClass, $handler)) { $controller->invoke($handler); return $controller->getResponse(); } else { throw new RouteException(sprintf('Route: the method "%s" does not exist', $handler)); } } else { throw new RouteException(sprintf('Route: path "%s" does not exist', $request->package() . '/Route/' . $route . '/' . $request->method() . '.php')); } }
php
{ "resource": "" }
q248655
FileUpload.read
validation
public function read() { $data = ''; $fileObj = $this->openFile(); while (!$fileObj->eof()) { $data .= $fileObj->fread(4096); } $fileObj = null; return $data; }
php
{ "resource": "" }
q248656
FileUpload.errorMessage
validation
public function errorMessage(): string { static $errors = array( UPLOAD_ERR_INI_SIZE => 'The file "%s" exceeds your upload_max_filesize ini directive (limit is %d KiB).', UPLOAD_ERR_FORM_SIZE => 'The file "%s" exceeds the upload limit defined in your form.', UPLOAD_ERR_PARTIAL => 'The file "%s" was only partially uploaded.', UPLOAD_ERR_NO_FILE => 'No file was uploaded.', UPLOAD_ERR_CANT_WRITE => 'The file "%s" could not be written on disk.', UPLOAD_ERR_NO_TMP_DIR => 'File could not be uploaded: missing temporary directory.', UPLOAD_ERR_EXTENSION => 'File upload was stopped by a PHP extension.', ); $errorCode = $this->error; $maxFileSize = $errorCode === UPLOAD_ERR_INI_SIZE ? $this->getMaxFileSize() / 1024 : 0; $message = isset($errors[$errorCode]) ? $errors[$errorCode] : 'The file "%s" was not uploaded due to an unknown error.'; return sprintf($message, $this->name, $maxFileSize); }
php
{ "resource": "" }
q248657
FileUpload.getMaxFileSize
validation
public function getMaxFileSize(): int { $iniMax = strtolower(ini_get('upload_max_filesize')); if ('' === $iniMax) { return PHP_INT_MAX; } $max = ltrim($iniMax, '+'); if (0 === strpos($max, '0x')) { $max = intval($max, 16); } elseif (0 === strpos($max, '0')) { $max = intval($max, 8); } else { $max = (int) $max; } switch (substr($iniMax, -1)) { case 't': $max *= 1024; // no break case 'g': $max *= 1024; // no break case 'm': $max *= 1024; // no break case 'k': $max *= 1024; // no break } return $max; }
php
{ "resource": "" }
q248658
BaseController.setView
validation
protected function setView(string $name = '', array $data = []) { if (!empty($data)) { $this->data = array_replace($this->data, $data); } $content = (new Native($this->packageRoot, $this->request->language(), !Wrap::isEnabled()))->getContent($name, $this->data); $this->response->setContent($content); }
php
{ "resource": "" }
q248659
BaseController.setJSONContent
validation
protected function setJSONContent(array $content) { if ($this->deleteJsonKeys) { $content = $this->deleteArrayKeys($content); } $content = json_encode($content, JSON_UNESCAPED_UNICODE); $this->response->setContentTypeJson(); $this->response->setContent($content); }
php
{ "resource": "" }
q248660
BaseController.setRedirect
validation
protected function setRedirect(string $url = '', int $statusCode = 303) { $this->response->redirect($url, $statusCode); }
php
{ "resource": "" }
q248661
BaseController.getNumList
validation
protected function getNumList(): array { preg_match_all('/\/\d+/u', $this->request->route(), $numList); $numList = $numList[0]; $numList = array_map(function($val) { return intval(ltrim($val, '/')); }, $numList); return $numList; }
php
{ "resource": "" }
q248662
EeMediaGalleryUpdateObserver.initializeProductMediaGalleryValueToEntity
validation
protected function initializeProductMediaGalleryValueToEntity(array $attr) { // load the row/value ID $rowId = $attr[MemberNames::ROW_ID]; $valueId = $attr[MemberNames::VALUE_ID]; // query whether the product media gallery value to entity entity already exists or not if ($this->loadProductMediaGalleryValueToEntityByValueIdAndRowId($valueId, $rowId)) { return; } // simply return the attributes return $attr; }
php
{ "resource": "" }
q248663
DetailView.renderAlertBlock
validation
protected function renderAlertBlock() { $session = \Yii::$app->session; $flashes = $session->getAllFlashes(); $alertContainerOptions = [ 'style' => 'max-width:400px' ]; if (count($flashes) === 0) { Html::addCssStyle($alertContainerOptions, 'display:none;'); } $out = Html::beginTag('div', $alertContainerOptions); foreach ($flashes as $type => $message) { if (is_array($message)) { $message = implode('<br>', $message); } $alertWidgetOptions = []; $alertWidgetOptions['body'] = $message; $alertWidgetOptions['options'] = [ 'class' => ['alert', 'alert-success'], 'style' => 'padding-left:10px;padding-right:10px;' ]; $out .= "\n" . Alert::widget($alertWidgetOptions); $session->removeFlash($type); } $out .= "\n</div>"; return $this->alertBlockAddon . $out; }
php
{ "resource": "" }
q248664
GridView.registerWidget
validation
protected function registerWidget($name = null, $id = null) { if ($name === null) { $name = $this->getDefaultJsWidgetName(); } $this->_registerBundle(); if (!$this->isAjaxCrud && $this->getUpdateUrl()) { if ($id === null) { $id = $this->options['id']; } $options = empty($this->clientOptions) ? '' : Json::htmlEncode([ 'updateUrl' => Url::to($this->getUpdateUrl()) ]); $js = "jQuery('#$id').$name($options);"; $this->getView()->registerJs($js); } }
php
{ "resource": "" }
q248665
MenuViewHelper.render
validation
public function render($menu = 'Default', $debug = false, $class = null) { $response = $this->initiateSubRequest(); return $response->getContent(); }
php
{ "resource": "" }
q248666
Swf.setSource
validation
public function setSource($source = '') { if(!$this->isValid($source)) { throw new InvalidSourceExtensionException(); } $this->source = $source; return $this; }
php
{ "resource": "" }
q248667
Swf.isValid
validation
private function isValid($source = '') { if(empty($source)) { return false; } else { $extension = substr($source, -3); if(strtolower($extension) !== 'swf') { return false; } } return true; }
php
{ "resource": "" }
q248668
Swf.renderEmbed
validation
public function renderEmbed() { if(!$this->isValid($this->source)) { throw new InvalidSourceExtensionException(); } return sprintf($this->embedDecorator, $this->width, $this->height, $this->source); }
php
{ "resource": "" }
q248669
Swf.renderObject
validation
public function renderObject() { if(!$this->isValid($this->source)) { throw new InvalidSourceExtensionException(); } return sprintf($this->objectDecorator, $this->width, $this->height, $this->source); }
php
{ "resource": "" }
q248670
AuthController.loginAction
validation
public function loginAction(Request $request) { $session = $request->getSession(); $form = $this->createFormBuilder() ->add('username', TextType::class, array('label' => 'Username')) ->add('password', PasswordType::class, array('label' => 'Password')) ->add('rememberMe', CheckboxType::class, array('label' => 'Remember Me', 'required' => false)) ->getForm(); $helper = $this->get('security.authentication_utils'); if ($lastUsername = $helper->getLastUsername()) { $form->setData(array('username' => $lastUsername)); } return array( 'form' => $form->createView() ); }
php
{ "resource": "" }
q248671
Country.addRegion
validation
public function addRegion(RegionInterface $region) { $region->setCountry($this); $this->regions->add($region); }
php
{ "resource": "" }
q248672
MimeType.getInstance
validation
public static function getInstance(): MimeType { if (null === self::$instance) { self::$instance = new self(); } return self::$instance; }
php
{ "resource": "" }
q248673
MimeType.guess
validation
public function guess(string $path): string { if (!is_file($path)) { throw new FileNotFoundException($path); } if (!is_readable($path)) { throw new AccessDeniedException($path); } if (0 == count($this->guesserList)) { $msg = 'Unable to guess the mime type as no guessers are available'; if (!FileInfoMimeType::isSupported()) { $msg .= ' (Did you enable the php_fileinfo extension?)'; } throw new \LogicException($msg); } /** @var FileInfoMimeType|BinaryMimeType $guesser */ foreach ($this->guesserList as $guesser) { if ('' != $mimeType = $guesser->guess($path)) { return $mimeType; } } return ''; }
php
{ "resource": "" }
q248674
Export.export
validation
public function export(Defender $defender) { $content = json_encode($defender->dangerFiles); $name = 'defender/defender-'.$this->date.'.json'; if ($this->storage->exists($name)) { $this->storage->delete($name); } $this->storage->put($name, $content); }
php
{ "resource": "" }
q248675
Defender.getDirContents
validation
private function getDirContents($dir, &$results = []) { $files = scandir($dir); foreach ($files as $value) { $path = realpath($dir.DIRECTORY_SEPARATOR.$value); if (!is_dir($path)) { $results[] = $path; continue; } if ($value != '.' && $value != '..') { $this->getDirContents($path, $results); $results[] = $path; } } return $results; }
php
{ "resource": "" }
q248676
Defender.scan
validation
public function scan() { $files = $this->extensionsFile($this->files); foreach ($files as $file) { $content = file_get_contents($file); if (str_contains($file, '.php') && !str_contains($file, $this->exceptionsValid) && !$this->checkForValidPhp($content) ) { $this->notValid[] = $file; } if (str_contains($content, $this->signatures)) { $this->dangerFiles[] = $file; /*([ 'path' => $file, //'meta' => $meta, 'date' => date('d.m.Y',$meta['mtime']), 'size' => $meta['size'], ]; */ } } return $this; }
php
{ "resource": "" }
q248677
EeMediaGalleryObserver.prepareProductMediaGalleryValueToEntityAttributes
validation
protected function prepareProductMediaGalleryValueToEntityAttributes() { // initialize and return the entity return $this->initializeEntity( array( MemberNames::VALUE_ID => $this->valueId, MemberNames::ROW_ID => $this->parentId ) ); }
php
{ "resource": "" }
q248678
Wrap.handleFatal
validation
public static function handleFatal() { $error = error_get_last(); if(null !== $error) { self::render($error["type"], $error["message"], $error["file"], $error["line"]); } }
php
{ "resource": "" }
q248679
Wrap.handleException
validation
public static function handleException(\Throwable $e) { self::render($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine(), null, $e->getTrace(), get_class($e)); }
php
{ "resource": "" }
q248680
EeMediaGalleryValueUpdateObserver.initializeProductMediaGalleryValue
validation
protected function initializeProductMediaGalleryValue(array $attr) { // load the row/value/store ID $rowId = $attr[MemberNames::ROW_ID]; $valueId = $attr[MemberNames::VALUE_ID]; $storeId = $attr[MemberNames::STORE_ID]; // query whether the product media gallery value already exists or not if ($entity = $this->loadProductMediaGalleryValueByValueIdAndStoreIdAndRowId($valueId, $storeId, $rowId)) { return $this->mergeEntity($entity, $attr); } // simply return the attributes return $attr; }
php
{ "resource": "" }
q248681
Module.reloadModule
validation
protected function reloadModule(Wrapper $wrapper, $module) { $moduleStatus = $wrapper->ModuleManager->reload($module); $module = Inflector::camelize($module); switch ($moduleStatus) { //AlreadyUnloaded case 'AU': $wrapper->Channel->sendMessage('The Module `' . $module . '` doesn\'t exist and cannot be reloaded.'); break; //AlreadyLoaded case 'AL': $wrapper->Channel->sendMessage('The Module `' . $module . '` is already loaded.'); break; //Loaded case 'L': $wrapper->Channel->sendMessage('Module `' . $module . '` reloaded successfully.'); break; //NotFound case 'NF': $wrapper->Channel->sendMessage('Failed to reload the Module `' . $module . '`.'); break; } }
php
{ "resource": "" }
q248682
IfAccesOnControllersActionViewHelper.hasAccessToAction
validation
protected function hasAccessToAction($packageKey, $subpackageKey, $controllerName, $actionName) { $actionControllerName = $this->router->getControllerObjectName($packageKey, $subpackageKey, $controllerName); try { return $this->privilegeManager->isGranted( 'Neos\Flow\Security\Authorization\Privilege\Method\MethodPrivilege', new MethodPrivilegeSubject( new JoinPoint( NULL, $actionControllerName, $actionName . 'Action', array() ) ) ); } catch(AccessDeniedException $e) { return FALSE; } }
php
{ "resource": "" }
q248683
GroupController.showAction
validation
public function showAction($id) { $em = $this->getDoctrine()->getEntityManager(); $group = $em->getRepository('Orkestra\Bundle\ApplicationBundle\Entity\Group')->find($id); if (!$group) { throw $this->createNotFoundException('Unable to locate Group'); } return array( 'group' => $group, ); }
php
{ "resource": "" }
q248684
GroupController.newAction
validation
public function newAction() { $group = new Group(); $form = $this->createForm(GroupType::class, $group); return array( 'group' => $group, 'form' => $form->createView() ); }
php
{ "resource": "" }
q248685
GroupController.createAction
validation
public function createAction() { $group = new Group(); $form = $this->createForm(GroupType::class, $group); $form->bindRequest($this->getRequest()); if ($form->isValid()) { $em = $this->getDoctrine()->getEntityManager(); $em->persist($group); $em->flush(); $this->get('session')->getFlashBag()->set('success', 'The group has been created.'); return $this->redirect($this->generateUrl('orkestra_group_show', array('id' => $group->getId()))); } return array( 'group' => $group, 'form' => $form->createView() ); }
php
{ "resource": "" }
q248686
GroupController.editAction
validation
public function editAction($id) { $em = $this->getDoctrine()->getEntityManager(); $group = $em->getRepository('Orkestra\Bundle\ApplicationBundle\Entity\Group')->find($id); if (!$group) { throw $this->createNotFoundException('Unable to locate Group'); } $form = $this->createForm(GroupType::class, $group); return array( 'group' => $group, 'form' => $form->createView(), ); }
php
{ "resource": "" }
q248687
GroupController.updateAction
validation
public function updateAction($id) { $em = $this->getDoctrine()->getEntityManager(); $group = $em->getRepository('Orkestra\Bundle\ApplicationBundle\Entity\Group')->find($id); if (!$group) { throw $this->createNotFoundException('Unable to locate Group'); } $form = $this->createForm(GroupType::class, $group); $form->bindRequest($this->getRequest()); if ($form->isValid()) { $em->persist($group); $em->flush(); $this->get('session')->getFlashBag()->set('success', 'Your changes have been saved.'); return $this->redirect($this->generateUrl('orkestra_group_show', array('id' => $id))); } return array( 'group' => $group, 'form' => $form->createView(), ); }
php
{ "resource": "" }
q248688
common.decrypt
validation
function decrypt($data, $password) { $data = base64_decode($data); $salt = substr($data, 0, 16); $ct = substr($data, 16); $rounds = 3; // depends on key length $data00 = $password.$salt; $hash = array(); $hash[0] = hash('sha256', $data00, true); $result = $hash[0]; for ($i = 1; $i < $rounds; $i++) { $hash[$i] = hash('sha256', $hash[$i - 1].$data00, true); $result .= $hash[$i]; } $key = substr($result, 0, 32); $iv = substr($result, 32,16); return openssl_decrypt($ct, 'AES-256-CBC', $key, true, $iv); }
php
{ "resource": "" }
q248689
common.encrypt
validation
function encrypt($data, $password) { // Set a random salt $salt = openssl_random_pseudo_bytes(16); $salted = ''; $dx = ''; while (strlen($salted) < 48) { $dx = hash('sha256', $dx.$password.$salt, true); $salted .= $dx; } $key = substr($salted, 0, 32); $iv = substr($salted, 32,16); $encrypted_data = openssl_encrypt($data, 'AES-256-CBC', $key, true, $iv); return base64_encode($salt . $encrypted_data); }
php
{ "resource": "" }
q248690
Processpool.exec
validation
public function exec(string $execfile, array $args): bool { return $this->process->exec($execfile, $args); }
php
{ "resource": "" }
q248691
Processpool.useQueue
validation
public function useQueue(int $msgkey = 0, int $mode = 2) { $this->process->useQueue($msgkey, $mode); }
php
{ "resource": "" }
q248692
Package.boot
validation
public function boot(\Neos\Flow\Core\Bootstrap $bootstrap) { //register Configuration Type Menu $dispatcher = $bootstrap->getSignalSlotDispatcher(); $dispatcher->connect('Neos\Flow\Configuration\ConfigurationManager', 'configurationManagerReady', function ($configurationManager) { $configurationManager->registerConfigurationType('Menus'); } ); }
php
{ "resource": "" }
q248693
Breadcrumbs.renderRTL
validation
protected function renderRTL(): string { $trail = ''; if ($this->after) { $trail .= '<span class="after">'.$this->after.'</span> '; } $trail .= \join( ' <span class="sep delimiter">'.$this->delimiter.'</span> ', \array_reverse($this->links) ); if ($this->before) { $trail .= ' <span class="before">'.$this->before.'</span>'; } return $trail; }
php
{ "resource": "" }
q248694
Breadcrumbs.renderLTR
validation
protected function renderLTR(): string { $trail = ''; if ($this->before) { $trail .= '<span class="before">'.$this->before.'</span> '; } $trail .= \join( ' <span class="sep delimiter">'.$this->delimiter.'</span> ', $this->links ); if ($this->after) { $trail .= ' <span class="after">'.$this->after.'</span>'; } return $trail; }
php
{ "resource": "" }
q248695
Breadcrumbs.getFirstTerm
validation
protected function getFirstTerm(WP_Post $post) { $taxonomies = $this->getTaxonomies($post->post_type); foreach ($taxonomies as $taxonomy) { $post_terms = \get_the_terms($post, $taxonomy); if (!$post_terms || \is_wp_error($post_terms)) { continue; } return $post_terms[0]; } }
php
{ "resource": "" }
q248696
Breadcrumbs.getTaxonomies
validation
protected function getTaxonomies(string $post_type): array { $return = []; $taxes = \get_object_taxonomies($post_type, 'objects'); foreach ($taxes as $tax_slug => $tax_object) { if (\is_taxonomy_hierarchical($tax_slug)) { $return[] = $tax_slug; } } return $return; }
php
{ "resource": "" }
q248697
FileManager.ensureDirectoryExists
validation
private function ensureDirectoryExists($path) { if (!is_dir($path)) { if (!mkdir($path, 0777, true)) { throw new \RuntimeException(sprintf('Could not create directory "%s"', $path)); } } return $path; }
php
{ "resource": "" }
q248698
EntityOperationResult.persist
validation
public function persist(ObjectManager $manager) { foreach ($this->entities as $entity) { $manager->persist($entity); } if ($this->root) { $manager->persist($this->root); } }
php
{ "resource": "" }
q248699
Font.background
validation
public function background(): Font { if ($this->color !== null) { $this->turnToBackground(); } $this->background = true; return $this; }
php
{ "resource": "" }