-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
ba1657b Upstream travis ci config (swoft-cloud/swoft-component#160) ffdb60e 修复Json Validator会失效的BUG (swoft-cloud/swoft-component#153) 4d788e9 修复自定义注解无法使用Aop切面编程的BUG (swoft-cloud/swoft-component#139) 405a83e Optimize (swoft-cloud/swoft-component#143) b72e04c 修复执行php bin/swoft stop命令时master进程异常未退出的问题,以及停止失败后,pid文件被删除的问题 (#134) a30bf58 修改`ComposerHelper::getDirByNamespace`匹配有误的BUG (swoft-cloud/swoft-component#137) 43088e6 Update PoolHelper.php (swoft-cloud/swoft-component#131) 82aadc2 Scan bean according to Composer settings (#115) 5e55e72 Add psysh for debug (swoft-cloud/swoft-component#109) 93c3ec7 Parse namespace to dir path according to composer settings (swoft-cloud/swoft-component#103) git-subtree-dir: src/framework git-subtree-split: ba1657b
- Loading branch information
1 parent
740e211
commit 1fab514
Showing
15 changed files
with
213 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace Swoft\Helper; | ||
|
||
|
||
use Composer\Autoload\ClassLoader; | ||
|
||
class ComposerHelper | ||
{ | ||
|
||
/** | ||
* @var ClassLoader|mixed | ||
*/ | ||
static $loader; | ||
|
||
/** | ||
* @return ClassLoader | ||
*/ | ||
public static function getLoader(): ClassLoader | ||
{ | ||
if (! self::$loader) { | ||
$loader = self::findLoader(); | ||
$loader instanceof ClassLoader && self::$loader = $loader; | ||
} | ||
return self::$loader; | ||
} | ||
|
||
/** | ||
* @return ClassLoader | ||
* @throws \RuntimeException When Composer loader not found | ||
*/ | ||
public static function findLoader(): ClassLoader | ||
{ | ||
$composerClass = ''; | ||
foreach (get_declared_classes() as $declaredClass) { | ||
if (StringHelper::startsWith($declaredClass, 'ComposerAutoloaderInit') && method_exists($declaredClass, 'getLoader')) { | ||
$composerClass = $declaredClass; | ||
break; | ||
} | ||
} | ||
if (! $composerClass) { | ||
throw new \RuntimeException('Composer loader not found.'); | ||
} | ||
return $composerClass::getLoader(); | ||
} | ||
|
||
/** | ||
* @param string $namespace | ||
* @return string | ||
*/ | ||
public static function getDirByNamespace(string $namespace): string | ||
{ | ||
$dir = ''; | ||
$loader = self::findLoader(); | ||
$prefixesPsr4 = $loader->getPrefixesPsr4(); | ||
$maxLength = 0; | ||
foreach ($prefixesPsr4 as $prefix => $path) { | ||
if (StringHelper::startsWith($namespace, $prefix)) { | ||
$strLen = strlen($prefix); | ||
if ($strLen > $maxLength) { | ||
$dir = current($path) . DIRECTORY_SEPARATOR . substr($namespace, $strLen); | ||
$maxLength = $strLen; | ||
} | ||
} | ||
} | ||
return $dir; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace SwoftTest\Aop\Annotation; | ||
|
||
/** | ||
* Class DemoAnnotation | ||
* @Annotation | ||
* @Target("METHOD") | ||
* @package SwoftTest\Aop\Annotation | ||
*/ | ||
class DemoAnnotation | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
public function __construct(array $values) | ||
{ | ||
if (isset($values['name'])) { | ||
$this->name = $values['name']; | ||
} | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
namespace SwoftTest\Aop\Collector; | ||
|
||
class DemoCollector | ||
{ | ||
/** | ||
* The annotations of method | ||
* | ||
* @var array | ||
*/ | ||
public static $methodAnnotations = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace SwoftTest\Aop\Parser; | ||
|
||
use Swoft\Bean\Collector; | ||
use SwoftTest\Aop\Collector\DemoCollector; | ||
|
||
class DemoAnnotationParser | ||
{ | ||
public function parser(string $className, $objectAnnotation = null, string $propertyName = "", string $methodName = "", $propertyValue = null) | ||
{ | ||
Collector::$methodAnnotations[$className][$methodName][] = get_class($objectAnnotation); | ||
DemoCollector::$methodAnnotations[$className][$methodName] = $objectAnnotation; | ||
return null; | ||
} | ||
} |
Oops, something went wrong.