mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-04 04:37:46 +08:00
Format code
This commit is contained in:
parent
80259c1af8
commit
04a8057648
@ -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)) {
|
||||
|
@ -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);
|
||||
|
@ -31,7 +31,7 @@ class ResolvableInputObjectType extends TheCodingMachineResolvableInputObjectTyp
|
||||
private $argumentResolver;
|
||||
|
||||
/**
|
||||
* @var callable&array<int, object|string>
|
||||
* @var array<int, object|string>|callable
|
||||
*/
|
||||
private $resolve;
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user