Doc #75947 [Ver->Csd]: Tidy creates an undocumented property Tidy->value

[email protected] Sun, 31 Dec 2023 12:12:34 +0000
Newsgroups php.doc.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=75947&edit=1

 ID:                 75947
 Updated by:         [email protected]
 Reported by:        tandre at themeetgroup dot com
 Summary:            Tidy creates an undocumented property Tidy->value
-Status:             Verified
+Status:             Closed
 Type:               Documentation Problem
 Package:            Tidy
 PHP Version:        Irrelevant
-Assigned To:        
+Assigned To:        nielsdos
 Block user comment: N
 Private report:     N

 New Comment:

This is documented nowadays.


Previous Comments:
------------------------------------------------------------------------
[2018-02-28 23:15:06] [email protected]

> The test script shows that $x->value is indeed being created
> after calling parseString.

Actually, the `value` property is already created when the tidy
object is instantiated.  POC:

  <?php
  $x = new tidy;
  var_dump(
      property_exists('tidy', 'value'),
      property_exists($x, 'value)
  );

gives

  bool(false)
  bool(true)

------------------------------------------------------------------------
[2018-02-10 20:02:10] tandre at themeetgroup dot com

Description:
------------
The test script shows that $x->value is indeed being created after calling parseString.

This property seems like it is created in all versions from PHP 5.0 to 7.2 (haven't checked earlier versions)

https://github.com/php/php-src/blob/PHP-5.0/ext/tidy/tidy.c#L685-L690
https://github.com/php/php-src/blob/PHP-7.2.2/ext/tidy/tidy.c#L820-L827

However, Tidy->value is not mentioned in any of the following places:

- https://secure.php.net/manual/en/class.tidy.php#tidy.synopsis
- https://secure.php.net/manual/en/tidy.parsestring.php#refsect1-tidy.parsestring-examples does not mention that $tidy->value would be created.


Also, I'm wondering it it would make sense to deprecate attempts to access Tidy->value in PHP 7.3:

- It's undocumented, so not many applications would use it (hopefully)
- It's inefficient to generate HTML/XML strings which which won't be used
- Not sure if generating the string affects Tidy->errorBuffer.

I discovered this when investigating a bug in php's use of tidy-html5 5.6.0 (worked in 5.4.0): https://github.com/htacg/tidy-html5/issues/673#issuecomment-364683244 

- Feel free to file a new issue for that if it makes sense to? I wasn't sure.

Test script:
---------------
$x = new Tidy();
$x->parseString('<p>example</p>', ['show-body-only'=>true]);
printf("Value property:   %s\n", $x->value);  // $x->value exists after calling parseString/parseFile, but 
printf("cast to (string): %s\n", (string)$x);

Expected result:
----------------
I expect the existence of the property Tidy->value to be documented on php.net (Or to be deprecated in php 7.3 and removed in 8.0)

Actual result:
--------------
Tidy->value is not documented, but exists.
The above test script outputs the following:

Value property:   <p>example</p>

cast to (string): <p>example</p>




------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=75947&edit=1