完善注释,修正获取头尾元素的逻辑

This commit is contained in:
Jerry Yan 2021-02-19 11:17:56 +08:00
parent f3b66aeac3
commit 273f6ba2e8
3 changed files with 17 additions and 30 deletions

View File

@ -15,8 +15,8 @@ class FileReader extends StringReader
{ {
/** /**
* FileReader constructor. * FileReader constructor.
* @param string $fileName * @param string $fileName 文件名
* @throws FileNotFoundException * @throws FileNotFoundException 文件不存在时报错
* @author Jerry Yan <792602257@qq.com> * @author Jerry Yan <792602257@qq.com>
* @date 2021/1/26 13:52 * @date 2021/1/26 13:52
*/ */

View File

@ -38,19 +38,23 @@ abstract class TokenInterface
/** /**
* 获取链表第一个元素 * 获取链表第一个元素
* @return ?$this * @return $this
* @author Jerry Yan <792602257@qq.com> * @author Jerry Yan <792602257@qq.com>
* @date 2021/1/22 10:01 * @date 2021/1/22 10:01
*/ */
public function getFirstToken(): ?TokenInterface public function getFirstToken(): TokenInterface
{ {
if ($this->hasPrevToken()) return $this->getPrevToken()->getFirstToken(); return $this->hasPrevToken() ? $this->getPrevToken()->getFirstToken() : $this;
else return $this;
} }
public function getLastToken(): ?TokenInterface /**
* 获取链表最后一个元素
* @return $this
* @author Jerry Yan <792602257@qq.com>
* @date 2021/2/19 11:05
*/
public function getLastToken(): TokenInterface
{ {
if ($this->hasNextToken()) return $this->getNextToken()->getLastToken(); return $this->hasNextToken() ? $this->getNextToken()->getLastToken() : $this;
else return $this;
} }
public function hasPrevToken(): bool public function hasPrevToken(): bool
{ {
@ -84,4 +88,8 @@ abstract class TokenInterface
{ {
return $this->getLength(); return $this->getLength();
} }
public function getRawString(): string
{
return $this->_raw;
}
} }

View File

@ -1,21 +0,0 @@
<?php
/**
* @filename TokenType.php
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 15:04
*/
namespace JerryYan\DSL\Token;
/**
* Token分类Enum
* @package JerryYan\DSL\Token
* @author Jerry Yan <792602257@qq.com>
* @date 2020/12/17 15:04
*/
final class TokenType
{
}