Skip to content

Commit 87e2594

Browse files
committedDec 14, 2023
fix for php8 migration
1 parent 9e22144 commit 87e2594

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed
 

‎src/class.Checker.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ private function addInfoClassId() {
309309
$nodes = array_merge((array) $classes,(array) $ids);
310310

311311
// Remove nodes for which all class names are ASCII
312-
if (count($nodes) > 0)
312+
if ($nodes && count($nodes) > 0)
313313
$nodes = array_filter($nodes, function ($valArray) {
314314
$valArray['values'] = preg_filter('/[^\x20-\x7E]/', '$0', $valArray['values']);
315315
if (empty($valArray['values']))
@@ -324,7 +324,7 @@ private function addInfoClassId() {
324324
Information::addInfo($category, $title, $value, $display_value);
325325

326326
// Remove nodes for which all class names are NFC
327-
if (count($nodes) > 0)
327+
if ($nodes && count($nodes) > 0)
328328
// FIXME? case class="nonASCII nonNFC" may report two nonNFC names if $valArray[values] is not edited. the check should be value by value.
329329
$nodes = array_filter($nodes, function (&$valArray) {
330330
if (is_array($valArray['values']))
@@ -892,7 +892,7 @@ private function hasValue ($array) {
892892

893893
private function getFirstCVP ($array) {
894894
// returns the first code-value pair from an array of code-value pairs
895-
if (count($array) > 0) { return $array[0]; }
895+
if ($array && count($array) > 0) { return $array[0]; }
896896
else return null;
897897
}
898898

@@ -1111,7 +1111,7 @@ private function addReportLanguages() {
11111111

11121112
// ERROR: A lang attribute value did not match an xml:lang value when they appeared together on the same tag.
11131113
$nonMatchingAttrs = array();
1114-
if (count($htmlLangAttrs) > 0)
1114+
if ($htmlLangAttrs && count($htmlLangAttrs) > 0)
11151115
array_walk($htmlLangAttrs, function (&$valArray, $key) use (&$xmlLangAttrs, &$nonMatchingAttrs) {
11161116
$code = $valArray['code'];
11171117
if (($el = Utils::findCodeIn($code, $xmlLangAttrs)) != null) {
@@ -1139,7 +1139,7 @@ private function addReportDirValues() {
11391139
// ERROR: Incorrect values used for dir attribute
11401140
$dirNodes = $this->doc->getNodesWithAttr('dir');
11411141
$isXML = $this->doc->isServedAsXML;
1142-
if (count($dirNodes) > 0) {
1142+
if ($dirNodes && count($dirNodes) > 0) {
11431143
$invalidDirNodes = array_filter($dirNodes, function ($array) use ($isXML) {
11441144
if (is_array($array['values'])) { $array['values'] = implode(' ',$array['values']); }
11451145
if (! $isXML) { $array['values'] = strtolower($array['values']); }
@@ -1191,14 +1191,14 @@ private function addReportDirValues() {
11911191

11921192
// WARNING: CSS is being used to set direction
11931193
$styleNodes = $this->doc->getNodesWithAttr('style');
1194-
if (count($styleNodes) > 0) {
1194+
if ($styleNodes && count($styleNodes) > 0) {
11951195
$invalidstyleNodes = array_filter($styleNodes, function ($array) {
11961196
if (is_array($array['values'])) { $array['values'] = implode(' ',$array['values']); }
11971197
$array['values'] = strtolower($array['values']);
11981198
if (preg_match('/direction:\s*rtl/',$array['values']) || preg_match('/direction:\s*ltr/',$array['values'])) { return true; }
11991199
return false;
12001200
});
1201-
if (count($invalidstyleNodes) > 0)
1201+
if ($invalidstyleNodes && count($invalidstyleNodes) > 0)
12021202
Report::addReport(
12031203
'rep_markup_css_direction',
12041204
'dir_category', REPORT_LEVEL_WARNING,
@@ -1214,7 +1214,7 @@ private function addReportDirValues() {
12141214
private function addReportMisc() {
12151215
// WARNING: are there non-NFC class or id names?
12161216
$nonNFCs = Information::getValues('classId_non_nfc');
1217-
if (count($nonNFCs) > 0) {
1217+
if ($nonNFCs && count($nonNFCs) > 0) {
12181218
Report::addReport(
12191219
'rep_latin_non_nfc',
12201220
'nonLatin_category', REPORT_LEVEL_WARNING,
@@ -1488,4 +1488,4 @@ private function addReportMisc() {
14881488
}
14891489
}
14901490

1491-
Checker::_init();
1491+
Checker::_init();

0 commit comments

Comments
 (0)