From c60264204390dbda8152068932097447eb8d0e98 Mon Sep 17 00:00:00 2001 From: chengyao <64066545+topyao@users.noreply.github.com> Date: Thu, 18 Aug 2022 09:50:04 +0800 Subject: [PATCH 1/6] =?UTF-8?q?Fix:=20=E5=8F=82=E6=95=B0=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/http-message/src/ServerRequest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/http-message/src/ServerRequest.php b/src/http-message/src/ServerRequest.php index 6f4b9941..7cdca52e 100644 --- a/src/http-message/src/ServerRequest.php +++ b/src/http-message/src/ServerRequest.php @@ -175,11 +175,11 @@ public static function createFromAmp($request): static public static function createFromPsrRequest(ServerRequestInterface $request): static { $psrRequest = new static($request->getMethod(), $request->getUri(), $request->getHeaders(), $request->getBody()); - $psrRequest->serverParams = new ServerBag($request->getServerParams()); - $psrRequest->cookieParams = new CookieBag($request->getCookieParams()); - $psrRequest->queryParams = new ParameterBag($request->getQueryParams()); - $psrRequest->parsedBody = new ParameterBag($request->getParsedBody()); - $psrRequest->uploadedFiles = new FileBag($request->getUploadedFiles()); + $psrRequest->serverParams = new ServerBag($request->getServerParams() ?: []); + $psrRequest->cookieParams = new CookieBag($request->getCookieParams() ?: []); + $psrRequest->queryParams = new ParameterBag($request->getQueryParams() ?: []); + $psrRequest->parsedBody = new ParameterBag($request->getParsedBody() ?: []); + $psrRequest->uploadedFiles = new FileBag($request->getUploadedFiles() ?: []); return $psrRequest; } From 2bf1e2a13d90da53da50ba31ab45aaed7b6a62ea Mon Sep 17 00:00:00 2001 From: chengyao <64066545+topyao@users.noreply.github.com> Date: Thu, 18 Aug 2022 09:50:20 +0800 Subject: [PATCH 2/6] =?UTF-8?q?Pref:=20=E4=BF=AE=E6=94=B9token=20cookie?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/http-server/src/Middleware/VerifyCSRFToken.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/http-server/src/Middleware/VerifyCSRFToken.php b/src/http-server/src/Middleware/VerifyCSRFToken.php index 73a4b2fd..f0ac1100 100644 --- a/src/http-server/src/Middleware/VerifyCSRFToken.php +++ b/src/http-server/src/Middleware/VerifyCSRFToken.php @@ -50,7 +50,7 @@ class VerifyCSRFToken implements MiddlewareInterface public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { if ($this->shouldVerify($request)) { - if (is_null($previousToken = $request->getCookieParams()['X-XSRF-TOKEN'] ?? null)) { + if (is_null($previousToken = $request->getCookieParams()['X-CSRF-TOKEN'] ?? null)) { $this->abort(); } @@ -79,7 +79,7 @@ protected function parseToken(ServerRequestInterface $request): string */ protected function addCookieToResponse(ResponseInterface $response): ResponseInterface { - return $response->withCookie('X-XSRF-TOKEN', $this->newCSRFToken(), time() + $this->expires); + return $response->withCookie('X-CSRF-TOKEN', $this->newCSRFToken(), time() + $this->expires); } /** From 1761f2d4a61280e7e23ffe113c8dded3eebb9dba Mon Sep 17 00:00:00 2001 From: chengyao <64066545+topyao@users.noreply.github.com> Date: Sat, 20 Aug 2022 08:09:00 +0800 Subject: [PATCH 3/6] =?UTF-8?q?Pref:=20=E4=BC=98=E5=8C=96swoole=20table?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0replace=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/swoole/src/Table/Model.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/swoole/src/Table/Model.php b/src/swoole/src/Table/Model.php index b44eba9b..9a1795a2 100644 --- a/src/swoole/src/Table/Model.php +++ b/src/swoole/src/Table/Model.php @@ -86,6 +86,9 @@ public function getPrimaryKey(): string return $this->key; } + /** + * @return $this + */ public function fill(array $attributes): static { foreach ($attributes as $key => $value) { @@ -207,7 +210,16 @@ public static function update(string $key, array $attributes = []): static return $model; } - public static function exists(string $key): mixed + /** + * @return $this + */ + public function replace(array $attributes): static + { + $this->fill($attributes)->save(); + return $this; + } + + public static function exists(string $key): bool { return static::getSwooleTable()->exists($key); } From 4189b40af5270b8ef220255f7230030c43cf8893 Mon Sep 17 00:00:00 2001 From: chengyao <64066545+topyao@users.noreply.github.com> Date: Sat, 20 Aug 2022 08:09:32 +0800 Subject: [PATCH 4/6] =?UTF-8?q?Pref:=20=E6=B7=BB=E5=8A=A0=E5=8D=8F?= =?UTF-8?q?=E7=A8=8B=E7=9B=B8=E5=85=B3=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/swoole/src/Context.php | 14 +++++++++----- src/swoole/src/Coroutine.php | 10 +++++++++- src/swoole/src/Parallel.php | 3 ++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/swoole/src/Context.php b/src/swoole/src/Context.php index 01666291..85099172 100644 --- a/src/swoole/src/Context.php +++ b/src/swoole/src/Context.php @@ -1,5 +1,14 @@ add(count($this->callbacks)); foreach ($this->callbacks as $key => $callback) { $this->concurrentChannel && $this->concurrentChannel->push(true); - Coroutine::create(function() use ($callback, $key, $wg, &$result, &$throwables) { + Coroutine::create(function () use ($callback, $key, $wg, &$result, &$throwables) { try { $result[$key] = call($callback); } catch (Throwable $throwable) { From be849f5624d606a08994f4db365f457a801077a4 Mon Sep 17 00:00:00 2001 From: chengyao <64066545+topyao@users.noreply.github.com> Date: Sat, 20 Aug 2022 08:10:08 +0800 Subject: [PATCH 5/6] =?UTF-8?q?Style:=20=E4=BB=A3=E7=A0=81=E9=A3=8E?= =?UTF-8?q?=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aop/src/PropertyHandlerVisitor.php | 5 +- src/aop/src/ProxyHandlerVisitor.php | 5 +- src/cache/src/Cache.php | 23 -- src/database/src/Connector/AutoConnector.php | 5 +- src/database/src/Connector/BaseConnector.php | 5 +- src/database/src/Connector/PoolConnector.php | 5 +- .../src/Eloquent/Relation/HasMany.php | 8 +- src/database/src/Manager.php | 4 +- src/database/src/Query/Builder.php | 20 +- src/database/src/Query/Join.php | 7 +- .../src/Exception/VarDumperAbort.php | 5 +- src/http-message/src/Bag/FileBag.php | 5 +- src/http-throttle/src/ThrottleMiddleware.php | 17 +- src/utils/src/Arr.php | 6 +- src/utils/src/Collection.php | 37 +- src/utils/src/Filesystem.php | 7 +- src/utils/src/LazyCollection.php | 9 +- src/utils/src/Pipeline.php | 14 +- src/utils/src/Pluralizer.php | 19 +- .../src/Proxy/HigherOrderCollectionProxy.php | 25 +- src/utils/src/Proxy/HigherOrderTapProxy.php | 20 +- src/utils/src/Proxy/HigherOrderWhenProxy.php | 34 +- src/utils/src/Resource/ResourceCollection.php | 11 +- src/utils/src/Str.php | 326 +++--------------- src/utils/src/Stringable.php | 295 +++++----------- src/utils/src/helpers.php | 42 +-- src/validator/src/Rules.php | 8 +- src/view/src/Engine/Blade/Compiler.php | 8 +- 28 files changed, 275 insertions(+), 700 deletions(-) diff --git a/src/aop/src/PropertyHandlerVisitor.php b/src/aop/src/PropertyHandlerVisitor.php index bf9d8f7c..6a9c9a4f 100644 --- a/src/aop/src/PropertyHandlerVisitor.php +++ b/src/aop/src/PropertyHandlerVisitor.php @@ -36,8 +36,9 @@ class PropertyHandlerVisitor extends NodeVisitorAbstract { - public function __construct(protected Metadata $metadata) - { + public function __construct( + protected Metadata $metadata + ) { } public function enterNode(Node $node) diff --git a/src/aop/src/ProxyHandlerVisitor.php b/src/aop/src/ProxyHandlerVisitor.php index 8330b9b0..2b423978 100644 --- a/src/aop/src/ProxyHandlerVisitor.php +++ b/src/aop/src/ProxyHandlerVisitor.php @@ -28,8 +28,9 @@ class ProxyHandlerVisitor extends NodeVisitorAbstract { - public function __construct(protected Metadata $metadata) - { + public function __construct( + protected Metadata $metadata + ) { } public function leaveNode(Node $node) diff --git a/src/cache/src/Cache.php b/src/cache/src/Cache.php index 769ed2f3..a367ac92 100644 --- a/src/cache/src/Cache.php +++ b/src/cache/src/Cache.php @@ -20,9 +20,6 @@ class Cache implements CacheInterface { - /** - * @param CacheDriverInterface $driver - */ public function __construct( protected CacheDriverInterface $driver ) { @@ -113,12 +110,6 @@ public function deleteMultiple($keys) } } - /** - * @param string $key - * @param Closure $callback - * @param int|null $ttl - * @return mixed - */ public function remember(string $key, Closure $callback, ?int $ttl = null): mixed { if (! $this->has($key)) { @@ -127,30 +118,16 @@ public function remember(string $key, Closure $callback, ?int $ttl = null): mixe return $this->get($key); } - /** - * @param string $key - * @param int $step - * @return int - */ public function increment(string $key, int $step = 1): int { return $this->driver->increment($key, $step); } - /** - * @param string $key - * @param int $step - * @return int - */ public function decrement(string $key, int $step = 1): int { return $this->driver->decrement($key, $step); } - /** - * @param string $key - * @return mixed - */ public function pull(string $key): mixed { $value = $this->get($key); diff --git a/src/database/src/Connector/AutoConnector.php b/src/database/src/Connector/AutoConnector.php index 62f84644..06f72e62 100644 --- a/src/database/src/Connector/AutoConnector.php +++ b/src/database/src/Connector/AutoConnector.php @@ -26,8 +26,9 @@ class AutoConnector implements ConnectorInterface protected array $container = []; - public function __construct(protected DatabaseConfig $config) - { + public function __construct( + protected DatabaseConfig $config + ) { } /** diff --git a/src/database/src/Connector/BaseConnector.php b/src/database/src/Connector/BaseConnector.php index ea8e2a8b..af17807e 100644 --- a/src/database/src/Connector/BaseConnector.php +++ b/src/database/src/Connector/BaseConnector.php @@ -20,8 +20,9 @@ class BaseConnector implements ConnectorInterface { protected ArrayObject $pool; - public function __construct(protected DatabaseConfig $config) - { + public function __construct( + protected DatabaseConfig $config + ) { $this->pool = new ArrayObject(); } diff --git a/src/database/src/Connector/PoolConnector.php b/src/database/src/Connector/PoolConnector.php index 56cc4f7f..7877f9ed 100644 --- a/src/database/src/Connector/PoolConnector.php +++ b/src/database/src/Connector/PoolConnector.php @@ -34,8 +34,9 @@ class PoolConnector implements ConnectorInterface, PoolInterface */ protected int $size = 0; - public function __construct(protected DatabaseConfig $config) - { + public function __construct( + protected DatabaseConfig $config + ) { $this->pool = new Channel($this->capacity = $config->getPoolSize()); if ($config->isAutofill()) { $this->fill(); diff --git a/src/database/src/Eloquent/Relation/HasMany.php b/src/database/src/Eloquent/Relation/HasMany.php index 65016fb9..545b1ed9 100644 --- a/src/database/src/Eloquent/Relation/HasMany.php +++ b/src/database/src/Eloquent/Relation/HasMany.php @@ -16,7 +16,11 @@ class HasMany { - public function __construct(Builder $builder, Model $owner, $foreignKey, $localKey) - { + public function __construct( + protected Builder $builder, + protected Model $owner, + protected $foreignKey, + protected $localKey + ) { } } diff --git a/src/database/src/Manager.php b/src/database/src/Manager.php index 9666e712..8a8a3f5a 100644 --- a/src/database/src/Manager.php +++ b/src/database/src/Manager.php @@ -52,8 +52,8 @@ public function __call(string $name, array $arguments) public function connection(?string $name = null): Query { $name ??= $this->defaultConnection; - if (!isset($this->connections[$name])) { - if (!isset($this->config[$name])) { + if (! isset($this->connections[$name])) { + if (! isset($this->config[$name])) { throw new InvalidArgumentException('没有相关数据库连接'); } $config = $this->config[$name]; diff --git a/src/database/src/Query/Builder.php b/src/database/src/Query/Builder.php index dcf2886f..dc9d4cbb 100644 --- a/src/database/src/Query/Builder.php +++ b/src/database/src/Query/Builder.php @@ -123,7 +123,7 @@ public function whereLike($column, $value): static */ public function whereIn(string $column, array $in): static { - if (!empty($in)) { + if (! empty($in)) { $this->addBindings($in); $this->where[] = [$column, 'IN', sprintf('(%s)', rtrim(str_repeat('?, ', count($in)), ' ,'))]; } @@ -341,7 +341,7 @@ public function avg($column): int public function exists(): bool { - return (bool)$this->query->statement( + return (bool) $this->query->statement( sprintf('SELECT EXISTS(%s) AS MAX_EXIST', $this->toSql()), $this->bindings )->fetchColumn(); @@ -381,7 +381,7 @@ public function insert(array $record): int $this->bindings, ); - return (int)$this->query->getPdo()->lastInsertId(); + return (int) $this->query->getPdo()->lastInsertId(); } public function insertMany(array $records): mixed @@ -398,7 +398,7 @@ public function insertMany(array $records): mixed public function insertAll(array $data): array { - return array_map(fn($item) => $this->insert($item), $data); + return array_map(fn ($item) => $this->insert($item), $data); } public function update(array $data): int @@ -411,7 +411,7 @@ public function generateSelectQuery(): string $query = 'SELECT '; foreach (static::$clause as $value) { $compiler = 'compile' . ucfirst($value); - if (!empty($this->{$value})) { + if (! empty($this->{$value})) { $query .= $this->{$compiler}($this); } } @@ -465,15 +465,15 @@ protected function addBindings($value): void protected function aggregate(string $expression): int { - return (int)$this->query->statement( - $this->toSql((array)($expression . ' AS AGGREGATE')), + return (int) $this->query->statement( + $this->toSql((array) ($expression . ' AS AGGREGATE')), $this->bindings )->fetchColumn(); } protected function compileJoin(): string { - $joins = array_map(function(Join $item) { + $joins = array_map(function (Join $item) { $alias = $item->alias ? 'AS ' . $item->alias : ''; $on = $item->on ? ('ON ' . implode(' ', $item->on)) : ''; return ' ' . $item->league . ' ' . $item->table . ' ' . $alias . ' ' . $on; @@ -513,7 +513,7 @@ protected function compileOffset(): string protected function compileOrder(): string { - $orderBy = array_map(fn($item) => $item[0] instanceof Expression ? $item[0]->__toString() : implode(' ', $item), $this->order); + $orderBy = array_map(fn ($item) => $item[0] instanceof Expression ? $item[0]->__toString() : implode(' ', $item), $this->order); return ' ORDER BY ' . implode(', ', $orderBy); } @@ -524,7 +524,7 @@ protected function compileGroup(): string protected function compileHaving(): string { - $having = array_map(fn($item) => implode(' ', $item), $this->having); + $having = array_map(fn ($item) => implode(' ', $item), $this->having); return ' HAVING ' . implode(' AND ', $having); } diff --git a/src/database/src/Query/Join.php b/src/database/src/Query/Join.php index 54340502..10482ce3 100644 --- a/src/database/src/Query/Join.php +++ b/src/database/src/Query/Join.php @@ -38,11 +38,8 @@ public function __call($method, $args) } /** - * @param $first - * @param $last - * @param string $operator - * - * @return Builder + * @param $first + * @param $last */ public function on($first, $last, string $operator = '='): Builder { diff --git a/src/framework/src/Exception/VarDumperAbort.php b/src/framework/src/Exception/VarDumperAbort.php index 82ad96c3..838b73ec 100644 --- a/src/framework/src/Exception/VarDumperAbort.php +++ b/src/framework/src/Exception/VarDumperAbort.php @@ -15,7 +15,8 @@ class VarDumperAbort extends Exception { - public function __construct(public mixed $vars) - { + public function __construct( + public mixed $vars + ) { } } diff --git a/src/http-message/src/Bag/FileBag.php b/src/http-message/src/Bag/FileBag.php index 11080f15..4e986abc 100644 --- a/src/http-message/src/Bag/FileBag.php +++ b/src/http-message/src/Bag/FileBag.php @@ -16,8 +16,9 @@ class FileBag { - public function __construct(protected array $uploadedFiles = []) - { + public function __construct( + protected array $uploadedFiles = [] + ) { } public static function createFromGlobal(): static diff --git a/src/http-throttle/src/ThrottleMiddleware.php b/src/http-throttle/src/ThrottleMiddleware.php index 8d277d5e..89d91781 100644 --- a/src/http-throttle/src/ThrottleMiddleware.php +++ b/src/http-throttle/src/ThrottleMiddleware.php @@ -50,20 +50,21 @@ class ThrottleMiddleware implements MiddlewareInterface protected $key; // 解析后的标识 - protected int $waitSeconds = 0; // 下次合法请求还有多少秒 + protected int $waitSeconds = 0; // 下次合法请求还有多少秒 - protected int $now = 0; // 当前时间戳 + protected int $now = 0; // 当前时间戳 - protected int $max_requests = 0; // 规定时间内允许的最大请求次数 + protected int $max_requests = 0; // 规定时间内允许的最大请求次数 - protected int $expire = 0; // 规定时间 + protected int $expire = 0; // 规定时间 - protected int $remaining = 0; // 规定时间内还能请求的次数 + protected int $remaining = 0; // 规定时间内还能请求的次数 - protected string $driver = CounterSlider::class; + protected string $driver = CounterSlider::class; - public function __construct(protected CacheInterface $cache) - { + public function __construct( + protected CacheInterface $cache + ) { $this->handler = Context::getContainer()->make($this->driver); } diff --git a/src/utils/src/Arr.php b/src/utils/src/Arr.php index f6b9c65b..afde127b 100644 --- a/src/utils/src/Arr.php +++ b/src/utils/src/Arr.php @@ -22,10 +22,8 @@ class Arr { /** * Determine whether the given value is array accessible. - * - * @param mixed $value */ - public static function accessible($value): bool + public static function accessible(mixed $value): bool { return is_array($value) || $value instanceof ArrayAccess; } @@ -242,7 +240,7 @@ public static function get($array, $key = null, $default = null) if (static::exists($array, $key)) { return $array[$key]; } - if (! is_string($key) || strpos($key, '.') === false) { + if (! is_string($key) || ! str_contains($key, '.')) { return $array[$key] ?? value($default); } foreach (explode('.', $key) as $segment) { diff --git a/src/utils/src/Collection.php b/src/utils/src/Collection.php index a9d9cf61..9c988cd1 100644 --- a/src/utils/src/Collection.php +++ b/src/utils/src/Collection.php @@ -38,10 +38,8 @@ class Collection implements ArrayAccess, Enumerable /** * Create a new collection. - * - * @param mixed $items */ - public function __construct($items = []) + public function __construct(mixed $items = []) { $this->items = $this->getArrayableItems($items); } @@ -51,10 +49,8 @@ public function __construct($items = []) * * @param int $from * @param int $to - * - * @return static */ - public static function range($from, $to) + public static function range($from, $to): static { return new static(range($from, $to)); } @@ -71,10 +67,8 @@ public function all() /** * Get a lazy collection for the items in this collection. - * - * @return LazyCollection */ - public function lazy() + public function lazy(): LazyCollection { return new LazyCollection($this->items); } @@ -574,10 +568,8 @@ public function isEmpty() /** * Determine if the collection contains a single item. - * - * @return bool */ - public function containsOneItem() + public function containsOneItem(): bool { return $this->count() === 1; } @@ -1109,7 +1101,7 @@ public function split($numberOfGroups) } if ($size) { - $groups->push(new static(array_slice($this->items, $start, $size))); + $groups->push(new static(array_slice($this->items, $start, (int) $size))); $start += $size; } @@ -1120,12 +1112,8 @@ public function split($numberOfGroups) /** * Split a collection into a certain number of groups, and fill the first groups completely. - * - * @param int $numberOfGroups - * - * @return static */ - public function splitIn($numberOfGroups) + public function splitIn(int $numberOfGroups): static { return $this->chunk(ceil($this->count() / $numberOfGroups)); } @@ -1133,15 +1121,10 @@ public function splitIn($numberOfGroups) /** * Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception. * - * @param mixed $key - * @param mixed $operator - * @param mixed $value - * - * @throws ItemNotFoundException * @throws MultipleItemsFoundException - * @return mixed + * @throws ItemNotFoundException */ - public function sole($key = null, $operator = null, $value = null) + public function sole(mixed $key = null, mixed $operator = null, mixed $value = null): mixed { $filter = func_num_args() > 1 ? $this->operatorForWhere(...func_get_args()) @@ -1558,10 +1541,8 @@ protected function duplicateComparator($strict) /** * Sort the collection using multiple comparisons. - * - * @return static */ - protected function sortByMany(array $comparisons = []) + protected function sortByMany(array $comparisons = []): static { $items = $this->items; diff --git a/src/utils/src/Filesystem.php b/src/utils/src/Filesystem.php index e441121c..1d96355c 100644 --- a/src/utils/src/Filesystem.php +++ b/src/utils/src/Filesystem.php @@ -11,7 +11,6 @@ namespace Max\Utils; -use ErrorException; use FilesystemIterator; use Max\Macro\Macroable; use Max\Utils\Exception\FileNotFoundException; @@ -233,11 +232,7 @@ public function delete(array|string $paths): bool $success = true; foreach ($paths as $path) { - try { - if (! @unlink($path)) { - $success = false; - } - } catch (ErrorException $e) { + if (! @unlink($path)) { $success = false; } } diff --git a/src/utils/src/LazyCollection.php b/src/utils/src/LazyCollection.php index 298b2ba1..498a3f75 100644 --- a/src/utils/src/LazyCollection.php +++ b/src/utils/src/LazyCollection.php @@ -21,7 +21,6 @@ use Max\Utils\Exception\ItemNotFoundException; use Max\Utils\Exception\MultipleItemsFoundException; use Max\Utils\Traits\EnumeratesValues; -use ReturnTypeWillChange; use stdClass; use Traversable; @@ -95,10 +94,8 @@ public function all() /** * Eager load all items into a new lazy collection backed by an array. - * - * @return static */ - public function eager() + public function eager(): static { return new static($this->all()); } @@ -1406,7 +1403,7 @@ public function pad($size, $value) * * @return Traversable */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function getIterator() { return $this->makeIterator($this->source); @@ -1417,7 +1414,7 @@ public function getIterator() * * @return int */ - #[ReturnTypeWillChange] + #[\ReturnTypeWillChange] public function count() { if (is_array($this->source)) { diff --git a/src/utils/src/Pipeline.php b/src/utils/src/Pipeline.php index c6a482b5..0668f205 100644 --- a/src/utils/src/Pipeline.php +++ b/src/utils/src/Pipeline.php @@ -20,17 +20,15 @@ */ class Pipeline { - protected ContainerInterface $container; + protected array $pipes = []; - protected array $pipes = []; + protected mixed $passable; - protected mixed $passable; + protected string $method = 'handle'; - protected string $method = 'handle'; - - public function __construct(?ContainerInterface $container = null) - { - $this->container = $container; + public function __construct( + protected ?ContainerInterface $container = null + ) { } public function send(mixed $passable): static diff --git a/src/utils/src/Pluralizer.php b/src/utils/src/Pluralizer.php index fed4c0e4..15835b67 100644 --- a/src/utils/src/Pluralizer.php +++ b/src/utils/src/Pluralizer.php @@ -88,12 +88,8 @@ public static function plural(string $value, Countable|array|int $count = 2): st /** * Get the singular form of an English word. - * - * @param string $value - * - * @return string */ - public static function singular($value) + public static function singular(string $value): string { $singular = static::inflector()->singularize($value); @@ -116,25 +112,16 @@ public static function inflector(): Inflector /** * Determine if the given value is uncountable. - * - * @param string $value - * - * @return bool */ - protected static function uncountable($value) + protected static function uncountable(string $value): bool { return in_array(strtolower($value), static::$uncountable); } /** * Attempt to match the case on two strings. - * - * @param string $value - * @param string $comparison - * - * @return string */ - protected static function matchCase($value, $comparison) + protected static function matchCase(string $value, string $comparison): string { $functions = ['mb_strtolower', 'mb_strtoupper', 'ucfirst', 'ucwords']; diff --git a/src/utils/src/Proxy/HigherOrderCollectionProxy.php b/src/utils/src/Proxy/HigherOrderCollectionProxy.php index a807ee2b..0d38426d 100644 --- a/src/utils/src/Proxy/HigherOrderCollectionProxy.php +++ b/src/utils/src/Proxy/HigherOrderCollectionProxy.php @@ -20,27 +20,16 @@ */ class HigherOrderCollectionProxy { - /** - * The collection being operated on. - * - * @var Collection - */ - protected $collection; - - /** - * The method being proxied. - * - * @var string - */ - protected $method; - /** * Create a new proxy instance. + * + * @param Collection $collection the collection being operated on + * @param string $method the method being proxied */ - public function __construct(Collection $collection, string $method) - { - $this->method = $method; - $this->collection = $collection; + public function __construct( + protected Collection $collection, + protected string $method + ) { } /** diff --git a/src/utils/src/Proxy/HigherOrderTapProxy.php b/src/utils/src/Proxy/HigherOrderTapProxy.php index c681498f..2a53a4f8 100644 --- a/src/utils/src/Proxy/HigherOrderTapProxy.php +++ b/src/utils/src/Proxy/HigherOrderTapProxy.php @@ -17,28 +17,22 @@ */ class HigherOrderTapProxy { - /** - * The target being tapped. - * - * @var mixed - */ - public $target; - /** * Create a new tap proxy instance. * - * @param mixed $target + * @param mixed $target the target being tapped */ - public function __construct($target) - { - $this->target = $target; + public function __construct( + protected mixed $target + ) { } /** * Dynamically pass method calls to the target. * - * @param string $method - * @param array $parameters + * @param string $method + * @param array $parameters + * * @return mixed */ public function __call($method, $parameters) diff --git a/src/utils/src/Proxy/HigherOrderWhenProxy.php b/src/utils/src/Proxy/HigherOrderWhenProxy.php index 70c07d24..9f86f9c1 100644 --- a/src/utils/src/Proxy/HigherOrderWhenProxy.php +++ b/src/utils/src/Proxy/HigherOrderWhenProxy.php @@ -15,6 +15,7 @@ * Most of the methods in this file come from illuminate * thanks Laravel Team provide such a useful class. */ + use Max\Utils\Contract\Enumerable; /** @@ -24,35 +25,23 @@ */ class HigherOrderWhenProxy { - /** - * The collection being operated on. - * - * @var Enumerable - */ - protected $collection; - - /** - * The condition for proxying. - * - * @var bool - */ - protected $condition; - /** * Create a new proxy instance. * - * @param bool $condition + * @param Enumerable $collection the collection being operated on + * @param bool $condition the condition for proxying */ - public function __construct(Enumerable $collection, $condition) - { - $this->condition = $condition; - $this->collection = $collection; + public function __construct( + protected Enumerable $collection, + protected bool $condition + ) { } /** * Proxy accessing an attribute onto the collection. * - * @param string $key + * @param string $key + * * @return mixed */ public function __get($key) @@ -65,8 +54,9 @@ public function __get($key) /** * Proxy a method call onto the collection. * - * @param string $method - * @param array $parameters + * @param string $method + * @param array $parameters + * * @return mixed */ public function __call($method, $parameters) diff --git a/src/utils/src/Resource/ResourceCollection.php b/src/utils/src/Resource/ResourceCollection.php index 20201c2a..464b9189 100644 --- a/src/utils/src/Resource/ResourceCollection.php +++ b/src/utils/src/Resource/ResourceCollection.php @@ -18,17 +18,12 @@ */ class ResourceCollection implements JsonSerializable { - /** - * @var - */ - protected $collection; - /** * @param $collection */ - public function __construct($collection) - { - $this->collection = $collection; + public function __construct( + protected $collection + ) { } /** diff --git a/src/utils/src/Str.php b/src/utils/src/Str.php index 3bcb878c..d6e2feda 100644 --- a/src/utils/src/Str.php +++ b/src/utils/src/Str.php @@ -11,12 +11,14 @@ namespace Max\Utils; +use Countable; use League\CommonMark\GithubFlavoredMarkdownConverter; use Max\Macro\Macroable; use Ramsey\Uuid\Codec\TimestampFirstCombCodec; use Ramsey\Uuid\Generator\CombGenerator; use Ramsey\Uuid\Uuid; use Ramsey\Uuid\UuidFactory; +use Ramsey\Uuid\UuidInterface; use voku\helper\ASCII; class Str @@ -25,10 +27,8 @@ class Str /** * The cache of snake-cased words. - * - * @var array */ - protected static $snakeCache = []; + protected static array $snakeCache = []; /** * The cache of camel-cased words. @@ -83,45 +83,30 @@ public static function afterLast(string $subject, string $search): string /** * Transliterate a UTF-8 value to ASCII. - * - * @param string $value - * @param string $language - * - * @return string */ - public static function ascii($value, $language = 'en') + public static function ascii(string $value, string $language = 'en'): string { - return ASCII::to_ascii((string) $value, $language); + return ASCII::to_ascii($value, $language); } /** * Get the portion of a string before the first occurrence of a given value. - * - * @param string $subject - * @param string $search - * - * @return string */ - public static function before($subject, $search) + public static function before(string $subject, string $search): string { if ($search === '') { return $subject; } - $result = strstr($subject, (string) $search, true); + $result = strstr($subject, $search, true); return $result === false ? $subject : $result; } /** * Get the portion of a string before the last occurrence of a given value. - * - * @param string $subject - * @param string $search - * - * @return string */ - public static function beforeLast($subject, $search) + public static function beforeLast(string $subject, string $search): string { if ($search === '') { return $subject; @@ -138,14 +123,8 @@ public static function beforeLast($subject, $search) /** * Get the portion of a string between two given values. - * - * @param string $subject - * @param string $from - * @param string $to - * - * @return string */ - public static function between($subject, $from, $to) + public static function between(string $subject, string $from, string $to): string { if ($from === '' || $to === '') { return $subject; @@ -156,12 +135,8 @@ public static function between($subject, $from, $to) /** * Convert a value to camel case. - * - * @param string $value - * - * @return string */ - public static function camel($value) + public static function camel(string $value): string { if (isset(static::$camelCache[$value])) { return static::$camelCache[$value]; @@ -172,14 +147,8 @@ public static function camel($value) /** * Determine if a given string contains a given substring. - * - * @param string $haystack - * @param string|string[] $needles - * @param bool $ignoreCase - * - * @return bool */ - public static function contains($haystack, $needles, $ignoreCase = false) + public static function contains(string $haystack, array|string $needles, bool $ignoreCase = false): bool { if ($ignoreCase) { $haystack = mb_strtolower($haystack); @@ -197,14 +166,8 @@ public static function contains($haystack, $needles, $ignoreCase = false) /** * Determine if a given string contains all array values. - * - * @param string $haystack - * @param string[] $needles - * @param bool $ignoreCase - * - * @return bool */ - public static function containsAll($haystack, array $needles, $ignoreCase = false) + public static function containsAll(string $haystack, array $needles, bool $ignoreCase = false): bool { if ($ignoreCase) { $haystack = mb_strtolower($haystack); @@ -222,13 +185,8 @@ public static function containsAll($haystack, array $needles, $ignoreCase = fals /** * Determine if a given string ends with a given substring. - * - * @param string $haystack - * @param string|string[] $needles - * - * @return bool */ - public static function endsWith($haystack, $needles) + public static function endsWith(string $haystack, array|string $needles): bool { foreach ((array) $needles as $needle) { if ( @@ -244,13 +202,8 @@ public static function endsWith($haystack, $needles) /** * Cap a string with a single instance of a given value. - * - * @param string $value - * @param string $cap - * - * @return string */ - public static function finish($value, $cap) + public static function finish(string $value, string $cap): string { $quoted = preg_quote($cap, '/'); @@ -333,14 +286,8 @@ public static function length(string $value, ?string $encoding = null): int /** * Limit the number of characters in a string. - * - * @param string $value - * @param int $limit - * @param string $end - * - * @return string */ - public static function limit($value, $limit = 100, $end = '...') + public static function limit(string $value, int $limit = 100, string $end = '...'): string { if (mb_strwidth($value, 'UTF-8') <= $limit) { return $value; @@ -351,26 +298,16 @@ public static function limit($value, $limit = 100, $end = '...') /** * Convert the given string to lower-case. - * - * @param string $value - * - * @return string */ - public static function lower($value) + public static function lower(string $value): string { return mb_strtolower($value, 'UTF-8'); } /** * Limit the number of words in a string. - * - * @param string $value - * @param int $words - * @param string $end - * - * @return string */ - public static function words($value, $words = 100, $end = '...') + public static function words(string $value, int $words = 100, string $end = '...'): string { preg_match('/^\s*+(?:\S++\s*+){1,' . $words . '}/u', $value, $matches); @@ -383,30 +320,18 @@ public static function words($value, $words = 100, $end = '...') /** * Converts GitHub flavored Markdown into HTML. - * - * @param string $string - * - * @return string */ - public static function markdown($string, array $options = []) + public static function markdown(string $string, array $options = []): string { $converter = new GithubFlavoredMarkdownConverter($options); - return (string) $converter->convertToHtml($string); + return (string) $converter->convert($string); } /** * Masks a portion of a string with a repeated character. - * - * @param string $string - * @param string $character - * @param int $index - * @param null|int $length - * @param string $encoding - * - * @return string */ - public static function mask($string, $character, $index, $length = null, $encoding = 'UTF-8') + public static function mask(string $string, string $character, int $index, ?int $length = null, string $encoding = 'UTF-8'): string { if ($character === '') { return $string; @@ -430,13 +355,8 @@ public static function mask($string, $character, $index, $length = null, $encodi /** * Get the string matching the given pattern. - * - * @param string $pattern - * @param string $subject - * - * @return string */ - public static function match($pattern, $subject) + public static function match(string $pattern, string $subject): string { preg_match($pattern, $subject, $matches); @@ -463,42 +383,24 @@ public static function matchAll(string $pattern, string $subject): Collection /** * Pad both sides of a string with another. - * - * @param string $value - * @param int $length - * @param string $pad - * - * @return string */ - public static function padBoth($value, $length, $pad = ' ') + public static function padBoth(string $value, int $length, string $pad = ' '): string { return str_pad($value, $length, $pad, STR_PAD_BOTH); } /** * Pad the left side of a string with another. - * - * @param string $value - * @param int $length - * @param string $pad - * - * @return string */ - public static function padLeft($value, $length, $pad = ' ') + public static function padLeft(string $value, int $length, string $pad = ' '): string { return str_pad($value, $length, $pad, STR_PAD_LEFT); } /** * Pad the right side of a string with another. - * - * @param string $value - * @param int $length - * @param string $pad - * - * @return string */ - public static function padRight($value, $length, $pad = ' ') + public static function padRight(string $value, int $length, string $pad = ' '): string { return str_pad($value, $length, $pad, STR_PAD_RIGHT); } @@ -506,38 +408,25 @@ public static function padRight($value, $length, $pad = ' ') /** * Parse a Class[@]method style callback into class and method. * - * @param string $callback - * @param null|string $default - * * @return array */ - public static function parseCallback($callback, $default = null) + public static function parseCallback(string $callback, ?string $default = null): array { return static::contains($callback, '@') ? explode('@', $callback, 2) : [$callback, $default]; } /** * Get the plural form of an English word. - * - * @param string $value - * @param array|\Countable|int $count - * - * @return string */ - public static function plural($value, $count = 2) + public static function plural(string $value, Countable|int|array $count = 2): string { return Pluralizer::plural($value, $count); } /** * Pluralize the last word of an English, studly caps case string. - * - * @param string $value - * @param array|\Countable|int $count - * - * @return string */ - public static function pluralStudly($value, $count = 2) + public static function pluralStudly(string $value, Countable|int|array $count = 2): string { $parts = preg_split('/(.)(?=[A-Z])/u', $value, -1, PREG_SPLIT_DELIM_CAPTURE); @@ -548,12 +437,8 @@ public static function pluralStudly($value, $count = 2) /** * Generate a more truly "random" alpha-numeric string. - * - * @param int $length - * - * @return string */ - public static function random($length = 16) + public static function random(int $length = 16): string { $string = ''; @@ -570,10 +455,8 @@ public static function random($length = 16) /** * Repeat the given string. - * - * @return string */ - public static function repeat(string $string, int $times) + public static function repeat(string $string, int $times): string { return str_repeat($string, $times); } @@ -581,13 +464,9 @@ public static function repeat(string $string, int $times) /** * Replace a given value in the string sequentially with an array. * - * @param string $search * @param array $replace - * @param string $subject - * - * @return string */ - public static function replaceArray($search, array $replace, $subject) + public static function replaceArray(string $search, array $replace, string $subject): string { $segments = explode($search, $subject); @@ -606,26 +485,18 @@ public static function replaceArray($search, array $replace, $subject) * @param string|string[] $search * @param string|string[] $replace * @param string|string[] $subject - * - * @return string */ - public static function replace($search, $replace, $subject) + public static function replace(array|string $search, array|string $replace, array|string $subject): array|string { return str_replace($search, $replace, $subject); } /** * Replace the first occurrence of a given value in the string. - * - * @param string $search - * @param string $replace - * @param string $subject - * - * @return string */ - public static function replaceFirst($search, $replace, $subject) + public static function replaceFirst(string $search, string $replace, string $subject): string { - $search = (string) $search; + $search = $search; if ($search === '') { return $subject; @@ -642,14 +513,8 @@ public static function replaceFirst($search, $replace, $subject) /** * Replace the last occurrence of a given value in the string. - * - * @param string $search - * @param string $replace - * @param string $subject - * - * @return string */ - public static function replaceLast($search, $replace, $subject) + public static function replaceLast(string $search, string $replace, string $subject): string { if ($search === '') { return $subject; @@ -668,12 +533,8 @@ public static function replaceLast($search, $replace, $subject) * Remove any occurrence of the given string in the subject. * * @param array|string $search - * @param string $subject - * @param bool $caseSensitive - * - * @return string */ - public static function remove($search, $subject, $caseSensitive = true) + public static function remove(array|string $search, string $subject, bool $caseSensitive = true): string { return $caseSensitive ? str_replace($search, '', $subject) @@ -682,23 +543,16 @@ public static function remove($search, $subject, $caseSensitive = true) /** * Reverse the given string. - * - * @return string */ - public static function reverse(string $value) + public static function reverse(string $value): string { return implode(array_reverse(mb_str_split($value))); } /** * Begin a string with a single instance of a given value. - * - * @param string $value - * @param string $prefix - * - * @return string */ - public static function start($value, $prefix) + public static function start(string $value, string $prefix): string { $quoted = preg_quote($prefix, '/'); @@ -707,36 +561,24 @@ public static function start($value, $prefix) /** * Convert the given string to upper-case. - * - * @param string $value - * - * @return string */ - public static function upper($value) + public static function upper(string $value): string { return mb_strtoupper($value, 'UTF-8'); } /** * Convert the given string to title case. - * - * @param string $value - * - * @return string */ - public static function title($value) + public static function title(string $value): string { return mb_convert_case($value, MB_CASE_TITLE, 'UTF-8'); } /** * Convert the given string to title case for each word. - * - * @param string $value - * - * @return string */ - public static function headline($value) + public static function headline(string $value): string { $parts = explode(' ', $value); @@ -751,26 +593,16 @@ public static function headline($value) /** * Get the singular form of an English word. - * - * @param string $value - * - * @return string */ - public static function singular($value) + public static function singular(string $value): string { return Pluralizer::singular($value); } /** * Generate a URL friendly "slug" from a given string. - * - * @param string $title - * @param string $separator - * @param null|string $language - * - * @return string */ - public static function slug($title, $separator = '-', $language = 'en') + public static function slug(string $title, string $separator = '-', ?string $language = 'en'): string { $title = $language ? static::ascii($title, $language) : $title; @@ -793,13 +625,8 @@ public static function slug($title, $separator = '-', $language = 'en') /** * Convert a string to snake case. - * - * @param string $value - * @param string $delimiter - * - * @return string */ - public static function snake($value, $delimiter = '_') + public static function snake(string $value, string $delimiter = '_'): string { $key = $value; @@ -819,12 +646,9 @@ public static function snake($value, $delimiter = '_') /** * Determine if a given string starts with a given substring. * - * @param string $haystack * @param string|string[] $needles - * - * @return bool */ - public static function startsWith($haystack, $needles) + public static function startsWith(string $haystack, array|string $needles): bool { foreach ((array) $needles as $needle) { if ((string) $needle !== '' && str_starts_with($haystack, $needle)) { @@ -837,12 +661,8 @@ public static function startsWith($haystack, $needles) /** * Convert a value to studly caps case. - * - * @param string $value - * - * @return string */ - public static function studly($value) + public static function studly(string $value): string { $key = $value; @@ -861,29 +681,16 @@ public static function studly($value) /** * Returns the portion of the string specified by the start and length parameters. - * - * @param string $string - * @param int $start - * @param null|int $length - * - * @return string */ - public static function substr($string, $start, $length = null) + public static function substr(string $string, int $start, ?int $length = null): string { return mb_substr($string, $start, $length, 'UTF-8'); } /** * Returns the number of substring occurrences. - * - * @param string $haystack - * @param string $needle - * @param int $offset - * @param null|int $length - * - * @return int */ - public static function substrCount($haystack, $needle, $offset = 0, $length = null) + public static function substrCount(string $haystack, string $needle, int $offset = 0, ?int $length = null): int { if (! is_null($length)) { return substr_count($haystack, $needle, $offset, $length); @@ -893,15 +700,8 @@ public static function substrCount($haystack, $needle, $offset = 0, $length = nu /** * Replace text within a portion of a string. - * - * @param array|string $string - * @param array|string $replace - * @param array|int $offset - * @param null|array|int $length - * - * @return array|string */ - public static function substrReplace($string, $replace, $offset = 0, $length = null) + public static function substrReplace(array|string $string, array|string $replace, array|int $offset = 0, array|int|null $length = null): array|string { if ($length === null) { $length = strlen($string); @@ -912,46 +712,32 @@ public static function substrReplace($string, $replace, $offset = 0, $length = n /** * Make a string's first character uppercase. - * - * @param string $string - * - * @return string */ - public static function ucfirst($string) + public static function ucfirst(string $string): string { return static::upper(static::substr($string, 0, 1)) . static::substr($string, 1); } /** * Split a string into pieces by uppercase characters. - * - * @param string $string - * - * @return array */ - public static function ucsplit($string) + public static function ucsplit(string $string): array { return preg_split('/(?=\p{Lu})/u', $string, -1, PREG_SPLIT_NO_EMPTY); } /** * Get the number of words a string contains. - * - * @param string $string - * - * @return int */ - public static function wordCount($string) + public static function wordCount(string $string): int { return str_word_count($string); } /** * Generate a UUID (version 4). - * - * @return \Ramsey\Uuid\UuidInterface */ - public static function uuid() + public static function uuid(): UuidInterface { return static::$uuidFactory ? call_user_func(static::$uuidFactory) @@ -960,10 +746,8 @@ public static function uuid() /** * Generate a time-ordered UUID (version 4). - * - * @return \Ramsey\Uuid\UuidInterface */ - public static function orderedUuid() + public static function orderedUuid(): UuidInterface { if (static::$uuidFactory) { return call_user_func(static::$uuidFactory); @@ -986,7 +770,7 @@ public static function orderedUuid() /** * Set the callable that will be used to generate UUIDs. */ - public static function createUuidsUsing(callable $factory = null) + public static function createUuidsUsing(callable $factory = null): void { static::$uuidFactory = $factory; } @@ -994,7 +778,7 @@ public static function createUuidsUsing(callable $factory = null) /** * Indicate that UUIDs should be created normally and not using a custom factory. */ - public static function createUuidsNormally() + public static function createUuidsNormally(): void { static::$uuidFactory = null; } diff --git a/src/utils/src/Stringable.php b/src/utils/src/Stringable.php index ae3cc498..5e92f32a 100644 --- a/src/utils/src/Stringable.php +++ b/src/utils/src/Stringable.php @@ -28,30 +28,20 @@ class Stringable implements JsonSerializable use Macroable; use Tappable; - /** - * The underlying string value. - * - * @var string - */ - protected $value; - /** * Create a new instance of the class. * - * @param string $value + * @param string $value the underlying string value */ - public function __construct($value = '') - { - $this->value = (string) $value; + public function __construct( + protected string $value = '' + ) { } /** * Proxy dynamic properties onto methods. - * - * @param string $key - * @return mixed */ - public function __get($key) + public function __get(string $key) { return $this->{$key}(); } @@ -63,193 +53,141 @@ public function __get($key) */ public function __toString() { - return (string) $this->value; + return $this->value; } /** * Return the remainder of a string after the first occurrence of a given value. - * - * @param string $search - * @return static */ - public function after($search) + public function after(string $search): static { return new static(Str::after($this->value, $search)); } /** * Return the remainder of a string after the last occurrence of a given value. - * - * @param string $search - * @return static */ - public function afterLast($search) + public function afterLast(string $search): static { return new static(Str::afterLast($this->value, $search)); } /** * Append the given values to the string. - * - * @param array $values - * @return static */ - public function append(...$values) + public function append(string ...$values): static { return new static($this->value . implode('', $values)); } /** * Transliterate a UTF-8 value to ASCII. - * - * @param string $language - * @return static */ - public function ascii($language = 'en') + public function ascii(string $language = 'en'): static { return new static(Str::ascii($this->value, $language)); } /** * Get the trailing name component of the path. - * - * @param string $suffix - * @return static */ - public function basename($suffix = '') + public function basename(string $suffix = ''): static { return new static(basename($this->value, $suffix)); } /** * Get the basename of the class path. - * - * @return static */ - public function classBasename() + public function classBasename(): static { return new static(class_basename($this->value)); } /** * Get the portion of a string before the first occurrence of a given value. - * - * @param string $search - * @return static */ - public function before($search) + public function before(string $search): static { return new static(Str::before($this->value, $search)); } /** * Get the portion of a string before the last occurrence of a given value. - * - * @param string $search - * @return static */ - public function beforeLast($search) + public function beforeLast(string $search): static { return new static(Str::beforeLast($this->value, $search)); } /** * Get the portion of a string between two given values. - * - * @param string $from - * @param string $to - * @return static */ - public function between($from, $to) + public function between(string $from, string $to): static { return new static(Str::between($this->value, $from, $to)); } /** * Convert a value to camel case. - * - * @return static */ - public function camel() + public function camel(): static { return new static(Str::camel($this->value)); } /** * Determine if a given string contains a given substring. - * - * @param array|string $needles - * @return bool */ - public function contains($needles) + public function contains(array|string $needles): bool { return Str::contains($this->value, $needles); } /** * Determine if a given string contains all array values. - * - * @return bool */ - public function containsAll(array $needles) + public function containsAll(array $needles): bool { return Str::containsAll($this->value, $needles); } /** * Get the parent directory's path. - * - * @param int $levels - * @return static */ - public function dirname($levels = 1) + public function dirname(int $levels = 1): static { return new static(dirname($this->value, $levels)); } /** * Determine if a given string ends with a given substring. - * - * @param array|string $needles - * @return bool */ - public function endsWith($needles) + public function endsWith(array|string $needles): bool { return Str::endsWith($this->value, $needles); } /** * Determine if the string is an exact match with the given value. - * - * @param string $value - * @return bool */ - public function exactly($value) + public function exactly(string $value): bool { return $this->value === $value; } /** * Explode the string into an array. - * - * @param string $delimiter - * @param int $limit - * @return Collection */ - public function explode($delimiter, $limit = PHP_INT_MAX) + public function explode(string $delimiter, int $limit = PHP_INT_MAX): Collection { return collect(explode($delimiter, $this->value, $limit)); } /** * Split a string using a regular expression or by length. - * - * @param int|string $pattern - * @param int $limit - * @param int $flags - * @return Collection */ - public function split($pattern, $limit = -1, $flags = 0) + public function split(int|string $pattern, int $limit = -1, int $flags = 0): Collection { if (filter_var($pattern, FILTER_VALIDATE_INT) !== false) { return collect(mb_str_split($this->value, $pattern)); @@ -262,228 +200,168 @@ public function split($pattern, $limit = -1, $flags = 0) /** * Cap a string with a single instance of a given value. - * - * @param string $cap - * @return static */ - public function finish($cap) + public function finish(string $cap): static { return new static(Str::finish($this->value, $cap)); } /** * Determine if a given string matches a given pattern. - * - * @param array|string $pattern - * @return bool */ - public function is($pattern) + public function is(array|string $pattern): bool { return Str::is($pattern, $this->value); } /** * Determine if a given string is 7 bit ASCII. - * - * @return bool */ - public function isAscii() + public function isAscii(): bool { return Str::isAscii($this->value); } /** * Determine if the given string is empty. - * - * @return bool */ - public function isEmpty() + public function isEmpty(): bool { return $this->value === ''; } /** * Determine if the given string is not empty. - * - * @return bool */ - public function isNotEmpty() + public function isNotEmpty(): bool { return ! $this->isEmpty(); } /** * Convert a string to kebab case. - * - * @return static */ - public function kebab() + public function kebab(): static { return new static(Str::kebab($this->value)); } /** * Return the length of the given string. - * - * @param string $encoding - * @return int */ - public function length($encoding = null) + public function length(?string $encoding = null): int { return Str::length($this->value, $encoding); } /** * Limit the number of characters in a string. - * - * @param int $limit - * @param string $end - * @return static */ - public function limit($limit = 100, $end = '...') + public function limit(int $limit = 100, string $end = '...'): static { return new static(Str::limit($this->value, $limit, $end)); } /** * Convert the given string to lower-case. - * - * @return static */ - public function lower() + public function lower(): static { return new static(Str::lower($this->value)); } /** * Convert GitHub flavored Markdown into HTML. - * - * @return static */ - public function markdown(array $options = []) + public function markdown(array $options = []): static { return new static(Str::markdown($this->value, $options)); } /** * Get the string matching the given pattern. - * - * @param string $pattern - * @return static */ - public function match($pattern) + public function match(string $pattern): static { return new static(Str::match($pattern, $this->value)); } /** * Get the string matching the given pattern. - * - * @param string $pattern - * @return Collection */ - public function matchAll($pattern) + public function matchAll(string $pattern): Collection { return Str::matchAll($pattern, $this->value); } /** * Determine if the string matches the given pattern. - * - * @param string $pattern - * @return bool */ - public function test($pattern) + public function test(string $pattern): bool { return $this->match($pattern)->isNotEmpty(); } /** * Pad both sides of the string with another. - * - * @param int $length - * @param string $pad - * @return static */ - public function padBoth($length, $pad = ' ') + public function padBoth(int $length, string $pad = ' '): static { return new static(Str::padBoth($this->value, $length, $pad)); } /** * Pad the left side of the string with another. - * - * @param int $length - * @param string $pad - * @return static */ - public function padLeft($length, $pad = ' ') + public function padLeft(int $length, string $pad = ' '): static { return new static(Str::padLeft($this->value, $length, $pad)); } /** * Pad the right side of the string with another. - * - * @param int $length - * @param string $pad - * @return static */ - public function padRight($length, $pad = ' ') + public function padRight(int $length, string $pad = ' '): static { return new static(Str::padRight($this->value, $length, $pad)); } /** * Parse a Class@method style callback into class and method. - * - * @param null|string $default - * @return array */ - public function parseCallback($default = null) + public function parseCallback(?string $default = null): array { return Str::parseCallback($this->value, $default); } /** * Call the given callback and return a new string. - * - * @return static */ - public function pipe(callable $callback) + public function pipe(callable $callback): static { return new static(call_user_func($callback, $this)); } /** * Get the plural form of an English word. - * - * @param int $count - * @return static */ - public function plural($count = 2) + public function plural(int $count = 2): static { return new static(Str::plural($this->value, $count)); } /** * Pluralize the last word of an English, studly caps case string. - * - * @param int $count - * @return static */ - public function pluralStudly($count = 2) + public function pluralStudly(int $count = 2): static { return new static(Str::pluralStudly($this->value, $count)); } /** * Prepend the given values to the string. - * - * @param array $values - * @return static */ - public function prepend(...$values) + public function prepend(string ...$values): static { return new static(implode('', $values) . $this->value); } @@ -491,21 +369,17 @@ public function prepend(...$values) /** * Remove any occurrence of the given string in the subject. * - * @param array|string $search - * @param bool $caseSensitive - * @return static + * @param array|string $search */ - public function remove($search, $caseSensitive = true) + public function remove(array|string $search, bool $caseSensitive = true): static { return new static(Str::remove($search, $this->value, $caseSensitive)); } /** * Repeat the string. - * - * @return static */ - public function repeat(int $times) + public function repeat(int $times): static { return new static(Str::repeat($this->value, $times)); } @@ -513,22 +387,18 @@ public function repeat(int $times) /** * Replace the given value in the given string. * - * @param string|string[] $search - * @param string|string[] $replace - * @return static + * @param string|string[] $search + * @param string|string[] $replace */ - public function replace($search, $replace) + public function replace(array|string $search, array|string $replace): static { return new static(Str::replace($search, $replace, $this->value)); } /** * Replace a given value in the string sequentially with an array. - * - * @param string $search - * @return static */ - public function replaceArray($search, array $replace) + public function replaceArray(string $search, array $replace): static { return new static(Str::replaceArray($search, $replace, $this->value)); } @@ -536,8 +406,9 @@ public function replaceArray($search, array $replace) /** * Replace the first occurrence of a given value in the string. * - * @param string $search - * @param string $replace + * @param string $search + * @param string $replace + * * @return static */ public function replaceFirst($search, $replace) @@ -548,8 +419,9 @@ public function replaceFirst($search, $replace) /** * Replace the last occurrence of a given value in the string. * - * @param string $search - * @param string $replace + * @param string $search + * @param string $replace + * * @return static */ public function replaceLast($search, $replace) @@ -560,9 +432,10 @@ public function replaceLast($search, $replace) /** * Replace the patterns matching the given regular expression. * - * @param string $pattern - * @param Closure|string $replace - * @param int $limit + * @param string $pattern + * @param Closure|string $replace + * @param int $limit + * * @return static */ public function replaceMatches($pattern, $replace, $limit = -1) @@ -577,7 +450,8 @@ public function replaceMatches($pattern, $replace, $limit = -1) /** * Begin a string with a single instance of a given value. * - * @param string $prefix + * @param string $prefix + * * @return static */ public function start($prefix) @@ -618,8 +492,9 @@ public function singular() /** * Generate a URL friendly "slug" from a given string. * - * @param string $separator - * @param null|string $language + * @param string $separator + * @param null|string $language + * * @return static */ public function slug($separator = '-', $language = 'en') @@ -630,7 +505,8 @@ public function slug($separator = '-', $language = 'en') /** * Convert a string to snake case. * - * @param string $delimiter + * @param string $delimiter + * * @return static */ public function snake($delimiter = '_') @@ -641,7 +517,8 @@ public function snake($delimiter = '_') /** * Determine if a given string starts with a given substring. * - * @param array|string $needles + * @param array|string $needles + * * @return bool */ public function startsWith($needles) @@ -662,8 +539,9 @@ public function studly() /** * Returns the portion of the string specified by the start and length parameters. * - * @param int $start - * @param null|int $length + * @param int $start + * @param null|int $length + * * @return static */ public function substr($start, $length = null) @@ -674,9 +552,10 @@ public function substr($start, $length = null) /** * Returns the number of substring occurrences. * - * @param string $needle - * @param null|int $offset - * @param null|int $length + * @param string $needle + * @param null|int $offset + * @param null|int $length + * * @return int */ public function substrCount($needle, $offset = null, $length = null) @@ -687,7 +566,8 @@ public function substrCount($needle, $offset = null, $length = null) /** * Trim the string of the given characters. * - * @param string $characters + * @param string $characters + * * @return static */ public function trim($characters = null) @@ -698,7 +578,8 @@ public function trim($characters = null) /** * Left trim the string of the given characters. * - * @param string $characters + * @param string $characters + * * @return static */ public function ltrim($characters = null) @@ -709,7 +590,8 @@ public function ltrim($characters = null) /** * Right trim the string of the given characters. * - * @param string $characters + * @param string $characters + * * @return static */ public function rtrim($characters = null) @@ -730,7 +612,8 @@ public function ucfirst() /** * Execute the given callback if the string is empty. * - * @param callable $callback + * @param callable $callback + * * @return static */ public function whenEmpty($callback) @@ -747,7 +630,8 @@ public function whenEmpty($callback) /** * Execute the given callback if the string is not empty. * - * @param callable $callback + * @param callable $callback + * * @return static */ public function whenNotEmpty($callback) @@ -764,8 +648,9 @@ public function whenNotEmpty($callback) /** * Limit the number of words in a string. * - * @param int $words - * @param string $end + * @param int $words + * @param string $end + * * @return static */ public function words($words = 100, $end = '...') diff --git a/src/utils/src/helpers.php b/src/utils/src/helpers.php index 39633fae..d041853d 100644 --- a/src/utils/src/helpers.php +++ b/src/utils/src/helpers.php @@ -62,7 +62,7 @@ function data_get(mixed $target, array|int|string|null $key, mixed $default = nu if ($segment === '*') { if ($target instanceof Collection) { $target = $target->all(); - } else if (!is_array($target)) { + } elseif (! is_array($target)) { return value($default); } @@ -77,7 +77,7 @@ function data_get(mixed $target, array|int|string|null $key, mixed $default = nu if (Arr::accessible($target) && Arr::exists($target, $segment)) { $target = $target[$segment]; - } else if (is_object($target) && isset($target->{$segment})) { + } elseif (is_object($target) && isset($target->{$segment})) { $target = $target->{$segment}; } else { return value($default); @@ -95,7 +95,7 @@ function data_set(mixed &$target, array|string $key, mixed $value, bool $overwri $segments = is_array($key) ? $key : explode('.', $key); if (($segment = array_shift($segments)) === '*') { - if (!Arr::accessible($target)) { + if (! Arr::accessible($target)) { $target = []; } @@ -103,29 +103,29 @@ function data_set(mixed &$target, array|string $key, mixed $value, bool $overwri foreach ($target as &$inner) { data_set($inner, $segments, $value, $overwrite); } - } else if ($overwrite) { + } elseif ($overwrite) { foreach ($target as &$inner) { $inner = $value; } } - } else if (Arr::accessible($target)) { + } elseif (Arr::accessible($target)) { if ($segments) { - if (!Arr::exists($target, $segment)) { + if (! Arr::exists($target, $segment)) { $target[$segment] = []; } data_set($target[$segment], $segments, $value, $overwrite); - } else if ($overwrite || !Arr::exists($target, $segment)) { + } elseif ($overwrite || ! Arr::exists($target, $segment)) { $target[$segment] = $value; } - } else if (is_object($target)) { + } elseif (is_object($target)) { if ($segments) { - if (!isset($target->{$segment})) { + if (! isset($target->{$segment})) { $target->{$segment} = []; } data_set($target->{$segment}, $segments, $value, $overwrite); - } else if ($overwrite || !isset($target->{$segment})) { + } elseif ($overwrite || ! isset($target->{$segment})) { $target->{$segment} = $value; } } else { @@ -133,7 +133,7 @@ function data_set(mixed &$target, array|string $key, mixed $value, bool $overwri if ($segments) { data_set($target[$segment], $segments, $value, $overwrite); - } else if ($overwrite) { + } elseif ($overwrite) { $target[$segment] = $value; } } @@ -270,7 +270,7 @@ function e(Htmlable|string|DeferringDisplayableValue|null $value, bool $doubleEn */ function filled(mixed $value): bool { - return !blank($value); + return ! blank($value); } /** @@ -283,7 +283,7 @@ function object_get(object $object, ?string $key, mixed $default = null): mixed } foreach (explode('.', $key) as $segment) { - if (!is_object($object) || !isset($object->{$segment})) { + if (! is_object($object) || ! isset($object->{$segment})) { return value($default); } @@ -301,7 +301,7 @@ function optional(mixed $value = null, callable $callback = null): mixed if (is_null($callback)) { return new Optional($value); } - if (!is_null($value)) { + if (! is_null($value)) { return $callback($value); } } @@ -322,7 +322,7 @@ function retry(int $times, callable $callback, int|Closure $sleepMilliseconds = try { return $callback($attempts); } catch (Exception $e) { - if ($times < 1 || ($when && !$when($e))) { + if ($times < 1 || ($when && ! $when($e))) { throw $e; } @@ -359,7 +359,7 @@ function throw_if(mixed $condition, Throwable|string $exception = 'RuntimeExcept */ function throw_unless(mixed $condition, Throwable|string $exception = 'RuntimeException', ...$parameters): mixed { - throw_if(!$condition, $exception, ...$parameters); + throw_if(! $condition, $exception, ...$parameters); return $condition; } @@ -411,17 +411,17 @@ function with(mixed $value, callable $callback = null): mixed } /** - * 转为xml + * 转为xml. */ function data_to_xml(iterable $data): string { $xml = ''; foreach ($data as $key => $val) { - is_numeric($key) && $key = "item id=\"$key\""; - $xml .= "<$key>"; + is_numeric($key) && $key = "item id=\"{$key}\""; + $xml .= "<{$key}>"; $xml .= (is_array($val) || is_object($val)) ? data_to_xml($val) : $val; - list($key,) = explode(' ', $key); - $xml .= ""; + [$key] = explode(' ', $key); + $xml .= ""; } return $xml; diff --git a/src/validator/src/Rules.php b/src/validator/src/Rules.php index 1ec95f20..b974bcae 100644 --- a/src/validator/src/Rules.php +++ b/src/validator/src/Rules.php @@ -24,11 +24,9 @@ class Rules { - protected Validator $validator; - - public function __construct(Validator $validator) - { - $this->validator = $validator; + public function __construct( + protected Validator $validator + ) { } /** diff --git a/src/view/src/Engine/Blade/Compiler.php b/src/view/src/Engine/Blade/Compiler.php index b149cb88..5667354f 100644 --- a/src/view/src/Engine/Blade/Compiler.php +++ b/src/view/src/Engine/Blade/Compiler.php @@ -30,14 +30,12 @@ class Compiler protected ?string $parent; - protected BladeEngine $blade; - /** * Compiler constructor. */ - public function __construct(BladeEngine $blade) - { - $this->blade = $blade; + public function __construct( + protected BladeEngine $blade + ) { } /** From 200c445edcfe1564ed60906fdeff3b62c8e10601 Mon Sep 17 00:00:00 2001 From: chengyao <64066545+topyao@users.noreply.github.com> Date: Sat, 20 Aug 2022 08:15:30 +0800 Subject: [PATCH 6/6] =?UTF-8?q?Release:=20=E6=B7=BB=E5=8A=A0=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/aop/README.md | 2 +- src/aop/composer.json | 4 +- src/cache/README.md | 2 +- src/cache/composer.json | 4 +- src/config/composer.json | 2 +- src/database/composer.json | 6 +- src/http-message/composer.json | 2 +- .../src/Contract/HeaderInterface.php | 22 +++++++ src/http-message/src/Cookie.php | 66 ++++++++++--------- src/http-message/src/ServerRequest.php | 20 +++--- src/http-server/composer.json | 8 +-- src/routing/composer.json | 2 +- src/session/README.md | 2 +- src/session/composer.json | 4 +- src/validator/README.md | 2 +- src/view/composer.json | 4 +- 16 files changed, 88 insertions(+), 64 deletions(-) diff --git a/src/aop/README.md b/src/aop/README.md index a3e901dc..59faf7da 100644 --- a/src/aop/README.md +++ b/src/aop/README.md @@ -5,7 +5,7 @@ > 环境要求 PHP >= 8.0 ```shell -composer require max/aop:dev-master +composer require max/aop ``` # 使用,以下以webman为例 diff --git a/src/aop/composer.json b/src/aop/composer.json index 57eab748..4c8bf09c 100644 --- a/src/aop/composer.json +++ b/src/aop/composer.json @@ -17,8 +17,8 @@ "require": { "php": "^8.0", "ext-pcntl": "*", - "max/utils": "dev-master", - "max/di": "dev-master", + "max/utils": "^0.1", + "max/di": "^0.1", "nikic/php-parser": "^4.13", "symfony/finder": "*" } diff --git a/src/cache/README.md b/src/cache/README.md index fa4f09aa..2c62571b 100644 --- a/src/cache/README.md +++ b/src/cache/README.md @@ -16,7 +16,7 @@ 缓存组件基于PSR16开发,已经独立,不再必须使用MaxPHP。你可以使用下面的命令安装开发版本。 ``` -composer require max/cache:dev-master +composer require max/cache ``` # 使用 diff --git a/src/cache/composer.json b/src/cache/composer.json index adbc0c5e..62367021 100644 --- a/src/cache/composer.json +++ b/src/cache/composer.json @@ -27,9 +27,9 @@ }, "require": { "php": "^8.0", - "max/utils": "dev-master", + "max/utils": "^0.1", "psr/simple-cache": "^1.0", - "max/redis": "dev-master" + "max/redis": "^0.1" }, "extra": { "max": { diff --git a/src/config/composer.json b/src/config/composer.json index 0b51b790..33577ae1 100644 --- a/src/config/composer.json +++ b/src/config/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": "^8.0", - "max/utils": "dev-master" + "max/utils": "^0.1" }, "extra": { "max": { diff --git a/src/database/composer.json b/src/database/composer.json index a1033c9f..e58eb93b 100644 --- a/src/database/composer.json +++ b/src/database/composer.json @@ -20,9 +20,9 @@ "php": "^8.0", "ext-pdo": "*", "ext-json": "*", - "max/utils": "dev-master", - "max/config": "dev-master", - "max/context": "dev-master" + "max/utils": "^0.1", + "max/config": "^0.1", + "max/context": "^0.1" }, "extra": { "max": { diff --git a/src/http-message/composer.json b/src/http-message/composer.json index 22d0cc44..a172ec41 100644 --- a/src/http-message/composer.json +++ b/src/http-message/composer.json @@ -20,6 +20,6 @@ "require": { "php": "^8.0", "psr/http-message": "^1.0", - "max/utils": "dev-master" + "max/utils": "^0.1" } } diff --git a/src/http-message/src/Contract/HeaderInterface.php b/src/http-message/src/Contract/HeaderInterface.php index 40bf4d61..3dbd947a 100644 --- a/src/http-message/src/Contract/HeaderInterface.php +++ b/src/http-message/src/Contract/HeaderInterface.php @@ -1,21 +1,43 @@ name . '='; + if ($this->value === '') { + $str .= 'deleted; expires=' . gmdate('D, d-M-Y H:i:s T', time() - 31536001) . '; max-age=-31536001'; + } else { + $str .= $this->value; + if ($this->expires !== 0) { + $str .= '; expires=' . gmdate('D, d-m-Y H:i:s T', $this->expires) . '; max-age=' . $this->getMaxAge(); + } + } + if ($this->path) { + $str .= '; path=' . $this->path; + } + if ($this->domain) { + $str .= '; domain=' . $this->domain; + } + if ($this->secure) { + $str .= '; secure'; + } + if ($this->httponly) { + $str .= '; httponly'; + } + if ($this->sameSite) { + $str .= '; samesite=' . $this->sameSite; + } + return $str; + } + /** * 解析Cookie字符串,返回对象 */ @@ -76,38 +110,6 @@ public static function parse(string $str): Cookie ); } - /** - * 生成对应的Cookie字符串 - */ - public function __toString(): string - { - $str = $this->name . '='; - if ($this->value === '') { - $str .= 'deleted; expires=' . gmdate('D, d-M-Y H:i:s T', time() - 31536001) . '; max-age=-31536001'; - } else { - $str .= $this->value; - if ($this->expires !== 0) { - $str .= '; expires=' . gmdate('D, d-m-Y H:i:s T', $this->expires) . '; max-age=' . $this->getMaxAge(); - } - } - if ($this->path) { - $str .= '; path=' . $this->path; - } - if ($this->domain) { - $str .= '; domain=' . $this->domain; - } - if ($this->secure) { - $str .= '; secure'; - } - if ($this->httponly) { - $str .= '; httponly'; - } - if ($this->sameSite) { - $str .= '; samesite=' . $this->sameSite; - } - return $str; - } - public function setName(string $name): void { $this->name = $name; diff --git a/src/http-message/src/ServerRequest.php b/src/http-message/src/ServerRequest.php index 7cdca52e..f1ec42eb 100644 --- a/src/http-message/src/ServerRequest.php +++ b/src/http-message/src/ServerRequest.php @@ -73,11 +73,11 @@ public static function createFromSwooleRequest($request, array $attributes = []) $hasPort = true; $uri = $uri->withPort($hostHeaderParts[1]); } - } else if (isset($server['server_name'])) { + } elseif (isset($server['server_name'])) { $uri = $uri->withHost($server['server_name']); - } else if (isset($server['server_addr'])) { + } elseif (isset($server['server_addr'])) { $uri = $uri->withHost($server['server_addr']); - } else if (isset($header['host'])) { + } elseif (isset($header['host'])) { $hasPort = true; if (strpos($header['host'], ':')) { [$host, $port] = explode(':', $header['host'], 2); @@ -91,7 +91,7 @@ public static function createFromSwooleRequest($request, array $attributes = []) $uri = $uri->withHost($host); } - if (!$hasPort && isset($server['server_port'])) { + if (! $hasPort && isset($server['server_port'])) { $uri = $uri->withPort($server['server_port']); } @@ -105,7 +105,7 @@ public static function createFromSwooleRequest($request, array $attributes = []) } } - if (!$hasQuery && isset($server['query_string'])) { + if (! $hasQuery && isset($server['query_string'])) { $uri = $uri->withQuery($server['query_string']); } @@ -115,7 +115,7 @@ public static function createFromSwooleRequest($request, array $attributes = []) $psrRequest->body = new StringStream($request->getContent()); $psrRequest->cookieParams = new CookieBag($request->cookie ?? []); $psrRequest->queryParams = new ParameterBag($request->get ?? []); - $psrRequest->uploadedFiles = new FileBag($request->files ?? []); // TODO Convert to UploadedFiles. + $psrRequest->uploadedFiles = new FileBag($request->files ?? []); // TODO Convert to UploadedFiles. $psrRequest->attributes = new ParameterBag($attributes); return $psrRequest; @@ -273,7 +273,7 @@ public function getParsedBody() public function withParsedBody($data) { $new = clone $this; - $new->parsedBody = $data instanceof ParameterBag ? $data : new ParameterBag((array)$data); + $new->parsedBody = $data instanceof ParameterBag ? $data : new ParameterBag((array) $data); return $new; } @@ -324,10 +324,10 @@ public function withoutAttribute($name) public function getRealIp(): string { $headers = $this->getHeaders(); - if (isset($headers['x-forwarded-for'][0]) && !empty($headers['x-forwarded-for'][0])) { + if (isset($headers['x-forwarded-for'][0]) && ! empty($headers['x-forwarded-for'][0])) { return $headers['x-forwarded-for'][0]; } - if (isset($headers['x-real-ip'][0]) && !empty($headers['x-real-ip'][0])) { + if (isset($headers['x-real-ip'][0]) && ! empty($headers['x-real-ip'][0])) { return $headers['x-real-ip'][0]; } $serverParams = $this->getServerParams(); @@ -378,7 +378,7 @@ public function url(): string { $uri = $this->getUri(); $url = $uri->getPath(); - if (!empty($query = $uri->getQuery())) { + if (! empty($query = $uri->getQuery())) { $url .= '?' . $query; } return $url; diff --git a/src/http-server/composer.json b/src/http-server/composer.json index 18da7f2b..e3091dc4 100644 --- a/src/http-server/composer.json +++ b/src/http-server/composer.json @@ -15,10 +15,10 @@ ], "require": { "php": "^8.0", - "max/http-message": "dev-master", - "max/utils": "dev-master", - "max/routing": "dev-master", - "max/di": "dev-master", + "max/http-message": "^0.1", + "max/utils": "^0.1", + "max/routing": "^0.1", + "max/di": "^0.1", "psr/http-server-middleware": "^1.0", "psr/http-server-handler": "^1.0", "psr/event-dispatcher": "^1.0" diff --git a/src/routing/composer.json b/src/routing/composer.json index 339f8b2e..dbcf77c6 100644 --- a/src/routing/composer.json +++ b/src/routing/composer.json @@ -12,7 +12,7 @@ ], "require": { "php": "^8.0", - "max/http-message": "dev-master" + "max/http-message": "^0.1" }, "autoload": { "psr-4": { diff --git a/src/session/README.md b/src/session/README.md index bb9bbb1d..629697cf 100644 --- a/src/session/README.md +++ b/src/session/README.md @@ -1,7 +1,7 @@ Session组件,支持File和Redis存储 ```php -composer require max/session:dev-master +composer require max/session ``` ```php diff --git a/src/session/composer.json b/src/session/composer.json index 1d1685fa..accfff2e 100644 --- a/src/session/composer.json +++ b/src/session/composer.json @@ -16,7 +16,7 @@ }, "require": { "php": "^8.0", - "max/utils": "dev-master", - "max/redis": "dev-master" + "max/utils": "^0.1", + "max/redis": "^0.1" } } diff --git a/src/validator/README.md b/src/validator/README.md index 8efa8ad0..0c47adab 100644 --- a/src/validator/README.md +++ b/src/validator/README.md @@ -16,7 +16,7 @@ MaxPHP验证器组件 # 安装 ``` -composer require max/validator:dev-master +composer require max/validator ``` # 使用 diff --git a/src/view/composer.json b/src/view/composer.json index 5e2634fb..2df8861a 100644 --- a/src/view/composer.json +++ b/src/view/composer.json @@ -12,8 +12,8 @@ ], "require": { "php": "^8.0", - "max/utils": "dev-master", - "max/config": "dev-master" + "max/utils": "^0.1", + "max/config": "^0.1" }, "autoload": { "psr-4": {