Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve removal of unused comments #243

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions src/Visitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 PHPDoc 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);
Expand Down
57 changes: 0 additions & 57 deletions wordpress-stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
}
Expand Down Expand Up @@ -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 = '';
Expand Down Expand Up @@ -27615,31 +27606,6 @@ public function parse_file()
}
}
namespace {
#
# Portable PHP password hashing framework.
#
# Version 0.5 / WordPress.
#
# Written by Solar Designer <solar at openwall.com> 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.
*
Expand Down Expand Up @@ -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)
{
}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
Expand Down