mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 03:37:44 +08:00
Format code (#5063)
This commit is contained in:
parent
ff979a63c1
commit
dd8e12ca42
@ -37,7 +37,7 @@
|
||||
"elasticsearch/elasticsearch": "^7.0",
|
||||
"fig/http-message-util": "^1.1.2",
|
||||
"filp/whoops": "^2.7",
|
||||
"friendsofphp/php-cs-fixer": "3.4.0",
|
||||
"friendsofphp/php-cs-fixer": "^3.4",
|
||||
"google/protobuf": "^3.6.1",
|
||||
"grpc/grpc": "^1.15",
|
||||
"guzzlehttp/guzzle": "^6.3|^7.0",
|
||||
|
@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Hyperf\Config;
|
||||
|
||||
use Hyperf\Utils\Composer;
|
||||
|
||||
use function class_exists;
|
||||
use function is_string;
|
||||
use function method_exists;
|
||||
|
@ -86,7 +86,7 @@ class Parser
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trim($value) === '' || ! $this->between((int) $value, ($min > $start ? $min : $start), $max)) {
|
||||
if (trim($value) === '' || ! $this->between((int) $value, $min > $start ? $min : $start, $max)) {
|
||||
continue;
|
||||
}
|
||||
$result[] = (int) $value;
|
||||
|
@ -14,6 +14,7 @@ namespace Hyperf\Database\Model\Events;
|
||||
use Hyperf\Database\Model\Model;
|
||||
use Hyperf\Event\Stoppable;
|
||||
use Psr\EventDispatcher\StoppableEventInterface;
|
||||
|
||||
use function class_basename;
|
||||
use function lcfirst;
|
||||
use function method_exists;
|
||||
|
@ -77,9 +77,9 @@ class VendorPublishCommand extends SymfonyCommand
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$item = (Arr::where($publish, function ($item) use ($id) {
|
||||
$item = Arr::where($publish, function ($item) use ($id) {
|
||||
return $item['id'] == $id;
|
||||
}));
|
||||
});
|
||||
|
||||
if (empty($item)) {
|
||||
$output->writeln(sprintf('<fg=red>No file can be published from [%s].</>', $id));
|
||||
|
@ -13,6 +13,7 @@ namespace Hyperf\Di\Definition;
|
||||
|
||||
use Hyperf\Di\ReflectionManager;
|
||||
use ReflectionFunctionAbstract;
|
||||
|
||||
use function class_exists;
|
||||
use function interface_exists;
|
||||
use function is_callable;
|
||||
|
@ -16,9 +16,7 @@ class FactoryDefinition implements DefinitionInterface
|
||||
private bool $needProxy = false;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param callable|string $factory
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct(private string $name, private mixed $factory, private array $parameters = [])
|
||||
{
|
||||
|
@ -14,6 +14,7 @@ namespace Hyperf\Dispatcher;
|
||||
use Hyperf\Dispatcher\Exceptions\InvalidArgumentException;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
|
||||
use function is_string;
|
||||
|
||||
abstract class AbstractRequestHandler
|
||||
|
@ -62,10 +62,10 @@ class WhoopsExceptionHandler extends ExceptionHandler
|
||||
$accepts = $request->getHeaderLine('accept');
|
||||
foreach (self::$preference as $contentType => $handler) {
|
||||
if (Str::contains($accepts, $contentType)) {
|
||||
return [$this->setupHandler(new $handler()), $contentType];
|
||||
return [$this->setupHandler(new $handler()), $contentType];
|
||||
}
|
||||
}
|
||||
return [new PlainTextHandler(), 'text/plain'];
|
||||
return [new PlainTextHandler(), 'text/plain'];
|
||||
}
|
||||
|
||||
protected function setupHandler($handler)
|
||||
|
@ -16,6 +16,7 @@ use Hyperf\Contract\StdoutLoggerInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use function sprintf;
|
||||
use function str_replace;
|
||||
|
||||
|
@ -24,6 +24,7 @@ use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use TheCodingMachine\GraphQLite\Annotations\AbstractRequest;
|
||||
use TheCodingMachine\GraphQLite\Annotations\Exceptions\ClassNotFoundException;
|
||||
|
||||
use function in_array;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
@ -184,7 +185,7 @@ class AnnotationReader
|
||||
if ($this->isErrorImportant($annotationClass, $refClass->getDocComment(), $refClass->getName())) {
|
||||
throw $e;
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
default:
|
||||
throw new \RuntimeException("Unexpected mode '{$this->mode}'."); // @codeCoverageIgnore
|
||||
}
|
||||
@ -219,7 +220,7 @@ class AnnotationReader
|
||||
if ($this->isErrorImportant($annotationClass, $refMethod->getDocComment(), $refMethod->getDeclaringClass()->getName())) {
|
||||
throw $e;
|
||||
}
|
||||
return null;
|
||||
return null;
|
||||
default:
|
||||
throw new \RuntimeException("Unexpected mode '{$this->mode}'."); // @codeCoverageIgnore
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ use TheCodingMachine\GraphQLite\Types\DateTimeType;
|
||||
use TheCodingMachine\GraphQLite\Types\ID;
|
||||
use TheCodingMachine\GraphQLite\Types\TypeResolver;
|
||||
use TheCodingMachine\GraphQLite\Types\UnionType;
|
||||
|
||||
use function array_merge;
|
||||
use function get_parent_class;
|
||||
|
||||
@ -715,7 +716,7 @@ class FieldsBuilder
|
||||
if ($mapToInputType) {
|
||||
return $this->typeMapper->mapClassToInputType($className);
|
||||
}
|
||||
return $this->typeMapper->mapClassToInterfaceOrType($className, $subType);
|
||||
return $this->typeMapper->mapClassToInterfaceOrType($className, $subType);
|
||||
}
|
||||
} elseif ($type instanceof Array_) {
|
||||
return GraphQLType::listOf(GraphQLType::nonNull($this->toGraphQlType($type->getValueType(), $subType, $mapToInputType)));
|
||||
|
@ -18,6 +18,7 @@ use TheCodingMachine\GraphQLite\Mappers\RecursiveTypeMapperInterface;
|
||||
use TheCodingMachine\GraphQLite\Types\ArgumentResolver;
|
||||
use TheCodingMachine\GraphQLite\Types\ResolvableInputInterface;
|
||||
use TheCodingMachine\GraphQLite\Types\ResolvableInputObjectType as TheCodingMachineResolvableInputObjectType;
|
||||
|
||||
use function get_class;
|
||||
|
||||
/**
|
||||
|
@ -28,6 +28,7 @@ use TheCodingMachine\GraphQLite\Mappers\RecursiveTypeMapperInterface;
|
||||
use TheCodingMachine\GraphQLite\Mappers\TypeMapperInterface;
|
||||
use TheCodingMachine\GraphQLite\NamingStrategyInterface;
|
||||
use TheCodingMachine\GraphQLite\Types\MutableObjectType;
|
||||
|
||||
use function array_keys;
|
||||
use function filemtime;
|
||||
|
||||
|
@ -172,7 +172,7 @@ class BaseClient
|
||||
private function init()
|
||||
{
|
||||
if (! empty($this->options['client'])) {
|
||||
if (! ($this->options['client'] instanceof GrpcClient)) {
|
||||
if (! $this->options['client'] instanceof GrpcClient) {
|
||||
throw new InvalidArgumentException('Parameter client have to instanceof Hyperf\GrpcClient\GrpcClient');
|
||||
}
|
||||
$this->grpcClient = $this->options['client'];
|
||||
|
@ -36,7 +36,7 @@ class CookieJar implements CookieJarInterface
|
||||
public function __construct(private $strictMode = false, $cookieArray = [])
|
||||
{
|
||||
foreach ($cookieArray as $cookie) {
|
||||
if (! ($cookie instanceof SetCookie)) {
|
||||
if (! $cookie instanceof SetCookie) {
|
||||
$cookie = new SetCookie($cookie);
|
||||
}
|
||||
$this->setCookie($cookie);
|
||||
|
@ -34,6 +34,7 @@ use Hyperf\Utils\Str;
|
||||
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
use function get_class;
|
||||
|
||||
class Response implements PsrResponseInterface, ResponseInterface
|
||||
|
@ -24,6 +24,7 @@ use Psr\Container\ContainerInterface;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Swoole\Server;
|
||||
use Swoole\Timer;
|
||||
|
||||
use function gc_status;
|
||||
use function getrusage;
|
||||
use function memory_get_peak_usage;
|
||||
|
@ -50,7 +50,7 @@ class MetricFactoryPicker
|
||||
$driver = $config->get("metric.metric.{$name}.driver", PrometheusFactory::class);
|
||||
|
||||
$factory = $container->get($driver);
|
||||
if (! ($factory instanceof MetricFactoryInterface)) {
|
||||
if (! $factory instanceof MetricFactoryInterface) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('The driver %s is not a valid factory.', $driver)
|
||||
);
|
||||
|
@ -474,7 +474,7 @@ class Connection
|
||||
|
||||
$len = ($len - $written);
|
||||
if ($len > 0) {
|
||||
$msg = substr($msg, (0 - $len));
|
||||
$msg = substr($msg, 0 - $len);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ use bandwidthThrottle\tokenBucket\TokenBucket;
|
||||
use Hyperf\RateLimit\Storage\RedisStorage;
|
||||
use Hyperf\Redis\Redis;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
use function make;
|
||||
|
||||
class RateLimitHandler
|
||||
|
@ -19,6 +19,7 @@ use Hyperf\Redis\Redis;
|
||||
use malkusch\lock\mutex\Mutex;
|
||||
use malkusch\lock\mutex\PHPRedisMutex;
|
||||
use Psr\SimpleCache\InvalidArgumentException;
|
||||
|
||||
use function make;
|
||||
|
||||
class RedisStorage implements Storage, GlobalScope
|
||||
|
@ -70,9 +70,9 @@ class ResourceTest extends TestCase
|
||||
public function testAnObjectsMayBeConvertedToJson()
|
||||
{
|
||||
$this->http(function () {
|
||||
return (ObjectResource::make(
|
||||
return ObjectResource::make(
|
||||
(object) ['first_name' => 'Bob', 'age' => 40]
|
||||
))->toResponse();
|
||||
)->toResponse();
|
||||
})->assertJson([
|
||||
'data' => [
|
||||
'name' => 'Bob',
|
||||
@ -613,7 +613,7 @@ class ResourceTest extends TestCase
|
||||
'Mohamed',
|
||||
$this->mergeWhen(false, ['Adam', 'Matt']),
|
||||
'Jeffrey',
|
||||
$this->mergeWhen(false, (['Abigail', 'Lydia'])),
|
||||
$this->mergeWhen(false, ['Abigail', 'Lydia']),
|
||||
]);
|
||||
}
|
||||
};
|
||||
|
@ -110,7 +110,7 @@ class Calculator
|
||||
continue;
|
||||
}
|
||||
if ($match === '-' && ($key === 0 || (isset($matches[0][$key - 1]) && in_array($matches[0][$key - 1], ['+', '-', '*', '/', '('])))) {
|
||||
$numStack->push($match . ($matches[0][$key + 1]));
|
||||
$numStack->push($match . $matches[0][$key + 1]);
|
||||
unset($matches[0][$key + 1]);
|
||||
continue;
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ use Symfony\Component\Finder\Finder;
|
||||
class FileHandler implements SessionHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @param Filesystem $files
|
||||
* @param string $path the path where sessions should be stored
|
||||
* @param int $minutes the number of minutes the session should be valid
|
||||
*/
|
||||
|
@ -221,17 +221,17 @@ class SessionMiddlewareTest extends TestCase
|
||||
$reflectionClass = new ReflectionClass(SessionMiddleware::class);
|
||||
$reflectionMethod = $reflectionClass->getMethod('fullUrl');
|
||||
$reflectionMethod->setAccessible(true);
|
||||
$result = $reflectionMethod->invokeArgs($middleware, [new Request('get', (new Uri($path = '/foo/bar')))]);
|
||||
$result = $reflectionMethod->invokeArgs($middleware, [new Request('get', new Uri($path = '/foo/bar'))]);
|
||||
$this->assertSame($path, $result);
|
||||
$result = $reflectionMethod->invokeArgs($middleware, [new Request('get', (new Uri($path = '/foo/bar?baz=1')))]);
|
||||
$result = $reflectionMethod->invokeArgs($middleware, [new Request('get', new Uri($path = '/foo/bar?baz=1'))]);
|
||||
$this->assertSame($path, $result);
|
||||
$result = $reflectionMethod->invokeArgs($middleware, [new Request('get', (new Uri($path = '/foo/bar?baz=1&bar=foo')))]);
|
||||
$result = $reflectionMethod->invokeArgs($middleware, [new Request('get', new Uri($path = '/foo/bar?baz=1&bar=foo'))]);
|
||||
$this->assertSame($path, $result);
|
||||
$result = $reflectionMethod->invokeArgs($middleware, [new Request('get', (new Uri($path = '/foo/bar/')))]);
|
||||
$result = $reflectionMethod->invokeArgs($middleware, [new Request('get', new Uri($path = '/foo/bar/'))]);
|
||||
$this->assertSame($path, $result);
|
||||
$result = $reflectionMethod->invokeArgs($middleware, [new Request('get', (new Uri($path = '/foo/bar/?baz=1')))]);
|
||||
$result = $reflectionMethod->invokeArgs($middleware, [new Request('get', new Uri($path = '/foo/bar/?baz=1'))]);
|
||||
$this->assertSame($path, $result);
|
||||
$result = $reflectionMethod->invokeArgs($middleware, [new Request('get', (new Uri($path = '/foo/bar/?baz=1&bar=foo')))]);
|
||||
$result = $reflectionMethod->invokeArgs($middleware, [new Request('get', new Uri($path = '/foo/bar/?baz=1&bar=foo'))]);
|
||||
$this->assertSame($path, $result);
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ class SnowflakeGeneratorTest extends TestCase
|
||||
$generator = new SnowflakeIdGenerator($metaGenerator);
|
||||
|
||||
$meta = $generator->degenerate(PHP_INT_MAX);
|
||||
$days = intval(($meta->getTimeInterval()) / (3600 * 24 * 1000));
|
||||
$days = intval($meta->getTimeInterval() / (3600 * 24 * 1000));
|
||||
$this->assertSame(25451, $days); // 70 years.
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class SocketIORouter extends MetadataCollector
|
||||
|
||||
$instance = ApplicationContext::getContainer()->get($class);
|
||||
|
||||
if (! ($instance instanceof NamespaceInterface)) {
|
||||
if (! $instance instanceof NamespaceInterface) {
|
||||
throw new RouteNotFoundException("namespace {$nsp} must be an instance of NamespaceInterface");
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,9 @@ namespace Hyperf\Swagger\Command;
|
||||
use Hyperf\Command\Command;
|
||||
use OpenApi\Analysis;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
use function OpenApi\scan;
|
||||
|
||||
use const OpenApi\UNDEFINED;
|
||||
|
||||
class GenCommand extends Command
|
||||
|
@ -17,6 +17,7 @@ use Hyperf\Guzzle\CoroutineHandler;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Swoole\Coroutine\Http\Client;
|
||||
use SwooleTracker\Stats;
|
||||
|
||||
use function getSwooleTrackerSpanId;
|
||||
use function getSwooleTrackerTraceId;
|
||||
|
||||
|
@ -15,6 +15,7 @@ use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
use function trackerHookMalloc;
|
||||
|
||||
class HookMallocMiddleware implements MiddlewareInterface
|
||||
|
@ -17,6 +17,7 @@ use Jaeger\Config;
|
||||
use OpenTracing\Tracer;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
use const Jaeger\SAMPLER_TYPE_CONST;
|
||||
|
||||
class JaegerTracerFactory implements NamedFactoryInterface
|
||||
|
@ -19,6 +19,7 @@ use Hyperf\Tracer\SpanTagManager;
|
||||
use Hyperf\Tracer\SwitchManager;
|
||||
use OpenTracing\Tracer;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
use const OpenTracing\Formats\TEXT_MAP;
|
||||
|
||||
class HttpClientAspect extends AbstractAspect
|
||||
|
@ -23,6 +23,7 @@ use Hyperf\Tracer\SwitchManager;
|
||||
use OpenTracing\Span;
|
||||
use OpenTracing\Tracer;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
use const OpenTracing\Formats\TEXT_MAP;
|
||||
|
||||
class JsonRpcAspect extends AbstractAspect
|
||||
|
@ -16,6 +16,7 @@ use Hyperf\Rpc;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use OpenTracing\Span;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
use const OpenTracing\Formats\TEXT_MAP;
|
||||
use const OpenTracing\Tags\SPAN_KIND;
|
||||
use const OpenTracing\Tags\SPAN_KIND_RPC_SERVER;
|
||||
|
@ -39,7 +39,7 @@ class TracerFactory
|
||||
|
||||
$factory = $container->get($driver);
|
||||
|
||||
if (! ($factory instanceof NamedFactoryInterface)) {
|
||||
if (! $factory instanceof NamedFactoryInterface) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf('The driver %s is not a valid factory.', $driver)
|
||||
);
|
||||
|
@ -14,6 +14,7 @@ namespace Hyperf\Utils\Serializer;
|
||||
use Symfony\Component\Serializer\Normalizer\CacheableSupportsMethodInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
|
||||
use function get_class;
|
||||
use function is_scalar;
|
||||
|
||||
|
@ -13,6 +13,7 @@ namespace Hyperf\Utils\Traits;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Error;
|
||||
|
||||
use function get_class;
|
||||
|
||||
trait ForwardsCalls
|
||||
|
@ -877,7 +877,7 @@ trait ValidatesAttributes
|
||||
if (is_string($value) && trim($value) === '') {
|
||||
return false;
|
||||
}
|
||||
if ((is_countable($value)) && count($value) < 1) {
|
||||
if (is_countable($value) && count($value) < 1) {
|
||||
return false;
|
||||
}
|
||||
if ($value instanceof SplFileInfo) {
|
||||
@ -1211,7 +1211,7 @@ trait ValidatesAttributes
|
||||
$secondDate = $this->getDateTimeWithOptionalFormat($format, $this->getValue($second));
|
||||
}
|
||||
|
||||
return ($firstDate && $secondDate) && ($this->compare($firstDate, $secondDate, $operator));
|
||||
return ($firstDate && $secondDate) && $this->compare($firstDate, $secondDate, $operator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,8 +40,6 @@ class View implements ArrayAccess, Htmlable, ViewInterface, \Stringable
|
||||
/**
|
||||
* Create a new view instance.
|
||||
*
|
||||
* @param string $view
|
||||
* @param string $path
|
||||
* @param mixed $data
|
||||
*/
|
||||
/**
|
||||
|
@ -33,6 +33,7 @@ use HyperfTest\ViewEngine\Stub\AlertSlot;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Psr\EventDispatcher\ListenerProviderInterface;
|
||||
|
||||
use function Hyperf\ViewEngine\view;
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user