1Package::DeprecationManUasgeerr(C3o)ntributed Perl DocumPeanctkaatgieo:n:DeprecationManager(3)
2
3
4

NAME

6       Package::DeprecationManager - Manage deprecation warnings for your
7       distribution
8

VERSION

10       version 0.17
11

SYNOPSIS

13         package My::Class;
14
15         use Package::DeprecationManager -deprecations => {
16             'My::Class::foo' => '0.02',
17             'My::Class::bar' => '0.05',
18             'feature-X'      => '0.07',
19         };
20
21         sub foo {
22             deprecated( 'Do not call foo!' );
23
24             ...
25         }
26
27         sub bar {
28             deprecated();
29
30             ...
31         }
32
33         sub baz {
34             my %args = @_;
35
36             if ( $args{foo} ) {
37                 deprecated(
38                     message => ...,
39                     feature => 'feature-X',
40                 );
41             }
42         }
43
44         package Other::Class;
45
46         use My::Class -api_version => '0.04';
47
48         My::Class->new()->foo(); # warns
49         My::Class->new()->bar(); # does not warn
50         My::Class->new()->bar(); # does not warn again
51

DESCRIPTION

53       This module allows you to manage a set of deprecations for one or more
54       modules.
55
56       When you import "Package::DeprecationManager", you must provide a set
57       of "-deprecations" as a hash ref. The keys are "feature" names, and the
58       values are the version when that feature was deprecated.
59
60       In many cases, you can simply use the fully qualified name of a
61       subroutine or method as the feature name. This works for cases where
62       the whole subroutine is deprecated. However, the feature names can be
63       any string. This is useful if you don't want to deprecate an entire
64       subroutine, just a certain usage.
65
66       You can also provide an optional array reference in the "-ignore"
67       parameter.
68
69       The values to be ignored can be package names or regular expressions
70       (made with "qr//").  Use this to ignore packages in your distribution
71       that can appear on the call stack when a deprecated feature is used.
72
73       As part of the import process, "Package::DeprecationManager" will
74       export two subroutines into its caller. It provides an "import()" sub
75       for the caller and a "deprecated()" sub.
76
77       The "import()" sub allows callers of your class to specify an
78       "-api_version" parameter. If this is supplied, then deprecation
79       warnings are only issued for deprecations with API versions earlier
80       than the one specified.
81
82       You must call the "deprecated()" sub in each deprecated subroutine.
83       When called, it will issue a warning using "Carp::cluck()".
84
85       The "deprecated()" sub can be called in several ways. If you do not
86       pass any arguments, it will generate an appropriate warning message. If
87       you pass a single argument, this is used as the warning message.
88
89       Finally, you can call it with named arguments. Currently, the only
90       allowed names are "message" and "feature". The "feature" argument
91       should correspond to the feature name passed in the "-deprecations"
92       hash.
93
94       If you don't explicitly specify a feature, the "deprecated()" sub uses
95       "caller()" to identify its caller, using its fully qualified subroutine
96       name.
97
98       A given deprecation warning is only issued once for a given package.
99       This module tracks this based on both the feature name and the error
100       message itself. This means that if you provide several different error
101       messages for the same feature, all of those errors will appear.
102
103   Other import() subs
104       This module works by installing an "import" sub in any package that
105       uses it. If that package already has an "import" sub, then that
106       "import" will be called after any arguments passed for
107       "Package::DeprecationManager" are stripped out. You need to define your
108       "import" sub before you "use Package::DeprecationManager" to make this
109       work:
110
111         package HasExporter;
112
113         use Exporter qw( import );
114
115         use Package::DeprecationManager -deprecations => {
116             'HasExporter::foo' => '0.02',
117         };
118
119         our @EXPORT_OK = qw( some_sub another_sub );
120

DONATIONS

122       If you'd like to thank me for the work I've done on this module, please
123       consider making a "donation" to me via PayPal. I spend a lot of free
124       time creating free software, and would appreciate any support you'd
125       care to offer.
126
127       Please note that I am not suggesting that you must do this in order for
128       me to continue working on this particular software. I will continue to
129       do so, inasmuch as I have in the past, for as long as it interests me.
130
131       Similarly, a donation made in this way will probably not make me work
132       on this software much more, unless I get so many donations that I can
133       consider working on free software full time, which seems unlikely at
134       best.
135
136       To donate, log into PayPal and send money to autarch@urth.org or use
137       the button on this page:
138       <http://www.urth.org/~autarch/fs-donation.html>
139

CREDITS

141       The idea for this functionality and some of its implementation was
142       originally created as Class::MOP::Deprecated by Goro Fuji.
143

BUGS

145       Please report any bugs or feature requests to
146       "bug-package-deprecationmanager@rt.cpan.org", or through the web
147       interface at <http://rt.cpan.org>.  I will be notified, and then you'll
148       automatically be notified of progress on your bug as I make changes.
149
150       Bugs may be submitted through the RT bug tracker
151       <http://rt.cpan.org/Public/Dist/Display.html?Name=Package-
152       DeprecationManager> (or bug-package-deprecationmanager@rt.cpan.org
153       <mailto:bug-package-deprecationmanager@rt.cpan.org>).
154
155       I am also usually active on IRC as 'drolsky' on "irc://irc.perl.org".
156

DONATIONS

158       If you'd like to thank me for the work I've done on this module, please
159       consider making a "donation" to me via PayPal. I spend a lot of free
160       time creating free software, and would appreciate any support you'd
161       care to offer.
162
163       Please note that I am not suggesting that you must do this in order for
164       me to continue working on this particular software. I will continue to
165       do so, inasmuch as I have in the past, for as long as it interests me.
166
167       Similarly, a donation made in this way will probably not make me work
168       on this software much more, unless I get so many donations that I can
169       consider working on free software full time (let's all have a chuckle
170       at that together).
171
172       To donate, log into PayPal and send money to autarch@urth.org, or use
173       the button at <http://www.urth.org/~autarch/fs-donation.html>.
174

AUTHOR

176       Dave Rolsky <autarch@urth.org>
177

CONTRIBUTORS

179       •   Jesse Luehrs <doy@tozt.net>
180
181       •   Karen Etheridge <ether@cpan.org>
182
183       •   Tomas Doran <bobtfish@bobtfish.net>
184
186       This software is Copyright (c) 2016 by Dave Rolsky.
187
188       This is free software, licensed under:
189
190         The Artistic License 2.0 (GPL Compatible)
191
192
193
194perl v5.36.0                      2022-07-22    Package::DeprecationManager(3)
Impressum