Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.1.0 #49

Merged
merged 13 commits into from
Sep 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2022] [ChengYao <987861463@qq.com>]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"Max\\Database\\": "src/database/src",
"Max\\Di\\": "src/di/src",
"Max\\Event\\": "src/event/src",
"Max\\": "src/framework/src",
"Max\\Http\\Server\\": "src/http-server/src",
"Max\\Http\\Message\\": "src/http-message/src",
"Max\\Routing\\": "src/routing/src",
Expand Down Expand Up @@ -45,7 +44,6 @@
"max/di": "*",
"max/aop": "*",
"max/event": "*",
"max/framework": "*",
"max/http-message": "*",
"max/http-server": "*",
"max/log": "*",
Expand Down
2 changes: 1 addition & 1 deletion src/aop/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2022] [ChengYao <987861463@qq.com>]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
15 changes: 11 additions & 4 deletions src/aop/src/PropertyHandlerVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,24 @@ public function leaveNode(Node $node)
foreach ($reflectionConstructor->getParameters() as $key => $reflectionParameter) {
$type = $reflectionParameter->getType();
if (is_null($type)
|| ($type instanceof ReflectionNamedType && $type->isBuiltin())
|| $type instanceof ReflectionUnionType
|| $type->getName() === 'Closure') {
|| ($type instanceof ReflectionNamedType && ($type->isBuiltin() || $type->getName() === 'Closure'))
) {
continue;
}
if ($type instanceof ReflectionUnionType) {
$unionType = [];
foreach ($type->getTypes() as $reflectionNamedType) {
$unionType[] = ($reflectionNamedType->isBuiltin() ? '' : '\\') . $reflectionNamedType->getName();
}
$params[$key]->type = new Name(implode('|', $unionType));
continue;
}
$allowsNull = $reflectionParameter->allowsNull() ? '?' : '';
$params[$key]->type = new Name($allowsNull . '\\' . $type->getName());
}
}
$c = [];
if (! $this->metadata->hasConstructor) {
if (!$this->metadata->hasConstructor) {
$constructor = new ClassMethod('__construct', [
'params' => $params,
]);
Expand Down
23 changes: 2 additions & 21 deletions src/aop/src/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function init(ScannerConfig $config): void
self::$astManager = new AstManager();
self::$classMap = self::findClasses($config->getPaths());
self::$proxyMap = $proxyMap = self::$runtimeDir . 'proxy.php';
if (!$config->isCache() || !self::$filesystem->exists($proxyMap)) {
if (! $config->isCache() || ! self::$filesystem->exists($proxyMap)) {
self::$filesystem->exists($proxyMap) && self::$filesystem->delete($proxyMap);
if (($pid = pcntl_fork()) == -1) {
throw new Exception('Process fork failed.');
Expand All @@ -79,25 +79,6 @@ public static function findClasses(array $dirs): array
return $classes;
}

public static function scanConfig(string $installedJsonDir): array
{
$installed = json_decode(file_get_contents($installedJsonDir), true);
$installed = $installed['packages'] ?? $installed;
$config = [];
foreach ($installed as $package) {
if (isset($package['extra']['max']['config'])) {
$configProvider = $package['extra']['max']['config'];
$configProvider = new $configProvider();
if (method_exists($configProvider, '__invoke')) {
if (is_array($configItem = $configProvider())) {
$config = array_merge_recursive($config, $configItem);
}
}
}
}
return $config;
}

public static function addClass(string $class, string $path): void
{
self::$classMap[$class] = $path;
Expand All @@ -110,7 +91,7 @@ private static function getProxyMap(array $collectors): array
{
if (! self::$filesystem->exists(self::$proxyMap)) {
$proxyDir = self::$runtimeDir . 'proxy/';
self::$filesystem->makeDirectory($proxyDir, 0755, true, true);
self::$filesystem->exists($proxyDir) || self::$filesystem->makeDirectory($proxyDir, 0755, true, true);
self::$filesystem->cleanDirectory($proxyDir);
self::collect($collectors);
$collectedClasses = array_unique(array_merge(AspectCollector::getCollectedClasses(), PropertyAnnotationCollector::getCollectedClasses()));
Expand Down
2 changes: 1 addition & 1 deletion src/cache/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2022] [ChengYao <987861463@qq.com>]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 4 additions & 0 deletions src/cache/publish/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@
'port' => 11211, // 端口
],
],
'apcu' => [
'driver' => \Max\Cache\Driver\ApcDriver::class,
'config' => [],
],
],
];
14 changes: 7 additions & 7 deletions src/cache/src/Driver/ApcDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,37 @@ class ApcDriver extends AbstractDriver
{
public function has(string $key): bool
{
return (bool) apc_exists($key);
return (bool) \apc_exists($key);
}

public function get(string $key): mixed
{
$data = apc_fetch($key, $success);
$data = \apc_fetch($key, $success);
return $success === true ? $data : null;
}

public function set(string $key, mixed $value, ?int $ttl = null): bool
{
return (bool) apc_store($key, $value, (int) $ttl);
return (bool) \apc_store($key, $value, (int) $ttl);
}

public function clear(): bool
{
return apc_clear_cache('user');
return \apc_clear_cache('user');
}

public function delete(string $key): bool
{
return (bool) apc_delete($key);
return (bool) \apc_delete($key);
}

public function increment(string $key, int $step = 1): int|bool
{
return apc_inc($key, $step);
return \apc_inc($key, $step);
}

public function decrement(string $key, int $step = 1): int|bool
{
return apc_dec($key, $step);
return \apc_dec($key, $step);
}
}
2 changes: 1 addition & 1 deletion src/config/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2022] [ChengYao <987861463@qq.com>]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 0 additions & 5 deletions src/config/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,5 @@
"require": {
"php": "^8.0",
"max/utils": "^1.0"
},
"extra": {
"max": {
"config": "Max\\Config\\ConfigProvider"
}
}
}
24 changes: 0 additions & 24 deletions src/config/src/ConfigProvider.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/context/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2022] [ChengYao <987861463@qq.com>]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/database/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2022] [ChengYao <987861463@qq.com>]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/di/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2022] [ChengYao <987861463@qq.com>]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion src/event/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright [2022] [ChengYao <987861463@qq.com>]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
5 changes: 0 additions & 5 deletions src/event/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,5 @@
"require": {
"php": "^8.0",
"psr/event-dispatcher": "^1.0"
},
"extra": {
"max": {
"config": "Max\\Event\\ConfigProvider"
}
}
}
26 changes: 0 additions & 26 deletions src/event/src/ConfigProvider.php

This file was deleted.

Loading