php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74707 Tidy has incorrect ReflectionFunction param counts for functions taking tidy
Submitted: 2017-06-08 05:50 UTC Modified: 2017-06-08 05:55 UTC
From: tandre at themeetgroup dot com Assigned:
Status: Closed Package: Tidy (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2017-06-08 05:50 UTC] tandre at themeetgroup dot com
Description:
------------
Many of the functions implemented in tidy accept an instance of the class Tidy. However, the ReflectionFunction of those haven't been updated yet, or are incorrect (e.g. https://secure.php.net/tidy_access_count and probably tidy_getopt)


Test script:
---------------
<?php
foreach (array('tidy_access_count', 'tidy_clean_repair', 'tidy_config_count', 'tidy_diagnose', 'tidy_get_config', 'tidy_get_error_buffer', 'tidy_get_head', 'tidy_get_html', 'tidy_get_html_ver', 'tidy_getopt', 'tidy_get_output', 'tidy_get_root', 'tidy_get_status', 'tidy_is_xhtml', 'tidy_is_xml') as $tidyFunctionName) {
  $reflection = new ReflectionFunction($tidyFunctionName);
  if ($reflection->getNumberOfParameters() === 0) {
     echo "$tidyFunctionName has 0 parameters according to ReflectionFunction, invoking with 0 parameters";
     error_reporting(E_ALL);
     $tidyFunctionName();
  }
}


Expected result:
----------------
I should not see any occurences of errors such as "Warning: tidy_get_error_buffer() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7", but I see multiple

Additionally, for https://secure.php.net/tidy_getopt the test script should say that it expects 2 parameters, not 1.

Actual result:
--------------
tidy_access_count has 0 parameters according to ReflectionFunction, invoking with 0 parameters
Warning: tidy_access_count() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7
tidy_clean_repair has 0 parameters according to ReflectionFunction, invoking with 0 parameters
Warning: tidy_clean_repair() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7
tidy_config_count has 0 parameters according to ReflectionFunction, invoking with 0 parameters
Warning: tidy_config_count() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7
tidy_diagnose has 0 parameters according to ReflectionFunction, invoking with 0 parameters
Warning: tidy_diagnose() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7
tidy_get_config has 0 parameters according to ReflectionFunction, invoking with 0 parameters
Warning: tidy_get_config() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7
tidy_get_error_buffer has 0 parameters according to ReflectionFunction, invoking with 0 parameters
Warning: tidy_get_error_buffer() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7
tidy_get_head has 0 parameters according to ReflectionFunction, invoking with 0 parameters
Warning: tidy_get_head() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7
tidy_get_html has 0 parameters according to ReflectionFunction, invoking with 0 parameters
Warning: tidy_get_html() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7
tidy_get_html_ver has 0 parameters according to ReflectionFunction, invoking with 0 parameters
Warning: tidy_get_html_ver() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7
* tidy_getopt has 1 parameters according to ReflectionFunction, not invoking
tidy_get_output has 0 parameters according to ReflectionFunction, invoking with 0 parameters
Warning: tidy_get_output() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7
tidy_get_root has 0 parameters according to ReflectionFunction, invoking with 0 parameters
Warning: tidy_get_root() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7
tidy_get_status has 0 parameters according to ReflectionFunction, invoking with 0 parameters
Warning: tidy_get_status() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7
tidy_is_xhtml has 0 parameters according to ReflectionFunction, invoking with 0 parameters
Warning: tidy_is_xhtml() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7
tidy_is_xml has 0 parameters according to ReflectionFunction, invoking with 0 parameters
Warning: tidy_is_xml() expects exactly 1 parameter, 0 given in /path/to/tidy_test.php on line 7


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-06-08 05:55 UTC] tandre at themeetgroup dot com
Additionally, the below methods all have reflection parameter counts of 0, but really expect one parameter

php > $x = new Tidy();
php > $x->getOptDoc();

Warning: tidy::getOptDoc() expects exactly 1 parameter, 0 given in php shell code on line 1
php > $x->getOpt();

Warning: tidy::getOpt() expects exactly 1 parameter, 0 given in php shell code on line 1
php > $x->parseFile();

Warning: tidy::parseFile() expects at least 1 parameter, 0 given in php shell code on line 1
php > $x->parseString();

Warning: tidy::parseString() expects at least 1 parameter, 0 given in php shell code on line 1
php > $x->repairFile();

Warning: tidy::repairFile() expects at least 1 parameter, 0 given in php shell code on line 1
php > $x->repairString();

Warning: tidy::repairString() expects at least 1 parameter, 0 given in php shell code on line 1
 [2018-02-10 18:10 UTC] nikic@php.net
Automatic comment on behalf of carusogabriel34@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=78ed55d7b77c776713e39e665bbc13ea2d6ca0c4
Log: Fixed bug #74707
 [2018-02-10 18:10 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC