Location.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of phpDocumentor.
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. *
  9. * @link http://phpdoc.org
  10. */
  11. namespace phpDocumentor\Reflection;
  12. /**
  13. * The location where an element occurs within a file.
  14. *
  15. * @psalm-immutable
  16. */
  17. final class Location
  18. {
  19. /** @var int */
  20. private $lineNumber = 0;
  21. /** @var int */
  22. private $columnNumber = 0;
  23. /**
  24. * Initializes the location for an element using its line number in the file and optionally the column number.
  25. */
  26. public function __construct(int $lineNumber, int $columnNumber = 0)
  27. {
  28. $this->lineNumber = $lineNumber;
  29. $this->columnNumber = $columnNumber;
  30. }
  31. /**
  32. * Returns the line number that is covered by this location.
  33. */
  34. public function getLineNumber() : int
  35. {
  36. return $this->lineNumber;
  37. }
  38. /**
  39. * Returns the column number (character position on a line) for this location object.
  40. */
  41. public function getColumnNumber() : int
  42. {
  43. return $this->columnNumber;
  44. }
  45. }