| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace PHPSA\Compiler\Expression\AssignOp; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use PHPSA\CompiledExpression; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use PHPSA\Compiler\Expression; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use PHPSA\Compiler\Expression\AbstractExpressionCompiler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use PHPSA\Context; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 10 |  |  | class Div extends AbstractExpressionCompiler | 
            
                                                                        
                            
            
                                    
            
            
                | 11 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 12 |  |  |     protected $name = 'PhpParser\Node\Expr\AssignOp\Div'; | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |      * {left-expr} /= {right-expr} | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |      * @param \PhpParser\Node\Expr\AssignOp\Div $expr | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |      * @param Context $context | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |      * @return CompiledExpression | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 | 20 |  |     protected function compile($expr, Context $context) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 | 20 |  |         $left = $context->getExpressionCompiler()->compile($expr->var); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 | 20 |  |         $expExpression = $context->getExpressionCompiler()->compile($expr->expr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 | 20 |  |         if ($expExpression->isEquals(0)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 | 1 |  |             $context->notice( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 | 1 |  |                 'language-error', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 | 1 |  |                 'You are trying to divide by 0.', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |                 $expr | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 | 1 |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 | 1 |  |             return new CompiledExpression(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 19 |  |         switch ($left->getType()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 | 19 |  |             case CompiledExpression::INTEGER: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 19 |  |             case CompiledExpression::DOUBLE: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 | 19 |  |             case CompiledExpression::NUMBER: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 | 19 |  |             case CompiledExpression::BOOLEAN: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 | 18 |  |                 switch ($expExpression->getType()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 | 18 |  |                     case CompiledExpression::INTEGER: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 | 18 |  |                     case CompiledExpression::DOUBLE: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 | 18 |  |                     case CompiledExpression::NUMBER: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 18 |  |                     case CompiledExpression::BOOLEAN: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 | 18 |  |                         return CompiledExpression::fromZvalValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 18 |  |                             $left->getValue() / $expExpression->getValue() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 18 |  |                         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 | 1 |  |         return new CompiledExpression(); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 53 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 54 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 55 |  |  |  |