shell bypass 403

GrazzMean Shell

Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.144.230.81
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : Moose::Manual::Types.3pm
.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Moose::Manual::Types 3"
.TH Moose::Manual::Types 3 "2021-11-07" "perl v5.26.3" "User Contributed Perl Documentation"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Moose::Manual::Types \- Moose's type system
.SH "VERSION"
.IX Header "VERSION"
version 2.2201
.SH "TYPES IN PERL?"
.IX Header "TYPES IN PERL?"
Moose provides its own type system for attributes. You can also use
these types to validate method parameters with the help of a MooseX
module.
.PP
Moose's type system is based on a combination of Perl 5's own
\&\fIimplicit\fR types and some Perl 6 concepts. You can create your
own subtypes with custom constraints, making it easy to express any
sort of validation.
.PP
Types have names, and you can re-use them by name, making it easy to
share types throughout a large application.
.PP
However, this is not a \*(L"real\*(R" type system. Moose does not magically make Perl
start associating types with variables. This is just an advanced parameter
checking system which allows you to associate a name with a constraint.
.PP
That said, it's still pretty damn useful, and we think it's one of the
things that makes Moose both fun and powerful. Taking advantage of the
type system makes it much easier to ensure that you are getting valid
data, and it also contributes greatly to code maintainability.
.SH "THE TYPES"
.IX Header "THE TYPES"
The basic Moose type hierarchy looks like this
.PP
.Vb 10
\&  Any
\&      Item
\&          Bool
\&          Maybe[\`a]
\&          Undef
\&          Defined
\&              Value
\&                  Str
\&                      Num
\&                          Int
\&                      ClassName
\&                      RoleName
\&              Ref
\&                  ScalarRef[\`a]
\&                  ArrayRef[\`a]
\&                  HashRef[\`a]
\&                  CodeRef
\&                  RegexpRef
\&                  GlobRef
\&                  FileHandle
\&                  Object
.Ve
.PP
In practice, the only difference between \f(CW\*(C`Any\*(C'\fR and \f(CW\*(C`Item\*(C'\fR is
conceptual. \f(CW\*(C`Item\*(C'\fR is used as the top-level type in the hierarchy.
.PP
The rest of these types correspond to existing Perl concepts.
In particular:
.IP "\(bu" 4
\&\f(CW\*(C`Bool\*(C'\fR accepts \f(CW1\fR for true, and undef, 0, or the empty string as false.
.IP "\(bu" 4
\&\f(CW\*(C`Maybe[\`a]\*(C'\fR accepts either \f(CW\*(C`\`a\*(C'\fR or \f(CW\*(C`undef\*(C'\fR.
.IP "\(bu" 4
\&\f(CW\*(C`Num\*(C'\fR accepts integers, floating point numbers (both in decimal notation &
exponential notation), 0, .0, 0.0 etc. It doesn't accept numbers with
whitespace, Inf, Infinity, \*(L"0 but true\*(R", NaN & other such strings.
.IP "\(bu" 4
\&\f(CW\*(C`ClassName\*(C'\fR and \f(CW\*(C`RoleName\*(C'\fR accept strings that are either the name of a class or the name of a role. The class/role must already be loaded when the constraint is checked.
.IP "\(bu" 4
\&\f(CW\*(C`FileHandle\*(C'\fR accepts either an IO::Handle object or a builtin perl filehandle (see \*(L"openhandle\*(R" in Scalar::Util).
.IP "\(bu" 4
\&\f(CW\*(C`Object\*(C'\fR accepts any blessed reference.
.PP
The types followed by \*(L"[`a]\*(R" can be parameterized. So instead of just
plain \f(CW\*(C`ArrayRef\*(C'\fR we can say that we want \f(CW\*(C`ArrayRef[Int]\*(C'\fR instead. We
can even do something like \f(CW\*(C`HashRef[ArrayRef[Str]]\*(C'\fR.
.PP
The \f(CW\*(C`Maybe[\`a]\*(C'\fR type deserves a special mention. Used by itself, it
doesn't really mean anything (and is equivalent to \f(CW\*(C`Item\*(C'\fR). When it
is parameterized, it means that the value is either \f(CW\*(C`undef\*(C'\fR or the
parameterized type. So \f(CW\*(C`Maybe[Int]\*(C'\fR means an integer or \f(CW\*(C`undef\*(C'\fR.
.PP
For more details on the type hierarchy, see
Moose::Util::TypeConstraints.
.SH "WHAT IS A TYPE?"
.IX Header "WHAT IS A TYPE?"
It's important to realize that types are not classes (or
packages). Types are just objects (Moose::Meta::TypeConstraint
objects, to be exact) with a name and a constraint. Moose maintains a
global type registry that lets it convert names like \f(CW\*(C`Num\*(C'\fR into the
appropriate object.
.PP
However, class names \fIcan be\fR type names. When you define a new class
using Moose, it defines an associated type name behind the scenes:
.PP
.Vb 1
\&  package MyApp::User;
\&
\&  use Moose;
.Ve
.PP
Now you can use \f(CW\*(AqMyApp::User\*(Aq\fR as a type name:
.PP
.Vb 4
\&  has creator => (
\&      is  => \*(Aqro\*(Aq,
\&      isa => \*(AqMyApp::User\*(Aq,
\&  );
.Ve
.PP
However, for non-Moose classes there's no magic. You may have to
explicitly declare the class type. This is a bit muddled because Moose
assumes that any unknown type name passed as the \f(CW\*(C`isa\*(C'\fR value for an
attribute is a class. So this works:
.PP
.Vb 4
\&  has \*(Aqbirth_date\*(Aq => (
\&      is  => \*(Aqro\*(Aq,
\&      isa => \*(AqDateTime\*(Aq,
\&  );
.Ve
.PP
In general, when Moose is presented with an unknown name, it assumes
that the name is a class:
.PP
.Vb 4
\&  subtype \*(AqModernDateTime\*(Aq
\&      => as \*(AqDateTime\*(Aq
\&      => where { $_\->year() >= 1980 }
\&      => message { \*(AqThe date you provided is not modern enough\*(Aq };
\&
\&  has \*(Aqvalid_dates\*(Aq => (
\&      is  => \*(Aqro\*(Aq,
\&      isa => \*(AqArrayRef[DateTime]\*(Aq,
\&  );
.Ve
.PP
Moose will assume that \f(CW\*(C`DateTime\*(C'\fR is a class name in both of these
instances.
.SH "SUBTYPES"
.IX Header "SUBTYPES"
Moose uses subtypes in its built-in hierarchy. For example, \f(CW\*(C`Int\*(C'\fR is
a child of \f(CW\*(C`Num\*(C'\fR.
.PP
A subtype is defined in terms of a parent type and a constraint. Any
constraints defined by the parent(s) will be checked first, followed by
constraints defined by the subtype. A value must pass \fIall\fR of these
checks to be valid for the subtype.
.PP
Typically, a subtype takes the parent's constraint and makes it more
specific.
.PP
A subtype can also define its own constraint failure message. This
lets you do things like have an error \*(L"The value you provided (20),
was not a valid rating, which must be a number from 1\-10.\*(R" This is
much friendlier than the default error, which just says that the value
failed a validation check for the type. The default error can, however,
be made more friendly by installing Devel::PartialDump (version 0.14 or
higher), which Moose will use if possible to display the invalid value.
.PP
Here's a simple (and useful) subtype example:
.PP
.Vb 4
\&  subtype \*(AqPositiveInt\*(Aq,
\&      as \*(AqInt\*(Aq,
\&      where { $_ > 0 },
\&      message { "The number you provided, $_, was not a positive number" };
.Ve
.PP
Note that the sugar functions for working with types are all exported
by Moose::Util::TypeConstraints.
.SH "TYPE NAMES"
.IX Header "TYPE NAMES"
Type names are global throughout the current Perl
interpreter. Internally, Moose maps names to type objects via a
registry.
.PP
If you have multiple apps or libraries all using Moose in the same
process, you could have problems with collisions. We recommend that
you prefix names with some sort of namespace indicator to prevent
these sorts of collisions.
.PP
For example, instead of calling a type \*(L"PositiveInt\*(R", call it
\&\*(L"MyApp::Type::PositiveInt\*(R" or \*(L"MyApp::Types::PositiveInt\*(R". We
recommend that you centralize all of these definitions in a single
package, \f(CW\*(C`MyApp::Types\*(C'\fR, which can be loaded by other classes in your
application.
.PP
However, before you do this, you should look at the MooseX::Types
module. This module makes it easy to create a \*(L"type library\*(R" module, which can
export your types as perl constants.
.PP
.Vb 1
\&  has \*(Aqcounter\*(Aq => (is => \*(Aqrw\*(Aq, isa => PositiveInt);
.Ve
.PP
This lets you use a short name rather than needing to fully qualify the name
everywhere. It also allows you to easily create parameterized types:
.PP
.Vb 1
\&  has \*(Aqcounts\*(Aq => (is => \*(Aqro\*(Aq, isa => HashRef[PositiveInt]);
.Ve
.PP
This module will check your names at compile time, and is generally more
robust than the string type parsing for complex cases.
.SH "COERCION"
.IX Header "COERCION"
A coercion lets you tell Moose to automatically convert one type to another.
.PP
.Vb 2
\&  subtype \*(AqArrayRefOfInts\*(Aq,
\&      as \*(AqArrayRef[Int]\*(Aq;
\&
\&  coerce \*(AqArrayRefOfInts\*(Aq,
\&      from \*(AqInt\*(Aq,
\&      via { [ $_ ] };
.Ve
.PP
You'll note that we created a subtype rather than coercing \f(CW\*(C`ArrayRef[Int]\*(C'\fR
directly. It's a bad idea to add coercions to the raw built in
types.
.PP
Coercions are global, just like type names, so a coercion applied to a built
in type is seen by all modules using Moose types. This is \fIanother\fR reason
why it is good to namespace your types.
.PP
Moose will \fInever\fR try to coerce a value unless you explicitly ask for
it. This is done by setting the \f(CW\*(C`coerce\*(C'\fR attribute option to a true value:
.PP
.Vb 1
\&  package Foo;
\&
\&  has \*(Aqsizes\*(Aq => (
\&      is     => \*(Aqro\*(Aq,
\&      isa    => \*(AqArrayRefOfInts\*(Aq,
\&      coerce => 1,
\&  );
\&
\&  Foo\->new( sizes => 42 );
.Ve
.PP
This code example will do the right thing, and the newly created
object will have \f(CW\*(C`[ 42 ]\*(C'\fR as its \f(CW\*(C`sizes\*(C'\fR attribute.
.SS "Deep coercion"
.IX Subsection "Deep coercion"
Deep coercion is the coercion of type parameters for parameterized
types. Let's take these types as an example:
.PP
.Vb 3
\&  subtype \*(AqHexNum\*(Aq,
\&      as \*(AqStr\*(Aq,
\&      where { /[a\-f0\-9]/i };
\&
\&  coerce \*(AqInt\*(Aq,
\&      from \*(AqHexNum\*(Aq,
\&      via { hex $_ };
\&
\&  has \*(Aqsizes\*(Aq => (
\&      is     => \*(Aqro\*(Aq,
\&      isa    => \*(AqArrayRef[Int]\*(Aq,
\&      coerce => 1,
\&  );
.Ve
.PP
If we try passing an array reference of hex numbers for the \f(CW\*(C`sizes\*(C'\fR
attribute, Moose will not do any coercion.
.PP
However, you can define a set of subtypes to enable coercion between
two parameterized types.
.PP
.Vb 2
\&  subtype \*(AqArrayRefOfHexNums\*(Aq,
\&      as \*(AqArrayRef[HexNum]\*(Aq;
\&
\&  subtype \*(AqArrayRefOfInts\*(Aq,
\&      as \*(AqArrayRef[Int]\*(Aq;
\&
\&  coerce \*(AqArrayRefOfInts\*(Aq,
\&      from \*(AqArrayRefOfHexNums\*(Aq,
\&      via { [ map { hex } @{$_} ] };
\&
\&  Foo\->new( sizes => [ \*(Aqa1\*(Aq, \*(Aqff\*(Aq, \*(Aq22\*(Aq ] );
.Ve
.PP
Now Moose will coerce the hex numbers to integers.
.PP
Moose does not attempt to chain coercions, so it will not
coerce a single hex number. To do that, we need to define a separate
coercion:
.PP
.Vb 3
\&  coerce \*(AqArrayRefOfInts\*(Aq,
\&      from \*(AqHexNum\*(Aq,
\&      via { [ hex $_ ] };
.Ve
.PP
Yes, this can all get verbose, but coercion is tricky magic, and we
think it's best to make it explicit.
.SH "TYPE UNIONS"
.IX Header "TYPE UNIONS"
Moose allows you to say that an attribute can be of two or more
disparate types. For example, we might allow an \f(CW\*(C`Object\*(C'\fR or
\&\f(CW\*(C`FileHandle\*(C'\fR:
.PP
.Vb 4
\&  has \*(Aqoutput\*(Aq => (
\&      is  => \*(Aqrw\*(Aq,
\&      isa => \*(AqObject | FileHandle\*(Aq,
\&  );
.Ve
.PP
Moose actually parses that string and recognizes that you are creating
a type union. The \f(CW\*(C`output\*(C'\fR attribute will accept any sort of object,
as well as an unblessed file handle. It is up to you to do the right
thing for each of them in your code.
.PP
Whenever you use a type union, you should consider whether or not
coercion might be a better answer.
.PP
For our example above, we might want to be more specific, and insist
that output be an object with a \f(CW\*(C`print\*(C'\fR method:
.PP
.Vb 1
\&  duck_type \*(AqCanPrint\*(Aq, [qw(print)];
.Ve
.PP
We can coerce file handles to an object that satisfies this condition
with a simple wrapper class:
.PP
.Vb 1
\&  package FHWrapper;
\&
\&  use Moose;
\&
\&  has \*(Aqhandle\*(Aq => (
\&      is  => \*(Aqrw\*(Aq,
\&      isa => \*(AqFileHandle\*(Aq,
\&  );
\&
\&  sub print {
\&      my $self = shift;
\&      my $fh   = $self\->handle();
\&
\&      print {$fh} @_;
\&  }
.Ve
.PP
Now we can define a coercion from \f(CW\*(C`FileHandle\*(C'\fR to our wrapper class:
.PP
.Vb 3
\&  coerce \*(AqCanPrint\*(Aq
\&      => from \*(AqFileHandle\*(Aq
\&      => via { FHWrapper\->new( handle => $_ ) };
\&
\&  has \*(Aqoutput\*(Aq => (
\&      is     => \*(Aqrw\*(Aq,
\&      isa    => \*(AqCanPrint\*(Aq,
\&      coerce => 1,
\&  );
.Ve
.PP
This pattern of using a coercion instead of a type union will help
make your class internals simpler.
.SH "TYPE CREATION HELPERS"
.IX Header "TYPE CREATION HELPERS"
The Moose::Util::TypeConstraints module exports a number of helper
functions for creating specific kinds of types. These include
\&\f(CW\*(C`class_type\*(C'\fR, \f(CW\*(C`role_type\*(C'\fR, \f(CW\*(C`maybe_type\*(C'\fR, and \f(CW\*(C`duck_type\*(C'\fR. See the
docs for details.
.PP
One helper worth noting is \f(CW\*(C`enum\*(C'\fR, which allows you to create a
subtype of \f(CW\*(C`Str\*(C'\fR that only allows the specified values:
.PP
.Vb 1
\&  enum \*(AqRGB\*(Aq, [qw( red green blue )];
.Ve
.PP
This creates a type named \f(CW\*(C`RGB\*(C'\fR.
.SH "ANONYMOUS TYPES"
.IX Header "ANONYMOUS TYPES"
All of the type creation functions return a type object. This type
object can be used wherever you would use a type name, as a parent
type, or as the value for an attribute's \f(CW\*(C`isa\*(C'\fR option:
.PP
.Vb 4
\&  has \*(Aqsize\*(Aq => (
\&      is  => \*(Aqro\*(Aq,
\&      isa => subtype( \*(AqInt\*(Aq => where { $_ > 0 } ),
\&  );
.Ve
.PP
This is handy when you want to create a one-off type and don't want to
\&\*(L"pollute\*(R" the global namespace registry.
.SH "VALIDATING METHOD PARAMETERS"
.IX Header "VALIDATING METHOD PARAMETERS"
Moose does not provide any means of validating method
parameters. However, there are several MooseX extensions on \s-1CPAN\s0 which
let you do this.
.PP
The simplest and least sugary is Params::ValidationCompiler. This
lets you validate a set of named parameters using Moose types:
.PP
.Vb 2
\&  use Moose::Util::TypeConstraints qw( find_type_constraint );
\&  use Params::ValidationCompiler qw( validation_for );
\&
\&  {
\&      my $validator = validation_for(
\&          params => {
\&              foo => { type => find_type_constraint(\*(AqInt\*(Aq) },
\&              bar => {
\&                  type     => find_type_constraint(\*(AqStr\*(Aq),
\&                  optional => 1,
\&              },
\&              baz => {
\&                  type    => find_type_constraint(\*(AqInt\*(Aq),
\&                  default => 42,
\&              },
\&          },
\&      );
\&
\&      sub foo {
\&          my %args = $validator\->(@_);
\&      }
\&}
.Ve
.PP
Params::ValidationCompiler also supports coercions.
.PP
There are several more powerful extensions that support method parameter
validation using Moose types, including Moops, which gives you a full-blown
\&\f(CW\*(C`method\*(C'\fR keyword.
.PP
.Vb 3
\&  method morning ( Str $name ) {
\&      $self\->say("Good morning ${name}!");
\&  }
.Ve
.SH "LOAD ORDER ISSUES"
.IX Header "LOAD ORDER ISSUES"
Because Moose types are defined at runtime, you may run into load
order problems. In particular, you may want to use a class's type
constraint before that type has been defined.
.PP
In order to ameliorate this problem, we recommend defining \fIall\fR of your
custom types in one module, \f(CW\*(C`MyApp::Types\*(C'\fR, and then loading this module in
all of your other modules.
.SH "AUTHORS"
.IX Header "AUTHORS"
.IP "\(bu" 4
Stevan Little <stevan@cpan.org>
.IP "\(bu" 4
Dave Rolsky <autarch@urth.org>
.IP "\(bu" 4
Jesse Luehrs <doy@cpan.org>
.IP "\(bu" 4
Shawn M Moore <sartak@cpan.org>
.IP "\(bu" 4
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
.IP "\(bu" 4
Karen Etheridge <ether@cpan.org>
.IP "\(bu" 4
Florian Ragwitz <rafl@debian.org>
.IP "\(bu" 4
Hans Dieter Pearcey <hdp@cpan.org>
.IP "\(bu" 4
Chris Prather <chris@prather.org>
.IP "\(bu" 4
Matt S Trout <mstrout@cpan.org>
.SH "COPYRIGHT AND LICENSE"
.IX Header "COPYRIGHT AND LICENSE"
This software is copyright (c) 2006 by Infinity Interactive, Inc.
.PP
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
© 2025 GrazzMean