1Perl::Critic::Policy::OUPbsejererlc:tC:soC:nr:tiPrtriiobchu:it:bePidotlIPinecdryil:r:eDOcobtcjSueymcnettnsat:xa:(tP3ir)oonhibitIndirectSyntax(3)
2
3
4

NAME

6       Perl::Critic::Policy::Objects::ProhibitIndirectSyntax - Prohibit
7       indirect object call syntax.
8

AFFILIATION

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

DESCRIPTION

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

CONFIGURATION

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

CAVEATS

39       The general situation can not be handled via static analysis.
40

SEE ALSO

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

AUTHOR

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.16.3          Perl::Critic2:0:1P4o-l0i6c-y0:9:Objects::ProhibitIndirectSyntax(3)
Impressum