| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file is part of the GesdinetJWTRefreshTokenBundle package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * (c) Gesdinet <http://www.gesdinet.com/> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | namespace Gesdinet\JWTRefreshTokenBundle\Command; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Symfony\Component\Console\Command\Command; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Symfony\Component\Console\Input\InputArgument; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Symfony\Component\Console\Input\InputInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Symfony\Component\Console\Output\OutputInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * Class ClearInvalidRefreshTokensCommand. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | class ClearInvalidRefreshTokensCommand extends Command | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     protected static $defaultName = 'gesdinet:jwt:clear'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 | 4 |  |     private $refreshTokenManager; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 29 | 4 |  |     public function __construct(RefreshTokenManagerInterface $refreshTokenManager) | 
            
                                                                        
                            
            
                                    
            
            
                | 30 | 4 |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 31 | 4 |  |         parent::__construct(); | 
            
                                                                        
                            
            
                                    
            
            
                | 32 | 4 |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 33 | 4 |  |         $this->refreshTokenManager = $refreshTokenManager; | 
            
                                                                        
                            
            
                                    
            
            
                | 34 | 4 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 | 4 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * @see Command | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     protected function configure() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 | 1 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $this | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 1 |  |             ->setDescription('Clear invalid refresh tokens.') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             ->addArgument('datetime', InputArgument::OPTIONAL); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 | 1 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * @see Command | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     protected function execute(InputInterface $input, OutputInterface $output) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 1 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 | 1 |  |         $datetime = $input->getArgument('datetime'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 1 |  |         if (null === $datetime) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 | 1 |  |             $datetime = new \DateTime(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 1 |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 | 1 |  |             $datetime = new \DateTime($datetime); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $revokedTokens = $this->refreshTokenManager->revokeAllInvalid($datetime); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         foreach ($revokedTokens as $revokedToken) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             $output->writeln(sprintf('Revoke <comment>%s</comment>', $revokedToken->getRefreshToken())); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 65 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 66 |  |  |  | 
            
                        
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.