1Perl::Critic::Policy::OUPbsejererlc:tC:soC:nr:tiPrtriiobchu:it:bePidotlIPinecdryil:r:eDOcobtcjSueymcnettnsat:xa:(tP3ir)oonhibitIndirectSyntax(3)
2
3
4
6 Perl::Critic::Policy::Objects::ProhibitIndirectSyntax - Prohibit
7 indirect object call syntax.
8
10 This Policy is part of the core Perl::Critic distribution.
11
13 Indirect object syntax is commonly used in other object-oriented
14 languages for instantiating objects. Perl allows this, but to say that
15 it supports it may be going too far. Instead of writing
16
17 my $foo = new Foo;
18
19 it is preferable to write
20
21 my $foo = Foo->new;
22
23 The problem is that Perl needs to make a number of assumptions at
24 compile time to disambiguate the first form, so it tends to be fragile
25 and to produce hard-to-track-down bugs.
26
28 Indirect object syntax is also hard for Perl::Critic to disambiguate,
29 so this policy only checks certain subroutine calls. The names of the
30 subroutines can be configured using the "forbid" configuration option:
31
32 [Objects::ProhibitIndirectSyntax]
33 forbid = create destroy
34
35 The "new" subroutine is configured by default; any additional "forbid"
36 values are in addition to "new".
37
39 The general situation can not be handled via static analysis.
40
42 Perl::Critic::Policy::Dynamic::NoIndirect and indirect both do a better
43 job with this, but they require that you compile/execute your code.
44
46 Thomas R. Wyant, III wyant at cpan dot org
47
49 Copyright (c) 2009-2011 Tom Wyant.
50
51 This program is free software; you can redistribute it and/or modify it
52 under the same terms as Perl itself. The full text of this license can
53 be found in the LICENSE file included with this module.
54
55
56
57perl v5.32.0 Perl::Critic2:0:2P0o-l0i7c-y2:8:Objects::ProhibitIndirectSyntax(3)