Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 150
Zeile 27... Zeile 27...
27
    {
27
    {
28
        $this->lexer = $lexer;
28
        $this->lexer = $lexer;
29
        $this->commentStrategy = $commentStrategy;
29
        $this->commentStrategy = $commentStrategy;
30
    }
30
    }
Zeile 31... Zeile 31...
31
 
31
 
32
    public function parse() : Result
32
    public function parse(): Result
33
    {
33
    {
34
        if ($this->lexer->token['type'] === EmailLexer::S_OPENPARENTHESIS) {
34
        if ($this->lexer->current->isA(EmailLexer::S_OPENPARENTHESIS)) {
35
            $this->openedParenthesis++;
35
            $this->openedParenthesis++;
36
            if($this->noClosingParenthesis()) {
36
            if ($this->noClosingParenthesis()) {
37
                return new InvalidEmail(new UnclosedComment(), $this->lexer->token['value']);
37
                return new InvalidEmail(new UnclosedComment(), $this->lexer->current->value);
38
            }
38
            }
Zeile 39... Zeile 39...
39
        }
39
        }
40
 
40
 
41
        if ($this->lexer->token['type'] === EmailLexer::S_CLOSEPARENTHESIS) {
41
        if ($this->lexer->current->isA(EmailLexer::S_CLOSEPARENTHESIS)) {
Zeile 42... Zeile 42...
42
            return new InvalidEmail(new UnOpenedComment(), $this->lexer->token['value']);
42
            return new InvalidEmail(new UnOpenedComment(), $this->lexer->current->value);
Zeile 43... Zeile 43...
43
        }
43
        }
44
 
44
 
Zeile 45... Zeile 45...
45
        $this->warnings[WarningComment::CODE] = new WarningComment();
45
        $this->warnings[WarningComment::CODE] = new WarningComment();
46
 
46
 
47
        $moreTokens = true;
47
        $moreTokens = true;
48
        while ($this->commentStrategy->exitCondition($this->lexer, $this->openedParenthesis) && $moreTokens){
48
        while ($this->commentStrategy->exitCondition($this->lexer, $this->openedParenthesis) && $moreTokens) {
49
 
49
 
50
            if ($this->lexer->isNextToken(EmailLexer::S_OPENPARENTHESIS)) {
50
            if ($this->lexer->isNextToken(EmailLexer::S_OPENPARENTHESIS)) {
51
                $this->openedParenthesis++;
51
                $this->openedParenthesis++;
52
            }
52
            }
53
            $this->warnEscaping();
53
            $this->warnEscaping();
Zeile 54... Zeile 54...
54
            if($this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) {
54
            if ($this->lexer->isNextToken(EmailLexer::S_CLOSEPARENTHESIS)) {
55
                $this->openedParenthesis--;
55
                $this->openedParenthesis--;
56
            }
56
            }
57
            $moreTokens = $this->lexer->moveNext();
57
            $moreTokens = $this->lexer->moveNext();
58
        }
58
        }
59
 
59
 
Zeile 60... Zeile 60...
60
        if($this->openedParenthesis >= 1) {
60
        if ($this->openedParenthesis >= 1) {
Zeile 61... Zeile 61...
61
            return new InvalidEmail(new UnclosedComment(), $this->lexer->token['value']);
61
            return new InvalidEmail(new UnclosedComment(), $this->lexer->current->value);
Zeile 73... Zeile 73...
73
 
73
 
74
 
74
 
75
    /**
75
    /**
76
     * @return bool
76
     * @return bool
77
     */
77
     */
78
    private function warnEscaping() : bool
78
    private function warnEscaping(): bool
79
    {
79
    {
80
        //Backslash found
80
        //Backslash found
81
        if ($this->lexer->token['type'] !== EmailLexer::S_BACKSLASH) {
81
        if (!$this->lexer->current->isA(EmailLexer::S_BACKSLASH)) {
Zeile 82... Zeile 82...
82
            return false;
82
            return false;
83
        }
83
        }
84
 
84
 
Zeile 85... Zeile 85...
85
        if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
85
        if (!$this->lexer->isNextTokenAny(array(EmailLexer::S_SP, EmailLexer::S_HTAB, EmailLexer::C_DEL))) {
86
            return false;
86
            return false;
87
        }
87
        }
88
 
-
 
89
        $this->warnings[QuotedPart::CODE] =
88
 
Zeile 90... Zeile 89...
90
            new QuotedPart($this->lexer->getPrevious()['type'], $this->lexer->token['type']);
89
        $this->warnings[QuotedPart::CODE] =
91
        return true;
90
            new QuotedPart($this->lexer->getPrevious()->type, $this->lexer->current->type);
92
 
91
        return true;
93
    }
92
    }
94
 
93
 
95
    private function noClosingParenthesis() : bool 
94
    private function noClosingParenthesis(): bool