| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * PHP Smart Analysis project 2015-2016 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @author Patsura Dmitry https://github.com/ovr <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | namespace PHPSA\Compiler\Expression\AssignOp; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use PHPSA\CompiledExpression; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use PHPSA\Compiler\Expression; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use PHPSA\Compiler\Expression\AbstractExpressionCompiler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use PHPSA\Context; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | class Mod extends AbstractExpressionCompiler | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     protected $name = 'PhpParser\Node\Expr\AssignOp\Mod'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |      * It's used in conditions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * {left-expr} %= {right-expr} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |      * @param \PhpParser\Node\Expr\AssignOp\Mod $expr | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      * @param Context $context | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * @return CompiledExpression | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 26 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 27 | 11 |  |     protected function compile($expr, Context $context) | 
            
                                                        
            
                                    
            
            
                | 28 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 29 | 11 |  |         $left = $context->getExpressionCompiler()->compile($expr->var); | 
            
                                                        
            
                                    
            
            
                | 30 | 11 |  |         $expExpression = $context->getExpressionCompiler()->compile($expr->expr); | 
            
                                                        
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 32 | 11 |  |         switch ($left->getType()) { | 
            
                                                        
            
                                    
            
            
                | 33 | 11 |  |             case CompiledExpression::INTEGER: | 
            
                                                        
            
                                    
            
            
                | 34 | 11 |  |             case CompiledExpression::DOUBLE: | 
            
                                                        
            
                                    
            
            
                | 35 | 11 |  |             case CompiledExpression::NUMBER: | 
            
                                                        
            
                                    
            
            
                | 36 | 11 |  |             case CompiledExpression::BOOLEAN: | 
            
                                                        
            
                                    
            
            
                | 37 | 10 |  |                 switch ($expExpression->getType()) { | 
            
                                                        
            
                                    
            
            
                | 38 | 10 |  |                     case CompiledExpression::INTEGER: | 
            
                                                        
            
                                    
            
            
                | 39 | 10 |  |                     case CompiledExpression::DOUBLE: | 
            
                                                        
            
                                    
            
            
                | 40 | 10 |  |                     case CompiledExpression::NUMBER: | 
            
                                                        
            
                                    
            
            
                | 41 | 10 |  |                     case CompiledExpression::BOOLEAN: | 
            
                                                        
            
                                    
            
            
                | 42 | 9 |  |                         return CompiledExpression::fromZvalValue( | 
            
                                                        
            
                                    
            
            
                | 43 | 9 |  |                             $left->getValue() % $expExpression->getValue() | 
            
                                                        
            
                                    
            
            
                | 44 | 9 |  |                         ); | 
            
                                                        
            
                                    
            
            
                | 45 |  |  |                         break; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 46 | 1 |  |                 } | 
            
                                                        
            
                                    
            
            
                | 47 | 1 |  |                 break; | 
            
                                                        
            
                                    
            
            
                | 48 | 2 |  |         } | 
            
                                                        
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 50 | 2 |  |         return new CompiledExpression(CompiledExpression::UNKNOWN); | 
            
                                                        
            
                                    
            
            
                | 51 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 52 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 53 |  |  |  | 
            
                        
The break statement is not necessary if it is preceded for example by a return statement:
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.