Class: PhpCop::Cop::Files::PhpTags
- Defined in:
- lib/phpcop/cop/files/phptags.rb
Overview
This class test file php use correctly tags PHP ‘<?php ?>’ or ‘<?= ?>’
Constant Summary collapse
- MSG_ALERT_DESCRIB =
'Dont use correctly PHP Tags.'- TAG_OPEN =
['\<\?php', '\<\?='].freeze
- TAG_CLOSE =
['\?\>'].freeze
Constants inherited from Cop
Instance Attribute Summary collapse
-
#count_close ⇒ Object
readonly
Returns the value of attribute count_close.
-
#count_open ⇒ Object
readonly
Returns the value of attribute count_open.
Attributes inherited from Cop
Instance Method Summary collapse
-
#initialize(file, path, line = nil, line_number = nil) ⇒ PhpTags
constructor
A new instance of PhpTags.
- #test_counters ⇒ Object
-
#test_line(line, line_number) ⇒ Object
Parse line and test if line use correctly tags PHP.
Constructor Details
#initialize(file, path, line = nil, line_number = nil) ⇒ PhpTags
Returns a new instance of PhpTags.
15 16 17 |
# File 'lib/phpcop/cop/files/phptags.rb', line 15 def initialize(file, path, line = nil, line_number = nil) super(file, path, line, line_number) end |
Instance Attribute Details
#count_close ⇒ Object (readonly)
Returns the value of attribute count_close.
9 10 11 |
# File 'lib/phpcop/cop/files/phptags.rb', line 9 def count_close @count_close end |
#count_open ⇒ Object (readonly)
Returns the value of attribute count_open.
9 10 11 |
# File 'lib/phpcop/cop/files/phptags.rb', line 9 def count_open @count_open end |
Instance Method Details
#test_counters ⇒ Object
19 20 21 22 |
# File 'lib/phpcop/cop/files/phptags.rb', line 19 def test_counters # Test if tags open is equal to tags close return_an_error(MSG_ALERT_DESCRIB) unless @count_open == @count_close end |
#test_line(line, line_number) ⇒ Object
Parse line and test if line use correctly tags PHP
25 26 27 28 29 30 31 32 |
# File 'lib/phpcop/cop/files/phptags.rb', line 25 def test_line(line, line_number) @line = line @line_number = line_number # Parse file and search tags exists parse_and_search_open_tag # If file contains tag <?php or <?= search close tags parse_and_search_close_tag end |