|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
5
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
6
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
7
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
8
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
9
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
10
|
|
|
* THE SOFTWARE. |
|
11
|
|
|
* |
|
12
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
13
|
|
|
* and is licensed under the MIT license. |
|
14
|
|
|
* |
|
15
|
|
|
* Copyright (c) 2015-2016 Yuuki Takezawa |
|
16
|
|
|
* |
|
17
|
|
|
*/ |
|
18
|
|
|
namespace Ytake\LaravelAspect\Console; |
|
19
|
|
|
|
|
20
|
|
|
use Illuminate\Console\Command; |
|
21
|
|
|
use Illuminate\Filesystem\Filesystem; |
|
22
|
|
|
use Illuminate\Contracts\Config\Repository as ConfigRepository; |
|
23
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Class ClearAnnotationCacheCommand |
|
27
|
|
|
* |
|
28
|
|
|
* @codeCoverageIgnore |
|
29
|
|
|
*/ |
|
30
|
|
|
class ClearAnnotationCacheCommand extends Command |
|
31
|
|
|
{ |
|
32
|
|
|
/** @var string */ |
|
33
|
|
|
protected $name = 'ytake:annotation-clear-cache'; |
|
34
|
|
|
|
|
35
|
|
|
/** @var string */ |
|
36
|
|
|
protected $description = 'Flush the application annotation cache'; |
|
37
|
|
|
|
|
38
|
|
|
/** @var array */ |
|
39
|
|
|
protected $config; |
|
40
|
|
|
|
|
41
|
|
|
/** @var Filesystem */ |
|
42
|
|
|
protected $filesystem; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param ConfigRepository $config |
|
46
|
|
|
* @param Filesystem $filesystem |
|
47
|
|
|
*/ |
|
48
|
|
|
public function __construct(ConfigRepository $config, Filesystem $filesystem) |
|
49
|
|
|
{ |
|
50
|
|
|
parent::__construct(); |
|
51
|
|
|
$this->config = $config->get('ytake-laravel-aop.annotation'); |
|
|
|
|
|
|
52
|
|
|
$this->filesystem = $filesystem; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return void |
|
57
|
|
|
*/ |
|
58
|
|
|
public function fire() |
|
59
|
|
|
{ |
|
60
|
|
|
/** @var string $driver */ |
|
61
|
|
|
$driver = $this->argument('driver'); |
|
62
|
|
|
if ($driver === 'file') { |
|
63
|
|
|
$driverConfig = $this->config['drivers']['file']; |
|
64
|
|
|
$directories = $this->filesystem->glob($driverConfig['cache_dir'] . '/*'); |
|
65
|
|
|
foreach ($directories as $directory) { |
|
66
|
|
|
$this->filesystem->deleteDirectory($directory); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
// @codeCoverageIgnoreStart |
|
70
|
|
|
if ($driver === 'apcu') { |
|
71
|
|
|
// clear cache |
|
72
|
|
|
apcu_clear_cache(); |
|
73
|
|
|
} |
|
74
|
|
|
// @codeCoverageIgnoreEnd |
|
75
|
|
|
$this->info('annotation cache clear!'); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @return array |
|
80
|
|
|
*/ |
|
81
|
|
|
protected function getArguments() |
|
82
|
|
|
{ |
|
83
|
|
|
return [ |
|
84
|
|
|
[ |
|
85
|
|
|
'driver', |
|
86
|
|
|
InputArgument::OPTIONAL, |
|
87
|
|
|
'The name of the driver you would like to clear.', |
|
88
|
|
|
$this->config['default'], |
|
89
|
|
|
], |
|
90
|
|
|
]; |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..