envato / envato-theme-check

The WordPress Theme Check plugin for Envato
GNU General Public License v2.0
208 stars 57 forks source link

regex statement triggers PHP short tag warning. #28

Closed kprovance closed 6 years ago

kprovance commented 6 years ago

Otto never fixed this either. So...

preg_match('/^\[(.+?)\]:[ ]*+<?(\S+?)>?(?:[ ]+['\'(](.+)['\')])?[ ]*+$/', $Line['text'], $matches)

is the offending line

scottparry commented 6 years ago

Have you got a code example that is being picked up?

kprovance commented 6 years ago

It's part of a larger library that parses MD. Here is the function.

protected function blockReference($Line)
    {
        if (strpos($Line['text'], ']') !== false
            and preg_match('/^\[(.+?)\]:[ ]*+<?(\S+?)>?(?:[ ]+["\'(](.+)["\')])?[ ]*+$/', $Line['text'], $matches)
        ) {
            $id = strtolower($matches[1]);

            $Data = array(
                'url' => $matches[2],
                'title' => isset($matches[3]) ? $matches[3] : null,
            );

            $this->DefinitionData['Reference'][$id] = $Data;

            $Block = array(
                'element' => array(),
            );

            return $Block;
        }
    }
scottparry commented 6 years ago

066a2b5b5efd9c53f90c40465bc369b547a25cdd