Trait Position
A trait that adds a mutable position (line and column numbers). Implements
the interface Parco\Positional
.
Methods summary
public
int[]
|
|
public
|
#
setPosition( array $pos )
Set the stored position.
Parameters
|
public
integer
|
#
line( )
Get the stored line number.
Get the stored line number.
Deprecated
Returns
integer Line number (starting from 1).
|
public
integer
|
#
column( )
Get the stored column number.
Get the stored column number.
Deprecated
Returns
integer Column number (starting from 1).
|
public
integer
|
#
getInputLine( string[] $lines )
Get the line number for an array of lines.
Returns 0 if the position is unknown, or the sequence of lines is
empty.
Returns the last line number if position is at the end of the input.
Get the line number for an array of lines.
Returns 0 if the position is unknown, or the sequence of lines is
empty.
Returns the last line number if position is at the end of the input.
Parameters
- $lines
- List of lines (e.g. result of
explode("\n", $input) ).
Returns
integer The positive line number or 0 if unknown.
Since
1.1.0
|
public
integer
|
#
getInputColumn( string[] $lines )
Get the column number for an array of lines.
Returns 0 if the position is unknown, or the sequence of lines is
empty.
If the position is at the end of the input,
Get the column number for an array of lines.
Returns 0 if the position is unknown, or the sequence of lines is
empty.
If the position is at the end of the input,
Parameters
- $lines
- List of lines (e.g. result of
explode("\n", $input) ).
Returns
integer The positive column number or 0 if unknown.
Since
1.1.0
|
public static
integer
|
#
comparePositions( array $a, array $b )
Compare two positions.
Parameters
- $a
- First position.
- $b
- Second position.
Returns
integer 0 if the two positions are equal, a negative integer if
$b is greater than $a , and a positive integer if $a is
greater than $b .
|