logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Perl::Critic::Policy::Community::Prototypes - Don't use function prototypes

Affiliation

       This policy is part of Perl::Critic::Community.

Author

       Dan Book, "dbook@cpan.org"

Configuration

       This policy can be configured to recognize additional modules as enabling the "signatures" feature, by
       putting an entry in a ".perlcriticrc" file like this:

         [Community::Prototypes]
         signature_enablers = MyApp::Base

Description

       Function prototypes are primarily a hint to the Perl parser for parsing the function's argument list.
       They are not a way to validate or count the arguments passed to the function, and will cause confusion if
       used this way. Often, the prototype can simply be left out, but see "Signatures" in perlsub for a more
       modern method of declaring arguments.

         sub foo ($$) { ... } # not ok
         sub foo { ... }      # ok
         use feature 'signatures'; sub foo ($bar, $baz) { ... }      # ok
         use experimental 'signatures'; sub foo ($bar, $baz) { ... } # ok

       This policy is similar to the core policy
       Perl::Critic::Policy::Subroutines::ProhibitSubroutinePrototypes, but additionally ignores files using the
       "signatures" feature (which is also enabled by a "use" declaration of perl version 5.36 or higher), and
       allows empty prototypes and prototypes containing "&", as these are often useful for structural behavior.

Name

       Perl::Critic::Policy::Community::Prototypes - Don't use function prototypes

See Also

       Perl::Critic

perl v5.40.1                                       2025-03-22              Perl::Critic::...ity::Prototypes(3pm)

See Also