Perl::C...wMethod(3)
π Perl::C...wMethod(3) π
okay bestie, welcome to the manual page for Perl::Critic::Policy::Moose::ProhibitNewMethod β yes that's a whole mouthful, the header up top just calls it Perl::C...wMethod(3) because even man pages gotta truncate, and it lives in the User Contributed Perl Documentation section. she's niche, she's opinionated, she's here to stop you from doing a thing. let's get into it π
β¨ NAME β¨
Perl::Critic::Policy::Moose::ProhibitNewMethod β don't override Moose's standard constructors. that's it, that's the whole personality. π
πΈ VERSION πΈ
version 1.05 β she's been around a minute, she knows what she's talking about.
π¦ DESCRIPTION π¦
so like. overriding new() on a Moose class? it's giving chaos. it causes a whole bunch of problems, including:
- speed issues (she's slow now, not slay)
- problems with the order of invocation of constructors when multiple inheritance is involved
the way that multiple inheritance just does NOT play nice with a hand-rolled new()... yeah. π
instead, bestie, use BUILDARGS() and BUILD(). those are the correct lil hooks, they exist for exactly this, use them. periodt. β¨
π AFFILIATION π
this policy is part of Perl::Critic::Moose. she's not out here alone, she's got a whole squad.
π CONFIGURATION π
there is a single option, and it's called equivalent_modules. what does it do? it lets you specify modules that should be treated the exact same as Moose and Moose::Role β like, if you were doing something with Moose::Exporter, iykyk. π
for example, if you were to have this in your .perlcriticrc file:
[Moose::ProhibitNewMethod]
equivalent_modules = MyCompany::Moose MooseX::NewThing
then the following code would result in a violation:
package Baz;
use MyCompany::Moose;
sub new {
...
}
not me catching you in 4K. π the policy sees MyCompany::Moose and goes "that's a Moose, actually" and flags your sub new. iconic behavior fr fr.
π SEE ALSO π
Moose::Manual::ConstructionMoose::Manual::BestPractices
go read these, they're the required reading bestie, they'll explain the whole construction vibe properly. π«Ά
π SUPPORT π
bugs may be submitted through the RT bug tracker <http://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Critic-Moose> (or <bug-perl-critic-moose@rt.cpan.org>).
she is also usually active on IRC as 'drolsky' on "irc://irc.perl.org" β so if you gotta talk to a human, that's the human. πΈ
β AUTHORS β
- Elliot Shank
<perl@galumph.com> - Dave Rolsky
<autarch@urth.org>
absolute legends, both of them. π
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2008 - 2016 by Elliot Shank.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. so like, go off, but with the terms, okay? π
and that's the whole page bestie!! this manual page was served to you by perl v5.42.0, dated 2025-07-25, and honestly? iconic of it. mwah π
β¨π¦
π¦ where this page comes from
- fedora 43: perl-Perl-Critic-Moose 1.05-27.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms