Class: PHP::Operator

Inherits:
PHP::Expression show all
Defined in:
lib/php/syntax/operator.rb

Overview

See Also:

Class Method Summary

Instance Method Summary

Methods inherited from PHP::Node

#<<, #<=>, #children?, #each, #indent, #indent=, #initialize, #to_php, #to_s

Constructor Details

This class inherits a constructor from PHP::Node

Class Method Details

+ (Object) for(operator)



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/php/syntax/operator.rb', line 5

def self.for(operator)
  case operator
    when :-@    then Arithmetic::Negation
    when :+     then Arithmetic::Addition
    when :-     then Arithmetic::Subtraction
    when :*     then Arithmetic::Multiplication
    when :'/'   then Arithmetic::Division
    when :'%'   then Arithmetic::Modulus
    when :~     then Bitwise::Not
    when :&     then Bitwise::And
    when :|     then Bitwise::Or
    when :^     then Bitwise::Xor
    when :>>    then Bitwise::ShiftRight
    when :==    then Comparison::Equal
    when :===   then Comparison::Identical
    when :'!='  then Comparison::NotEqual
    when :'!==' then Comparison::NotIdentical
    when :<     then Comparison::LessThan
    when :>     then Comparison::MoreThan
    when :<=    then Comparison::LessOrEqual
    when :>=    then Comparison::MoreOrEqual
    when :'!'   then Logical::Not
    when :'&&'  then Logical::And
    when :'||'  then Logical::Or
    when :<<    then String::Concatenation
    when :=~    then Regex::Match
  end
end

Instance Method Details

- (Array<Expression>) operands

This method is abstract.

Returns the operands for this operation.

Returns:

Raises:

  • (NotImplementedError)


50
51
52
# File 'lib/php/syntax/operator.rb', line 50

def operands
  raise NotImplementedError
end

- (Object) operator Also known as: to_sym

This method is abstract.

Returns the operator for this operation.

Returns:

  • Symbol

Raises:

  • (NotImplementedError)


39
40
41
# File 'lib/php/syntax/operator.rb', line 39

def operator
  raise NotImplementedError
end

- (Array<Object>) to_a Also known as: to_sxp

Returns an array representation of this operation.

Returns:

  • (Array<Object>)


58
59
60
# File 'lib/php/syntax/operator.rb', line 58

def to_a
  [operator, *operands]
end