NAME

Devel::Isa::Explainer::_MRO - Method-resolution-order Utilities for DIE

VERSION

version 0.002900

FUNCTIONS

is_mro_proxy

if ( MRO_PROXIES and is_mro_proxy( $package, $sub ) ) {
  // its a proxy
} else {
  // anything else
}

Prior to 5.009_005, backwards-compatibility support for MRO for 5.8 has to install "proxy" subs at various levels that emulate alternative resolution orders by hiding relevant nodes in the gaps in tree.

This detects those nodes so that we can pretend they don't exist.

get_linear_isa

my $isa = get_linear_isa( $class );

This function is like mro::get_linear_isa()|mro/get_linear_isa, with the exception that it includes UNIVERSAL and any parents of UNIVERSAL where relevant.

If pointed at UNIVERSAL, will include UNIVERSALs parents.

If pointed at a parent of UNIVERSAL, will not show UNIVERSAL, despite the fact calling ->can() on a parent of UNIVERSAL still works, despite the fact its actually defined in UNIVERSAL.

get_package_sub

my $sub = get_package_sub($package, $sub);

Fetch a directly defined CodeRef from $package named $sub

Fake proxy methods (such as Class::C3 proxies) and stubs are ignored by this and instead return undef

$result = undef / CODEREF

get_package_subs

my $hashref = get_package_subs( $packagename );

Returns a hash of the packages directly defined sub's.

$result = { SUBNAME => CODEREF, ... };

get_linear_class_shadows

my $arrayref = get_linear_class_shadows( $classname )

Combines get_linear_isa() and get_package_subs(), traversing the inheritance bottom up, computing shadowing as it goes.

Returns:

$result     = [ $hashref, $hashref, $hashref,   ... ]
$hashrefref = { class => CLASSNAME, subs => $submap }
$submap     = { SUBNAME => $subrecord,          ... }
$subrecord  = { shadowing => BOOLEAN,
                shadowed  => BOOLEAN,
                ref       => CODEREF,               }

get_parents

my $parents = get_parents( $package );

This utility finds the effective "depth 1" parents of a given class. That is, in normal conditions, it just returns the contents of @ISA verbatim.

However, if @ISA is empty, it returns the effective parent, UNIVERSAL unless of course, the given class is a parent of UNIVERSAL itself (insert drugs here) at which point it will return an empty list.

Because despite the fact a parent of UNIVERSAL can call UNIVERSAL methods, reporting UNIVERSAL->parent->parent == UNIVERSAL will of course create cycles for anyone who touches it.

get_linear_method_map

my $arrayref = get_linear_method_map( $classname, $method )

Returns an ArrayRef describing the vertical stack of a given method.

ISA levels without defined CodeRefs are represented as undef

$result   = [ $arrayref, $arrayref, $arrayref, ... ]
$arrayref = [ CLASSNAME, undef / CODEREF           ]

get_linear_class_map

my $arrayref = get_linear_class_map( $classname )

Returns CodeRef stashes for all packages in $classname's inheritance (including UNIVERSALs) in method-resolution-order.

Returns:

$result   = [ $arrayref, $arrayref, $arrayref,  ... ]
$arrayref = [ CLASSNAME, $submap                    ]
$submap   = { SUBNAME => CODEREF,               ... }

get_flattened_class

my $hashref = get_flattened_class( $class_name );

Returns a fully expanded "Flat" representation of a classes hierarchy, with still enough data present to trace method resolution.

Returns:

$result = { SUBNAME => $entry, ... }
$entry  = { ref     => CODEREF,
            via     => CLASSNAME,
            parents => $parentrefs, }

$parentrefs      = [ $parentref_entry, ... ]
$parentref_entry = [ CLASSNAME, CODEREF    ]

AUTHOR

Kent Fredric <kentnl@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Kent Fredric <kentfredric@gmail.com>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.