| 1 | package Fukurama::Class::Attributes::OOStandard::InheritationCheck; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use Fukurama::Class::Version(0.02); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use Fukurama::Class::Rigid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use Fukurama::Class::Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Fukurama::Class::Tree(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | my $AVOID_DOUBLE_INHERIT_ERRORS = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | my $IGNORE_UNOVERWRITABLE_TYPE = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 'implements' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | Fukurama::Class::Attributes::OOStandard::InheritationCheck - Helper-class to check the inheritation of code attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | Version 0.02 (beta) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | - (its only a collection of methods, it's unusable outside of it's own context :) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | A helper class for Fukurama::Class::Attributes::OOStandard to check code attribute syntax. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | =head1 EXPORT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | =item check_inheritation( method_name:STRING, parent_class:CLASS, child_class:CLASS, inheritation_type:STRING, definition_data:\HASH ) return:VOID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | Check the inheritations of all defined declarations to avoid differend method signatures for parent and child. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | =head1 AUTHOR, BUGS, SUPPORT, ACKNOWLEDGEMENTS, COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | see perldoc of L<Fukurama::Class> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # STATIC void | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 262 | ▶ | sub _check_level_contains { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_level_contains: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 262 | my $class = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 262 | my $level = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 262 | ▶ | _croak("Internal error: check-level '$level' is not defined in attribute-class") if(!defined(${"Fukurama\::Class\::Attributes\::OOStandard\::$level"})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 262 | ▶ | return 1 if($Fukurama::Class::Attributes::OOStandard::CHECK_LEVEL >= ${"Fukurama\::Class\::Attributes\::OOStandard\::$level"}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # STATIC void | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 152 | ▶ | sub check_inheritation { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_inheritation: called CC=16 SCAR=28.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 152 | my $class = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 152 | my $method_name = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 152 | my $parent_class = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 152 | my $child_class = $_[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 152 | my $inheritation_type = $_[4]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 152 | my $definition_data = $_[5]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 152 | ▶ | return if(!$class->_check_level_contains('LEVEL_CHECK_SYNTAX')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 152 | my $parent_id = "$parent_class\::$method_name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 152 | my $child_id = "$child_class\::$method_name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 152 | ▶ | if(Fukurama::Class::Tree->is_special_sub($method_name)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 42 | ▶ | if($definition_data->{'register'}->{$parent_id}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $class->_throw_inherit_error("You can't defined any attribute for perl-intern subroutine", $parent_class, $method_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 42 | ▶ | if($definition_data->{'register'}->{$child_id}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $class->_throw_inherit_error("You can't defined any attribute for perl-intern subroutine", $child_class, $method_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 42 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 110 | my $parent_exist = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 110 | my $child_exist = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 110 | ▶ | $parent_exist = 1 if(*{$parent_id}{'CODE'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 110 | ▶ | $child_exist = 1 if(*{$child_id}{'CODE'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 110 | my $parent = $definition_data->{'register'}->{$parent_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 110 | my $child = $definition_data->{'register'}->{$child_id}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 110 | ▶ | if($class->_check_level_contains('LEVEL_CHECK_FORCE_ATTRIBUTES')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 110 | ▶ | if(!$definition_data->{'register'}->{$parent_id} && $parent_exist) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $definition_data->{"register"}{$parent_id} and $parent_exist
MC/DC0%0/2
not $definition_data->{"register"}{$parent_id} and $parent_exist
not $definition_data->{"register"}{$parent_id}
$parent_exist
Truth table66%2/3
not(A) and B
A= not $definition_data->{"register"}{$parent_id}B= $parent_exist
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $class->_throw_inherit_error("You don't have defined any attribute for", $parent_class, $method_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 110 | ▶ | if(!$definition_data->{'register'}->{$child_id} && $child_exist) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $definition_data->{"register"}{$child_id} and $child_exist
MC/DC0%0/2
not $definition_data->{"register"}{$child_id} and $child_exist
not $definition_data->{"register"}{$child_id}
$child_exist
Truth table66%2/3
not(A) and B
A= not $definition_data->{"register"}{$child_id}B= $child_exist
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $class->_throw_inherit_error("You don't have defined any attribute for", $child_class, $method_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 110 | $class->_check_attribute_inheritation($parent, $parent_exist, $parent_class, $child, $child_exist, $child_class, $method_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 110 | $class->_check_inheritation_type($parent, $parent_exist, $parent_class, $child, $child_exist, $child_class, $method_name, $inheritation_type, $definition_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 110 | ▶ | if($parent_exist && $parent && $child_exist && $child) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$parent_exist and $parent and $child_exist and $child
$parent_exist and $parent and $child_exist
$parent_exist and $parent
MC/DC50%2/4
$parent_exist and $parent and $child_exist and $child
$parent_exist
$parent
$child_exist
$child
Truth table60%3/5
A and B and C and D
A= $parent_existB= $parentC= $child_existD= $child
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 68 | $class->_compare_definitions($parent, $child, $definition_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 110 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # STATIC void | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 110 | ▶ | sub _check_attribute_inheritation { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_attribute_inheritation: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 110 | my $class = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 110 | my $parent = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 110 | my $parent_exist = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 110 | my $parent_class = $_[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 110 | my $child = $_[4]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 110 | my $child_exist = $_[5]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 110 | my $child_class = $_[6]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 110 | my $method_name = $_[7]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 110 | ▶ | if($parent_exist && $parent && $child_exist && !$child) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$parent_exist and $parent and $child_exist and not $child
$parent_exist and $parent and $child_exist
$parent_exist and $parent
MC/DC0%0/4
$parent_exist and $parent and $child_exist and not $child
$parent_exist
$parent
$child_exist
not $child
Truth table60%3/5
A and B and C and not(D)
A= $parent_existB= $parentC= $child_existD= not $child
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $class->_throw_inherit_error("You don't have defined any attribute for child of " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | "'$parent_class->$method_name', which has an attribute ", $child_class, $method_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 110 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # STATIC void | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 110 | ▶ | sub _check_inheritation_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_inheritation_type: called CC=11 SCAR=29.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 110 | my $class = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 110 | my $parent = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 110 | my $parent_exist = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 110 | my $parent_class = $_[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 110 | my $child = $_[4]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 110 | my $child_exist = $_[5]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 110 | my $child_class = $_[6]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 110 | my $method_name = $_[7]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 110 | my $inheritation_type = $_[8]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 110 | my $definition_data = $_[9]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 110 | ▶ | return if(!$parent_exist || !$parent); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$parent_exist and $parent
MC/DC50%1/2
$parent_exist and $parent
$parent_exist
$parent
Truth table66%2/3
A and B
A= $parent_existB= $parent
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 96 | ▶ | if($definition_data->{'type'}->{$parent->{'type'}} eq 'unoverwritable') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 4 | ▶ | if($child_exist && !$IGNORE_UNOVERWRITABLE_TYPE->{$inheritation_type}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$child_exist and not $IGNORE_UNOVERWRITABLE_TYPE->{$inheritation_type}
MC/DC0%0/2
$child_exist and not $IGNORE_UNOVERWRITABLE_TYPE->{$inheritation_type}
$child_exist
not $IGNORE_UNOVERWRITABLE_TYPE->{$inheritation_type}
Truth table33%1/3
A and not(B)
A= $child_existB= not $IGNORE_UNOVERWRITABLE_TYPE->{$inheritation_type}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $class->_throw_inherit_error("You've overwritten the method '$parent_class->$method_name', " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | "which is defined as '$parent->{'type'}'", $child_class, $method_name, $inheritation_type); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } elsif($definition_data->{'type'}->{$parent->{'type'}} eq 'overwrite') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if(!$child_exist) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $class->_throw_inherit_error("You don't have overwritten the method '$parent_class->$method_name', " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | "which is defined as '$parent->{'type'}'", $child_class, $method_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 96 | ▶ | if($definition_data->{'access_level_type'}->{$parent->{'access_level'}} eq 'unoverwritable') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if($child_exist && !$IGNORE_UNOVERWRITABLE_TYPE->{$inheritation_type}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$child_exist and not $IGNORE_UNOVERWRITABLE_TYPE->{$inheritation_type}
MC/DC0%0/2
$child_exist and not $IGNORE_UNOVERWRITABLE_TYPE->{$inheritation_type}
$child_exist
not $IGNORE_UNOVERWRITABLE_TYPE->{$inheritation_type}
Truth table0%0/3
A and not(B)
A= $child_existB= not $IGNORE_UNOVERWRITABLE_TYPE->{$inheritation_type}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $class->_throw_inherit_error("You've overwritten the method '$parent_class->$method_name', " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | "which is defined as '$parent->{'access_level'}'", $child_class, $method_name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 96 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # STATIC void | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 68 | ▶ | sub _compare_definitions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compare_definitions: called CC=7 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 68 | my $class = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 68 | my $parent = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 68 | my $child = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 68 | my $definition_data = $_[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 68 | ▶ | if($parent->{'sub_data'}->{'attribute'} ne $child->{'sub_data'}->{'attribute'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $class->_throw_compare_error("Child and parent have to be the same subroutine type ($parent->{'sub_data'}->{'attribute'})", $parent, $child); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 68 | ▶ | if($parent->{'sub_data'}->{'sub_name'} ne $child->{'sub_data'}->{'sub_name'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $class->_throw_compare_error("INTERNAL ERROR: compare different subroutine-names", $parent, $child); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 68 | ▶ | if($parent->{'static'} ne $child->{'static'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | $class->_throw_compare_error("Child and parent have to be the same access type (" . ($parent->{'static'} ? 'static' : 'non static') . ")", $parent, $child); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 68 | ▶ | if($definition_data->{'access_level'}->{$child->{'access_level'}} != $definition_data->{'access_level'}->{$parent->{'access_level'}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | $class->_throw_compare_error("The child-access-level ($child->{'access_level'}) can't be another as the parent-access-level ($parent->{'access_level'})", $parent, $child); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 68 | my $io_errors = $class->_compare_list($parent, $child, 'para', 'parameter', 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 68 | push(@$io_errors, @{$class->_compare_list($parent, $child, 'opt_para', 'optional parameter', 1)}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 68 | push(@$io_errors, @{$class->_compare_list($parent, $child, 'result', '$return value', 0)}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 68 | push(@$io_errors, @{$class->_compare_list($parent, $child, 'array_result', '@return value', 1)}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 68 | ▶ | if(scalar(@$io_errors)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $class->_throw_compare_error(join("\n", @$io_errors), $parent, $child); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 68 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # STATIC srting[] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 272 | ▶ | sub _compare_list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compare_list: called CC=14 SCAR=28.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 272 | my $class = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 272 | my $parent = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 272 | my $child = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 272 | my $io_key = $_[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 272 | my $io_type = $_[4]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 272 | my $child_can_extend = $_[5]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 272 | my $errors = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 272 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 272 | while(1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 512 | my $parent_io = $parent->{$io_key}->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 512 | my $child_io = $child->{$io_key}->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 512 | ▶ | last if(!$parent_io && !$child_io); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$parent_io or $child_io
MC/DC100%2/2
$parent_io or $child_io
$parent_io
$child_io
Truth table100%3/3
A or B
A= $parent_ioB= $child_io
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 240 | my $error_prefix = "> - $io_type " . ($i + 1) . ': '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 240 | ▶ | if(!$parent_io && $child_io) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
not $parent_io and $child_io
MC/DC50%1/2
not $parent_io and $child_io
not $parent_io
$child_io
Truth table66%2/3
not(A) and B
A= not $parent_ioB= $child_io
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 18 | ▶ | if(!$child_can_extend) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | push(@$errors, "$error_prefix no further $io_type is/are allowed in child " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | "(- <> $child_io->{'type'}$child_io->{'ref'})."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | ▶ | } elsif($parent_io && !$child_io) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$parent_io and not $child_io
MC/DC0%0/2
$parent_io and not $child_io
$parent_io
not $child_io
Truth table33%1/3
A and not(B)
A= $parent_ioB= not $child_io
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | push(@$errors, "$error_prefix child has less ${io_type}s than parent " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | "($parent_io->{'type'}$parent_io->{'ref'} <> -)."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | ▶ | } elsif($parent_io->{'ref'} ne $child_io->{'ref'} || $parent_io->{'type'} ne $child_io->{'type'}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$parent_io->{"ref"} ne $child_io->{"ref"} or $parent_io->{"type"} ne $child_io->{"type"}
MC/DC50%1/2
$parent_io->{"ref"} ne $child_io->{"ref"} or $parent_io->{"type"} ne $child_io->{"type"}
$parent_io->{"ref"} ne $child_io->{"ref"}
$parent_io->{"type"} ne $child_io->{"type"}
Truth table66%2/3
A or B
A= $parent_io->{"ref"} ne $child_io->{"ref"}B= $parent_io->{"type"} ne $child_io->{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 42 | ▶ | if($parent_io->{'check'}->{'is_class'} && $parent_io->{'ref'} eq $child_io->{'ref'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$parent_io->{"check"}{"is_class"} and $parent_io->{"ref"} eq $child_io->{"ref"}
MC/DC0%0/2
$parent_io->{"check"}{"is_class"} and $parent_io->{"ref"} eq $child_io->{"ref"}
$parent_io->{"check"}{"is_class"}
$parent_io->{"ref"} eq $child_io->{"ref"}
Truth table33%1/3
A and B
A= $parent_io->{"check"}{"is_class"}B= $parent_io->{"ref"} eq $child_io->{"ref"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 42 | ▶ | if(!UNIVERSAL::isa($child_io->{'type'}, $parent_io->{'type'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | push(@$errors, "$error_prefix childs ${io_type}-class doesnt inherit from parents ${io_type}-class " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | "($parent_io->{'type'}$parent_io->{'ref'} <> $child_io->{'type'}$child_io->{'ref'})."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | push(@$errors, "$error_prefix child has different ${io_type}-definition than parent " . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | "($parent_io->{'type'}$parent_io->{'ref'} <> $child_io->{'type'}$child_io->{'ref'})."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 240 | ++$i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 272 | ▶ | unshift(@$errors, "Error(s) in $io_type:") if(scalar(@$errors)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 272 | return $errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # STATIC void | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | sub _throw_compare_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_throw_compare_error: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $class = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my $msg = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $parent = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my $child = $_[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $parent_d = $parent->{'sub_data'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my $child_d = $child->{'sub_data'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $parent_subdef = "$parent_d->{'class'}->$parent_d->{'sub_name'} : $parent_d->{'attribute'}($parent_d->{'data'})"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my $child_subdef = "$child_d->{'class'}->$child_d->{'sub_name'} : $child_d->{'attribute'}($child_d->{'data'})"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my $error = "Error in $parent->{'sub_data'}->{'attribute'} definition:\n> $msg\n> parent: $parent_subdef\n> child: $child_subdef\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | if(!$AVOID_DOUBLE_INHERIT_ERRORS->{$error}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $AVOID_DOUBLE_INHERIT_ERRORS->{$error} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | _croak($error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # STATIC void | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | sub _throw_inherit_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_throw_inherit_error: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my $class = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my $msg = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my $classname = $_[2]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my $subname = $_[3]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | my $inheritation_type = $_[4]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | my $type = ($inheritation_type ? " with '$inheritation_type'" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my $error = "Error in subroutine definition$type:\n> $msg\n> class: '$classname', subroutine '$subname'\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if(!$AVOID_DOUBLE_INHERIT_ERRORS->{$error}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $AVOID_DOUBLE_INHERIT_ERRORS->{$error} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | _croak($error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||