<?php
/**
* PHPソース情報クラス
*
* PHP version 5
*
* @package    debug
* @author     stk2k <stk2k@sazysoft.com>
* @copyright  2008 stk2k, sazysoft
*/

class PhpSourceInfo extends Object
{
	private $_file;
	private $_line;

	/*
	 *	コンストラクタ
	 */
	public function __construct( $file, $line )
	{
		parent::__construct();

		$this->_file = $file;
		$this->_line = $line;
	}


	/*
	 *	ソースファイル名を取得
	 */
	public function getFile()
	{
		return $this->_file;
	}

	/*
	 *	行番号を取得
	 */
	public function getLine()
	{
		return $this->_line;
	}

	/*
	 *	文字列化
	 */
	public function toString()
	{
		$keyword_file = ResourceLocator::getSystemPath( s('data'), s('php.kwd') );

		$file = $this->_file;
		$line = $this->_line;

		$p = new PhpSourceParser();
		$p->init( $keyword_file );
		$tokens = $p->parse( $this->_file );
		$html = PhpSourceRenderer::render( $tokens, '%4d:', NULL, $line - 5, $line + 5 );

		return $html;
	}
}
return __FILE__;
