Skip to content

Commit

Permalink
Merge pull request #49 from marxphp/1.x
Browse files Browse the repository at this point in the history
1.1.0
  • Loading branch information
bbuugg authored Sep 11, 2022
2 parents 801118f + 01238e2 commit 9b255c6
Show file tree
Hide file tree
Showing 56 changed files with 1,044 additions and 1,119 deletions.
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

0 comments on commit 9b255c6

Please sign in to comment.