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::ClassHierarchies::ProhibitOneArgBless - Write "bless {}, $class;" instead of just

Affiliation

       This Policy is part of the core Perl::Critic distribution.

Author

       Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>

Configuration

       This Policy is not configurable except for the standard options.

Description

       Always use the two-argument form of "bless" because it allows subclasses to inherit your constructor.

           sub new {
               my $class = shift;
               my $self = bless {};          # not ok
               my $self = bless {}, $class;  # ok
               return $self;
           }

Name

       Perl::Critic::Policy::ClassHierarchies::ProhibitOneArgBless - Write "bless {}, $class;" instead of just
       "bless {};".

See Also