Problems with PHP's HTTP::negotiateLanguage

The latest version of PEAR’s HTTP::negotiateLanguage is improved, but still fails on one of the three simple criteria given below. My version can be found as part of the mySociety source code.

General language tags should match more specific documents

Accept-Language should be case-insensitive

Space before a comma should be ignored