From 78f39056c8fba68ad0a7b002e52273f81a839f7f Mon Sep 17 00:00:00 2001 From: Christian Walde Date: Fri, 27 Dec 2024 15:31:07 +0100 Subject: [PATCH] detect signatures more accurately in newer PPI versions --- .../Policy/Plicease/ProhibitSignaturesAndAtUnderscore.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Perl/Critic/Policy/Plicease/ProhibitSignaturesAndAtUnderscore.pm b/lib/Perl/Critic/Policy/Plicease/ProhibitSignaturesAndAtUnderscore.pm index 81d5c38..6052819 100644 --- a/lib/Perl/Critic/Policy/Plicease/ProhibitSignaturesAndAtUnderscore.pm +++ b/lib/Perl/Critic/Policy/Plicease/ProhibitSignaturesAndAtUnderscore.pm @@ -82,7 +82,8 @@ sub violates { my $subs = $elem->find('PPI::Statement::Sub') || []; foreach my $sub (@$subs) { - next unless defined $sub->prototype; + next unless( $PPI::Document::VERSION > 1.279 ? + @{$sub->find('PPI::Structure::Signature')} : defined $sub->prototype ); my $symbols = $sub->find('PPI::Token::Symbol') || []; foreach my $symbol (@$symbols) { next unless $symbol->symbol eq '@_';