dxw / Fammel

A Haml parsing library for PHP
48 stars 5 forks source link

Some Notice issues #4

Closed ravishi closed 14 years ago

ravishi commented 14 years ago

Some issues I found out. They are not a big trouble, since just need to put a @ in some lines. But you better correct them from now.

The following are from tokerniser.class.php.

public function get_attr_name()
{
    $token = '';

    do
    {
        $token = $token . $c;
    }
    while(strlen($c = $this->get_char()) && preg_match('/^[a-zA-Z:-]+$/', $c));  

    $this->rewind();
    return $token;
}

Here we don't have the $c var when the do loop starts. So we get a Notice.

public function get_attr_value($c)
{
    $token = '';

    if($eat != '"')
    {

    }

    do
    {
        $token = "$token$c";
    }
    while(strlen($c = $this->get_char()) && $c != '"');

    // No rewind -- we don't want the closing quote.
    return $token;
}

And here, of course, where is the $eat var? Another Notice.

$c = $this->_input[$this->_pos];        // at get_char() method

if($this->_input[$this->_pos] == "\n")  // at rewind() method

Here may occur that $this->_pos is an inexistent index and another Notice is generated.

Some other problems occur at the haml_parser_new.class.php file. There they are:

if($this->next->indent > $this->indent)
{
    // [...]
    if(!($this->next_sibling->action == HamlRule::EXEC && $this->next_sibling->next->indent > $this->next_sibling->indent))

Sometimes $this->next and $this->next_sibling are not objects. So we get a Notice.

dxw commented 14 years ago

Thanks, Ravishi -- I've fixed those. Should show up when I next push.