Skip to content

Commit

Permalink
Merge pull request #38 from tab-engineer/1.x
Browse files Browse the repository at this point in the history
1.x
  • Loading branch information
bbuugg authored Aug 20, 2022
2 parents bd41a90 + 200c445 commit 7bd7727
Show file tree
Hide file tree
Showing 49 changed files with 403 additions and 779 deletions.
2 changes: 1 addition & 1 deletion src/aop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
> 环境要求 PHP >= 8.0
```shell
composer require max/aop:dev-master
composer require max/aop
```

# 使用,以下以webman为例
Expand Down
4 changes: 2 additions & 2 deletions src/aop/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*"
}
Expand Down
5 changes: 3 additions & 2 deletions src/aop/src/PropertyHandlerVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/aop/src/ProxyHandlerVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/cache/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
缓存组件基于PSR16开发,已经独立,不再必须使用MaxPHP。你可以使用下面的命令安装开发版本。

```
composer require max/cache:dev-master
composer require max/cache
```

# 使用
Expand Down
4 changes: 2 additions & 2 deletions src/cache/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
23 changes: 0 additions & 23 deletions src/cache/src/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

class Cache implements CacheInterface
{
/**
* @param CacheDriverInterface $driver
*/
public function __construct(
protected CacheDriverInterface $driver
) {
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/config/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"require": {
"php": "^8.0",
"max/utils": "dev-master"
"max/utils": "^0.1"
},
"extra": {
"max": {
Expand Down
6 changes: 3 additions & 3 deletions src/database/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
5 changes: 3 additions & 2 deletions src/database/src/Connector/AutoConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ class AutoConnector implements ConnectorInterface

protected array $container = [];

public function __construct(protected DatabaseConfig $config)
{
public function __construct(
protected DatabaseConfig $config
) {
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/database/src/Connector/BaseConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
5 changes: 3 additions & 2 deletions src/database/src/Connector/PoolConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 6 additions & 2 deletions src/database/src/Eloquent/Relation/HasMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
}
}
4 changes: 2 additions & 2 deletions src/database/src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
20 changes: 10 additions & 10 deletions src/database/src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)), ' ,'))];
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}
Expand Down
7 changes: 2 additions & 5 deletions src/database/src/Query/Join.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
5 changes: 3 additions & 2 deletions src/framework/src/Exception/VarDumperAbort.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

class VarDumperAbort extends Exception
{
public function __construct(public mixed $vars)
{
public function __construct(
public mixed $vars
) {
}
}
2 changes: 1 addition & 1 deletion src/http-message/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"require": {
"php": "^8.0",
"psr/http-message": "^1.0",
"max/utils": "dev-master"
"max/utils": "^0.1"
}
}
5 changes: 3 additions & 2 deletions src/http-message/src/Bag/FileBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

class FileBag
{
public function __construct(protected array $uploadedFiles = [])
{
public function __construct(
protected array $uploadedFiles = []
) {
}

public static function createFromGlobal(): static
Expand Down
22 changes: 22 additions & 0 deletions src/http-message/src/Contract/HeaderInterface.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,43 @@
<?php

declare(strict_types=1);

/**
* This file is part of MaxPHP.
*
* @link https://github.com/marxphp
* @license https://github.com/marxphp/max/blob/master/LICENSE
*/

namespace Max\Http\Message\Contract;

interface HeaderInterface
{
public const HEADER_CONTENT_TYPE = 'Content-Type';

public const HEADER_SET_COOKIE = 'Set-Cookie';

public const HEADER_PRAGMA = 'Pragma';

public const HEADER_ACCEPT = 'Accept';

public const HEADER_EXPIRES = 'Expires';

public const HEADER_CACHE_CONTROL = 'Cache-Control';

public const HEADER_CONTENT_TRANSFER_ENCODING = 'Content-Transfer-Encoding';

public const HEADER_CONTENT_DISPOSITION = 'Content-Disposition';

public const HEADER_ORIGIN = 'Origin';

public const HEADER_ACCESS_CONTROL_ALLOW_ORIGIN = 'Access-Control-Allow-Origin';

public const HEADER_ACCESS_CONTROL_MAX_AGE = 'Access-Control-Max-Age';

public const HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS = 'Access-Control-Allow-Credentials';

public const HEADER_ACCESS_CONTROL_ALLOW_METHODS = 'Access-Control-Allow-Methods';

public const HEADER_ACCESS_CONTROL_ALLOW_HEADERS = 'Access-Control-Allow-Headers';
}
Loading

0 comments on commit 7bd7727

Please sign in to comment.