Convert stats consumers to use new PageStatistics::getStat()
Print summary per page and overall

Particularly summarized errors and warnings.
Fix diff header
Fix error when no code panels were found
Collapse whitespace when creating outlines

Fixes an issue where errors were reported if outlines differed only in
whitespace.
Adjust summary formatting

Removed parenthesis from errors and warnings
Fix error when no headings found

In NamedAnchorHtmlTransformer

Message: Warning: Creating default object from empty value

It seems to occur when QueryPath DOMQuery::has() is called when there
are no matches.

The same error for code panels was fixed in commit
b94c03920bad1249e77238e6585e964d0a99d3ae
Add average time per page to summary
Write stats to file every 100 records
Fix error when content is empty

In CodePanelHtmlTransformer.
Note: this fix causes .code.panel stats to not be generated if
content is empty

Error message:
Argument 1 passed to DOMXPath::__construct() must be an instance of DOMDocument, null given
Fix issue where data wasn't added to head when head was missing
Fix issue where DocumentOutliner was outputting corrupt utf-8

This was causing the stats file to be emptied because json_encode
was choking on the invalid utf-8. Resulting json error message:
Malformed UTF-8 characters, possibly incorrectly encoded

The issue occurred in DocumentOutliner::collapseWhitespace in the
preg_replace function. Apparently preg_replace used with \s does not
play well with multi-byte strings.
Improve stats file write handling

Check for JSON errors before writing stats file so it won't overwrite
it if there was an error. Print any such error messages.

Also modified to update stats file after processing each.

Updated FileIo::write() to return the number of bytes written.

See also commit 02caad770c9607ece8e85f3b31f6dab8d5b06878:
Fix issue where DocumentOutliner was outputting corrupt utf-8