src/Container.php
private function makeRule($nid) {
        $rule = isset($this->rules[$nid]) ? $this->rules[$nid] : [];

        if (class_exists($nid)) {
            for ($class = get_parent_class($nid); !empty($class); $class = get_parent_class($class)) {
                // Don't add the rule if it doesn't say to inherit.
                if (!isset($this->rules[$class]) || (isset($this->rules[$class]['inherit']) && !$this->rules[$class]['inherit'])) {
                    break;
                }
                $rule += $this->rules[$class];
            }

            // Add the default rule.
            if (!empty($this->rules['*']['inherit'])) {
                $rule += $this->rules['*'];
            }

            // Add interface calls to the rule.
            $interfaces = class_implements($nid);
            foreach ($interfaces as $interface) {
                if (isset($this->rules[$interface])) {
                    $interfaceRule = $this->rules[$interface];

                    if (isset($interfaceRule['inherit']) && $interfaceRule['inherit'] === false) {
                        continue;
                    }

                    if (!isset($rule['shared']) && isset($interfaceRule['shared'])) {
                        $rule['shared'] = $interfaceRule['shared'];
                    }

                    if (!isset($rule['constructorArgs']) && isset($interfaceRule['constructorArgs'])) {
                        $rule['constructorArgs'] = $interfaceRule['constructorArgs'];
                    }

                    if (!empty($interfaceRule['calls'])) {
                        $rule['calls'] = array_merge(
                            isset($rule['calls']) ? $rule['calls'] : [],
                            $interfaceRule['calls']
                        );
                    }
                }
            }
        } elseif (!empty($this->rules['*']['inherit'])) {
            // Add the default rule.
            $rule += $this->rules['*'];
        }

        return $rule;
    }
private function makeRule($nid) {
        $rule = isset($this->rules[$nid]) ? $this->rules[$nid] : [];

        if (class_exists($nid)) {
            for ($class = get_parent_class($nid); !empty($class); $class = get_parent_class($class)) {
                // Don't add the rule if it doesn't say to inherit.
                if (!isset($this->rules[$class]) || (isset($this->rules[$class]['inherit']) && !$this->rules[$class]['inherit'])) {
                    break;
                }
                $rule += $this->rules[$class];
            }

            // Add the default rule.
            if (!empty($this->rules['*']['inherit'])) {
                $rule += $this->rules['*'];
            }

            // Add interface calls to the rule.
            $interfaces = class_implements($nid);
            foreach ($interfaces as $interface) {
                if (isset($this->rules[$interface])) {
                    $interfaceRule = $this->rules[$interface];

                    if (isset($interfaceRule['inherit']) && $interfaceRule['inherit'] === false) {
                        continue;
                    }

                    if (!isset($rule['shared']) && isset($interfaceRule['shared'])) {
                        $rule['shared'] = $interfaceRule['shared'];
                    }

                    if (!isset($rule['constructorArgs']) && isset($interfaceRule['constructorArgs'])) {
                        $rule['constructorArgs'] = $interfaceRule['constructorArgs'];
                    }

                    if (!empty($interfaceRule['calls'])) {
                        $rule['calls'] = array_merge(
                            isset($rule['calls']) ? $rule['calls'] : [],
                            $interfaceRule['calls']
                        );
                    }
                }
            }
        } elseif (!empty($this->rules['*']['inherit'])) {
            // Add the default rule.
            $rule += $this->rules['*'];
        }

        return $rule;
    }
private function makeRule ( $ nid ) { $ rule = isset ( $ this -> rules [ $ nid ] ) ? $ this -> rules [ $ nid ] : [ ] ; if ( class_exists ( $ nid ) ) { for ( $ class = get_parent_class ( $ nid ) ; ! empty ( $ class ) ; $ class = get_parent_class ( $ class ) ) { // Don't add the rule if it doesn't say to inherit. if ( ! isset ( $ this -> rules [ $ class ] ) || ( isset ( $ this -> rules [ $ class ] [ 'inherit' ] ) && ! $ this -> rules [ $ class ] [ 'inherit' ] ) ) { break ; } $ rule += $ this -> rules [ $ class ] ; } // Add the default rule. if ( ! empty ( $ this -> rules [ '*' ] [ 'inherit' ] ) ) { $ rule += $ this -> rules [ '*' ] ; } // Add interface calls to the rule. $ interfaces = class_implements ( $ nid ) ; foreach ( $ interfaces as $ interface ) { if ( isset ( $ this -> rules [ $ interface ] ) ) { $ interfaceRule = $ this -> rules [ $ interface ] ; if ( isset ( $ interfaceRule [ 'inherit' ] ) && $ interfaceRule [ 'inherit' ] === false ) { continue ; } if ( ! isset ( $ rule [ 'shared' ] ) && isset ( $ interfaceRule [ 'shared' ] ) ) { $ rule [ 'shared' ] = $ interfaceRule [ 'shared' ] ; } if ( ! isset ( $ rule [ 'constructorArgs' ] ) && isset ( $ interfaceRule [ 'constructorArgs' ] ) ) { $ rule [ 'constructorArgs' ] = $ interfaceRule [ 'constructorArgs' ] ; } if ( ! empty ( $ interfaceRule [ 'calls' ] ) ) { $ rule [ 'calls' ] = array_merge ( isset ( $ rule [ 'calls' ] ) ? $ rule [ 'calls' ] : [ ] , $ interfaceRule [ 'calls' ] ) ; } } } } elseif ( ! empty ( $ this -> rules [ '*' ] [ 'inherit' ] ) ) { // Add the default rule. $ rule += $ this -> rules [ '*' ] ; } return $ rule ; }
Make a rule based on an ID.

@param string $nid A normalized ID.
@return array Returns an array representing a rule.
Make a rule based on an ID .