diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..94d3f56 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,10 @@ +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/.styleci.yml export-ignore +/.scrutinizer.yml export-ignore +/.sensiolabs.yml export-ignore +/nitpick.json export-ignore +/composer.lock export-ignore +/tests/ export-ignore +/phpunit.xml export-ignore diff --git a/.gitignore b/.gitignore index d069e29..3358e2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ vendor composer.lock composer.phar +*.result.cache + diff --git a/LICENSE b/LICENSE index bd6c22b..3403ac3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015-2017 Yuuki Takezawa +Copyright (c) 2015-2020 Yuuki Takezawa Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 09b9a34..ebca534 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ This library is heavily inspired by the [jcabi/jcabi-aspects](https://github.com 5.6.x | 2.1.* 5.7.x | 3.0.* 6.0.x | 4.0 - + 7.x | 5.0 + ### install ```bash diff --git a/composer.json b/composer.json index dbd2e36..f39b384 100644 --- a/composer.json +++ b/composer.json @@ -17,27 +17,27 @@ } ], "require": { - "php": "^7.1", - "illuminate/console": "^6.0", - "illuminate/filesystem": "^6.0", - "illuminate/support": "^6.0", - "illuminate/config": "^6.0", - "illuminate/contracts": "^6.0", - "illuminate/log": "^6.0", - "illuminate/database": "^6.0", - "illuminate/cache": "^6.0", - "illuminate/events": "^6.0", - "illuminate/bus": "^6.0", - "illuminate/queue": "^6.0", + "php": "^7.2.5", + "illuminate/console": "^7.0", + "illuminate/filesystem": "^7.0", + "illuminate/support": "^7.0", + "illuminate/config": "^7.0", + "illuminate/contracts": "^7.0", + "illuminate/log": "^7.0", + "illuminate/database": "^7.0", + "illuminate/cache": "^7.0", + "illuminate/events": "^7.0", + "illuminate/bus": "^7.0", + "illuminate/queue": "^7.0", "ray/aop": "^2.9", "doctrine/annotations": "^1.4", "nikic/php-parser": "^4.0", "psr/log": "~1.0" }, "require-dev": { - "symfony/framework-bundle": "^4.1", - "symfony/console": "^4.1", - "phpunit/phpunit": "^7.0", + "symfony/framework-bundle": "^5.0", + "symfony/console": "^5.0", + "phpunit/phpunit": "^8.5", "mockery/mockery": "*", "satooshi/php-coveralls": "*", "sebastian/phpcpd": "*", @@ -45,8 +45,8 @@ "pdepend/pdepend" : "^2.2.4", "phpmd/phpmd": "@stable", "squizlabs/php_codesniffer": "~2.7", - "illuminate/encryption":"^6.0", - "vlucas/phpdotenv": "^3.3" + "illuminate/encryption":"^7.0", + "vlucas/phpdotenv": "^4.1.4" }, "autoload": { "psr-4": { diff --git a/src/AnnotateClass.php b/src/AnnotateClass.php index f9ccf22..6b9d465 100644 --- a/src/AnnotateClass.php +++ b/src/AnnotateClass.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Annotation/AnnotationReaderTrait.php b/src/Annotation/AnnotationReaderTrait.php index b1fe421..120d59c 100644 --- a/src/Annotation/AnnotationReaderTrait.php +++ b/src/Annotation/AnnotationReaderTrait.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ namespace Ytake\LaravelAspect\Annotation; diff --git a/src/Annotation/CacheEvict.php b/src/Annotation/CacheEvict.php index da9dc6d..7784e80 100644 --- a/src/Annotation/CacheEvict.php +++ b/src/Annotation/CacheEvict.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ namespace Ytake\LaravelAspect\Annotation; diff --git a/src/Annotation/CachePut.php b/src/Annotation/CachePut.php index 39c0382..66846ae 100644 --- a/src/Annotation/CachePut.php +++ b/src/Annotation/CachePut.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ namespace Ytake\LaravelAspect\Annotation; diff --git a/src/Annotation/Cacheable.php b/src/Annotation/Cacheable.php index 4079c52..b632ce1 100644 --- a/src/Annotation/Cacheable.php +++ b/src/Annotation/Cacheable.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ namespace Ytake\LaravelAspect\Annotation; diff --git a/src/Annotation/Delayed.php b/src/Annotation/Delayed.php index 58e4161..c85572d 100644 --- a/src/Annotation/Delayed.php +++ b/src/Annotation/Delayed.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ namespace Ytake\LaravelAspect\Annotation; diff --git a/src/Annotation/EagerQueue.php b/src/Annotation/EagerQueue.php index 1aa69e1..287c508 100644 --- a/src/Annotation/EagerQueue.php +++ b/src/Annotation/EagerQueue.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ namespace Ytake\LaravelAspect\Annotation; diff --git a/src/Annotation/LazyQueue.php b/src/Annotation/LazyQueue.php index d52416f..e74ad08 100644 --- a/src/Annotation/LazyQueue.php +++ b/src/Annotation/LazyQueue.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ namespace Ytake\LaravelAspect\Annotation; diff --git a/src/Annotation/LogExceptions.php b/src/Annotation/LogExceptions.php index 543aa96..1b08995 100644 --- a/src/Annotation/LogExceptions.php +++ b/src/Annotation/LogExceptions.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Annotation/Loggable.php b/src/Annotation/Loggable.php index b78b5e4..6498663 100644 --- a/src/Annotation/Loggable.php +++ b/src/Annotation/Loggable.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Annotation/LoggableAnnotate.php b/src/Annotation/LoggableAnnotate.php index bb1174d..e7fd4b3 100644 --- a/src/Annotation/LoggableAnnotate.php +++ b/src/Annotation/LoggableAnnotate.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Annotation/MessageDriven.php b/src/Annotation/MessageDriven.php index aba54d0..29d2dcc 100644 --- a/src/Annotation/MessageDriven.php +++ b/src/Annotation/MessageDriven.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Annotation/PostConstruct.php b/src/Annotation/PostConstruct.php index 8edf459..d6b112d 100644 --- a/src/Annotation/PostConstruct.php +++ b/src/Annotation/PostConstruct.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Annotation/QueryLog.php b/src/Annotation/QueryLog.php index eca945b..dc551de 100644 --- a/src/Annotation/QueryLog.php +++ b/src/Annotation/QueryLog.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ namespace Ytake\LaravelAspect\Annotation; diff --git a/src/Annotation/RetryOnFailure.php b/src/Annotation/RetryOnFailure.php index 5aabae6..e676a8f 100644 --- a/src/Annotation/RetryOnFailure.php +++ b/src/Annotation/RetryOnFailure.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Annotation/Transactional.php b/src/Annotation/Transactional.php index 264ff41..23997c4 100644 --- a/src/Annotation/Transactional.php +++ b/src/Annotation/Transactional.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/AnnotationConfiguration.php b/src/AnnotationConfiguration.php index 9cb7d7f..a7e1d8d 100644 --- a/src/AnnotationConfiguration.php +++ b/src/AnnotationConfiguration.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/AspectBind.php b/src/AspectBind.php index 26f0792..529a7e2 100644 --- a/src/AspectBind.php +++ b/src/AspectBind.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ @@ -51,8 +51,11 @@ class AspectBind * @param string $path * @param bool $cacheable */ - public function __construct(Filesystem $filesystem, string $path, bool $cacheable = false) - { + public function __construct( + Filesystem $filesystem, + string $path, + bool $cacheable = false + ) { $this->filesystem = $filesystem; $this->cacheable = $cacheable; $this->path = $path; @@ -60,9 +63,10 @@ public function __construct(Filesystem $filesystem, string $path, bool $cacheabl /** * @param string $class - * @param array $pointcuts - * + * @param array $pointcuts * @return mixed|\Ray\Aop\BindInterface + * @throws \Doctrine\Common\Annotations\AnnotationException + * @throws \ReflectionException */ public function bind(string $class, array $pointcuts) { diff --git a/src/AspectDriverInterface.php b/src/AspectDriverInterface.php index 69425ce..91081cf 100644 --- a/src/AspectDriverInterface.php +++ b/src/AspectDriverInterface.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ namespace Ytake\LaravelAspect; diff --git a/src/AspectManager.php b/src/AspectManager.php index 42fe091..c03ed29 100644 --- a/src/AspectManager.php +++ b/src/AspectManager.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ @@ -37,8 +37,8 @@ class AspectManager extends Manager protected function createRayDriver(): AspectDriverInterface { return new RayAspectKernel( - $this->app, - $this->app['files'], + $this->container, + $this->container['files'], $this->getConfigure('ray') ); } @@ -56,7 +56,7 @@ protected function createNoneDriver(): AspectDriverInterface */ public function getDefaultDriver() { - return $this->app['config']->get('ytake-laravel-aop.aspect.default'); + return $this->container['config']->get('ytake-laravel-aop.aspect.default'); } /** @@ -66,8 +66,8 @@ public function getDefaultDriver() */ protected function getConfigure(string $driver): array { - $aspectConfigure = $this->app['config']->get('ytake-laravel-aop.aspect.drivers'); - $aspectConfigure[$driver]['modules'] = $this->app['config']->get('ytake-laravel-aop.aspect.modules', []); + $aspectConfigure = $this->container['config']->get('ytake-laravel-aop.aspect.drivers'); + $aspectConfigure[$driver]['modules'] = $this->container['config']->get('ytake-laravel-aop.aspect.modules', []); return $aspectConfigure[$driver]; } diff --git a/src/AspectServiceProvider.php b/src/AspectServiceProvider.php index c290e34..3f84dc5 100644 --- a/src/AspectServiceProvider.php +++ b/src/AspectServiceProvider.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Console/ClearCacheCommand.php b/src/Console/ClearCacheCommand.php index 4031227..02b6f3a 100644 --- a/src/Console/ClearCacheCommand.php +++ b/src/Console/ClearCacheCommand.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ @@ -54,7 +54,7 @@ public function __construct(ConfigRepository $config, Filesystem $filesystem) /** * @return void */ - public function handle() + public function handle(): void { $configure = $this->config->get('ytake-laravel-aop.aspect'); $driverConfig = $configure['drivers'][$configure['default']]; diff --git a/src/Console/CompileCommand.php b/src/Console/CompileCommand.php index cfd7dc4..0c631f5 100644 --- a/src/Console/CompileCommand.php +++ b/src/Console/CompileCommand.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ @@ -50,7 +50,7 @@ public function __construct(AspectManager $aspectManager) /** * @return void */ - public function handle() + public function handle(): void { $this->aspectManager->weave(); $this->info('class files compiled!'); diff --git a/src/Console/ModulePublishCommand.php b/src/Console/ModulePublishCommand.php index 370e8f1..34400e7 100644 --- a/src/Console/ModulePublishCommand.php +++ b/src/Console/ModulePublishCommand.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ @@ -73,7 +73,7 @@ public function __construct(Filesystem $filesystem) * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException * @throws \ReflectionException */ - public function handle() + public function handle(): void { foreach ($this->modules as $className => $module) { $path = $this->getPath($this->parseClassName($className, $this->argument('module_dir'))); diff --git a/src/ConsoleServiceProvider.php b/src/ConsoleServiceProvider.php index b1b68b6..2d341bf 100644 --- a/src/ConsoleServiceProvider.php +++ b/src/ConsoleServiceProvider.php @@ -13,11 +13,12 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ namespace Ytake\LaravelAspect; +use Illuminate\Contracts\Support\DeferrableProvider; use Illuminate\Support\ServiceProvider; use Ytake\LaravelAspect\Console\CompileCommand; use Ytake\LaravelAspect\Console\ClearCacheCommand; @@ -26,11 +27,8 @@ /** * Class AspectServiceProvider */ -class ConsoleServiceProvider extends ServiceProvider +class ConsoleServiceProvider extends ServiceProvider implements DeferrableProvider { - /** @var bool */ - protected $defer = true; - public function boot(): void { $this->registerCommands(); diff --git a/src/ContainerInterceptor.php b/src/ContainerInterceptor.php index 31bb3eb..bc444e2 100644 --- a/src/ContainerInterceptor.php +++ b/src/ContainerInterceptor.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Exception/ClassNotFoundException.php b/src/Exception/ClassNotFoundException.php index f5e8ed4..9d1e13a 100644 --- a/src/Exception/ClassNotFoundException.php +++ b/src/Exception/ClassNotFoundException.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Exception/FileNotFoundException.php b/src/Exception/FileNotFoundException.php index 5de2548..5ec7a31 100644 --- a/src/Exception/FileNotFoundException.php +++ b/src/Exception/FileNotFoundException.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Interceptor/AbstractCache.php b/src/Interceptor/AbstractCache.php index 3a6063f..4e0e9f1 100644 --- a/src/Interceptor/AbstractCache.php +++ b/src/Interceptor/AbstractCache.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Interceptor/AbstractLogger.php b/src/Interceptor/AbstractLogger.php index 6247f04..914ceb4 100644 --- a/src/Interceptor/AbstractLogger.php +++ b/src/Interceptor/AbstractLogger.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ @@ -39,11 +39,13 @@ abstract class AbstractLogger /** * @param LoggableAnnotate $annotation * @param MethodInvocation $invocation - * * @return array + * @throws \ReflectionException */ - protected function logFormatter(LoggableAnnotate $annotation, MethodInvocation $invocation): array - { + protected function logFormatter( + LoggableAnnotate $annotation, + MethodInvocation $invocation + ): array { $context = []; $arguments = $invocation->getArguments(); foreach ($invocation->getMethod()->getParameters() as $parameter) { diff --git a/src/Interceptor/CacheEvictInterceptor.php b/src/Interceptor/CacheEvictInterceptor.php index f35a3ee..1c52f8c 100644 --- a/src/Interceptor/CacheEvictInterceptor.php +++ b/src/Interceptor/CacheEvictInterceptor.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Interceptor/CachePutInterceptor.php b/src/Interceptor/CachePutInterceptor.php index ebf0d00..a55aa67 100644 --- a/src/Interceptor/CachePutInterceptor.php +++ b/src/Interceptor/CachePutInterceptor.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Interceptor/CacheableInterceptor.php b/src/Interceptor/CacheableInterceptor.php index bb44ca3..f1e7219 100644 --- a/src/Interceptor/CacheableInterceptor.php +++ b/src/Interceptor/CacheableInterceptor.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ @@ -32,13 +32,14 @@ class CacheableInterceptor extends AbstractCache { /** * @param MethodInvocation $invocation - * * @return mixed + * @throws \Psr\SimpleCache\InvalidArgumentException */ public function invoke(MethodInvocation $invocation) { /** @var Cacheable $annotation */ - $annotation = $invocation->getMethod()->getAnnotation($this->annotation) ?? new $this->annotation([]); + $annotation = $invocation->getMethod()->getAnnotation($this->annotation) + ?? new $this->annotation([]); $keys = $this->generateCacheName($annotation->cacheName, $invocation); if (!is_array($annotation->key)) { $annotation->key = [$annotation->key]; diff --git a/src/Interceptor/LogExceptionsInterceptor.php b/src/Interceptor/LogExceptionsInterceptor.php index f3585b2..3f8c0d2 100644 --- a/src/Interceptor/LogExceptionsInterceptor.php +++ b/src/Interceptor/LogExceptionsInterceptor.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Interceptor/LoggableInterceptor.php b/src/Interceptor/LoggableInterceptor.php index d4ace01..b821bbf 100644 --- a/src/Interceptor/LoggableInterceptor.php +++ b/src/Interceptor/LoggableInterceptor.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Interceptor/MessageDrivenInterceptor.php b/src/Interceptor/MessageDrivenInterceptor.php index 3c41c55..23dd9c6 100644 --- a/src/Interceptor/MessageDrivenInterceptor.php +++ b/src/Interceptor/MessageDrivenInterceptor.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ namespace Ytake\LaravelAspect\Interceptor; diff --git a/src/Interceptor/QueryLogInterceptor.php b/src/Interceptor/QueryLogInterceptor.php index 3073b47..dd955e5 100644 --- a/src/Interceptor/QueryLogInterceptor.php +++ b/src/Interceptor/QueryLogInterceptor.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Interceptor/RetryOnFailureInterceptor.php b/src/Interceptor/RetryOnFailureInterceptor.php index 030a6ff..35d6806 100644 --- a/src/Interceptor/RetryOnFailureInterceptor.php +++ b/src/Interceptor/RetryOnFailureInterceptor.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Interceptor/TransactionalInterceptor.php b/src/Interceptor/TransactionalInterceptor.php index 44bd609..530fb2f 100644 --- a/src/Interceptor/TransactionalInterceptor.php +++ b/src/Interceptor/TransactionalInterceptor.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/LumenAspectServiceProvider.php b/src/LumenAspectServiceProvider.php index 1f754d7..1d3995a 100644 --- a/src/LumenAspectServiceProvider.php +++ b/src/LumenAspectServiceProvider.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Matcher/AnnotationScanMatcher.php b/src/Matcher/AnnotationScanMatcher.php index 80c5fda..f5f0a32 100644 --- a/src/Matcher/AnnotationScanMatcher.php +++ b/src/Matcher/AnnotationScanMatcher.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Modules/AspectModule.php b/src/Modules/AspectModule.php index 09e1f85..72a88da 100644 --- a/src/Modules/AspectModule.php +++ b/src/Modules/AspectModule.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Modules/CacheEvictModule.php b/src/Modules/CacheEvictModule.php index 53a7dc3..abf6e18 100644 --- a/src/Modules/CacheEvictModule.php +++ b/src/Modules/CacheEvictModule.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Modules/CachePutModule.php b/src/Modules/CachePutModule.php index 8dc5750..fad94ae 100644 --- a/src/Modules/CachePutModule.php +++ b/src/Modules/CachePutModule.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Modules/CacheableModule.php b/src/Modules/CacheableModule.php index 57bf496..0e724a6 100644 --- a/src/Modules/CacheableModule.php +++ b/src/Modules/CacheableModule.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Modules/LogExceptionsModule.php b/src/Modules/LogExceptionsModule.php index e0b27f5..29c2314 100644 --- a/src/Modules/LogExceptionsModule.php +++ b/src/Modules/LogExceptionsModule.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Modules/LoggableModule.php b/src/Modules/LoggableModule.php index 8305cf7..3408880 100644 --- a/src/Modules/LoggableModule.php +++ b/src/Modules/LoggableModule.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Modules/MessageDrivenModule.php b/src/Modules/MessageDrivenModule.php index ed6bbb9..1b795fd 100644 --- a/src/Modules/MessageDrivenModule.php +++ b/src/Modules/MessageDrivenModule.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Modules/PostConstructModule.php b/src/Modules/PostConstructModule.php index 4d86686..d994eb4 100644 --- a/src/Modules/PostConstructModule.php +++ b/src/Modules/PostConstructModule.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Modules/QueryLogModule.php b/src/Modules/QueryLogModule.php index 03bba0c..2be7646 100644 --- a/src/Modules/QueryLogModule.php +++ b/src/Modules/QueryLogModule.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Modules/RetryOnFailureModule.php b/src/Modules/RetryOnFailureModule.php index 9ec85cc..74f49a9 100644 --- a/src/Modules/RetryOnFailureModule.php +++ b/src/Modules/RetryOnFailureModule.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Modules/TransactionalModule.php b/src/Modules/TransactionalModule.php index 11c8f51..e8e466c 100644 --- a/src/Modules/TransactionalModule.php +++ b/src/Modules/TransactionalModule.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/NullAspectKernel.php b/src/NullAspectKernel.php index ad6086c..eeb377b 100644 --- a/src/NullAspectKernel.php +++ b/src/NullAspectKernel.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/PointCut/CacheEvictPointCut.php b/src/PointCut/CacheEvictPointCut.php index 03aca4c..b336271 100644 --- a/src/PointCut/CacheEvictPointCut.php +++ b/src/PointCut/CacheEvictPointCut.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/PointCut/CachePutPointCut.php b/src/PointCut/CachePutPointCut.php index 801901a..9328ee7 100644 --- a/src/PointCut/CachePutPointCut.php +++ b/src/PointCut/CachePutPointCut.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/PointCut/CacheablePointCut.php b/src/PointCut/CacheablePointCut.php index f7c60f8..bf7fd31 100644 --- a/src/PointCut/CacheablePointCut.php +++ b/src/PointCut/CacheablePointCut.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/PointCut/CommonPointCut.php b/src/PointCut/CommonPointCut.php index b577460..7183889 100644 --- a/src/PointCut/CommonPointCut.php +++ b/src/PointCut/CommonPointCut.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/PointCut/LogExceptionsPointCut.php b/src/PointCut/LogExceptionsPointCut.php index fac31d7..dcf1701 100644 --- a/src/PointCut/LogExceptionsPointCut.php +++ b/src/PointCut/LogExceptionsPointCut.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/PointCut/LoggablePointCut.php b/src/PointCut/LoggablePointCut.php index 35e6c4e..f2923c3 100644 --- a/src/PointCut/LoggablePointCut.php +++ b/src/PointCut/LoggablePointCut.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/PointCut/MessageDrivenPointCut.php b/src/PointCut/MessageDrivenPointCut.php index 0d7483e..cf98f59 100644 --- a/src/PointCut/MessageDrivenPointCut.php +++ b/src/PointCut/MessageDrivenPointCut.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/PointCut/PointCutable.php b/src/PointCut/PointCutable.php index c228872..a12daef 100644 --- a/src/PointCut/PointCutable.php +++ b/src/PointCut/PointCutable.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/PointCut/PostConstructPointCut.php b/src/PointCut/PostConstructPointCut.php index 2b03d61..a9acf99 100644 --- a/src/PointCut/PostConstructPointCut.php +++ b/src/PointCut/PostConstructPointCut.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/PointCut/QueryLogPointCut.php b/src/PointCut/QueryLogPointCut.php index 59afa86..e2986bc 100644 --- a/src/PointCut/QueryLogPointCut.php +++ b/src/PointCut/QueryLogPointCut.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/PointCut/RetryOnFailurePointCut.php b/src/PointCut/RetryOnFailurePointCut.php index 9aa50b8..32e254c 100644 --- a/src/PointCut/RetryOnFailurePointCut.php +++ b/src/PointCut/RetryOnFailurePointCut.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/PointCut/TransactionalPointCut.php b/src/PointCut/TransactionalPointCut.php index ae576b1..937794e 100644 --- a/src/PointCut/TransactionalPointCut.php +++ b/src/PointCut/TransactionalPointCut.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Queue/EagerMessage.php b/src/Queue/EagerMessage.php index 9acbc26..3ac0e61 100644 --- a/src/Queue/EagerMessage.php +++ b/src/Queue/EagerMessage.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Queue/LazyMessage.php b/src/Queue/LazyMessage.php index da9da4a..446bbe2 100644 --- a/src/Queue/LazyMessage.php +++ b/src/Queue/LazyMessage.php @@ -13,12 +13,13 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ namespace Ytake\LaravelAspect\Queue; +use ReflectionClass; use Ray\Aop\MethodInvocation; use Illuminate\Bus\Queueable; use Illuminate\Container\Container; @@ -26,6 +27,9 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; +use function get_class; +use function array_values; + /** * Class LazyMessage */ @@ -53,15 +57,21 @@ public function __construct(MethodInvocation $invocation) */ public function handle(Container $container) { - $class = new \ReflectionClass(get_class($this->methodInvocation->getThis())); + $class = new ReflectionClass(get_class($this->methodInvocation->getThis())); if ($class->getFileName()) { $method = $this->methodInvocation->getMethod()->getName(); + $parameters = $this->methodInvocation->getMethod()->getParameters(); + $array = array_values($this->methodInvocation->getArguments()->getArrayCopy()); + $arguments = []; + foreach ($parameters as $k => $parameter) { + $arguments[$parameter->getName()] = $array[$k]; + } $container->call( [ $this->methodInvocation->getThis(), $method, ], - $this->methodInvocation->getArguments()->getArrayCopy() + $arguments ); } } diff --git a/src/RayAspectKernel.php b/src/RayAspectKernel.php index dd4244c..c0a0d8d 100644 --- a/src/RayAspectKernel.php +++ b/src/RayAspectKernel.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ @@ -102,7 +102,9 @@ public function register(string $module = null): void /** * weaving * + * @throws \Doctrine\Common\Annotations\AnnotationException * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException + * @throws \ReflectionException */ public function weave(): void { @@ -133,6 +135,7 @@ protected function containerAdaptor(Container $container): ContainerInterceptor /** * @return Compiler + * @throws \Doctrine\Common\Annotations\AnnotationException */ protected function getCompiler(): Compiler { diff --git a/src/Transaction/Execute.php b/src/Transaction/Execute.php index 2a01962..dacd131 100644 --- a/src/Transaction/Execute.php +++ b/src/Transaction/Execute.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Transaction/Runnable.php b/src/Transaction/Runnable.php index f1729b2..bb1fc02 100644 --- a/src/Transaction/Runnable.php +++ b/src/Transaction/Runnable.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Transaction/Runner.php b/src/Transaction/Runner.php index 503b04a..9d6e42a 100644 --- a/src/Transaction/Runner.php +++ b/src/Transaction/Runner.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/Transaction/TransactionInvoker.php b/src/Transaction/TransactionInvoker.php index d43ce29..41ff295 100644 --- a/src/Transaction/TransactionInvoker.php +++ b/src/Transaction/TransactionInvoker.php @@ -13,7 +13,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ diff --git a/src/config/ytake-laravel-aop.php b/src/config/ytake-laravel-aop.php index 376218d..193c9a2 100644 --- a/src/config/ytake-laravel-aop.php +++ b/src/config/ytake-laravel-aop.php @@ -12,7 +12,7 @@ * This software consists of voluntary contributions made by many individuals * and is licensed under the MIT license. * - * Copyright (c) 2015-2018 Yuuki Takezawa + * Copyright (c) 2015-2020 Yuuki Takezawa * */ return [ diff --git a/tests/AnnotationScanMatcherTest.php b/tests/AnnotationScanMatcherTest.php index 1e79eac..20b85ef 100644 --- a/tests/AnnotationScanMatcherTest.php +++ b/tests/AnnotationScanMatcherTest.php @@ -11,7 +11,7 @@ class AnnotationScanMatcherTest extends \AspectTestCase /** @var AnnotationScanMatcher */ private $matcher; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->matcher = new AnnotationScanMatcher; diff --git a/tests/AspectBindTest.php b/tests/AspectBindTest.php index eec77b1..43d93bf 100644 --- a/tests/AspectBindTest.php +++ b/tests/AspectBindTest.php @@ -8,7 +8,7 @@ class AspectBindTest extends AspectTestCase /** @var \Illuminate\Filesystem\Filesystem */ protected $file; - public function setUp() + public function setUp(): void { parent::setUp(); $this->file = $this->app['files']; @@ -36,7 +36,7 @@ public function testShouldReturnCacheableBindInstance() $this->assertTrue($this->file->exists($this->getDir())); } - public function tearDown() + public function tearDown(): void { $this->file->deleteDirectory($this->getDir()); parent::tearDown(); diff --git a/tests/AspectLogExceptionsTest.php b/tests/AspectLogExceptionsTest.php index 0f54cda..037329d 100644 --- a/tests/AspectLogExceptionsTest.php +++ b/tests/AspectLogExceptionsTest.php @@ -14,7 +14,7 @@ class AspectLogExceptionsTest extends \AspectTestCase /** @var \Illuminate\Filesystem\Filesystem */ protected $file; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); @@ -27,11 +27,10 @@ protected function setUp() } /** - * @expectedException \Exception - * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ public function testDefaultLogger() { + $this->expectException(\Exception::class); // $this->log->useFiles($this->getDir() . '/.testing.exceptions.log'); /** @var \__Test\AspectLoggable $cache */ $cache = $this->app->make(\__Test\AspectLogExceptions::class); @@ -48,8 +47,8 @@ public function testShouldBeLogger() $cache->normalLog(1); } catch (\Exception $e) { $put = $this->app['files']->get($this->getDir() . '/.testing.exceptions.log'); - $this->assertContains('LogExceptions:__Test\AspectLogExceptions.normalLog', $put); - $this->assertContains('"code":0,"error_message":"', $put); + $this->assertStringContainsString('LogExceptions:__Test\AspectLogExceptions.normalLog', $put); + $this->assertStringContainsString('"code":0,"error_message":"', $put); } $this->app['files']->deleteDirectory($this->getDir()); } @@ -70,8 +69,8 @@ public function testExpectException() $cache->expectException(); } catch (\LogicException $e) { $put = $this->app['files']->get($this->getDir() . '/.testing.exceptions.log'); - $this->assertContains('LogExceptions:__Test\AspectLogExceptions.expectException', $put); - $this->assertContains('"code":0,"error_message":"', $put); + $this->assertStringContainsString('LogExceptions:__Test\AspectLogExceptions.expectException', $put); + $this->assertStringContainsString('"code":0,"error_message":"', $put); } $this->app['files']->deleteDirectory($this->getDir()); } diff --git a/tests/AspectLoggableTest.php b/tests/AspectLoggableTest.php index 6aa21ec..c7c160c 100644 --- a/tests/AspectLoggableTest.php +++ b/tests/AspectLoggableTest.php @@ -14,7 +14,7 @@ class AspectLoggableTest extends \AspectTestCase /** @var \Illuminate\Filesystem\Filesystem */ protected $file; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); @@ -32,8 +32,8 @@ public function testDefaultLogger() $cache = $this->app->make(\__Test\AspectLoggable::class); $cache->normalLog(1); $put = $this->app['files']->get($this->logDir() . '/.testing.log'); - $this->assertContains('Loggable:__Test\AspectLoggable.normalLog', $put); - $this->assertContains('{"args":{"id":1},"result":1', $put); + $this->assertStringContainsString('Loggable:__Test\AspectLoggable.normalLog', $put); + $this->assertStringContainsString('{"args":{"id":1},"result":1', $put); } public function testSkipResultLogger() @@ -42,11 +42,11 @@ public function testSkipResultLogger() $cache = $this->app->make(\__Test\AspectLoggable::class); $cache->skipResultLog(1); $put = $this->app['files']->get($this->logDir() . '/.testing.log'); - $this->assertContains('Loggable:__Test\AspectLoggable.skipResultLog', $put); - $this->assertNotContains('"result":1', $put); + $this->assertStringContainsString('Loggable:__Test\AspectLoggable.skipResultLog', $put); + $this->assertStringNotContainsString('"result":1', $put); } - public function tearDown() + public function tearDown(): void { $this->app['files']->deleteDirectory($this->logDir()); parent::tearDown(); diff --git a/tests/AspectManagerTest.php b/tests/AspectManagerTest.php index 8e2c414..99197a4 100644 --- a/tests/AspectManagerTest.php +++ b/tests/AspectManagerTest.php @@ -5,7 +5,7 @@ class AspectManagerTest extends \AspectTestCase /** @var \Ytake\LaravelAspect\AspectManager $manager */ protected $manager; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); @@ -13,7 +13,7 @@ protected function setUp() public function testCreateDriverInstance() { - $this->assertInternalType('string', $this->manager->getDefaultDriver()); + $this->assertIsString($this->manager->getDefaultDriver()); } public function testCreateGoDriverInstance() diff --git a/tests/AspectMergeTest.php b/tests/AspectMergeTest.php index 8b0ef7c..e931809 100644 --- a/tests/AspectMergeTest.php +++ b/tests/AspectMergeTest.php @@ -10,7 +10,7 @@ class AspectMergeTest extends \AspectTestCase protected static $instance; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); diff --git a/tests/AspectQueryLogTest.php b/tests/AspectQueryLogTest.php index 27b8c0d..210ce16 100644 --- a/tests/AspectQueryLogTest.php +++ b/tests/AspectQueryLogTest.php @@ -16,7 +16,7 @@ class AspectQueryLogTest extends \AspectTestCase /** @var \Illuminate\Filesystem\Filesystem */ protected $file; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); @@ -34,8 +34,8 @@ public function testDefaultLogger() $concrete = $this->app->make(AspectQueryLog::class); $concrete->start(); $put = $this->app['files']->get($this->logDir() . '/.testing.log'); - $this->assertContains('INFO: QueryLog:__Test\AspectQueryLog.start', $put); - $this->assertContains('SELECT date(\'now\')', $put); + $this->assertStringContainsString('INFO: QueryLog:__Test\AspectQueryLog.start', $put); + $this->assertStringContainsString('SELECT date(\'now\')', $put); } public function testTransactionalLogger() @@ -44,21 +44,19 @@ public function testTransactionalLogger() $concrete = $this->app->make(AspectQueryLog::class); $concrete->multipleDatabaseAppendRecord(); $put = $this->app['files']->get($this->logDir() . '/.testing.log'); - $this->assertContains('INFO: QueryLog:__Test\AspectQueryLog.multipleDatabaseAppendRecord', $put); - $this->assertContains('"queries":[{"query":"CREATE TABLE tests (test varchar(255) NOT NULL)"', $put); + $this->assertStringContainsString('INFO: QueryLog:__Test\AspectQueryLog.multipleDatabaseAppendRecord', $put); + $this->assertStringContainsString('"queries":[{"query":"CREATE TABLE tests (test varchar(255) NOT NULL)"', $put); } - /** - * @expectedException \Exception - */ public function testExceptionalDatabaseLogger() { + $this->expectException(\Exception::class); /** @var AspectQueryLog $concrete */ $concrete = $this->app->make(AspectQueryLog::class); $concrete->appendRecord(['test' => 'testing']); } - public function tearDown() + public function tearDown(): void { $this->app['files']->deleteDirectory($this->logDir()); parent::tearDown(); diff --git a/tests/AspectTestCase.php b/tests/AspectTestCase.php index 6782273..4317f6b 100644 --- a/tests/AspectTestCase.php +++ b/tests/AspectTestCase.php @@ -12,13 +12,12 @@ class AspectTestCase extends \PHPUnit\Framework\TestCase /** @var \Illuminate\Container\Container $app */ protected $app; - protected function setUp() + protected function setUp(): void { $this->createApplicationContainer(); } /** - * @return \Illuminate\Config\Repository * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ protected function registerConfigure() diff --git a/tests/CacheEvictTest.php b/tests/CacheEvictTest.php index c76d9a8..66ed2a3 100644 --- a/tests/CacheEvictTest.php +++ b/tests/CacheEvictTest.php @@ -5,7 +5,7 @@ class CacheEvictTest extends \AspectTestCase /** @var \Ytake\LaravelAspect\AspectManager $manager */ protected $manager; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); diff --git a/tests/CachePutTest.php b/tests/CachePutTest.php index 5233793..57a1d21 100644 --- a/tests/CachePutTest.php +++ b/tests/CachePutTest.php @@ -7,7 +7,7 @@ class CachePutTest extends \AspectTestCase protected static $instance; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); @@ -30,11 +30,9 @@ public function testCachePutReturnUpdatedValue() $this->assertSame(1000, $this->app['cache']->get('singleKey:1000')); } - /** - * @expectedException \InvalidArgumentException - */ public function testCacheableGenerateCacheNameSingleKey() { + $this->expectException(\InvalidArgumentException::class); $cache = $this->app->make(\__Test\AspectCachePut::class); $cache->throwExceptionCache(); } diff --git a/tests/CacheableTest.php b/tests/CacheableTest.php index e34d272..62bcef3 100644 --- a/tests/CacheableTest.php +++ b/tests/CacheableTest.php @@ -5,7 +5,7 @@ class CacheableTest extends \AspectTestCase /** @var \Ytake\LaravelAspect\AspectManager $manager */ protected $manager; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); diff --git a/tests/Commands/AspectClearCacheCommandTest.php b/tests/Commands/AspectClearCacheCommandTest.php index c1cab8b..8771160 100644 --- a/tests/Commands/AspectClearCacheCommandTest.php +++ b/tests/Commands/AspectClearCacheCommandTest.php @@ -11,7 +11,7 @@ class AspectClearCacheCommandTest extends \AspectTestCase /** @var \Ytake\LaravelAspect\Console\ClearCacheCommand */ protected $command; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); @@ -52,9 +52,4 @@ protected function resolveManager() $aspect = $this->manager->driver('ray'); $aspect->register(\__Test\CacheableModule::class); } - - protected function tearDown() - { - - } } diff --git a/tests/IgnoreAnnotationTest.php b/tests/IgnoreAnnotationTest.php index fe38b46..58576cc 100644 --- a/tests/IgnoreAnnotationTest.php +++ b/tests/IgnoreAnnotationTest.php @@ -8,7 +8,7 @@ class IgnoreAnnotationTest extends AspectTestCase /** @var \Ytake\LaravelAspect\AspectManager $manager */ protected $manager; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); diff --git a/tests/Interceptor/MessageDrivenInterceptorTest.php b/tests/Interceptor/MessageDrivenInterceptorTest.php index de34b02..9fddf7c 100644 --- a/tests/Interceptor/MessageDrivenInterceptorTest.php +++ b/tests/Interceptor/MessageDrivenInterceptorTest.php @@ -1,14 +1,12 @@ manager = new \Ytake\LaravelAspect\AspectManager($this->app); @@ -24,14 +22,16 @@ protected function setUp() $this->interceptor = new MessageDrivenInterceptor; } - public function testShouldDispatchMethod() + public function testShouldDispatchMethod(): void { $this->expectOutputString('this'); $this->interceptor->setBusDispatcher( $this->app->make(Dispatcher::class) ); $this->interceptor->setAnnotation(MessageDriven::class); - $this->interceptor->invoke(new StubMessageDrivenInvocation()); + $this->interceptor->invoke( + new StubMessageDrivenInvocation() + ); } /** @@ -52,9 +52,9 @@ class StubMessageDrivenInvocation implements \Ray\Aop\MethodInvocation public function getNamedArguments(): \ArrayObject { + return new \ArrayObject([]); } - public function getArguments(): \ArrayObject { return new \ArrayObject(['argument' => 'this']); @@ -67,19 +67,20 @@ public function proceed() public function getThis() { - return new \__Test\AspectMessageDriven; + return new \__Test\AspectMessageDriven(); } /** * @return \Ray\Aop\ReflectionMethod * @throws ReflectionException + * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function getMethod(): \Ray\Aop\ReflectionMethod { $reflectionClass = new \ReflectionClass(\__Test\AspectMessageDriven::class); $reflectionMethod = new \Ray\Aop\ReflectionMethod(\__Test\AspectMessageDriven::class, 'exec'); $reflectionMethod->setObject( - Container::getInstance()->make(\__Test\AspectMessageDriven::class), + Container::getInstance()->make(\__Test\AspectMessageDriven::class, []), $reflectionClass->getMethod('exec') ); diff --git a/tests/MessageDrivenFunctionalTest.php b/tests/MessageDrivenFunctionalTest.php index 6cd44e8..0d6f7aa 100644 --- a/tests/MessageDrivenFunctionalTest.php +++ b/tests/MessageDrivenFunctionalTest.php @@ -18,7 +18,7 @@ class MessageDrivenFunctionalTest extends AspectTestCase /** @var \Illuminate\Filesystem\Filesystem */ protected $file; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); @@ -37,8 +37,8 @@ public function testShouldBeLazyQueue() $concrete = $this->app->make(AspectMessageDriven::class); $concrete->exec('this'); $put = $this->app['files']->get($this->logDir() . '/.testing.log'); - $this->assertContains('Loggable:__Test\AspectMessageDriven.exec {"args":{"param":"this"}', $put); - $this->assertContains('Queued:__Test\AspectMessageDriven.logWith', $put); + $this->assertStringContainsString('Loggable:__Test\AspectMessageDriven.exec {"args":{"param":"this"}', $put); + $this->assertStringContainsString('Queued:__Test\AspectMessageDriven.logWith', $put); } public function testShouldBeEagerQueue() @@ -47,7 +47,7 @@ public function testShouldBeEagerQueue() $concrete = $this->app->make(AspectMessageDriven::class); $concrete->eagerExec('testing'); $put = $this->app['files']->get($this->logDir() . '/.testing.log'); - $this->assertContains('Queued:__Test\AspectMessageDriven.logWith', $put); + $this->assertStringContainsString('Queued:__Test\AspectMessageDriven.logWith', $put); } protected function resolveManager() @@ -59,7 +59,7 @@ protected function resolveManager() $aspect->weave(); } - public function tearDown() + public function tearDown(): void { $this->app['files']->deleteDirectory($this->logDir()); parent::tearDown(); diff --git a/tests/PostConstructTest.php b/tests/PostConstructTest.php index 6e3a230..fa6bc1d 100644 --- a/tests/PostConstructTest.php +++ b/tests/PostConstructTest.php @@ -8,7 +8,7 @@ class PostConstructTest extends \AspectTestCase /** @var \Ytake\LaravelAspect\AspectManager $manager */ protected $manager; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); diff --git a/tests/RayAspectKernelTest.php b/tests/RayAspectKernelTest.php index 13285a6..7d69d65 100644 --- a/tests/RayAspectKernelTest.php +++ b/tests/RayAspectKernelTest.php @@ -4,7 +4,7 @@ class RayAspectKernelTest extends \AspectTestCase { /** @var \Ytake\LaravelAspect\RayAspectKernel */ protected $kernel; - public function setUp() + public function setUp(): void { parent::setUp(); $aspectConfigure = $this->app['config']->get('ytake-laravel-aop.aspect.drivers'); @@ -15,42 +15,10 @@ public function setUp() ); } - /** - * @expectedException \Ytake\LaravelAspect\Exception\ClassNotFoundException - * @expectedExceptionMessage class not found at path: NotFoundClass - */ public function testExceptionCaseNotFoundClassRegister() { + $this->expectException(\Exception::class); $this->kernel->register('NotFoundClass'); } - - /** - * @expectedException \Exception - */ - public function testShouldThrowExceptionNotFoundClass() - { - $this->kernel->register(StubLoggableModule::class); - $this->kernel->register(StubTransactionalModule::class); - $this->kernel->weave(); - } -} - -/** - * Class StubLoggableModule - */ -class StubLoggableModule extends \Ytake\LaravelAspect\Modules\LoggableModule -{ - protected $classes = [ - 'testing', - ]; } -/** - * Class StubTransactionalModule - */ -class StubTransactionalModule extends \Ytake\LaravelAspect\Modules\TransactionalModule -{ - protected $classes = [ - 'testing' - ]; -} diff --git a/tests/ResolveInstanceTest.php b/tests/ResolveInstanceTest.php index e1efa27..fed8cfb 100644 --- a/tests/ResolveInstanceTest.php +++ b/tests/ResolveInstanceTest.php @@ -8,7 +8,7 @@ class ResolveInstanceTest extends AspectTestCase /** @var \Ytake\LaravelAspect\AspectManager $manager */ protected $manager; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); diff --git a/tests/RetryOnFailureTest.php b/tests/RetryOnFailureTest.php index d78dddd..61a9259 100644 --- a/tests/RetryOnFailureTest.php +++ b/tests/RetryOnFailureTest.php @@ -8,7 +8,7 @@ class RetryOnFailureTest extends AspectTestCase /** @var \Ytake\LaravelAspect\AspectManager $manager */ protected $manager; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); diff --git a/tests/TransactionalTest.php b/tests/TransactionalTest.php index 33304e3..fc5a299 100644 --- a/tests/TransactionalTest.php +++ b/tests/TransactionalTest.php @@ -8,7 +8,7 @@ class TransactionalTest extends \AspectTestCase protected static $instance; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->manager = new \Ytake\LaravelAspect\AspectManager($this->app); @@ -18,21 +18,19 @@ protected function setUp() public function testTransactionalAssertString() { $transactional = $this->app->make(\__Test\AspectTransactionalString::class); - $this->assertContains('testing', $transactional->start()); + $this->assertStringContainsString('testing', $transactional->start()); } public function testTransactionalDatabase() { $transactional = $this->app->make(\__Test\AspectTransactionalDatabase::class); - $this->assertInternalType('array', $transactional->start()); + $this->assertIsArray($transactional->start()); $this->assertInstanceOf('stdClass', $transactional->start()[0]); } - /** - * @expectedException \Illuminate\Database\QueryException - */ public function testTransactionalDatabaseThrowException() { + $this->expectException(\Illuminate\Database\QueryException::class); /** @var \__Test\AspectTransactionalDatabase $transactional */ $transactional = $this->app->make(\__Test\AspectTransactionalDatabase::class); try { @@ -42,11 +40,9 @@ public function testTransactionalDatabaseThrowException() } } - /** - * @expectedException \Illuminate\Database\QueryException - */ public function testTransactionalDatabaseThrowLogicException() { + $this->expectException(\Illuminate\Database\QueryException::class); /** @var \__Test\AspectTransactionalDatabase $transactional */ $transactional = $this->app->make(\__Test\AspectTransactionalDatabase::class); try { @@ -66,11 +62,9 @@ public function testShouldReturnAppendRecord() $this->assertObjectHasAttribute('test', $result); } - /** - * @expectedException \Illuminate\Database\QueryException - */ public function testTransactionalMultipleDatabaseThrowException() { + $this->expectException(\Illuminate\Database\QueryException::class); /** @var \__Test\AspectTransactionalDatabase $transactional */ $transactional = $this->app->make(\__Test\AspectTransactionalDatabase::class); try { diff --git a/tests/logs/clover.xml b/tests/logs/clover.xml index 5a628ef..5e62529 100644 --- a/tests/logs/clover.xml +++ b/tests/logs/clover.xml @@ -1,329 +1,329 @@ - - + + - + - + - - - + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - + + + + + - + + + + - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - + + + + + - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - + + - + - - - + + + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + @@ -331,632 +331,636 @@ - + - + - - - - + + + + - + - + - - - - + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + - + - - - + + + - + - + - - - + + + - + - + - - - + + + - + - + - - - + + + - + - + - - - + + + - + - - + + - + - + - - - + + + - + - + - - - + + + - + - + - - - + + + - + - + - - - + + + - + - + - - - - - - + + + + + + - + - + - - - - - - + + + + + + - + - + - - - - - - + + + + + + - + - - - - - - - - - - + + + + + + + + + + - + - + - - - - - - + + + + + + - + - + - - - - - - + + + + + + - + - - - - - + + + + + - + - + - - - - - - + + + + + + - + - + - - - - - - - + + + + + + + - + - + - - - - + + + + - + - + - - - - - - + + + + + + - + - + - + - - - - - - - + + + + + + + - + - + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - + - - - - - - + + + + + + - + - - - - - - - - + + + + + + + + - - + + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + - + diff --git a/tests/src/AspectMessageDriven.php b/tests/src/AspectMessageDriven.php index 2e0c71b..cf88d65 100644 --- a/tests/src/AspectMessageDriven.php +++ b/tests/src/AspectMessageDriven.php @@ -1,4 +1,5 @@ logWith($param); @@ -32,7 +34,7 @@ public function exec($param) * ) * @param string $message */ - public function eagerExec($message) + public function eagerExec(string $message) { $this->logWith($message); } @@ -43,7 +45,7 @@ public function eagerExec($message) * * @return string */ - public function logWith($message) + public function logWith(string $message) { return "Hello $message"; }