bopoda / robots-txt-parser

PHP class for parse all directives from robots.txt files according to specifications
http://robots.jeka.by
MIT License
44 stars 17 forks source link

Wrong boolean value in RobotsTxtValidator.php? #63

Open scott8035 opened 11 months ago

scott8035 commented 11 months ago

In https://github.com/bopoda/robots-txt-parser/blob/master/src/RobotsTxtParser/RobotsTxtValidator.php, there's a chunk of code at line 47:

        $hasAllowDirectives = true;
        foreach ($orderedDirectives as $directiveRow) {
            if ($directiveRow['directive'] == 'allow') {
                $hasAllowDirectives = true;
                break;
            }
        }

Shouldn't that be:

        $hasAllowDirectives = **false**;
        foreach ($orderedDirectives as $directiveRow) {
            if ($directiveRow['directive'] == 'allow') {
                $hasAllowDirectives = true;
                break;
            }
        }
bopoda commented 7 months ago

Yes, you are right @scott8035 . The initial intention was as in code you provided. In general it should work, but extra condition does not give profit. Will have a look at this class later to improve.