_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q249900 | MarketplaceWebService_Client.convertGetFeedSubmissionCount | validation | private function convertGetFeedSubmissionCount($request)
{
$parameters = array();
$parameters['Action'] = 'GetFeedSubmissionCount';
if ($request->isSetMarketplace()) {
$parameters['Marketplace'] = $request->getMarketplace();
}
if ($request->isSetMerchant()) {
$parameters['Merchant'] = $request->getMerchant();
}
if ($request->isSetFeedTypeList()) {
$feedTypeList = $request->getFeedTypeList();
foreach ($feedTypeList->getType() as $typeIndex => $type) {
$parameters['FeedTypeList' . '.' . 'Type' . '.' . ($typeIndex + 1)] = $type;
}
}
if ($request->isSetFeedProcessingStatusList()) {
$feedProcessingStatusList = $request->getFeedProcessingStatusList();
foreach ($feedProcessingStatusList->getStatus() as $statusIndex => $status) {
$parameters['FeedProcessingStatusList' . '.' . 'Status' . '.' . ($statusIndex + 1)] = $status;
}
}
if ($request->isSetSubmittedFromDate()) {
$parameters['SubmittedFromDate'] = $this->getFormattedTimestamp($request->getSubmittedFromDate());
}
if ($request->isSetSubmittedToDate()) {
$parameters['SubmittedToDate'] = $this->getFormattedTimestamp($request->getSubmittedToDate());
}
if ($request->isSetMWSAuthToken()) {
$parameters['MWSAuthToken'] = $request->getMWSAuthToken();
}
return array(CONVERTED_PARAMETERS_KEY => $parameters, CONVERTED_HEADERS_KEY => $this->defaultHeaders);
} | php | {
"resource": ""
} |
q249901 | MarketplaceWebService_Client.convertGetReportList | validation | private function convertGetReportList($request)
{
$parameters = array();
$parameters['Action'] = 'GetReportList';
if ($request->isSetMarketplace()) {
$parameters['Marketplace'] = $request->getMarketplace();
}
if ($request->isSetMerchant()) {
$parameters['Merchant'] = $request->getMerchant();
}
if ($request->isSetMaxCount()) {
$parameters['MaxCount'] = $request->getMaxCount();
}
if ($request->isSetReportTypeList()) {
$reportTypeList = $request->getReportTypeList();
foreach ($reportTypeList->getType() as $typeIndex => $type) {
$parameters['ReportTypeList' . '.' . 'Type' . '.' . ($typeIndex + 1)] = $type;
}
}
if ($request->isSetAcknowledged()) {
$parameters['Acknowledged'] = $request->getAcknowledged() ? "true" : "false";
}
if ($request->isSetAvailableFromDate()) {
$parameters['AvailableFromDate'] = $this->getFormattedTimestamp($request->getAvailableFromDate());
}
if ($request->isSetAvailableToDate()) {
$parameters['AvailableToDate'] = $this->getFormattedTimestamp($request->getAvailableToDate());
}
if ($request->isSetReportRequestIdList()) {
$reportRequestIdList = $request->getReportRequestIdList();
foreach ($reportRequestIdList->getId() as $idIndex => $id) {
$parameters['ReportRequestIdList' . '.' . 'Id' . '.' . ($idIndex + 1)] = $id;
}
}
if ($request->isSetMWSAuthToken()) {
$parameters['MWSAuthToken'] = $request->getMWSAuthToken();
}
return array(CONVERTED_PARAMETERS_KEY => $parameters, CONVERTED_HEADERS_KEY => $this->defaultHeaders);
} | php | {
"resource": ""
} |
q249902 | MarketplaceWebService_Client.convertGetFeedSubmissionResult | validation | private function convertGetFeedSubmissionResult($request)
{
$parameters = array();
$parameters['Action'] = 'GetFeedSubmissionResult';
if ($request->isSetMarketplace()) {
$parameters['Marketplace'] = $request->getMarketplace();
}
if ($request->isSetMerchant()) {
$parameters['Merchant'] = $request->getMerchant();
}
if ($request->isSetFeedSubmissionId()) {
$parameters['FeedSubmissionId'] = $request->getFeedSubmissionId();
}
if ($request->isSetMWSAuthToken()) {
$parameters['MWSAuthToken'] = $request->getMWSAuthToken();
}
return array(CONVERTED_PARAMETERS_KEY => $parameters, CONVERTED_HEADERS_KEY => $this->defaultHeaders);
} | php | {
"resource": ""
} |
q249903 | MarketplaceWebService_Client.convertGetFeedSubmissionList | validation | private function convertGetFeedSubmissionList($request)
{
$parameters = array();
$parameters['Action'] = 'GetFeedSubmissionList';
if ($request->isSetMarketplace()) {
$parameters['Marketplace'] = $request->getMarketplace();
}
if ($request->isSetMerchant()) {
$parameters['Merchant'] = $request->getMerchant();
}
if ($request->isSetFeedSubmissionIdList()) {
$feedSubmissionIdList = $request->getFeedSubmissionIdList();
foreach ($feedSubmissionIdList->getId() as $idIndex => $id) {
$parameters['FeedSubmissionIdList' . '.' . 'Id' . '.' . ($idIndex + 1)] = $id;
}
}
if ($request->isSetMaxCount()) {
$parameters['MaxCount'] = $request->getMaxCount();
}
if ($request->isSetFeedTypeList()) {
$feedTypeList = $request->getFeedTypeList();
foreach ($feedTypeList->getType() as $typeIndex => $type) {
$parameters['FeedTypeList' . '.' . 'Type' . '.' . ($typeIndex + 1)] = $type;
}
}
if ($request->isSetFeedProcessingStatusList()) {
$feedProcessingStatusList = $request->getFeedProcessingStatusList();
foreach ($feedProcessingStatusList->getStatus() as $statusIndex => $status) {
$parameters['FeedProcessingStatusList' . '.' . 'Status' . '.' . ($statusIndex + 1)] = $status;
}
}
if ($request->isSetSubmittedFromDate()) {
$parameters['SubmittedFromDate'] = $this->getFormattedTimestamp($request->getSubmittedFromDate());
}
if ($request->isSetSubmittedToDate()) {
$parameters['SubmittedToDate'] = $this->getFormattedTimestamp($request->getSubmittedToDate());
}
if ($request->isSetMWSAuthToken()) {
$parameters['MWSAuthToken'] = $request->getMWSAuthToken();
}
return array(CONVERTED_PARAMETERS_KEY => $parameters, CONVERTED_HEADERS_KEY => $this->defaultHeaders);
} | php | {
"resource": ""
} |
q249904 | MarketplaceWebService_Client.convertGetReportRequestList | validation | private function convertGetReportRequestList($request)
{
$parameters = array();
$parameters['Action'] = 'GetReportRequestList';
if ($request->isSetMarketplace()) {
$parameters['Marketplace'] = $request->getMarketplace();
}
if ($request->isSetMerchant()) {
$parameters['Merchant'] = $request->getMerchant();
}
if ($request->isSetReportRequestIdList()) {
$reportRequestIdList = $request->getReportRequestIdList();
foreach ($reportRequestIdList->getId() as $idIndex => $id) {
$parameters['ReportRequestIdList' . '.' . 'Id' . '.' . ($idIndex + 1)] = $id;
}
}
if ($request->isSetReportTypeList()) {
$reportTypeList = $request->getReportTypeList();
foreach ($reportTypeList->getType() as $typeIndex => $type) {
$parameters['ReportTypeList' . '.' . 'Type' . '.' . ($typeIndex + 1)] = $type;
}
}
if ($request->isSetReportProcessingStatusList()) {
$reportProcessingStatusList = $request->getReportProcessingStatusList();
foreach ($reportProcessingStatusList->getStatus() as $statusIndex => $status) {
$parameters['ReportProcessingStatusList' . '.' . 'Status' . '.' . ($statusIndex + 1)] = $status;
}
}
if ($request->isSetMaxCount()) {
$parameters['MaxCount'] = $request->getMaxCount();
}
if ($request->isSetRequestedFromDate()) {
$parameters['RequestedFromDate'] = $this->getFormattedTimestamp($request->getRequestedFromDate());
}
if ($request->isSetRequestedToDate()) {
$parameters['RequestedToDate'] = $this->getFormattedTimestamp($request->getRequestedToDate());
}
if ($request->isSetMWSAuthToken()) {
$parameters['MWSAuthToken'] = $request->getMWSAuthToken();
}
return array(CONVERTED_PARAMETERS_KEY => $parameters, CONVERTED_HEADERS_KEY => $this->defaultHeaders);
} | php | {
"resource": ""
} |
q249905 | MarketplaceWebService_Client.convertManageReportSchedule | validation | private function convertManageReportSchedule($request)
{
$parameters = array();
$parameters['Action'] = 'ManageReportSchedule';
if ($request->isSetMarketplace()) {
$parameters['Marketplace'] = $request->getMarketplace();
}
if ($request->isSetMerchant()) {
$parameters['Merchant'] = $request->getMerchant();
}
if ($request->isSetReportType()) {
$parameters['ReportType'] = $request->getReportType();
}
if ($request->isSetSchedule()) {
$parameters['Schedule'] = $request->getSchedule();
}
if ($request->isSetScheduleDate()) {
$parameters['ScheduleDate'] = $this->getFormattedTimestamp($request->getScheduleDate());
}
if ($request->isSetMWSAuthToken()) {
$parameters['MWSAuthToken'] = $request->getMWSAuthToken();
}
return array(CONVERTED_PARAMETERS_KEY => $parameters, CONVERTED_HEADERS_KEY => $this->defaultHeaders);
} | php | {
"resource": ""
} |
q249906 | MarketplaceWebService_Client.convertGetReportRequestCount | validation | private function convertGetReportRequestCount($request)
{
$parameters = array();
$parameters['Action'] = 'GetReportRequestCount';
if ($request->isSetMarketplace()) {
$parameters['Marketplace'] = $request->getMarketplace();
}
if ($request->isSetMerchant()) {
$parameters['Merchant'] = $request->getMerchant();
}
if ($request->isSetReportTypeList()) {
$reportTypeList = $request->getReportTypeList();
foreach ($reportTypeList->getType() as $typeIndex => $type) {
$parameters['ReportTypeList' . '.' . 'Type' . '.' . ($typeIndex + 1)] = $type;
}
}
if ($request->isSetReportProcessingStatusList()) {
$reportProcessingStatusList = $request->getReportProcessingStatusList();
foreach ($reportProcessingStatusList->getStatus() as $statusIndex => $status) {
$parameters['ReportProcessingStatusList' . '.' . 'Status' . '.' . ($statusIndex + 1)] = $status;
}
}
if ($request->isSetRequestedFromDate()) {
$parameters['RequestedFromDate'] = $this->getFormattedTimestamp($request->getRequestedFromDate());
}
if ($request->isSetRequestedToDate()) {
$parameters['RequestedToDate'] = $this->getFormattedTimestamp($request->getRequestedToDate());
}
if ($request->isSetMWSAuthToken()) {
$parameters['MWSAuthToken'] = $request->getMWSAuthToken();
}
return array(CONVERTED_PARAMETERS_KEY => $parameters, CONVERTED_HEADERS_KEY => $this->defaultHeaders);
} | php | {
"resource": ""
} |
q249907 | FBAInboundServiceMWS_Model_InvalidASINList.setInvalidASIN | validation | public function setInvalidASIN($value)
{
if (!$this->_isNumericArray($value)) {
$value = array($value);
}
$this->_fields['InvalidASIN']['FieldValue'] = $value;
return $this;
} | php | {
"resource": ""
} |
q249908 | MarketplaceWebServiceProducts_Model_MessageList.setMessage | validation | public function setMessage($value)
{
if (!$this->_isNumericArray($value)) {
$value = array($value);
}
$this->_fields['Message']['FieldValue'] = $value;
return $this;
} | php | {
"resource": ""
} |
q249909 | MarketplaceWebServiceProducts_Model_GetProductCategoriesForASINResult.setSelf | validation | public function setSelf($value)
{
if (!$this->_isNumericArray($value)) {
$value = array($value);
}
$this->_fields['Self']['FieldValue'] = $value;
return $this;
} | php | {
"resource": ""
} |
q249910 | CleanAssetsCommand.computeFileSystemDifferences | validation | protected function computeFileSystemDifferences()
{
$entityPathByFilesystems = [];
foreach ($this->resourceManager->getResourceConfigurations() as $resourceConfiguration) {
$className = $resourceConfiguration->getEntity();
$entityManager = $this->doctrine->getManagerForClass($className);
if (!$entityManager instanceof EntityManagerInterface) {
throw new \UnexpectedValueException("No manager found for class {$className}");
}
$repository = $entityManager->getRepository($className);
if (!$repository instanceof ResourceRepositoryInterface) {
throw new \UnexpectedValueException(
"Repository for class {$className} must implement ResourceRepositoryInterface"
);
}
$paths = $repository->getPaths();
$adapterReference = $this->adaptersByResourceType[$resourceConfiguration->getCode()];
if (array_key_exists($adapterReference, $entityPathByFilesystems)) {
/** @noinspection SlowArrayOperationsInLoopInspection */
$entityPathByFilesystems[$adapterReference] = array_merge(
$entityPathByFilesystems[$adapterReference],
$paths
);
} else {
$entityPathByFilesystems[$adapterReference] = $paths;
}
}
foreach ($this->adapters as $adapterReference => $adapter) {
$existingPaths = [];
foreach ($adapter->listContents() as $metadata) {
$entityPath = $metadata['path'];
if ('.gitkeep' === $entityPath) {
continue;
}
$existingPaths[$entityPath] = $entityPath;
}
$entityPaths = $entityPathByFilesystems[$adapterReference];
$this->extraFiles[$adapterReference] = array_diff_key($existingPaths, $entityPaths);
$this->missingFiles[$adapterReference] = array_diff_key($entityPaths, $existingPaths);
}
} | php | {
"resource": ""
} |
q249911 | Bag.fromRecursive | validation | public static function fromRecursive($collection)
{
$arr = Arr::from($collection);
foreach ($arr as $key => $value) {
if ($value instanceof stdClass || \is_iterable($value)) {
$value = static::fromRecursive($value);
}
$arr[$key] = $value;
}
return new static($arr);
} | php | {
"resource": ""
} |
q249912 | Bag.combine | validation | public static function combine($keys, $values)
{
$keys = Arr::from($keys);
$values = Arr::from($values);
if (count($keys) !== count($values)) {
throw new InvalidArgumentException('The size of keys and values needs to be the same.');
}
if (count($keys) === 0) {
return new static();
}
return new static(array_combine($keys, $values));
} | php | {
"resource": ""
} |
q249913 | Bag.iterateFromIndex | validation | private function iterateFromIndex($fromIndex)
{
Assert::integer($fromIndex);
$count = count($this->items);
if ($count === 0) {
return;
}
$last = $count - 2;
$index = $fromIndex < 0 ? max($last + $fromIndex, -1) : min($fromIndex - 1, $last);
$keys = array_keys($this->items);
while (++$index < $count) {
$key = $keys[$index];
yield $key => $this->items[$key];
}
} | php | {
"resource": ""
} |
q249914 | Bag.iterateReverseFromIndex | validation | private function iterateReverseFromIndex($fromIndex)
{
Assert::nullOrInteger($fromIndex);
$index = count($this->items);
if ($index === 0) {
return;
}
if ($fromIndex !== null) {
$index = $fromIndex < 0 ? max($index + $fromIndex, 1) : min($fromIndex + 1, $index);
}
$keys = array_keys($this->items);
while (--$index >= 0) {
$key = $keys[$index];
yield $key => $this->items[$key];
}
} | php | {
"resource": ""
} |
q249915 | Bag.mapKeys | validation | public function mapKeys(callable $callback)
{
$items = [];
foreach ($this->items as $key => $value) {
$items[$callback($key, $value)] = $value;
}
return $this->createFrom($items);
} | php | {
"resource": ""
} |
q249916 | Bag.merge | validation | public function merge($list)
{
return $this->createFrom(array_merge($this->items, Arr::from($list)));
} | php | {
"resource": ""
} |
q249917 | Bag.flip | validation | public function flip()
{
if (!$this->items) {
return $this->createFrom([]);
}
try {
return $this->createFrom(Thrower::call('array_flip', $this->items));
} catch (ErrorException $e) {
throw new LogicException('Only string and integer values can be flipped');
}
} | php | {
"resource": ""
} |
q249918 | Bag.unique | validation | public function unique()
{
$items = [];
foreach ($this->items as $item) {
if (array_search($item, $items, true) === false) {
$items[] = $item;
}
}
return $this->createFrom($items);
} | php | {
"resource": ""
} |
q249919 | Bag.chunk | validation | public function chunk($size, $preserveKeys = false)
{
$create = function ($items) {
return $this->createFrom($items);
};
return $this->createFrom(array_map($create, array_chunk($this->items, $size, $preserveKeys)));
} | php | {
"resource": ""
} |
q249920 | Bag.sort | validation | public function sort($order = SORT_ASC, $flags = SORT_REGULAR, $preserveKeys = false)
{
$this->validateSortArgs($order, $flags);
$items = $this->items;
if (!$preserveKeys) {
if ($order === SORT_ASC) {
sort($items, $flags);
} elseif ($order === SORT_DESC) {
rsort($items, $flags);
}
} else {
if ($order === SORT_ASC) {
asort($items, $flags);
} elseif ($order === SORT_DESC) {
arsort($items, $flags);
}
}
return $this->createFrom($items);
} | php | {
"resource": ""
} |
q249921 | Bag.sortKeys | validation | public function sortKeys($order = SORT_ASC, $flags = SORT_REGULAR)
{
$this->validateSortArgs($order, $flags);
$items = $this->items;
if ($order === SORT_ASC) {
ksort($items, $flags);
} else {
krsort($items, $flags);
}
return $this->createFrom($items);
} | php | {
"resource": ""
} |
q249922 | Bag.set | validation | public function set($key, $value)
{
Deprecated::method(1.1, MutableBag::class);
$this->items[$key] = $value;
} | php | {
"resource": ""
} |
q249923 | Bag.setPath | validation | public function setPath($path, $value)
{
Deprecated::method(1.1, MutableBag::class);
Arr::set($this->items, $path, $value);
} | php | {
"resource": ""
} |
q249924 | Arr.from | validation | public static function from($iterable)
{
if (is_array($iterable)) {
return $iterable;
}
// Don't mean to play favorites, but want to optimize where we can.
if ($iterable instanceof ImmutableBag) {
return $iterable->toArray();
}
if ($iterable instanceof Traversable) {
return iterator_to_array($iterable);
}
if ($iterable === null) {
return [];
}
if ($iterable instanceof \stdClass) {
return (array) $iterable;
}
Assert::nullOrIsIterable($iterable);
} | php | {
"resource": ""
} |
q249925 | Arr.fromRecursive | validation | public static function fromRecursive($iterable)
{
$arr = static::from($iterable);
foreach ($arr as $key => $value) {
if ($value instanceof \stdClass || \is_iterable($value)) {
$value = static::fromRecursive($value);
}
$arr[$key] = $value;
}
return $arr;
} | php | {
"resource": ""
} |
q249926 | Arr.set | validation | public static function set(&$data, $path, $value)
{
Assert::isArrayAccessible($data);
Assert::stringNotEmpty($path);
$queue = explode('/', $path);
// Optimization for simple sets.
if (count($queue) === 1) {
if ($path === '[]') {
$data[] = $value;
} elseif (static::$unsetMarker && $value === static::$unsetMarker) {
unset($data[$path]);
} else {
$data[$path] = $value;
}
return;
}
$invalidKey = null;
$current = &$data;
while (($key = array_shift($queue)) !== null) {
if (!is_array($current) && !($current instanceof ArrayAccess)) {
throw new RuntimeException(
sprintf(
"Cannot set '%s', because '%s' is already set and not an array or an object implementing ArrayAccess.",
$path,
$invalidKey
)
);
}
if (!$queue) {
if ($key === '[]') {
$current[] = $value;
} elseif (static::$unsetMarker && $value === static::$unsetMarker) {
unset($current[$key]);
} else {
$current[$key] = $value;
}
return;
}
if ($current instanceof Bag && !($current instanceof MutableBag)) {
Deprecated::warn('Mutating items in a ' . Bag::class, 1.1, 'Use a ' . MutableBag::class . ' instead.');
}
if (!isset($current[$key])) {
$current[$key] = [];
}
$next = null;
if ($current instanceof ArrayAccess && !static::canReturnArraysByReference($current, $key, $next, $e)) {
throw new RuntimeException(
sprintf(
"Cannot set '%s', because '%s' is an %s which does not return arrays by reference from its offsetGet() method. See %s for an example of how to do this.",
$path,
$invalidKey,
get_class($current),
MutableBag::class
),
0,
$e
);
}
// If checking if object can return arrays by ref needed to fetch the value in the object then
// use that so we don't have to fetch the value again.
if ($next !== null) {
$current = &$next;
unset($next); // so assigning null above doesn't wipe out actual data
} else {
$current = &$current[$key];
}
$invalidKey = $key;
}
} | php | {
"resource": ""
} |
q249927 | Arr.remove | validation | public static function remove(&$data, $path, $default = null)
{
if (!static::$unsetMarker) {
static::$unsetMarker = new \stdClass();
}
// Call get() with special default value so we can know if the key exists without calling has()
$value = static::get($data, $path, static::$unsetMarker);
/*
* If the path doesn't exist don't call set().
* This also prevents set() from creating middle arrays to get to the leaf node,
* which doesn't make sense in this case since we are just trying to remove the leaf node.
*/
if ($value === static::$unsetMarker) {
return $default;
}
// Set with special marker to unset value at path
static::set($data, $path, static::$unsetMarker);
return $value;
} | php | {
"resource": ""
} |
q249928 | Arr.replaceRecursive | validation | public static function replaceRecursive($iterable1, $iterable2)
{
Assert::allIsIterable([$iterable1, $iterable2]);
if ($iterable1 instanceof Traversable) {
$iterable1 = iterator_to_array($iterable1);
}
if ($iterable2 instanceof Traversable) {
$iterable2 = iterator_to_array($iterable2);
}
$merged = $iterable1;
foreach ($iterable2 as $key => $value) {
if ($value instanceof Traversable) {
$value = iterator_to_array($value);
}
if (is_array($value) && static::isAssociative($value)
&& isset($merged[$key]) && \is_iterable($merged[$key])
) {
$merged[$key] = static::replaceRecursive($merged[$key], $value);
} elseif ($value === null && isset($merged[$key]) && \is_iterable($merged[$key])) {
// Convert iterable to array to be consistent.
if ($merged[$key] instanceof Traversable) {
$merged[$key] = iterator_to_array($merged[$key]);
}
continue;
} else {
$merged[$key] = $value;
}
}
return $merged;
} | php | {
"resource": ""
} |
q249929 | Arr.canReturnArraysByReference | validation | private static function canReturnArraysByReference(ArrayAccess $obj, $key, &$value, &$ex)
{
static $supportedClasses = [
// Add our classes by default to help with performance since we can
Bag::class => true, // but deprecated
MutableBag::class => true,
// These fail reflection check below even though they work fine :rolleyes:
\ArrayObject::class => true,
\ArrayIterator::class => true,
\RecursiveArrayIterator::class => true,
];
static $noErrors = [];
$class = get_class($obj);
/*
* Check to see if offsetGet() is defined to return reference (with "&" before method name).
* This prevents us from triggering indirect modification notices.
* We know for sure that the method cannot return by reference if not defined correctly, so we cache false.
* We do not know for sure that the method can return by reference if it is defined correctly, so we cache
* null instead of true. This allows the reflection check to only happen once, but still drop through to
* validation below.
*/
if (!isset($supportedClasses[$class])) {
$supportedClasses[$class] = (new \ReflectionMethod($obj, 'offsetGet'))->returnsReference() ? null : false;
}
// If definite value return that, else run validation below.
if ($supportedClasses[$class] !== null) {
return $supportedClasses[$class];
}
if (isset($noErrors[$class])) {
$value1 = &$obj[$key];
} else {
Thrower::set();
try {
$value1 = &$obj[$key];
} catch (\ErrorException $e) {
$msg = $e->getMessage();
if ($msg === 'Only variable references should be returned by reference' ||
strpos($msg, 'Indirect modification of overloaded element') === 0
) {
$ex = $e;
return $supportedClasses[$class] = false;
}
throw $e;
} finally {
restore_error_handler();
}
// We assume the object is not going to trigger warnings at this point
$noErrors[$class] = true;
}
// We cannot validate this result because objects are always returned by reference (and scalars do not matter).
if (!is_array($value1)) {
// return value (via parameter) so set() doesn't have to fetch the item again.
// We cannot do this if is an array because it will be the value instead of the reference.
$value = $value1;
return true;
}
// Verify the object can return arrays by reference.
$value2 = &$obj[$key];
$testKey = uniqid('__reference_test_');
$value1[$testKey] = 'test';
$supportedClasses[$class] = isset($value2[$testKey]);
unset($value1[$testKey]);
return $supportedClasses[$class];
} | php | {
"resource": ""
} |
q249930 | Arr.doFlatten | validation | private static function doFlatten($iterable, $depth, callable $predicate, array $result = [])
{
foreach ($iterable as $item) {
if ($depth >= 1 && $predicate($item)) {
$result = static::doFlatten($item, $depth - 1, $predicate, $result);
} else {
$result[] = $item;
}
}
return $result;
} | php | {
"resource": ""
} |
q249931 | Circle.validateElementValues | validation | protected function validateElementValues() {
// Iterate over all fields
foreach ( self::$mandatoryFields as $field ) {
// If the field does not exist then exit with exception
if ( array_key_exists($field, $this->attributes) ) {
$value = (int) $this->attributes[$field];
if ( $value < 0 ) {
throw new \SVGCreator\SVGException("The " . $field . " value is lesser than 0, in element " . self::TYPE, 1);
}
}
}
} | php | {
"resource": ""
} |
q249932 | ScriptHandler.symlinkJQueryFileUpload | validation | public static function symlinkJQueryFileUpload(Event $event)
{
$IO = $event->getIO();
$composer = $event->getComposer();
$cmanager = new ComposerPathFinder($composer);
$ds = DIRECTORY_SEPARATOR;
$options = [
'targetSuffix' => self::getTargetSuffix('jquery-file-upload'),
'sourcePrefix' => "..{$ds}..{$ds}..{$ds}",
];
list($symlinkTarget, $symlinkName) = $cmanager->getSymlinkFromComposer(
'sidus/file-upload-bundle',
'blueimp/jquery-file-upload',
$options
);
$IO->write('Checking Symlink', false);
if (false === self::checkSymlink($symlinkTarget, $symlinkName, true)) {
$IO->write('Creating Symlink: '.$symlinkName, false);
self::createSymlink($symlinkTarget, $symlinkName);
}
$IO->write('<info>OK</info>');
} | php | {
"resource": ""
} |
q249933 | ScriptHandler.checkSymlink | validation | public static function checkSymlink($symlinkTarget, $symlinkName, $forceSymlink = false)
{
if ($forceSymlink && file_exists($symlinkName) && !is_link($symlinkName)) {
if ('link' !== filetype($symlinkName)) {
throw new \UnexpectedValueException("{$symlinkName} exists and is not a link");
}
} elseif (is_link($symlinkName)) {
$linkTarget = readlink($symlinkName);
if ($linkTarget !== $symlinkTarget) {
if (!$forceSymlink) {
throw new \UnexpectedValueException(
"Symlink '{$symlinkName}' points to '{$linkTarget}' instead of '{$symlinkTarget}'"
);
}
unlink($symlinkName);
return false;
}
return true;
}
return false;
} | php | {
"resource": ""
} |
q249934 | ScriptHandler.createSymlink | validation | public static function createSymlink($symlinkTarget, $symlinkName)
{
if (false === @symlink($symlinkTarget, $symlinkName)) {
throw new \UnexpectedValueException("An error occurred while creating symlink '{$symlinkName}'");
}
if (false === $target = readlink($symlinkName)) {
throw new \UnexpectedValueException("Symlink {$symlinkName} points to target {$target}");
}
} | php | {
"resource": ""
} |
q249935 | BinarySizeUtility.parse | validation | public static function parse($size, $fallbackUnits = null)
{
preg_match('/^(\d+)[.,]?(\d*)\s*(\w*)$/', $size, $matches);
if (empty($matches[1]) || (empty($matches[3]) && null === $fallbackUnits)) {
throw new \UnexpectedValueException("Unable to parse : '{$size}'");
}
$oSize = $matches[1];
if (!empty($matches[2])) {
$oSize .= '.'.$matches[2];
}
$oSize = (float) $oSize;
$unit = strtolower(empty($matches[3]) ? $fallbackUnits : $matches[3]);
$byteMultiplier = 1;
if ('b' === substr($unit, -1)) {
$byteMultiplier = 8;
$unit = substr($unit, 0, -1).'o';
}
if (!array_key_exists($unit, self::getBinarySizes())) {
throw new \UnexpectedValueException("Unexpected unit {$unit}");
}
return (int) ($oSize * self::getBinarySizes()[$unit] * $byteMultiplier);
} | php | {
"resource": ""
} |
q249936 | BinarySizeUtility.format | validation | public static function format($size, $decimals = 2, $decPoint = '.', $thousandsSep = '', $unitSep = '')
{
$output = $unit = null;
foreach (self::getBinarySizes() as $unit => $divider) {
$output = $size / $divider;
if ($output < 1000) {
break;
}
}
if (null === $output) {
throw new \UnexpectedValueException("Unable to parse value: '{$size}'");
}
$unit = $unit === 'o' ? 'o' : ucfirst($unit);
$trimmed = rtrim(rtrim(number_format($output, $decimals, $decPoint, $thousandsSep), '0'), $decPoint);
$formatted = $trimmed.$unitSep.$unit;
return str_replace(' ', utf8_encode(chr(160)), $formatted);
} | php | {
"resource": ""
} |
q249937 | ConfigureCommand.handle | validation | public function handle()
{
$config = $this->option('config');
if (!$config) {
throw new Exception('Config option is required.');
}
$configPath = realpath($config);
if (!file_exists($configPath)) {
throw new Exception('Configuration file not found.');
}
$config = require($configPath);
$this->info(sprintf('Configuring with file "%s".', $configPath));
$this->getRbacService()->configure($config);
$this->info('Configuration done.');
} | php | {
"resource": ""
} |
q249938 | Element.validateMandatoryAttribs | validation | protected function validateMandatoryAttribs() {
// Iterate over all fields
foreach ( static::$mandatoryFields as $field ) {
// If the field does not exist then exit with exception
if ( !array_key_exists($field, $this->attributes) ) {
throw new \SVGCreator\SVGException("The field " . $field . " does not exist for " . static::TYPE . ".", 1);
}
}
} | php | {
"resource": ""
} |
q249939 | Element.attr | validation | public function attr($attrKey, $attrValue = null) {
if ( !is_null($attrValue) ) {
if ( !is_array($this->attributes) ) {
$this->attributes = array();
}
$this->attributes[$attrKey] = $attrValue;
return $this;
} else {
if ( array_key_exists($attrKey, $this->attributes) ) {
return $this->attributes[$attrKey];
} else {
return null;
}
}
} | php | {
"resource": ""
} |
q249940 | Element.factoryElement | validation | private function factoryElement($type) {
switch ( $type ) {
case \SVGCreator\Element::CIRCLE:
return new \SVGCreator\Elements\Circle();
break;
case \SVGCreator\Element::DEFS:
return new \SVGCreator\Elements\Defs();
break;
case \SVGCreator\Element::GROUP:
return new \SVGCreator\Elements\Group();
break;
case \SVGCreator\Element::LINE:
return new \SVGCreator\Elements\Line();
break;
case \SVGCreator\Element::MARKER:
return new \SVGCreator\Elements\Marker();
break;
case \SVGCreator\Element::PATH:
return new \SVGCreator\Elements\Path();
break;
case \SVGCreator\Element::RECT:
return new \SVGCreator\Elements\Rect();
break;
case \SVGCreator\Element::SVG:
return new \SVGCreator\Elements\Svg();
break;
case \SVGCreator\Element::TEXT:
return new \SVGCreator\Elements\Text();
break;
case \SVGCreator\Element::POLYGON:
return new \SVGCreator\Elements\Polygon();
break;
default:
throw new \SVGCreator\SVGException("The tag " . $type . " is not implemented yet", 1);
break;
}
} | php | {
"resource": ""
} |
q249941 | Element.append | validation | public function append($element) {
if ( true === $element instanceof \SVGCreator\Element ) {
$this->childElements[] = $element;
return $element;
} else {
$elementCreated = $this->factoryElement($element);
$this->childElements[] = $elementCreated;
return $elementCreated;
}
} | php | {
"resource": ""
} |
q249942 | Element.getString | validation | public function getString() {
// Validate the element first of all!
$this->validateElement();
// Start writing the tag
$elementStringData = '';
$elementStringData = '<' . static::TYPE;
foreach ( $this->attributes as $key => $data ) {
$elementStringData .= ' ' . $key . '="' . $data . '"';
}
// Close the initiating tag
$elementStringData .= '>';
if ( $this->text !== null ) {
$elementStringData .= $this->text;
}
// If it has child elements we have to write them!
if ( count($this->childElements) > 0 ) {
// See if there are definitions to put if the type is svg this is run here
// because the definition area should be the first to appear!
if ( static::TYPE == 'svg' ) {
foreach ( $this->childElements as $childElement ) {
// Let's get the definitions array from the child element and propagate them to the top!
$this->defs = array_merge($this->defs, $childElement->getDefs());
}
// If there are definitions to add then add them
if ( count($this->defs) > 0 ) {
// Create the defs area
$defArea = new \SVGCreator\Elements\Defs();
foreach ( $this->defs as $def ) {
// Append all elements to def area
$defArea->append($def);
}
// Get the defarea xml
$elementStringData .= $defArea->getString();
}
}
// Iterate trough each element and write it's child element
foreach ( $this->childElements as $childElement ) {
$elementStringData .= $childElement->getString();
}
}
// Always close the tag with no self closing, simplifys things a bit
// and it's not a couple of bytes that has us worried
$elementStringData .= '</' . static::TYPE . '>';
$this->elementString = $elementStringData;
return $this->elementString;
} | php | {
"resource": ""
} |
q249943 | Element.saveElementAsFile | validation | public function saveElementAsFile($fileName) {
// Get the element string
$this->getString();
if ( false === file_put_contents($fileName, $this->elementString) ) {
return false;
} else {
return $fileName;
}
} | php | {
"resource": ""
} |
q249944 | CmsThemeServiceProvider.registerViewComposers | validation | protected function registerViewComposers()
{
$core = $this->getCore();
view()->composer($core->config('views.menu'), MenuComposer::class);
view()->composer($core->config('views.top'), TopComposer::class);
return $this;
} | php | {
"resource": ""
} |
q249945 | TranslatableScope.apply | validation | public function apply(EloquentBuilder $builder, Eloquent $model)
{
$this->table = $model->getTable();
$this->locale = $model->getLocale();
$this->i18nTable = $model->getI18nTable();
$this->fallback = $model->getFallbackLocale();
if(!starts_with($this->table, 'laravel_reserved_')) {
$this->createJoin($builder, $model);
$this->createWhere($builder, $model);
$this->createSelect($builder, $model);
}
} | php | {
"resource": ""
} |
q249946 | TranslatableScope.extend | validation | public function extend(EloquentBuilder $builder)
{
$builder->macro('onlyTranslated', function (EloquentBuilder $builder, $locale = null) {
$builder->getModel()->setOnlyTranslated(true);
if($locale) {
$builder->getModel()->setLocale($locale);
}
return $builder;
});
$builder->macro('withUntranslated', function (EloquentBuilder $builder) {
$builder->getModel()->setOnlyTranslated(false);
return $builder;
});
$builder->macro('withFallback', function (EloquentBuilder $builder, $fallbackLocale = null) {
$builder->getModel()->setWithFallback(true);
if($fallbackLocale) {
$builder->getModel()->setFallbackLocale($fallbackLocale);
}
return $builder;
});
$builder->macro('withoutFallback', function (EloquentBuilder $builder) {
$builder->getModel()->setWithFallback(false);
return $builder;
});
$builder->macro('translateInto', function (EloquentBuilder $builder, $locale) {
if($locale) {
$builder->getModel()->setLocale($locale);
}
return $builder;
});
$builder->macro('withoutTranslations', function (EloquentBuilder $builder) {
$builder->withoutGlobalScope(static::class);
return $builder;
});
$builder->macro('withAllTranslations', function (EloquentBuilder $builder) {
$builder->withoutGlobalScope(static::class)
->with('translations');
return $builder;
});
} | php | {
"resource": ""
} |
q249947 | FolderDropdownField.setLastFolderID | validation | public function setLastFolderID($folderID)
{
$request = Controller::curr()->getRequest();
$session = $request->getSession();
$session->set(get_class() . '.FolderID', $folderID);
} | php | {
"resource": ""
} |
q249948 | FolderDropdownField.getLastFolderID | validation | public function getLastFolderID()
{
$request = Controller::curr()->getRequest();
$session = $request->getSession();
return $session->get(self::class . '.FolderID');
} | php | {
"resource": ""
} |
q249949 | QueryBuilder.select | validation | public function select($columns = ['*'])
{
parent::select($columns);
$this->columns = $this->qualifyColumns($this->columns);
return $this;
} | php | {
"resource": ""
} |
q249950 | QueryBuilder.qualifyColumns | validation | protected function qualifyColumns($columns)
{
foreach($columns as &$column) {
if(!in_array($column, $this->model->translatableAttributes())) {
continue;
}
$primary = $this->qualifyTranslationColumn($column);
$fallback = $this->qualifyTranslationColumn($column, true);
if($this->model->shouldFallback()) {
$column = new Expression($this->compileIfNull($primary, $fallback, $column));
} else {
$column = $primary;
}
}
return $columns;
} | php | {
"resource": ""
} |
q249951 | QueryBuilder.where | validation | public function where($column, $operator = null, $value = null, $boolean = 'and')
{
// If the column is an array, we will assume it is an array of key-value pairs
// and can add them each as a where clause. We will maintain the boolean we
// received when the method was called and pass it into the nested where.
if (is_array($column)) {
return $this->addArrayOfWheres($column, $boolean);
}
// Then we need to check if we are dealing with a translated column and defer
// to the "whereTranslated" clause in that case. That way the user doesn't
// need to worry about translated columns and let us handle the details.
if(in_array($column, $this->model->translatableAttributes())) {
return $this->whereTranslated($column, $operator, $value, $boolean);
}
return parent::where($column, $operator, $value, $boolean);
} | php | {
"resource": ""
} |
q249952 | QueryBuilder.whereOriginal | validation | public function whereOriginal($column, $operator = null, $value = null, $boolean = 'and')
{
return parent::where($column, $operator, $value, $boolean);
} | php | {
"resource": ""
} |
q249953 | QueryBuilder.whereTranslated | validation | public function whereTranslated($column, $operator = null, $value = null, $boolean = 'and')
{
// Here we will make some assumptions about the operator. If only 2 values are
// passed to the method, we will assume that the operator is an equals sign
// and keep going. Otherwise, we'll require the operator to be passed in.
if (func_num_args() == 2) {
list($value, $operator) = [$operator, '='];
} elseif ($this->invalidOperatorAndValue($operator, $value)) {
throw new InvalidArgumentException('Illegal operator and value combination.');
}
// If the given operator is not found in the list of valid operators we will
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if (! in_array(strtolower($operator), $this->operators, true)) {
list($value, $operator) = [$operator, '='];
}
$fallbackColumn = $this->qualifyTranslationColumn($column, true);
$column = $this->qualifyTranslationColumn($column);
// Finally we'll check whether we need to consider fallback translations. In
// that case we need to create a complex "ifnull" clause, otherwise we can
// just prepend the translation alias and add the where clause normally.
if (!$this->model->shouldFallback() || $column instanceof Closure) {
return $this->where($column, $operator, $value, $boolean);
}
$condition = $this->compileIfNull($column, $fallbackColumn);
return $this->whereRaw("$condition $operator ?", [$value], $boolean);
} | php | {
"resource": ""
} |
q249954 | QueryBuilder.orWhereTranslated | validation | public function orWhereTranslated($column, $operator = null, $value = null)
{
return $this->whereTranslated($column, $operator, $value, 'or');
} | php | {
"resource": ""
} |
q249955 | QueryBuilder.whereSubQuery | validation | public function whereSubQuery($column, $query, $boolean = 'and')
{
list($type, $operator) = ['Sub', 'in'];
$this->wheres[] = compact('type', 'column', 'operator', 'query', 'boolean');
$this->addBinding($query->getBindings(), 'where');
return $this;
} | php | {
"resource": ""
} |
q249956 | ApiBase.getAccessToken | validation | public function getAccessToken(): ApiAccessToken
{
try {
$accessToken = $this->tokenStorage->getAccessToken();
} catch (UnableToAcquireAccessToken $e) {
$accessToken = null;
}
if ($accessToken && $accessToken->isExpired()) {
$this->tokenStorage->unsetAccessToken();
$accessToken = null;
}
return $accessToken ?: $this->refreshToken();
} | php | {
"resource": ""
} |
q249957 | Translatable.createInLocale | validation | public static function createInLocale($locale, array $attributes = [], $translations = [])
{
$model = (new static($attributes))->setLocale($locale);
if ($model->save() && is_array($translations)) {
$model->saveTranslations($translations);
}
return $model;
} | php | {
"resource": ""
} |
q249958 | Translatable.forceCreate | validation | public static function forceCreate(array $attributes, $translations = [])
{
$model = new static;
return static::unguarded(function () use ($model, $attributes, $translations){
return $model->create($attributes, $translations);
});
} | php | {
"resource": ""
} |
q249959 | Translatable.forceCreateInLocale | validation | public static function forceCreateInLocale($locale, array $attributes, $translations = [])
{
$model = new static;
return static::unguarded(function () use ($locale, $model, $attributes, $translations){
return $model->createInLocale($locale, $attributes, $translations);
});
} | php | {
"resource": ""
} |
q249960 | Translatable.fresh | validation | public function fresh($with = [])
{
if (!$this->exists) {
return;
}
$query = static::newQueryWithoutScopes()
->with(is_string($with) ? func_get_args() : $with)
->where($this->getKeyName(), $this->getKey());
(new TranslatableScope())->apply($query, $this);
return $query->first();
} | php | {
"resource": ""
} |
q249961 | Translatable.initTranslatableAttributes | validation | protected function initTranslatableAttributes()
{
if (property_exists($this, 'translatable')) {
$attributes = $this->translatable;
}else {
$attributes = $this->getTranslatableAttributesFromSchema();
}
static::$i18nAttributes[$this->getTable()] = $attributes;
} | php | {
"resource": ""
} |
q249962 | Translatable.getTranslatableAttributesFromSchema | validation | protected function getTranslatableAttributesFromSchema()
{
if ((!$con = $this->getConnection()) || (!$builder = $con->getSchemaBuilder())) {
return [];
}
if ($columns = TranslatableConfig::cacheGet($this->getI18nTable())) {
return $columns;
}
$columns = $builder->getColumnListing($this->getI18nTable());
unset($columns[array_search($this->getForeignKey(), $columns)]);
TranslatableConfig::cacheSet($this->getI18nTable(), $columns);
return $columns;
} | php | {
"resource": ""
} |
q249963 | Translatable.translate | validation | public function translate($locale)
{
$found = $this->translations->where($this->getLocaleKey(), $locale)->first();
if (!$found && $this->shouldFallback($locale)) {
return $this->translate($this->getFallbackLocale());
}
return $found;
} | php | {
"resource": ""
} |
q249964 | Translatable.translateOrNew | validation | public function translateOrNew($locale)
{
if (is_null($instance = $this->translate($locale))) {
return $this->newModelInstance();
}
return $instance;
} | php | {
"resource": ""
} |
q249965 | Translatable.translations | validation | public function translations()
{
$localKey = $this->getKeyName();
$foreignKey = $this->getForeignKey();
$instance = $this->translationModel();
return new HasMany($instance->newQuery(), $this, $instance->getTable() . '.' . $foreignKey, $localKey);
} | php | {
"resource": ""
} |
q249966 | Translatable.translationModel | validation | public function translationModel()
{
$translation = new TranslationModel();
$translation->setConnection($this->getI18nConnection());
$translation->setTable($this->getI18nTable());
$translation->setKeyName($this->getForeignKey());
$translation->setLocaleKey($this->getLocaleKey());
if ($attributes = $this->translatableAttributes()) {
$translation->fillable(array_intersect($attributes, $this->getFillable()));
}
return $translation;
} | php | {
"resource": ""
} |
q249967 | Translatable.shouldFallback | validation | public function shouldFallback($locale = null)
{
if (!$this->getWithFallback() || !$this->getFallbackLocale()) {
return false;
}
$locale = $locale ?: $this->getLocale();
return $locale != $this->getFallbackLocale();
} | php | {
"resource": ""
} |
q249968 | Translatable.getDirty | validation | public function getDirty()
{
$dirty = parent::getDirty();
if (!$this->localeChanged) {
return $dirty;
}
foreach ($this->translatableAttributes() as $key) {
if (isset($this->attributes[$key])) {
$dirty[$key] = $this->attributes[$key];
}
}
return $dirty;
} | php | {
"resource": ""
} |
q249969 | SelectUploadField.changeFolder | validation | public function changeFolder(HTTPRequest $request)
{
// CSRF check
$token = $this->getForm()->getSecurityToken();
if (!$token->checkRequest($request)) {
return $this->httpError(400);
}
$folderID = $request->postVar('FolderID');
if ($folderID) {
$this->FolderSelector()->setLastFolderID($folderID);
}
} | php | {
"resource": ""
} |
q249970 | SelectUploadField.updateFolderName | validation | protected function updateFolderName(HTTPRequest $request)
{
// check if allowed to select folder
if (!$this->getCanSelectFolder()) {
return;
}
// Get path from upload
$folderID = $request->requestVar("{$this->Name}/folder");
$path = $this->folderPathFromID($folderID);
if ($path !== false) {
$this->setFolderName($path);
$this->selectField->setValue($folderID);
}
} | php | {
"resource": ""
} |
q249971 | SelectUploadField.getCanSelectFolder | validation | public function getCanSelectFolder()
{
if (!$this->isActive()) {
return false;
}
if ($this->template && in_array($this->template, self::config()->disable_for_templates)) {
return false;
}
// Check config
$can = $this->canSelectFolder;
return (is_bool($can)) ? $can : Permission::check($can);
} | php | {
"resource": ""
} |
q249972 | Server.whitelist | validation | public function whitelist(string $address): WhitelistResponse
{
try {
$response = $this->callHydroApi(
'post',
'whitelist',
[
'timeout' => 60,
'json' => [
'address' => $address
]
]
);
$data = \GuzzleHttp\json_decode($response->getBody()->getContents(), true);
} catch (RuntimeException $e) {
throw AddressWhitelistingFailed::forAddress($address, $e->getMessage());
} catch (InvalidArgumentException $e) {
throw AddressWhitelistingFailed::forAddress($address, $e->getMessage());
} catch (GuzzleException $e) {
throw AddressWhitelistingFailed::forAddress($address, $e->getMessage());
} catch (ApiRequestFailed $e) {
throw AddressWhitelistingFailed::forAddress($address, $e->getMessage());
}
return new WhitelistResponse(
$data['hydro_address_id'],
$data['transaction_hash']
);
} | php | {
"resource": ""
} |
q249973 | Server.challenge | validation | public function challenge(string $hydroAddressId): ChallengeResponse
{
try {
$response = $this->callHydroApi(
'post',
'challenge',
[
'json' => [
'hydro_address_id' => $hydroAddressId
]
]
);
$data = \GuzzleHttp\json_decode($response->getBody()->getContents(), true, 512, JSON_BIGINT_AS_STRING);
} catch (RuntimeException $e) {
throw ChallengeFailed::forHydroAddressId($hydroAddressId, $e->getMessage());
} catch (InvalidArgumentException $e) {
throw ChallengeFailed::forHydroAddressId($hydroAddressId, $e->getMessage());
} catch (GuzzleException $e) {
throw ChallengeFailed::forHydroAddressId($hydroAddressId, $e->getMessage());
} catch (ApiRequestFailed $e) {
throw ChallengeFailed::forHydroAddressId($hydroAddressId, $e->getMessage());
}
return new ChallengeResponse(
$data['amount'],
(int) $data['challenge'],
(int) $data['partner_id'],
$data['transaction_hash']
);
} | php | {
"resource": ""
} |
q249974 | Builder.update | validation | public function update(array $values)
{
$updated = 0;
$modelKey = $this->getModel()->getKey();
$modelKeyName = $this->model->getKeyName();
$values = $this->addUpdatedAtColumn($values);
list($values, $i18nValues) = $this->filterValues($values);
$ids = $modelKey ? [$modelKey] : $this->pluck($modelKeyName)->all();
if($values) {
$updated += $this->updateBase($values, $ids);
}
if($i18nValues) {
$updated += $this->updateI18n($i18nValues, $ids);
}
return $updated;
} | php | {
"resource": ""
} |
q249975 | Builder.increment | validation | public function increment($column, $amount = 1, array $extra = [])
{
$extra = $this->addUpdatedAtColumn($extra);
return $this->noTranslationsQuery()->increment($column, $amount, $extra);
} | php | {
"resource": ""
} |
q249976 | Builder.decrement | validation | public function decrement($column, $amount = 1, array $extra = [])
{
$extra = $this->addUpdatedAtColumn($extra);
return $this->noTranslationsQuery()->decrement($column, $amount, $extra);
} | php | {
"resource": ""
} |
q249977 | Builder.insert | validation | public function insert(array $values)
{
list($values, $i18nValues) = $this->filterValues($values);
if($this->query->insert($values)) {
return $this->insertI18n($i18nValues, $values[$this->model->getKeyName()]);
}
} | php | {
"resource": ""
} |
q249978 | Builder.insertGetId | validation | public function insertGetId(array $values, $sequence = null)
{
list($values, $i18nValues) = $this->filterValues($values);
if($id = $this->query->insertGetId($values, $sequence)) {
if($this->insertI18n($i18nValues, $id)) {
return $id;
}
}
return false;
} | php | {
"resource": ""
} |
q249979 | Builder.filterValues | validation | protected function filterValues(array $values)
{
$attributes = $this->model->translatableAttributes();
$translatable = [];
foreach($attributes as $key) {
if(array_key_exists($key, $values)) {
$translatable[$key] = $values[$key];
unset($values[$key]);
}
}
return [$values, $translatable];
} | php | {
"resource": ""
} |
q249980 | Builder.updateBase | validation | private function updateBase(array $values, array $ids)
{
$query = $this->model->newQuery()
->whereIn($this->model->getKeyName(), $ids)
->getQuery();
return $query->update($values);
} | php | {
"resource": ""
} |
q249981 | Builder.i18nQuery | validation | public function i18nQuery()
{
$query = $this->getModel()->newQueryWithoutScopes()->getQuery();
$query->from($this->model->getI18nTable());
return $query;
} | php | {
"resource": ""
} |
q249982 | Builder.i18nDeleteQuery | validation | protected function i18nDeleteQuery($withGlobalScopes = true)
{
$subQuery = $withGlobalScopes ? $this->toBase() : $this->getQuery();
$subQuery->select($this->model->getQualifiedKeyName());
return $this->i18nQuery()->whereIn(
$this->model->getForeignKey(), $subQuery->pluck($this->model->getKeyName())
);
} | php | {
"resource": ""
} |
q249983 | TranslationModel.setKeysForSaveQuery | validation | protected function setKeysForSaveQuery(EloquentBuilder $query)
{
$query->where($this->getKeyName(), '=', $this->getKeyForSaveQuery());
$query->where($this->localeKey, '=', $this->{$this->localeKey});
return $query;
} | php | {
"resource": ""
} |
q249984 | Listener.start | validation | public function start()
{
$this->eventDispatcher->addListener(
'key:stop:listening',
function () {
$this->isListening = false;
}
);
$this->resetListener()
->overrideReadlineHandler()
->runLoop()
->restoreReadlineHandler();
} | php | {
"resource": ""
} |
q249985 | Listener.runLoop | validation | protected function runLoop()
{
while ($this->isListening) {
$this->stream->select();
// special key sequence has started
if (true === $this->charSequenceEnabled && null !== $this->escapePressedAt) {
if ($this->escapeKeyHasExpired()) {
$this->disableKeySequence();
$this->setCurrentKey($this->matcher->getKey($this->matcher->getEscapeKey()));
// run key listeners, if one of the key callbacks returns true
// break the loop and restore default terminal functionality
$this->dispatchKeyPressEvents($this->getCurrentKey());
}
}
// proceed if the stream isn't empty
if ($this->stream->isAvailable()) {
$char = $this->stream->getChar();
// start of the special key sequence
// mark the sequence start and setup the timer for the escape key
if ($this->matcher->getEscapeKey() === $char) {
$this->enableKeySequence();
$this->setCurrentKey($char);
} else {
$this->escapePressedAt = null;
if ($this->charSequenceEnabled) {
// if special key was pressed, concatenate the current
// escape character with the next characters that come
// in through the stream
$this->concatCurrentKey($char);
$mapped = $this->matcher->getKey($this->getCurrentKey());
// check and get which arrow key was pressed
if ($mapped) {
$this->setCurrentKey($mapped);
$this->disableKeySequence();
} else {
// we skip this iteration because the sequence isn't
// finished yet and we don't need to run the key
// listeners
continue;
}
} else {
// something out of basic latin charset so we ignore it
if ($this->matcher->isBasicLatin($char)) {
continue;
} else {
// normal keyboard key was pressed
$this->setCurrentKey($this->matcher->getKey($char) ?: $char);
}
}
// run key listeners, if one of the key callbacks returns true
// break the loop and restore default terminal functionality
$this->dispatchKeyPressEvents($this->getCurrentKey());
}
}
}
return $this;
} | php | {
"resource": ""
} |
q249986 | Listener.resetListener | validation | protected function resetListener()
{
$this->currentKey = null;
$this->escapePressedAt = null;
$this->charSequenceEnabled = false;
$this->isListening = true;
return $this;
} | php | {
"resource": ""
} |
q249987 | Detector.getListenerInstance | validation | public function getListenerInstance(EventDispatcher $eventDispatcher = null, StreamableInterface $stream = null)
{
//instantiate the key matcher object
$reflection = new \ReflectionClass('\\Iber\\Phkey\\Environment\\' . $this->getEnvironment() . '\\Matcher');
$matcher = $reflection->newInstance();
$reflection = new \ReflectionClass('\\Iber\\Phkey\\Environment\\' . $this->getEnvironment() . '\\Listener');
if (null === $eventDispatcher) {
$eventDispatcher = new EventDispatcher();
}
if (null === $stream) {
$stream = new Stream();
}
$listener = $reflection->newInstance($matcher, $eventDispatcher, $stream);
return $listener;
} | php | {
"resource": ""
} |
q249988 | Stream.select | validation | public function select()
{
$read = [$this->stream];
$write = null;
$except = null;
// if the process gets a system signal before the timeout is ran
// a warning is thrown therefore we need to suppress the warning
$this->selected = @stream_select(
$read,
$write,
$except,
0,
$this->timeout
);
return $this;
} | php | {
"resource": ""
} |
q249989 | ObjectDefinition.addMethodCall | validation | public function addMethodCall($methodName, array $arguments = array())
{
$this->actions[] = $methodCall = new MethodCall($methodName, $arguments);
return $methodCall;
} | php | {
"resource": ""
} |
q249990 | ServiceProviderLoader.loadFromRegistry | validation | public function loadFromRegistry(Registry $registry)
{
foreach ($registry as $key => $serviceProvider) {
$this->loadServiceProviderFactories($serviceProvider, $key);
}
foreach ($registry as $key => $serviceProvider) {
$this->loadServiceProviderExtensions($serviceProvider, $key);
}
} | php | {
"resource": ""
} |
q249991 | ValueUtils.dumpValue | validation | public static function dumpValue($value, $containerVariable, array $usedVariables): InlineEntryInterface
{
if (is_array($value)) {
return self::dumpArray($value, $containerVariable, $usedVariables);
} elseif ($value instanceof ReferenceInterface) {
return self::dumpReference($value, $containerVariable, $usedVariables);
} elseif ($value instanceof DumpableInterface) {
return self::dumpDefinition($value, $containerVariable, $usedVariables);
} elseif (is_object($value) || is_resource($value)) {
throw new \RuntimeException('Unable to dump a container if a parameter is an object or a resource.');
} else {
return new InlineEntry(var_export($value, true), null, $usedVariables, false);
}
} | php | {
"resource": ""
} |
q249992 | Parser.addCurrentMessage | validation | private function addCurrentMessage()
{
if ($this->currentMessage->hasTranslation()) {
$this->messages[] = $this->currentMessage;
$this->currentMessage = new Message();
}
} | php | {
"resource": ""
} |
q249993 | Compiler.addDefinition | validation | public function addDefinition($identifier, DefinitionInterface $definition)
{
$this->definitions[$identifier] = $definition;
unset($this->dumpableDefinitions[$identifier]);
} | php | {
"resource": ""
} |
q249994 | Compiler.register | validation | public function register(DefinitionProviderInterface $definitionProvider)
{
foreach ($definitionProvider->getDefinitions() as $identifier => $definition) {
$this->addDefinition($identifier, $definition);
}
} | php | {
"resource": ""
} |
q249995 | Master.start | validation | public function start($block = true, $interval = 100)
{
$loop = $this->loop;
$this->pool = new ParallelPool(function () use ($loop) {
$loop->run();
}, $this->count);
$this->pool->start();
$this->pool->keep($block, $interval);
} | php | {
"resource": ""
} |
q249996 | TrackerFactory.buildTracker | validation | public function buildTracker($numItems = Tracker::UNKNOWN, array $extraSubscribers = [])
{
$tracker = new Tracker($numItems);
foreach (array_merge($this->defaultSubscribers, $extraSubscribers) as $listener) {
$tracker->getDispatcher()->addSubscriber($listener);
}
return $tracker;
} | php | {
"resource": ""
} |
q249997 | Tracker.build | validation | public static function build(array $subscribers = [], $totalItems = self::UNKNOWN)
{
// New object
$that = new static($totalItems);
// Register subscribers
foreach ($subscribers as $subscriber) {
$that->addSubscriber($subscriber);
}
// Return it
return $that;
} | php | {
"resource": ""
} |
q249998 | Tracker.run | validation | public function run(\Traversable $items, callable $itemCallback)
{
$this->start();
foreach ($items as $item) {
call_user_func($itemCallback, $this, $item);
}
return $this->finish();
} | php | {
"resource": ""
} |
q249999 | Tracker.tick | validation | public function tick($status = Tick::SUCCESS, $msg = null, array $extraInfo = [], $incrementBy = 1)
{
if ( ! $this->isRunning()) {
$this->start();
}
$tick = new Tick($this, $status, $msg, $extraInfo, $incrementBy);
// Increment the counter
if (array_key_exists($tick->getStatus(), $this->numProcessedItems)) {
$this->numProcessedItems[$tick->getStatus()] += $tick->getIncrementBy();
}
else {
$this->numProcessedItems[$tick->getStatus()] = $tick->getIncrementBy();
}
$this->dispatcher->dispatch(Events::TRACKER_TICK, $tick);
$this->lastTick = $tick;
return $tick->getReport();
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.