/usr/share/perl5/Parse/Method/Signatures/Param.pm is in libparse-method-signatures-perl 1.003014-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | package Parse::Method::Signatures::Param;
use Moose;
use MooseX::Types::Structured qw/Tuple/;
use MooseX::Types::Moose qw/Bool Str ArrayRef HashRef/;
use namespace::clean -except => 'meta';
with 'MooseX::Traits';
has required => (
is => 'ro',
isa => Bool,
required => 1
);
has sigil => (
is => 'ro',
isa => Str,
required => 1,
);
has type_constraints => (
is => 'ro',
isa => 'Parse::Method::Signatures::TypeConstraint',
predicate => 'has_type_constraints',
handles => {
meta_type_constraint => 'tc'
},
);
has default_value => (
is => 'ro',
isa => Str,
predicate => 'has_default_value',
);
has constraints => (
is => 'ro',
isa => ArrayRef[Str],
predicate => 'has_constraints',
auto_deref => 1,
);
has param_traits => (
is => 'ro',
isa => ArrayRef[Tuple[Str, Str]],
predicate => 'has_traits',
auto_deref => 1
);
has '+_trait_namespace' => (
default => 'Parse::Method::Signatures::Param',
);
sub _stringify_type_constraints {
my ($self) = @_;
return $self->has_type_constraints
? $self->type_constraints->to_string . q{ }
: q{};
}
sub _stringify_default_value {
my ($self) = @_;
return $self->has_default_value
? q{ = } . $self->default_value
: q{};
}
sub _stringify_constraints {
my ($self) = @_;
return q{} unless $self->has_constraints;
return q{ where } . join(q{ where }, $self->constraints);
}
sub _stringify_traits {
my ($self) = @_;
return q{} unless $self->has_traits;
return q{ } . join q{ }, map { @{ $_ } } $self->param_traits;
}
sub to_string {
my ($self) = @_;
my $ret = q{};
$ret .= $self->_stringify_type_constraints;
$ret .= $self->_stringify_variable_name;
$ret .= $self->_stringify_required;
$ret .= $self->_stringify_default_value;
$ret .= $self->_stringify_constraints;
$ret .= $self->_stringify_traits;
return $ret;
}
__PACKAGE__->meta->make_immutable;
1;
=head1 NAME
Parse::Method::Signatures::Param - a parsed parameter from a signature
=head1 ATTRIBUTES
All attributes of this class are read-only.
=head2 required
Is this parameter required (true) or optional (false)?
=head2 sigil
The effective sigil ('$', '@' or '%') of this parameter.
=head2 type_constraints
=over
B<Type:> L<Parse::Method::Signatures::TypeConstraint>
B<Predicate:> has_type_constraints
=back
Representation of the type constraint for this parameter. Most commonly you
will just call L</meta_type_constraint> and not access this attribute directly.
=head2 default_value
=over
B<Type:> Str
B<Predicate:> has_default_value
=back
A string that should be eval'd or injected to get the default value for this
parameter. For example:
$name = 'bar'
Would give a default_value of "'bar'".
=head2 constraints
=over
B<Type:> ArrayRef[Str]
B<Predicate:> has_constraints
=back
C<where> constraints for this type. Each member of the array a the string
(including enclosing braces) of the where constraint block.
=head2 param_traits
=over
B<Type:> ArrayRef[ Tupple[Str,Str] ]
B<Predicate:> has_traits
=back
Traits that this parameter is declared to have. For instance
$foo does coerce
would have a trait of
['does', 'coerce']
=head1 METHODS
=head2 to_string
=head2 meta_type_constraint
Get the L<Moose::Meta::TypeConstraint> for this parameter. Check first that the
type has a type constraint:
$tc = $param->meta_type_constraint if $param->has_type_constraints;
=head1 SEE ALSO
L<Parse::Method::Signatures>.
=head1 AUTHORS
Ash Berlin <ash@cpan.org>.
Florian Ragwitz <rafl@debian.org>.
=head1 LICENSE
Licensed under the same terms as Perl itself.
|