Format code

This commit is contained in:
李铭昕 2022-01-14 19:09:25 +08:00
parent 80259c1af8
commit 04a8057648
4 changed files with 47 additions and 48 deletions

View File

@ -271,7 +271,7 @@ class InjectTest extends TestCase
throw new Exception('The process fork failed');
}
if ($pid === 0) {
$scanner = new Scanner($loader = Mockery::mock(ClassLoader::class), new ScanConfig(false, '/'));
$scanner = new Scanner($loader = Mockery::mock(ClassLoader::class), new ScanConfig(false, '/'), new NullScanHandler());
$reader = new AnnotationReader();
if (empty($classes)) {

View File

@ -316,7 +316,7 @@ class FieldsBuilder
}
/**
* @return GraphQLType&OutputType
* @return GraphQLType|OutputType
*/
private function mapReturnType(ReflectionMethod $refMethod, DocBlock $docBlockObj): GraphQLType
{
@ -332,7 +332,7 @@ class FieldsBuilder
$docBlockReturnType = $this->getDocBlocReturnType($docBlockObj, $refMethod);
try {
/** @var GraphQLType&OutputType $type */
/** @var GraphQLType|OutputType $type */
$type = $this->mapType($phpdocType, $docBlockReturnType, $returnType ? $returnType->allowsNull() : false, false);
} catch (TypeMappingException $e) {
throw TypeMappingException::wrapWithReturnInfo($e, $refMethod);

View File

@ -31,7 +31,7 @@ class ResolvableInputObjectType extends TheCodingMachineResolvableInputObjectTyp
private $argumentResolver;
/**
* @var callable&array<int, object|string>
* @var array<int, object|string>|callable
*/
private $resolve;

View File

@ -1383,50 +1383,6 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
return new static($results);
}
/**
* Sort the collection using multiple comparisons.
*
* @param array $comparisons
* @return static
*/
protected function sortByMany(array $comparisons = [])
{
$items = $this->items;
usort($items, function ($a, $b) use ($comparisons) {
foreach ($comparisons as $comparison) {
$comparison = Arr::wrap($comparison);
$prop = $comparison[0];
$ascending = Arr::get($comparison, 1, true) === true ||
Arr::get($comparison, 1, true) === 'asc';
$result = 0;
if (! is_string($prop) && is_callable($prop)) {
$result = $prop($a, $b);
} else {
$values = [data_get($a, $prop), data_get($b, $prop)];
if (! $ascending) {
$values = array_reverse($values);
}
$result = $values[0] <=> $values[1];
}
if ($result === 0) {
continue;
}
return $result;
}
});
return new static($items);
}
/**
* Sort the collection in descending order using the given callback.
*
@ -1736,6 +1692,49 @@ class Collection implements ArrayAccess, Arrayable, Countable, IteratorAggregate
static::$proxies[] = $method;
}
/**
* Sort the collection using multiple comparisons.
*
* @return static
*/
protected function sortByMany(array $comparisons = [])
{
$items = $this->items;
usort($items, function ($a, $b) use ($comparisons) {
foreach ($comparisons as $comparison) {
$comparison = Arr::wrap($comparison);
$prop = $comparison[0];
$ascending = Arr::get($comparison, 1, true) === true
|| Arr::get($comparison, 1, true) === 'asc';
$result = 0;
if (! is_string($prop) && is_callable($prop)) {
$result = $prop($a, $b);
} else {
$values = [data_get($a, $prop), data_get($b, $prop)];
if (! $ascending) {
$values = array_reverse($values);
}
$result = $values[0] <=> $values[1];
}
if ($result === 0) {
continue;
}
return $result;
}
});
return new static($items);
}
/**
* Get an operator checker callback.
* @param mixed|string $operator