Class: PHP::Statement::Return

Inherits:
PHP::Statement show all
Defined in:
lib/php/syntax/statement.rb

Instance Attribute Summary

Instance Method Summary

Methods inherited from PHP::Node

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

Constructor Details

- (Return) initialize(value)

A new instance of Return

Parameters:



21
22
23
# File 'lib/php/syntax/statement.rb', line 21

def initialize(value)
  @value = value
end

Instance Attribute Details

- (Expression) value

Returns:



17
18
19
# File 'lib/php/syntax/statement.rb', line 17

def value
  @value
end

Instance Method Details

- (String) to_php

Returns the PHP representation of this return statement.

Returns:

  • (String)


37
38
39
40
41
42
43
# File 'lib/php/syntax/statement.rb', line 37

def to_php
  if value?
    "return #{value}"
  else
    "return"
  end
end

- (Boolean) value?

Returns true if this statement has a value.

Returns:

  • (Boolean)


29
30
31
# File 'lib/php/syntax/statement.rb', line 29

def value?
  !value.nil?
end