Skip to content

Commit

Permalink
fix null empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelroecker committed Apr 4, 2016
1 parent a79fb5c commit bda2d1c
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/GlW3CValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private function sendToW3C($w3curl, $validator, $field, $htmltag, $file, $title,
if ($html->get(".success")) {
return null;
}

$html->delete('head style');
$style = '<style type="text/css" media="all">';
foreach ($csslist as $css) {
Expand All @@ -139,12 +139,12 @@ private function sendToW3C($w3curl, $validator, $field, $htmltag, $file, $title,
$stats[0]->delete();
}

$head = $html->get("head")[0]->getHtml();
$head = $html->get("head")[0]->getHtml();

$resulttag = $html->get($htmltag);
if (count($resulttag) <= 0) {
$result = '<p class="failure">There were errors.</p>';
} else {
} else {
$result = $resulttag[0]->getHtml();
}

Expand Down Expand Up @@ -175,16 +175,17 @@ private function validateFile(SplFileInfo $fileinfo)
$this->types[$ext]['css']
);

if (!$view) {
if ($view === null) {
return null;
}

$filedir = $this->resultrootdir . '/' . strtr($fileinfo->getRelativepath(), ["\\" => "/"]);
if (!$this->fs->exists($filedir)) {
$this->fs->mkdir($filedir);
}
$resultname = $filedir . "/w3c_" . $ext . "_" . $fileinfo->getBaseName($ext) . 'html';
file_put_contents($resultname, $view);

return $resultname;
}

Expand Down Expand Up @@ -231,7 +232,9 @@ private function validateFinder(Finder $files, $filter, callable $callback, arra
*/
foreach ($files as $file) {
$callback($file);
$result[strtr($file->getRelativePath() . '/' . $file->getFilename(),["\\" => "/"])] = $this->validateFile($file);
$result[strtr($file->getRelativePath() . '/' . $file->getFilename(), ["\\" => "/"])] = $this->validateFile(
$file
);
}
}

Expand All @@ -251,13 +254,19 @@ private function validateDirect($file, $filter, callable $callback, array &$resu
*/
foreach ($finder as $finderfile) {
$callback($finderfile);
$result[strtr($finderfile->getRelativePath() . '/' . $finderfile->getFilename(),["\\" => "/"])] = $this->validateFile($finderfile);
$result[strtr(
$finderfile->getRelativePath() . '/' . $finderfile->getFilename(),
["\\" => "/"]
)] = $this->validateFile($finderfile);
}
} else {
if (preg_match($filter, $file)) {
$finderfile = new SplFileInfo($file, "", "");
$callback($finderfile);
$result[strtr($finderfile->getRelativePath() . '/' . $finderfile->getFilename(),["\\" => "/"])] = $this->validateFile($finderfile);
$result[strtr(
$finderfile->getRelativePath() . '/' . $finderfile->getFilename(),
["\\" => "/"]
)] = $this->validateFile($finderfile);
}
}
}
Expand Down

0 comments on commit bda2d1c

Please sign in to comment.