1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-14 10:17:33 +01:00
psalm/src/Psalm/Issue/CodeIssue.php

77 lines
1.5 KiB
PHP
Raw Normal View History

2016-06-10 00:08:25 +02:00
<?php
2016-07-26 00:37:44 +02:00
namespace Psalm\Issue;
2016-06-10 00:08:25 +02:00
use Psalm\CodeLocation;
2016-06-10 00:08:25 +02:00
abstract class CodeIssue
{
const CODE_EXCEPTION = 1;
2016-11-02 07:29:00 +01:00
/**
* @var CodeLocation
2016-11-02 07:29:00 +01:00
*/
protected $code_location;
2016-11-01 05:39:41 +01:00
2016-11-02 07:29:00 +01:00
/**
* @var string
*/
2016-06-10 00:08:25 +02:00
protected $message;
2016-11-01 05:39:41 +01:00
/**
* @param string $message
* @param CodeLocation $code_location
2016-11-01 05:39:41 +01:00
*/
public function __construct($message, CodeLocation $code_location)
2016-06-10 00:08:25 +02:00
{
$this->code_location = $code_location;
2016-06-10 00:08:25 +02:00
$this->message = $message;
}
/**
2016-12-08 04:38:57 +01:00
* @return CodeLocation
*/
2016-12-08 04:38:57 +01:00
public function getLocation()
{
2016-12-08 04:38:57 +01:00
return $this->code_location;
}
/**
* @return string
*/
2016-12-08 04:38:57 +01:00
public function getShortLocation()
{
$previous_text = '';
if ($this->code_location->previous_location) {
$previous_location = $this->code_location->previous_location;
$previous_text = ' from ' . $previous_location->file_name . ':' . $previous_location->getLineNumber();
}
return $this->code_location->file_name . ':' . $this->code_location->getLineNumber() . $previous_text;
2016-06-10 00:08:25 +02:00
}
2016-11-02 07:29:00 +01:00
/**
* @return string
*/
2016-12-08 04:38:57 +01:00
public function getFilePath()
2016-06-10 00:08:25 +02:00
{
2016-12-08 04:38:57 +01:00
return $this->code_location->file_path;
2016-06-10 00:08:25 +02:00
}
2016-11-02 07:29:00 +01:00
/**
* @return string
*/
2016-12-08 04:38:57 +01:00
public function getFileName()
2016-06-10 00:08:25 +02:00
{
2016-12-08 04:38:57 +01:00
return $this->code_location->file_name;
}
/**
* @return string
*/
2016-12-08 04:38:57 +01:00
public function getMessage()
{
2016-12-08 04:38:57 +01:00
return $this->message;
2016-06-10 00:08:25 +02:00
}
}