Perl::...rgBless(3pm)
β¨ NAME β¨
Okay so the manual name is Perl::...rgBless(3pm), and the policy bestie in question is Perl::Critic::Policy::ClassHierarchies::ProhibitOneArgBless β and its whole thing is: Write "bless {}, $class;" instead of just "bless {};". Periodt. π
πΈ AFFILIATION πΈ
This Policy is part of the core Perl::Critic distribution. It's giving core-distribution royalty, no cap π.
π¦ DESCRIPTION π¦
Always use the two-argument form of bless because it allows subclasses to inherit your constructor. That's the tea, and it's iconic ββ¨
sub new {
my $class = shift;
my $self = bless {}; # not ok
my $self = bless {}, $class; # ok
return $self;
}
π CONFIGURATION π
This Policy is not configurable except for the standard options. That's it, that's the config vibe π«Ά
π AUTHOR π
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
π COPYRIGHT π
Copyright (c) 2005-2023 Imaginative Software Systems
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Source/version vibe check: perl v5.42.0, dated 2024-10-23, manual Perl::...rgBless(3pm) β bye bestie, go bless with two args and slay π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Perl-Critic 1.156.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms