From 06b41fac031ff722ef7f4ffb875319d2aba4814e Mon Sep 17 00:00:00 2001 From: Marian <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:23:58 +0200 Subject: [PATCH 1/2] Improve removal of unused comments --- src/Visitor.php | 30 +++++++++++------------- wordpress-stubs.php | 57 --------------------------------------------- 2 files changed, 14 insertions(+), 73 deletions(-) diff --git a/src/Visitor.php b/src/Visitor.php index 08f4022..c3322d2 100644 --- a/src/Visitor.php +++ b/src/Visitor.php @@ -879,28 +879,26 @@ private function getCleanCommentsNode(Node $node): Node return $node; } - // Remove "//" comments. $comments = []; foreach ($node->getComments() as $comment) { - if (strpos(trim($comment->getText()), '//') === 0) { + $commentText = trim($comment->getText()); + + // Strip out comments that are not doc comments. + if ( + strpos($commentText, '/**') === false + ) { continue; } - $comments[] = $comment; - } - - $node->setAttribute('comments', $comments); - if ($node->getDocComment() === null) { - return $node; - } + // Strip out comments that are not templates and not the actual docComment. + if ( + strpos($commentText, '/**#@') === false + && $commentText !== trim((string)$node->getDocComment()) + ) { + continue; + } - // Remove file comments that are bound to the first node in a file. - $comments = $node->getComments(); - if ( - $comments[0]->getText() !== (string)$node->getDocComment() - && strpos($comments[0]->getText(), '/**#@') !== 0 - ) { - array_shift($comments); + $comments[] = $comment; } $node->setAttribute('comments', $comments); diff --git a/wordpress-stubs.php b/wordpress-stubs.php index d2a3b08..ed58178 100644 --- a/wordpress-stubs.php +++ b/wordpress-stubs.php @@ -1556,12 +1556,10 @@ public function cleanup() */ class ftp_base { - /* Public variables */ var $LocalEcho; var $Verbose; var $OS_local; var $OS_remote; - /* Private variables */ var $_lastaction; var $_errors; var $_type; @@ -1592,7 +1590,6 @@ class ftp_base var $OS_FullName; var $_eol_code; var $AutoAsciiExt; - /* Constructor */ function __construct($port_mode = \FALSE, $verb = \FALSE, $le = \FALSE) { } @@ -2032,12 +2029,6 @@ public function clear_destination($remote_destination) { } } - /* For future use - define( 'PCLZIP_CB_PRE_LIST', 78005 ); - define( 'PCLZIP_CB_POST_LIST', 78006 ); - define( 'PCLZIP_CB_PRE_DELETE', 78007 ); - define( 'PCLZIP_CB_POST_DELETE', 78008 ); - */ class PclZip { var $zipname = ''; @@ -27615,31 +27606,6 @@ public function parse_file() } } namespace { - # - # Portable PHP password hashing framework. - # - # Version 0.5 / WordPress. - # - # Written by Solar Designer in 2004-2006 and placed in - # the public domain. Revised in subsequent years, still public domain. - # - # There's absolutely no warranty. - # - # The homepage URL for this framework is: - # - # http://www.openwall.com/phpass/ - # - # Please be sure to update the Version line if you edit this file in any way. - # It is suggested that you leave the main version number intact, but indicate - # your project name (after the slash) and add your own revision information. - # - # Please do not change the "private" password hashing method implemented in - # here, thereby making your hashes incompatible. However, if you must, please - # change the hash type identifier (the "$P$") to something different. - # - # Obviously, since this code is in the public domain, the above are not - # requirements (there can be none), but merely suggestions. - # /** * Portable PHP password hashing framework. * @@ -72150,20 +72116,6 @@ public function get_item_schema() public function get_collection_params() { } - /* - * Include a hash of the query args, so that different requests are stored in - * separate caches. - * - * MD5 is chosen for its speed, low-collision rate, universal availability, and to stay - * under the character limit for `_site_transient_timeout_{...}` keys. - * - * @link https://stackoverflow.com/questions/3665247/fastest-hash-for-non-cryptographic-uses - * - * @since 6.0.0 - * - * @param array $query_args Query arguments to generate a transient key from. - * @return string Transient key. - */ protected function get_transient_key($query_args) { } @@ -80108,9 +80060,6 @@ function wp_dashboard_empty() function wp_welcome_panel() { } - /* - * Deprecated functions come here to die. - */ /** * @since 2.1.0 * @deprecated 2.1.0 Use wp_editor() @@ -100633,9 +100582,6 @@ function wp_functionality_constants() function wp_templating_constants() { } - /* - * Deprecated functions come here to die. - */ /** * Retrieves all post data for a given post. * @@ -121172,9 +121118,6 @@ function ms_file_constants() function ms_subdomain_constants() { } - /* - * Deprecated functions come here to die. - */ /** * Get the "dashboard blog", the blog where users without a blog edit their profile data. * Dashboard blog functionality was removed in WordPress 3.1, replaced by the user admin. From daab0490219376afcfb9018f276f9be2809d3111 Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:44:01 +0200 Subject: [PATCH 2/2] Update src/Visitor.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Viktor Szépe --- src/Visitor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Visitor.php b/src/Visitor.php index c3322d2..c86068f 100644 --- a/src/Visitor.php +++ b/src/Visitor.php @@ -883,7 +883,7 @@ private function getCleanCommentsNode(Node $node): Node foreach ($node->getComments() as $comment) { $commentText = trim($comment->getText()); - // Strip out comments that are not doc comments. + // Strip out comments that are not PHPDoc comments. if ( strpos($commentText, '/**') === false ) {