src/Phan/Language/UnionType.php

Summary

Maintainability
F
1 mo
Test Coverage

File UnionType.php has 3895 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Phan\Language;
Severity: Major
Found in src/Phan/Language/UnionType.php - About 1 wk to fix

    UnionType has 279 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class UnionType implements Serializable
    {
        /**
         * @var string
         * A list of one or more types delimited by the '|'
    Severity: Major
    Found in src/Phan/Language/UnionType.php - About 5 days to fix

      Function castTypeListToCountable has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function castTypeListToCountable(CodeBase $code_base, array $type_list, bool $assume_subclass_implements_countable): array
          {
              $result = [];
              foreach ($type_list as $type) {
                  if ($type instanceof IterableType) {
      Severity: Minor
      Found in src/Phan/Language/UnionType.php - About 7 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function merge has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function merge(array $union_types, bool $normalize_array_shapes = true): UnionType
          {
              $n = \count($union_types);
              if ($n < 2) {
                  return \reset($union_types) ?: UnionType::$empty_instance;
      Severity: Minor
      Found in src/Phan/Language/UnionType.php - About 6 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function withFlattenedTopLevelArrayShapeTypeInstancesForSet has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function withFlattenedTopLevelArrayShapeTypeInstancesForSet(array $type_set): array
          {
              $result = [];
              $has_other_array_type = false;
              $empty_array_shape_type = null;
      Severity: Minor
      Found in src/Phan/Language/UnionType.php - About 4 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function iterableKeyUnionType has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          public function iterableKeyUnionType(CodeBase $code_base): UnionType
          {
              // This is frequently called, and has been optimized
              $new_type_builder = new UnionTypeBuilder();
              foreach ($this->type_set as $type) {
      Severity: Minor
      Found in src/Phan/Language/UnionType.php - About 4 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function applyNumericOperationToList has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function applyNumericOperationToList(array $type_set, Closure $operation): array
          {
              $added_fallbacks = false;
              $result = [];
              foreach ($type_set as $type) {
      Severity: Minor
      Found in src/Phan/Language/UnionType.php - About 4 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function extractTypePartsForStringInContext has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function extractTypePartsForStringInContext(string $type_string): array
          {
              static $cache = [];
              $parts = $cache[$type_string] ?? null;
              if (\is_array($parts)) {
      Severity: Minor
      Found in src/Phan/Language/UnionType.php - About 4 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function canCastToUnionTypeHandlingTemplates has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          public function canCastToUnionTypeHandlingTemplates(
              UnionType $target,
              CodeBase $code_base
          ): bool {
              // Fast-track most common cases first
      Severity: Minor
      Found in src/Phan/Language/UnionType.php - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function canCastToUnionType has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public function canCastToUnionType(
              UnionType $target
          ): bool {
              // Fast-track most common cases first
              $type_set = $this->type_set;
      Severity: Minor
      Found in src/Phan/Language/UnionType.php - About 3 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      The class UnionType has 120 public methods. Consider refactoring UnionType to keep number of public methods under 10.
      Open

      class UnionType implements Serializable
      {
          /**
           * @var string
           * A list of one or more types delimited by the '|'
      Severity: Minor
      Found in src/Phan/Language/UnionType.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      The class UnionType has 165 non-getter- and setter-methods. Consider refactoring UnionType to keep number of methods under 25.
      Open

      class UnionType implements Serializable
      {
          /**
           * @var string
           * A list of one or more types delimited by the '|'
      Severity: Minor
      Found in src/Phan/Language/UnionType.php by phpmd

      TooManyMethods

      Since: 0.1

      A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      The default was changed from 10 to 25 in PHPMD 2.3.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanymethods

      The class UnionType has an overall complexity of 1097 which is very high. The configured complexity threshold is 50.
      Open

      class UnionType implements Serializable
      {
          /**
           * @var string
           * A list of one or more types delimited by the '|'
      Severity: Minor
      Found in src/Phan/Language/UnionType.php by phpmd

      Function asClassList has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          public function asClassList(
              CodeBase $code_base,
              Context $context
          ): Generator {
              // Iterate over each viable class type to see if any
      Severity: Minor
      Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function asNormalizedTypeSetInner has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function asNormalizedTypeSetInner(array $type_set): array
          {
              if (\count($type_set) <= 1) {
                  return $type_set;
              }
      Severity: Minor
      Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function withFlattenedArrayShapeTypeInstancesForSet has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function withFlattenedArrayShapeTypeInstancesForSet(array $type_set): array
          {
              $result = [];
              $has_other_array_type = false;
              $empty_array_shape_type = null;
      Severity: Minor
      Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function hasSubtypeOf has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public function hasSubtypeOf(
              UnionType $target
          ): bool {
              // Fast-track most common cases first
              $type_set = $this->type_set;
      Severity: Minor
      Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method merge has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function merge(array $union_types, bool $normalize_array_shapes = true): UnionType
          {
              $n = \count($union_types);
              if ($n < 2) {
                  return \reset($union_types) ?: UnionType::$empty_instance;
      Severity: Major
      Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

        Function canStrictCastToUnionType has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public function canStrictCastToUnionType(CodeBase $code_base, UnionType $target): bool
            {
                // Fast-track most common cases first
                $type_set = $this->type_set;
                // If either type is unknown, we can't call it
        Severity: Minor
        Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function withFlattenedArrayShapeOrLiteralTypeInstancesForSet has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function withFlattenedArrayShapeOrLiteralTypeInstancesForSet(array $type_set): array
            {
                $result = [];
                $has_other_array_type = false;
                $empty_array_shape_type = null;
        Severity: Minor
        Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function isStrictSubtypeOf has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            public function isStrictSubtypeOf(CodeBase $code_base, UnionType $target): bool
            {
                // Fast-track most common cases first
                $type_set = $this->type_set;
                // If either type is unknown, we can't call it
        Severity: Minor
        Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function computeRealElementTypesForDestructuringAccess has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function computeRealElementTypesForDestructuringAccess(array $real_type_set): array
            {
                $result = [];
                foreach ($real_type_set as $type) {
                    if ($type instanceof StringType) {
        Severity: Minor
        Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function computeRealElementTypesForDimAccess has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function computeRealElementTypesForDimAccess(array $real_type_set): array
            {
                $result = [];
                foreach ($real_type_set as $type) {
                    if ($type instanceof StringType) {
        Severity: Minor
        Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function applyUnaryBitwiseNotOperatorToList has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function applyUnaryBitwiseNotOperatorToList(array $type_set, bool $is_real): array
            {
                if (!$type_set) {
                    // Can be int|string
                    return UnionType::typeSetFromString($is_real ? 'int|string' : 'int');
        Severity: Minor
        Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function mergeTypeParts has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function mergeTypeParts(array $parts): array
            {
                $prev_parts = [];
                $delta = 0;
                $results = [];
        Severity: Minor
        Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Method canCastToUnionTypeHandlingTemplates has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function canCastToUnionTypeHandlingTemplates(
                UnionType $target,
                CodeBase $code_base
            ): bool {
                // Fast-track most common cases first
        Severity: Major
        Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

          Function canCastToUnionTypeWithoutConfig has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public function canCastToUnionTypeWithoutConfig(
                  UnionType $target
              ): bool {
                  // Fast-track most common cases first
                  $type_set = $this->type_set;
          Severity: Minor
          Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function internalFunctionSignatureMap has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function internalFunctionSignatureMap(int $target_php_version): array
              {
                  static $php73_map = [];
          
                  if (!$php73_map) {
          Severity: Minor
          Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function genericArrayElementTypes has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public function genericArrayElementTypes(bool $add_real_types = false): UnionType
              {
                  // This is frequently called, and has been optimized
                  $result = [];
                  $type_set = $this->type_set;
          Severity: Minor
          Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method canCastToUnionType has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function canCastToUnionType(
                  UnionType $target
              ): bool {
                  // Fast-track most common cases first
                  $type_set = $this->type_set;
          Severity: Major
          Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

            Function asGeneratorTemplateType has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                public function asGeneratorTemplateType(): Type
                {
                    $fallback_values = UnionType::empty();
                    $fallback_keys = UnionType::empty();
            
            
            Severity: Minor
            Found in src/Phan/Language/UnionType.php - About 2 hrs to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function asScalarValues has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                public function asScalarValues(bool $strict = false): ?array
                {
                    $result = [];
                    $has_null = false;
                    $has_false = false;
            Severity: Minor
            Found in src/Phan/Language/UnionType.php - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function iterableValueUnionType has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                public function iterableValueUnionType(CodeBase $code_base): UnionType
                {
                    // This is frequently called, and has been optimized
                    // TODO: Support real types if the type set is exclusively real iterable types
                    $builder = new UnionTypeBuilder();
            Severity: Minor
            Found in src/Phan/Language/UnionType.php - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method internalFunctionSignatureMap has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function internalFunctionSignatureMap(int $target_php_version): array
                {
                    static $php73_map = [];
            
                    if (!$php73_map) {
            Severity: Minor
            Found in src/Phan/Language/UnionType.php - About 1 hr to fix

              Method asClassList has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function asClassList(
                      CodeBase $code_base,
                      Context $context
                  ): Generator {
                      // Iterate over each viable class type to see if any
              Severity: Minor
              Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                Method internalFunctionSignatureMapForFQSEN has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function internalFunctionSignatureMapForFQSEN(
                        $function_fqsen
                    ): array {
                        $map = self::internalFunctionSignatureMap(Config::get_closest_target_php_version_id());
                
                
                Severity: Minor
                Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                  Method canCastToUnionTypeWithoutConfig has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function canCastToUnionTypeWithoutConfig(
                          UnionType $target
                      ): bool {
                          // Fast-track most common cases first
                          $type_set = $this->type_set;
                  Severity: Minor
                  Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                    Method hasSubtypeOf has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function hasSubtypeOf(
                            UnionType $target
                        ): bool {
                            // Fast-track most common cases first
                            $type_set = $this->type_set;
                    Severity: Minor
                    Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                      Method asScalarValues has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function asScalarValues(bool $strict = false): ?array
                          {
                              $result = [];
                              $has_null = false;
                              $has_false = false;
                      Severity: Minor
                      Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                        Function combineArrayShapeTypes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                            private static function combineArrayShapeTypes(array $types, bool $add_mixed): ArrayShapeType
                            {
                                $is_nullable = false;
                                $field_types_list = [];
                                $common_field_types = [];
                        Severity: Minor
                        Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Method castTypeListToCountable has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function castTypeListToCountable(CodeBase $code_base, array $type_list, bool $assume_subclass_implements_countable): array
                            {
                                $result = [];
                                foreach ($type_list as $type) {
                                    if ($type instanceof IterableType) {
                        Severity: Minor
                        Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                          Method isStrictSubtypeOf has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function isStrictSubtypeOf(CodeBase $code_base, UnionType $target): bool
                              {
                                  // Fast-track most common cases first
                                  $type_set = $this->type_set;
                                  // If either type is unknown, we can't call it
                          Severity: Minor
                          Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                            Method canStrictCastToUnionType has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function canStrictCastToUnionType(CodeBase $code_base, UnionType $target): bool
                                {
                                    // Fast-track most common cases first
                                    $type_set = $this->type_set;
                                    // If either type is unknown, we can't call it
                            Severity: Minor
                            Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                              Function castTypeListToClassString has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private static function castTypeListToClassString(array $type_set): array
                                  {
                                      $result = [];
                                      $is_possibly_string = false;
                                      foreach ($type_set as $type) {
                              Severity: Minor
                              Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Function normalizeArrayShapes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private static function normalizeArrayShapes(array $type_set, array $array_shape_types, array $union_types, bool $from_real_type_set): array
                                  {
                                      // If one of the union types had no array shape types, merge the array shape types of other types with the empty type
                                      $add_mixed = false;
                                      foreach ($union_types as $union_type) {
                              Severity: Minor
                              Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Method asNormalizedTypeSetInner has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private static function asNormalizedTypeSetInner(array $type_set): array
                                  {
                                      if (\count($type_set) <= 1) {
                                          return $type_set;
                                      }
                              Severity: Minor
                              Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                Method iterableKeyUnionType has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function iterableKeyUnionType(CodeBase $code_base): UnionType
                                    {
                                        // This is frequently called, and has been optimized
                                        $new_type_builder = new UnionTypeBuilder();
                                        foreach ($this->type_set as $type) {
                                Severity: Minor
                                Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                  Method iterableValueUnionType has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function iterableValueUnionType(CodeBase $code_base): UnionType
                                      {
                                          // This is frequently called, and has been optimized
                                          // TODO: Support real types if the type set is exclusively real iterable types
                                          $builder = new UnionTypeBuilder();
                                  Severity: Minor
                                  Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                    Method withFlattenedTopLevelArrayShapeTypeInstancesForSet has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        private static function withFlattenedTopLevelArrayShapeTypeInstancesForSet(array $type_set): array
                                        {
                                            $result = [];
                                            $has_other_array_type = false;
                                            $empty_array_shape_type = null;
                                    Severity: Minor
                                    Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                      Function of has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          public static function of(array $type_list, array $real_type_set = []): UnionType
                                          {
                                              $n = \count($type_list);
                                              if ($n === 0) {
                                                  if ($real_type_set) {
                                      Severity: Minor
                                      Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                      Cognitive Complexity

                                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                      A method's cognitive complexity is based on a few simple rules:

                                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                      • Code is considered more complex for each "break in the linear flow of the code"
                                      • Code is considered more complex when "flow breaking structures are nested"

                                      Further reading

                                      Function canAnyTypeStrictCastToUnionType has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          public function canAnyTypeStrictCastToUnionType(CodeBase $code_base, UnionType $target, bool $allow_casting = true): bool
                                          {
                                              foreach ($this->type_set as $type) {
                                                  if ($type instanceof IntType && !$allow_casting) {
                                                      if (!$target->hasTypeMatchingCallback(static function (Type $type): bool {
                                      Severity: Minor
                                      Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                      Cognitive Complexity

                                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                      A method's cognitive complexity is based on a few simple rules:

                                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                      • Code is considered more complex for each "break in the linear flow of the code"
                                      • Code is considered more complex when "flow breaking structures are nested"

                                      Further reading

                                      Function internalFunctionSignatureMapForFQSEN has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          public static function internalFunctionSignatureMapForFQSEN(
                                              $function_fqsen
                                          ): array {
                                              $map = self::internalFunctionSignatureMap(Config::get_closest_target_php_version_id());
                                      
                                      
                                      Severity: Minor
                                      Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                      Cognitive Complexity

                                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                      A method's cognitive complexity is based on a few simple rules:

                                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                      • Code is considered more complex for each "break in the linear flow of the code"
                                      • Code is considered more complex when "flow breaking structures are nested"

                                      Further reading

                                      Method applyNumericOperationToList has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          private static function applyNumericOperationToList(array $type_set, Closure $operation): array
                                          {
                                              $added_fallbacks = false;
                                              $result = [];
                                              foreach ($type_set as $type) {
                                      Severity: Minor
                                      Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                        Method genericArrayElementTypes has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            public function genericArrayElementTypes(bool $add_real_types = false): UnionType
                                            {
                                                // This is frequently called, and has been optimized
                                                $result = [];
                                                $type_set = $this->type_set;
                                        Severity: Minor
                                        Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                          Method extractTypePartsForStringInContext has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              private static function extractTypePartsForStringInContext(string $type_string): array
                                              {
                                                  static $cache = [];
                                                  $parts = $cache[$type_string] ?? null;
                                                  if (\is_array($parts)) {
                                          Severity: Minor
                                          Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                            Function ofUnique has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                private static function ofUnique(array $type_list, array $real_type_set = []): UnionType
                                                {
                                                    $n = \count($type_list);
                                                    if ($n === 0) {
                                                        if ($real_type_set) {
                                            Severity: Minor
                                            Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                            Cognitive Complexity

                                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                            A method's cognitive complexity is based on a few simple rules:

                                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                            • Code is considered more complex for each "break in the linear flow of the code"
                                            • Code is considered more complex when "flow breaking structures are nested"

                                            Further reading

                                            Method combineArrayShapeTypes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                            Open

                                                private static function combineArrayShapeTypes(array $types, bool $add_mixed): ArrayShapeType
                                                {
                                                    $is_nullable = false;
                                                    $field_types_list = [];
                                                    $common_field_types = [];
                                            Severity: Minor
                                            Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                              Method mergeTypeParts has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                              Open

                                                  private static function mergeTypeParts(array $parts): array
                                                  {
                                                      $prev_parts = [];
                                                      $delta = 0;
                                                      $results = [];
                                              Severity: Minor
                                              Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                                The class UnionType has 228 public methods and attributes. Consider reducing the number of public items to less than 45.
                                                Open

                                                class UnionType implements Serializable
                                                {
                                                    /**
                                                     * @var string
                                                     * A list of one or more types delimited by the '|'
                                                Severity: Minor
                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                ExcessivePublicCount

                                                Since: 0.1

                                                A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.

                                                Example

                                                public class Foo {
                                                    public $value;
                                                    public $something;
                                                    public $var;
                                                    // [... more more public attributes ...]
                                                
                                                    public function doWork() {}
                                                    public function doMoreWork() {}
                                                    public function doWorkAgain() {}
                                                    // [... more more public methods ...]
                                                }

                                                Source https://phpmd.org/rules/codesize.html#excessivepubliccount

                                                Method applyUnaryBitwiseNotOperatorToList has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                                Open

                                                    private static function applyUnaryBitwiseNotOperatorToList(array $type_set, bool $is_real): array
                                                    {
                                                        if (!$type_set) {
                                                            // Can be int|string
                                                            return UnionType::typeSetFromString($is_real ? 'int|string' : 'int');
                                                Severity: Minor
                                                Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                                  Function asClassFQSENList has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      public function asClassFQSENList(
                                                          Context $context
                                                      ): Generator {
                                                          // Iterate over each viable class type to see if any
                                                          // have the constant we're looking for
                                                  Severity: Minor
                                                  Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                                  Cognitive Complexity

                                                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                  A method's cognitive complexity is based on a few simple rules:

                                                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                  • Code is considered more complex for each "break in the linear flow of the code"
                                                  • Code is considered more complex when "flow breaking structures are nested"

                                                  Further reading

                                                  Function applyUnaryNotOperatorToList has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      private static function applyUnaryNotOperatorToList(array $type_set): array
                                                      {
                                                          $contains_falsey = false;
                                                          $contains_truthy = false;
                                                          foreach ($type_set as $type) {
                                                  Severity: Minor
                                                  Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                                  Cognitive Complexity

                                                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                  A method's cognitive complexity is based on a few simple rules:

                                                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                  • Code is considered more complex for each "break in the linear flow of the code"
                                                  • Code is considered more complex when "flow breaking structures are nested"

                                                  Further reading

                                                  Function applyBoolCastToList has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      private static function applyBoolCastToList(array $type_set): array
                                                      {
                                                          $contains_falsey = false;
                                                          $contains_truthy = false;
                                                          foreach ($type_set as $type) {
                                                  Severity: Minor
                                                  Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                                  Cognitive Complexity

                                                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                  A method's cognitive complexity is based on a few simple rules:

                                                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                  • Code is considered more complex for each "break in the linear flow of the code"
                                                  • Code is considered more complex when "flow breaking structures are nested"

                                                  Further reading

                                                  Method asGeneratorTemplateType has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                                  Open

                                                      public function asGeneratorTemplateType(): Type
                                                      {
                                                          $fallback_values = UnionType::empty();
                                                          $fallback_keys = UnionType::empty();
                                                  
                                                  
                                                  Severity: Minor
                                                  Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                                    Method computeRealElementTypesForDestructuringAccess has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                                    Open

                                                        public static function computeRealElementTypesForDestructuringAccess(array $real_type_set): array
                                                        {
                                                            $result = [];
                                                            foreach ($real_type_set as $type) {
                                                                if ($type instanceof StringType) {
                                                    Severity: Minor
                                                    Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                                      Method computeRealElementTypesForDimAccess has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                                      Open

                                                          public static function computeRealElementTypesForDimAccess(array $real_type_set): array
                                                          {
                                                              $result = [];
                                                              foreach ($real_type_set as $type) {
                                                                  if ($type instanceof StringType) {
                                                      Severity: Minor
                                                      Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                                        Method withFlattenedArrayShapeTypeInstancesForSet has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                                        Open

                                                            private static function withFlattenedArrayShapeTypeInstancesForSet(array $type_set): array
                                                            {
                                                                $result = [];
                                                                $has_other_array_type = false;
                                                                $empty_array_shape_type = null;
                                                        Severity: Minor
                                                        Found in src/Phan/Language/UnionType.php - About 1 hr to fix

                                                          Function typesWithoutSubclassesOf has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public static function typesWithoutSubclassesOf(CodeBase $code_base, array $type_set, Type $object_type): array
                                                              {
                                                                  $is_nullable = false;
                                                                  $new_type_set = [];
                                                          
                                                          
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 55 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function canCastToDeclaredType has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function canCastToDeclaredType(CodeBase $code_base, Context $context, UnionType $other): bool
                                                              {
                                                                  if ($this->isNull()) {
                                                                      return $other->containsNullableOrMixed();
                                                                  }
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 55 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function isIdenticalTo has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function isIdenticalTo(UnionType $union_type): bool
                                                              {
                                                                  if ($this === $union_type) {
                                                                      // true about half the time.
                                                                      return true;
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 55 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function canAnyTypeWeakOverlapUnionType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              protected function canAnyTypeWeakOverlapUnionType(UnionType $target): bool
                                                              {
                                                                  foreach ($this->type_set as $type) {
                                                                      foreach ($target->type_set as $other_type) {
                                                                          if ($type->weaklyOverlaps($other_type)) {
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 45 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function mergeUniqueTypes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              private static function mergeUniqueTypes(array $type_list, array $other_type_list): array
                                                              {
                                                                  if (\count($other_type_list) <= 4) {
                                                                      // NOTE: implementing it this way takes advantage of copy-on-write for small arrays.
                                                                      // If no new types were added, the original array $type_list will be reused.
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 45 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function filterTypesInBoolFamily has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              private static function filterTypesInBoolFamily(array $type_list): array
                                                              {
                                                                  $result = [];
                                                                  foreach ($type_list as $type) {
                                                                      if ($type->isInBoolFamily()) {
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 45 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function toNonNullableTypeList has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              private static function toNonNullableTypeList(array $type_list): array
                                                              {
                                                                  $result = [];
                                                                  foreach ($type_list as $type) {
                                                                      if (!$type->isNullable()) {
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 45 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function asMappedListUnionType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function asMappedListUnionType(Closure $closure): UnionType
                                                              {
                                                                  // In php 7.3, this could be replaced with https://www.php.net/array_push
                                                                  $new_type_set = [];
                                                                  foreach ($this->type_set as $type) {
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 45 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function toNonFalseyTypeSet has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              private static function toNonFalseyTypeSet(array $type_set): array
                                                              {
                                                                  $result = [];
                                                                  foreach ($type_set as $type) {
                                                                      if (!$type->isPossiblyFalsey()) {
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 45 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function toNonTruthyTypeSet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              private static function toNonTruthyTypeSet(array $type_set): array
                                                              {
                                                                  $result = [];
                                                                  foreach ($type_set as $type) {
                                                                      if (!$type->isPossiblyTruthy()) {
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 35 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function withTemplateParameterTypeMap has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function withTemplateParameterTypeMap(
                                                                  array $template_parameter_type_map
                                                              ): UnionType {
                                                                  $has_template = false;
                                                                  $concrete_type_list = [];
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 35 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function withAssociativeArraysForSet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              private static function withAssociativeArraysForSet(array $type_set, bool $can_reduce_size): array
                                                              {
                                                                  foreach ($type_set as $i => $type) {
                                                                      if (!$type instanceof ArrayType) {
                                                                          continue;
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 35 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function hasLiterals has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function hasLiterals(): bool
                                                              {
                                                                  foreach ($this->type_set as $type) {
                                                                      if ($type instanceof LiteralTypeInterface) {
                                                                          $value = $type->getValue();
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 35 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function nonTrueClone has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function nonTrueClone(): UnionType
                                                              {
                                                                  $builder = new UnionTypeBuilder();
                                                                  $did_change = false;
                                                                  foreach ($this->type_set as $type) {
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 35 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function replaceWithTemplateTypes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function replaceWithTemplateTypes(UnionType $template_union_type): UnionType
                                                              {
                                                                  if ($template_union_type->isEmpty()) {
                                                                      return $this;
                                                                  }
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 35 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Function nonFalseClone has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                          Open

                                                              public function nonFalseClone(): UnionType
                                                              {
                                                                  $builder = new UnionTypeBuilder();
                                                                  $did_change = false;
                                                                  foreach ($this->type_set as $type) {
                                                          Severity: Minor
                                                          Found in src/Phan/Language/UnionType.php - About 35 mins to fix

                                                          Cognitive Complexity

                                                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                          A method's cognitive complexity is based on a few simple rules:

                                                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                          • Code is considered more complex for each "break in the linear flow of the code"
                                                          • Code is considered more complex when "flow breaking structures are nested"

                                                          Further reading

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                      return new self($type_list, true, $real_type_set);
                                                          Severity: Major
                                                          Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                        return true;
                                                            Severity: Major
                                                            Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                              return true;
                                                              Severity: Major
                                                              Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                        return false;
                                                                Severity: Major
                                                                Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                                  return \reset($type_list)->asRealUnionType();
                                                                  Severity: Major
                                                                  Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                            return false;
                                                                    Severity: Major
                                                                    Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                                  return true;
                                                                      Severity: Major
                                                                      Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                return new self($type_list, true, $real_type_set);
                                                                        Severity: Major
                                                                        Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                          return true;
                                                                          Severity: Major
                                                                          Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                            Avoid too many return statements within this method.
                                                                            Open

                                                                                            return true;
                                                                            Severity: Major
                                                                            Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                              Avoid too many return statements within this method.
                                                                              Open

                                                                                                  return $source_type->withIsNullable(false)->canCastToAnyTypeInSet($target_type_set);
                                                                              Severity: Major
                                                                              Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                Avoid too many return statements within this method.
                                                                                Open

                                                                                        return !$union_type->isPossiblyUndefined();
                                                                                Severity: Major
                                                                                Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                  Avoid too many return statements within this method.
                                                                                  Open

                                                                                              return true;
                                                                                  Severity: Major
                                                                                  Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                    Avoid too many return statements within this method.
                                                                                    Open

                                                                                            return false;
                                                                                    Severity: Major
                                                                                    Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                      Avoid too many return statements within this method.
                                                                                      Open

                                                                                              return false;
                                                                                      Severity: Major
                                                                                      Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                        Avoid too many return statements within this method.
                                                                                        Open

                                                                                                    return new self($type_list, false, $real_type_set);
                                                                                        Severity: Major
                                                                                        Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                          Avoid too many return statements within this method.
                                                                                          Open

                                                                                                          return true;
                                                                                          Severity: Major
                                                                                          Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                            Avoid too many return statements within this method.
                                                                                            Open

                                                                                                            return true;
                                                                                            Severity: Major
                                                                                            Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                              Avoid too many return statements within this method.
                                                                                              Open

                                                                                                              return false;
                                                                                              Severity: Major
                                                                                              Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                Avoid too many return statements within this method.
                                                                                                Open

                                                                                                                return true;
                                                                                                Severity: Major
                                                                                                Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                  Avoid too many return statements within this method.
                                                                                                  Open

                                                                                                                  return true;
                                                                                                  Severity: Major
                                                                                                  Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                    Avoid too many return statements within this method.
                                                                                                    Open

                                                                                                                            return true;
                                                                                                    Severity: Major
                                                                                                    Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                      Avoid too many return statements within this method.
                                                                                                      Open

                                                                                                                  return true;
                                                                                                      Severity: Major
                                                                                                      Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                        Avoid too many return statements within this method.
                                                                                                        Open

                                                                                                                            return false;
                                                                                                        Severity: Major
                                                                                                        Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                          Avoid too many return statements within this method.
                                                                                                          Open

                                                                                                                      return true;
                                                                                                          Severity: Major
                                                                                                          Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                            Avoid too many return statements within this method.
                                                                                                            Open

                                                                                                                    return false;
                                                                                                            Severity: Major
                                                                                                            Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                              Avoid too many return statements within this method.
                                                                                                              Open

                                                                                                                          return true;
                                                                                                              Severity: Major
                                                                                                              Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                Avoid too many return statements within this method.
                                                                                                                Open

                                                                                                                        return $result;
                                                                                                                Severity: Major
                                                                                                                Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                  Avoid too many return statements within this method.
                                                                                                                  Open

                                                                                                                          return $result;
                                                                                                                  Severity: Major
                                                                                                                  Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                    Avoid too many return statements within this method.
                                                                                                                    Open

                                                                                                                                    return \reset($type_list)->asRealUnionType();
                                                                                                                    Severity: Major
                                                                                                                    Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                      Avoid too many return statements within this method.
                                                                                                                      Open

                                                                                                                                      return $this;
                                                                                                                      Severity: Major
                                                                                                                      Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                        Avoid too many return statements within this method.
                                                                                                                        Open

                                                                                                                                            return $source_type->withIsNullable(false)->canCastToAnyTypeInSetHandlingTemplates($target_type_set, $code_base);
                                                                                                                        Severity: Major
                                                                                                                        Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                          Avoid too many return statements within this method.
                                                                                                                          Open

                                                                                                                                      return true;
                                                                                                                          Severity: Major
                                                                                                                          Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                            Avoid too many return statements within this method.
                                                                                                                            Open

                                                                                                                                                return $source_type->withIsNullable(false)->canCastToAnyTypeInSetWithoutConfig($target_type_set);
                                                                                                                            Severity: Major
                                                                                                                            Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                              Avoid too many return statements within this method.
                                                                                                                              Open

                                                                                                                                              return false;
                                                                                                                              Severity: Major
                                                                                                                              Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                Avoid too many return statements within this method.
                                                                                                                                Open

                                                                                                                                                return $this;
                                                                                                                                Severity: Major
                                                                                                                                Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                  Avoid too many return statements within this method.
                                                                                                                                  Open

                                                                                                                                                  return true;
                                                                                                                                  Severity: Major
                                                                                                                                  Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                    Avoid too many return statements within this method.
                                                                                                                                    Open

                                                                                                                                                return true;
                                                                                                                                    Severity: Major
                                                                                                                                    Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                      Avoid too many return statements within this method.
                                                                                                                                      Open

                                                                                                                                                          return false;
                                                                                                                                      Severity: Major
                                                                                                                                      Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                        Avoid too many return statements within this method.
                                                                                                                                        Open

                                                                                                                                                    return true;
                                                                                                                                        Severity: Major
                                                                                                                                        Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                          Avoid too many return statements within this method.
                                                                                                                                          Open

                                                                                                                                                  return false;
                                                                                                                                          Severity: Major
                                                                                                                                          Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                            Avoid too many return statements within this method.
                                                                                                                                            Open

                                                                                                                                                        return $php71_map;
                                                                                                                                            Severity: Major
                                                                                                                                            Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                              Avoid too many return statements within this method.
                                                                                                                                              Open

                                                                                                                                                      return false;
                                                                                                                                              Severity: Major
                                                                                                                                              Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                                Avoid too many return statements within this method.
                                                                                                                                                Open

                                                                                                                                                        return $php56_map;
                                                                                                                                                Severity: Major
                                                                                                                                                Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                                  Avoid too many return statements within this method.
                                                                                                                                                  Open

                                                                                                                                                                  return null;
                                                                                                                                                  Severity: Major
                                                                                                                                                  Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                                    Avoid too many return statements within this method.
                                                                                                                                                    Open

                                                                                                                                                                    return $type->getValue();
                                                                                                                                                    Severity: Major
                                                                                                                                                    Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                                      Avoid too many return statements within this method.
                                                                                                                                                      Open

                                                                                                                                                                  return $php70_map;
                                                                                                                                                      Severity: Major
                                                                                                                                                      Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                                        Avoid too many return statements within this method.
                                                                                                                                                        Open

                                                                                                                                                                    return true;
                                                                                                                                                        Severity: Major
                                                                                                                                                        Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                                          Avoid too many return statements within this method.
                                                                                                                                                          Open

                                                                                                                                                                          return false;
                                                                                                                                                          Severity: Major
                                                                                                                                                          Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                                            Avoid too many return statements within this method.
                                                                                                                                                            Open

                                                                                                                                                                            return null;
                                                                                                                                                            Severity: Major
                                                                                                                                                            Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                                              Avoid too many return statements within this method.
                                                                                                                                                              Open

                                                                                                                                                                              return true;
                                                                                                                                                              Severity: Major
                                                                                                                                                              Found in src/Phan/Language/UnionType.php - About 30 mins to fix

                                                                                                                                                                Function normalizeMultiTypes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    public static function normalizeMultiTypes(array $types): array
                                                                                                                                                                    {
                                                                                                                                                                        foreach ($types as $i => $type) {
                                                                                                                                                                            if ($type instanceof MultiType) {
                                                                                                                                                                                foreach ($type->asIndividualTypeInstances() as $new_type) {
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php - About 25 mins to fix

                                                                                                                                                                Cognitive Complexity

                                                                                                                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                                                                                                                A method's cognitive complexity is based on a few simple rules:

                                                                                                                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                                                                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                                                                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                                                                                                                Further reading

                                                                                                                                                                Function hasPhpdocOrRealTypeMatchingCallback has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    public function hasPhpdocOrRealTypeMatchingCallback(Closure $matcher_callback): bool
                                                                                                                                                                    {
                                                                                                                                                                        foreach ($this->type_set as $type) {
                                                                                                                                                                            if ($matcher_callback($type)) {
                                                                                                                                                                                return true;
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php - About 25 mins to fix

                                                                                                                                                                Cognitive Complexity

                                                                                                                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                                                                                                                A method's cognitive complexity is based on a few simple rules:

                                                                                                                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                                                                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                                                                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                                                                                                                Further reading

                                                                                                                                                                Function getUniqueTypes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    public static function getUniqueTypes(array $type_list): array
                                                                                                                                                                    {
                                                                                                                                                                        $new_type_list = [];
                                                                                                                                                                        if (\count($type_list) >= 8) {
                                                                                                                                                                            // This approach is faster, but only when there are 8 or more types (tested in php 7.3)
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php - About 25 mins to fix

                                                                                                                                                                Cognitive Complexity

                                                                                                                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                                                                                                                A method's cognitive complexity is based on a few simple rules:

                                                                                                                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                                                                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                                                                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                                                                                                                Further reading

                                                                                                                                                                Function isExclusivelyNarrowedFormOf has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    public function isExclusivelyNarrowedFormOf(CodeBase $code_base, UnionType $other): bool
                                                                                                                                                                    {
                                                                                                                                                                        if ($other->isEmpty()) {
                                                                                                                                                                            return true;
                                                                                                                                                                        }
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php - About 25 mins to fix

                                                                                                                                                                Cognitive Complexity

                                                                                                                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                                                                                                                A method's cognitive complexity is based on a few simple rules:

                                                                                                                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                                                                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                                                                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                                                                                                                Further reading

                                                                                                                                                                Function toNumericTypes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    private static function toNumericTypes(array $type_set): array
                                                                                                                                                                    {
                                                                                                                                                                        $result = [];
                                                                                                                                                                        foreach ($type_set as $type) {
                                                                                                                                                                            if ($type->isPossiblyNumeric()) {
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php - About 25 mins to fix

                                                                                                                                                                Cognitive Complexity

                                                                                                                                                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                                                                                                                                                A method's cognitive complexity is based on a few simple rules:

                                                                                                                                                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                                                                                                                                                • Code is considered more complex for each "break in the linear flow of the code"
                                                                                                                                                                • Code is considered more complex when "flow breaking structures are nested"

                                                                                                                                                                Further reading

                                                                                                                                                                The method canCastToUnionType() has an NPath complexity of 17280. The configured NPath complexity threshold is 200.
                                                                                                                                                                Open

                                                                                                                                                                    public function canCastToUnionType(
                                                                                                                                                                        UnionType $target
                                                                                                                                                                    ): bool {
                                                                                                                                                                        // Fast-track most common cases first
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                NPathComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                                                Example

                                                                                                                                                                class Foo {
                                                                                                                                                                    function bar() {
                                                                                                                                                                        // lots of complicated code
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                                                                                                                The method canCastToUnionTypeWithoutConfig() has an NPath complexity of 1728. The configured NPath complexity threshold is 200.
                                                                                                                                                                Open

                                                                                                                                                                    public function canCastToUnionTypeWithoutConfig(
                                                                                                                                                                        UnionType $target
                                                                                                                                                                    ): bool {
                                                                                                                                                                        // Fast-track most common cases first
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                NPathComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                                                Example

                                                                                                                                                                class Foo {
                                                                                                                                                                    function bar() {
                                                                                                                                                                        // lots of complicated code
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                                                                                                                The method merge() has an NPath complexity of 80688. The configured NPath complexity threshold is 200.
                                                                                                                                                                Open

                                                                                                                                                                    public static function merge(array $union_types, bool $normalize_array_shapes = true): UnionType
                                                                                                                                                                    {
                                                                                                                                                                        $n = \count($union_types);
                                                                                                                                                                        if ($n < 2) {
                                                                                                                                                                            return \reset($union_types) ?: UnionType::$empty_instance;
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                NPathComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                                                Example

                                                                                                                                                                class Foo {
                                                                                                                                                                    function bar() {
                                                                                                                                                                        // lots of complicated code
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                                                                                                                The method canStrictCastToUnionType() has an NPath complexity of 1152. The configured NPath complexity threshold is 200.
                                                                                                                                                                Open

                                                                                                                                                                    public function canStrictCastToUnionType(CodeBase $code_base, UnionType $target): bool
                                                                                                                                                                    {
                                                                                                                                                                        // Fast-track most common cases first
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                        // If either type is unknown, we can't call it
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                NPathComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                                                Example

                                                                                                                                                                class Foo {
                                                                                                                                                                    function bar() {
                                                                                                                                                                        // lots of complicated code
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                                                                                                                The class UnionType has 6159 lines of code. Current threshold is 1000. Avoid really long classes.
                                                                                                                                                                Open

                                                                                                                                                                class UnionType implements Serializable
                                                                                                                                                                {
                                                                                                                                                                    /**
                                                                                                                                                                     * @var string
                                                                                                                                                                     * A list of one or more types delimited by the '|'
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                The method hasSubtypeOf() has an NPath complexity of 1440. The configured NPath complexity threshold is 200.
                                                                                                                                                                Open

                                                                                                                                                                    public function hasSubtypeOf(
                                                                                                                                                                        UnionType $target
                                                                                                                                                                    ): bool {
                                                                                                                                                                        // Fast-track most common cases first
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                NPathComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                                                Example

                                                                                                                                                                class Foo {
                                                                                                                                                                    function bar() {
                                                                                                                                                                        // lots of complicated code
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                                                                                                                The method internalFunctionSignatureMap() has an NPath complexity of 3584. The configured NPath complexity threshold is 200.
                                                                                                                                                                Open

                                                                                                                                                                    public static function internalFunctionSignatureMap(int $target_php_version): array
                                                                                                                                                                    {
                                                                                                                                                                        static $php73_map = [];
                                                                                                                                                                
                                                                                                                                                                        if (!$php73_map) {
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                NPathComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                                                Example

                                                                                                                                                                class Foo {
                                                                                                                                                                    function bar() {
                                                                                                                                                                        // lots of complicated code
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                                                                                                                The method canCastToUnionTypeHandlingTemplates() has an NPath complexity of 17280. The configured NPath complexity threshold is 200.
                                                                                                                                                                Open

                                                                                                                                                                    public function canCastToUnionTypeHandlingTemplates(
                                                                                                                                                                        UnionType $target,
                                                                                                                                                                        CodeBase $code_base
                                                                                                                                                                    ): bool {
                                                                                                                                                                        // Fast-track most common cases first
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                NPathComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                                                Example

                                                                                                                                                                class Foo {
                                                                                                                                                                    function bar() {
                                                                                                                                                                        // lots of complicated code
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                                                                                                                The method isStrictSubtypeOf() has an NPath complexity of 1152. The configured NPath complexity threshold is 200.
                                                                                                                                                                Open

                                                                                                                                                                    public function isStrictSubtypeOf(CodeBase $code_base, UnionType $target): bool
                                                                                                                                                                    {
                                                                                                                                                                        // Fast-track most common cases first
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                        // If either type is unknown, we can't call it
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                NPathComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                                                Example

                                                                                                                                                                class Foo {
                                                                                                                                                                    function bar() {
                                                                                                                                                                        // lots of complicated code
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                                                                                                                The method iterableKeyUnionType() has an NPath complexity of 261. The configured NPath complexity threshold is 200.
                                                                                                                                                                Open

                                                                                                                                                                    public function iterableKeyUnionType(CodeBase $code_base): UnionType
                                                                                                                                                                    {
                                                                                                                                                                        // This is frequently called, and has been optimized
                                                                                                                                                                        $new_type_builder = new UnionTypeBuilder();
                                                                                                                                                                        foreach ($this->type_set as $type) {
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                NPathComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                                                Example

                                                                                                                                                                class Foo {
                                                                                                                                                                    function bar() {
                                                                                                                                                                        // lots of complicated code
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                                                                                                                The method asNormalizedTypeSetInner() has an NPath complexity of 384. The configured NPath complexity threshold is 200.
                                                                                                                                                                Open

                                                                                                                                                                    private static function asNormalizedTypeSetInner(array $type_set): array
                                                                                                                                                                    {
                                                                                                                                                                        if (\count($type_set) <= 1) {
                                                                                                                                                                            return $type_set;
                                                                                                                                                                        }
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                NPathComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                                                                                                                                                Example

                                                                                                                                                                class Foo {
                                                                                                                                                                    function bar() {
                                                                                                                                                                        // lots of complicated code
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                                                                                                                                                The method canCastToUnionTypeHandlingTemplates() has a Cyclomatic Complexity of 23. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public function canCastToUnionTypeHandlingTemplates(
                                                                                                                                                                        UnionType $target,
                                                                                                                                                                        CodeBase $code_base
                                                                                                                                                                    ): bool {
                                                                                                                                                                        // Fast-track most common cases first
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method asGeneratorTemplateType() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public function asGeneratorTemplateType(): Type
                                                                                                                                                                    {
                                                                                                                                                                        $fallback_values = UnionType::empty();
                                                                                                                                                                        $fallback_keys = UnionType::empty();
                                                                                                                                                                
                                                                                                                                                                
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method canStrictCastToUnionType() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public function canStrictCastToUnionType(CodeBase $code_base, UnionType $target): bool
                                                                                                                                                                    {
                                                                                                                                                                        // Fast-track most common cases first
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                        // If either type is unknown, we can't call it
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method applyUnaryBitwiseNotOperatorToList() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    private static function applyUnaryBitwiseNotOperatorToList(array $type_set, bool $is_real): array
                                                                                                                                                                    {
                                                                                                                                                                        if (!$type_set) {
                                                                                                                                                                            // Can be int|string
                                                                                                                                                                            return UnionType::typeSetFromString($is_real ? 'int|string' : 'int');
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method merge() has a Cyclomatic Complexity of 25. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public static function merge(array $union_types, bool $normalize_array_shapes = true): UnionType
                                                                                                                                                                    {
                                                                                                                                                                        $n = \count($union_types);
                                                                                                                                                                        if ($n < 2) {
                                                                                                                                                                            return \reset($union_types) ?: UnionType::$empty_instance;
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method asValueOrNullOrSelf() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public function asValueOrNullOrSelf()
                                                                                                                                                                    {
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                        if (\count($type_set) !== 1) {
                                                                                                                                                                            return $this;
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method canCastToUnionType() has a Cyclomatic Complexity of 23. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public function canCastToUnionType(
                                                                                                                                                                        UnionType $target
                                                                                                                                                                    ): bool {
                                                                                                                                                                        // Fast-track most common cases first
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method castTypeListToCountable() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public static function castTypeListToCountable(CodeBase $code_base, array $type_list, bool $assume_subclass_implements_countable): array
                                                                                                                                                                    {
                                                                                                                                                                        $result = [];
                                                                                                                                                                        foreach ($type_list as $type) {
                                                                                                                                                                            if ($type instanceof IterableType) {
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method iterableKeyUnionType() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public function iterableKeyUnionType(CodeBase $code_base): UnionType
                                                                                                                                                                    {
                                                                                                                                                                        // This is frequently called, and has been optimized
                                                                                                                                                                        $new_type_builder = new UnionTypeBuilder();
                                                                                                                                                                        foreach ($this->type_set as $type) {
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method internalFunctionSignatureMap() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public static function internalFunctionSignatureMap(int $target_php_version): array
                                                                                                                                                                    {
                                                                                                                                                                        static $php73_map = [];
                                                                                                                                                                
                                                                                                                                                                        if (!$php73_map) {
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method extractTypePartsForStringInContext() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    private static function extractTypePartsForStringInContext(string $type_string): array
                                                                                                                                                                    {
                                                                                                                                                                        static $cache = [];
                                                                                                                                                                        $parts = $cache[$type_string] ?? null;
                                                                                                                                                                        if (\is_array($parts)) {
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method asNormalizedTypeSetInner() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    private static function asNormalizedTypeSetInner(array $type_set): array
                                                                                                                                                                    {
                                                                                                                                                                        if (\count($type_set) <= 1) {
                                                                                                                                                                            return $type_set;
                                                                                                                                                                        }
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method applyNumericOperationToList() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    private static function applyNumericOperationToList(array $type_set, Closure $operation): array
                                                                                                                                                                    {
                                                                                                                                                                        $added_fallbacks = false;
                                                                                                                                                                        $result = [];
                                                                                                                                                                        foreach ($type_set as $type) {
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method isStrictSubtypeOf() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public function isStrictSubtypeOf(CodeBase $code_base, UnionType $target): bool
                                                                                                                                                                    {
                                                                                                                                                                        // Fast-track most common cases first
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                        // If either type is unknown, we can't call it
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method asClassList() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public function asClassList(
                                                                                                                                                                        CodeBase $code_base,
                                                                                                                                                                        Context $context
                                                                                                                                                                    ): Generator {
                                                                                                                                                                        // Iterate over each viable class type to see if any
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method asScalarValues() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public function asScalarValues(bool $strict = false): ?array
                                                                                                                                                                    {
                                                                                                                                                                        $result = [];
                                                                                                                                                                        $has_null = false;
                                                                                                                                                                        $has_false = false;
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method genericArrayElementTypes() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public function genericArrayElementTypes(bool $add_real_types = false): UnionType
                                                                                                                                                                    {
                                                                                                                                                                        // This is frequently called, and has been optimized
                                                                                                                                                                        $result = [];
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method iterableValueUnionType() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public function iterableValueUnionType(CodeBase $code_base): UnionType
                                                                                                                                                                    {
                                                                                                                                                                        // This is frequently called, and has been optimized
                                                                                                                                                                        // TODO: Support real types if the type set is exclusively real iterable types
                                                                                                                                                                        $builder = new UnionTypeBuilder();
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method canCastToUnionTypeWithoutConfig() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public function canCastToUnionTypeWithoutConfig(
                                                                                                                                                                        UnionType $target
                                                                                                                                                                    ): bool {
                                                                                                                                                                        // Fast-track most common cases first
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method hasSubtypeOf() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public function hasSubtypeOf(
                                                                                                                                                                        UnionType $target
                                                                                                                                                                    ): bool {
                                                                                                                                                                        // Fast-track most common cases first
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method withFlattenedTopLevelArrayShapeTypeInstancesForSet() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    private static function withFlattenedTopLevelArrayShapeTypeInstancesForSet(array $type_set): array
                                                                                                                                                                    {
                                                                                                                                                                        $result = [];
                                                                                                                                                                        $has_other_array_type = false;
                                                                                                                                                                        $empty_array_shape_type = null;
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The method asSingleScalarValueOrNull() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                                                                                                                                                                Open

                                                                                                                                                                    public function asSingleScalarValueOrNull()
                                                                                                                                                                    {
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                        if (\count($type_set) !== 1) {
                                                                                                                                                                            return null;
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CyclomaticComplexity

                                                                                                                                                                Since: 0.1

                                                                                                                                                                Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                                                                                                                                                Example

                                                                                                                                                                // Cyclomatic Complexity = 11
                                                                                                                                                                class Foo {
                                                                                                                                                                1   public function example() {
                                                                                                                                                                2       if ($a == $b) {
                                                                                                                                                                3           if ($a1 == $b1) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                4           } elseif ($a2 == $b2) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            } else {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                5       } elseif ($c == $d) {
                                                                                                                                                                6           while ($c == $d) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                7        } elseif ($e == $f) {
                                                                                                                                                                8           for ($n = 0; $n < $h; $n++) {
                                                                                                                                                                                fiddle();
                                                                                                                                                                            }
                                                                                                                                                                        } else {
                                                                                                                                                                            switch ($z) {
                                                                                                                                                                9               case 1:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                10              case 2:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                11              case 3:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                                default:
                                                                                                                                                                                    fiddle();
                                                                                                                                                                                    break;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                                                                                                                                                The class UnionType has a coupling between objects value of 57. Consider to reduce the number of dependencies under 13.
                                                                                                                                                                Open

                                                                                                                                                                class UnionType implements Serializable
                                                                                                                                                                {
                                                                                                                                                                    /**
                                                                                                                                                                     * @var string
                                                                                                                                                                     * A list of one or more types delimited by the '|'
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                CouplingBetweenObjects

                                                                                                                                                                Since: 1.1.0

                                                                                                                                                                A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

                                                                                                                                                                Example

                                                                                                                                                                class Foo {
                                                                                                                                                                    /**
                                                                                                                                                                     * @var \foo\bar\X
                                                                                                                                                                     */
                                                                                                                                                                    private $x = null;
                                                                                                                                                                
                                                                                                                                                                    /**
                                                                                                                                                                     * @var \foo\bar\Y
                                                                                                                                                                     */
                                                                                                                                                                    private $y = null;
                                                                                                                                                                
                                                                                                                                                                    /**
                                                                                                                                                                     * @var \foo\bar\Z
                                                                                                                                                                     */
                                                                                                                                                                    private $z = null;
                                                                                                                                                                
                                                                                                                                                                    public function setFoo(\Foo $foo) {}
                                                                                                                                                                    public function setBar(\Bar $bar) {}
                                                                                                                                                                    public function setBaz(\Baz $baz) {}
                                                                                                                                                                
                                                                                                                                                                    /**
                                                                                                                                                                     * @return \SplObjectStorage
                                                                                                                                                                     * @throws \OutOfRangeException
                                                                                                                                                                     * @throws \InvalidArgumentException
                                                                                                                                                                     * @throws \ErrorException
                                                                                                                                                                     */
                                                                                                                                                                    public function process(\Iterator $it) {}
                                                                                                                                                                
                                                                                                                                                                    // ...
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/design.html#couplingbetweenobjects

                                                                                                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    private static function mergeTypeParts(array $parts): array
                                                                                                                                                                    {
                                                                                                                                                                        $prev_parts = [];
                                                                                                                                                                        $delta = 0;
                                                                                                                                                                        $results = [];
                                                                                                                                                                Severity: Major
                                                                                                                                                                Found in src/Phan/Language/UnionType.php and 1 other location - About 1 day to fix
                                                                                                                                                                src/Phan/Language/Element/Comment/Builder.php on lines 1325..1357

                                                                                                                                                                Duplicated Code

                                                                                                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                                                Tuning

                                                                                                                                                                This issue has a mass of 355.

                                                                                                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                                                Refactorings

                                                                                                                                                                Further Reading

                                                                                                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    public function canStrictCastToUnionType(CodeBase $code_base, UnionType $target): bool
                                                                                                                                                                    {
                                                                                                                                                                        // Fast-track most common cases first
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                        // If either type is unknown, we can't call it
                                                                                                                                                                Severity: Major
                                                                                                                                                                Found in src/Phan/Language/UnionType.php and 1 other location - About 1 day to fix
                                                                                                                                                                src/Phan/Language/UnionType.php on lines 2645..2703

                                                                                                                                                                Duplicated Code

                                                                                                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                                                Tuning

                                                                                                                                                                This issue has a mass of 305.

                                                                                                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                                                Refactorings

                                                                                                                                                                Further Reading

                                                                                                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    public function isStrictSubtypeOf(CodeBase $code_base, UnionType $target): bool
                                                                                                                                                                    {
                                                                                                                                                                        // Fast-track most common cases first
                                                                                                                                                                        $type_set = $this->type_set;
                                                                                                                                                                        // If either type is unknown, we can't call it
                                                                                                                                                                Severity: Major
                                                                                                                                                                Found in src/Phan/Language/UnionType.php and 1 other location - About 1 day to fix
                                                                                                                                                                src/Phan/Language/UnionType.php on lines 2573..2631

                                                                                                                                                                Duplicated Code

                                                                                                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                                                Tuning

                                                                                                                                                                This issue has a mass of 305.

                                                                                                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                                                Refactorings

                                                                                                                                                                Further Reading

                                                                                                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    public function asExpandedTypesPreservingTemplate(
                                                                                                                                                                        CodeBase $code_base,
                                                                                                                                                                        int $recursion_depth = 0
                                                                                                                                                                    ): UnionType {
                                                                                                                                                                        if ($recursion_depth >= 12) {
                                                                                                                                                                Severity: Major
                                                                                                                                                                Found in src/Phan/Language/UnionType.php and 1 other location - About 4 hrs to fix
                                                                                                                                                                src/Phan/Language/UnionType.php on lines 4376..4407

                                                                                                                                                                Duplicated Code

                                                                                                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                                                Tuning

                                                                                                                                                                This issue has a mass of 173.

                                                                                                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                                                Refactorings

                                                                                                                                                                Further Reading

                                                                                                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    public function asExpandedTypes(
                                                                                                                                                                        CodeBase $code_base,
                                                                                                                                                                        int $recursion_depth = 0
                                                                                                                                                                    ): UnionType {
                                                                                                                                                                        // TODO: Preserve the original real types without expanding them?
                                                                                                                                                                Severity: Major
                                                                                                                                                                Found in src/Phan/Language/UnionType.php and 1 other location - About 4 hrs to fix
                                                                                                                                                                src/Phan/Language/UnionType.php on lines 4422..4452

                                                                                                                                                                Duplicated Code

                                                                                                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                                                Tuning

                                                                                                                                                                This issue has a mass of 173.

                                                                                                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                                                Refactorings

                                                                                                                                                                Further Reading

                                                                                                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    public static function computeRealElementTypesForDestructuringAccess(array $real_type_set): array
                                                                                                                                                                    {
                                                                                                                                                                        $result = [];
                                                                                                                                                                        foreach ($real_type_set as $type) {
                                                                                                                                                                            if ($type instanceof StringType) {
                                                                                                                                                                Severity: Major
                                                                                                                                                                Found in src/Phan/Language/UnionType.php and 1 other location - About 3 hrs to fix
                                                                                                                                                                src/Phan/Language/UnionType.php on lines 4068..4101

                                                                                                                                                                Duplicated Code

                                                                                                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                                                Tuning

                                                                                                                                                                This issue has a mass of 156.

                                                                                                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                                                Refactorings

                                                                                                                                                                Further Reading

                                                                                                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    public static function computeRealElementTypesForDimAccess(array $real_type_set): array
                                                                                                                                                                    {
                                                                                                                                                                        $result = [];
                                                                                                                                                                        foreach ($real_type_set as $type) {
                                                                                                                                                                            if ($type instanceof StringType) {
                                                                                                                                                                Severity: Major
                                                                                                                                                                Found in src/Phan/Language/UnionType.php and 1 other location - About 3 hrs to fix
                                                                                                                                                                src/Phan/Language/UnionType.php on lines 4109..4142

                                                                                                                                                                Duplicated Code

                                                                                                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                                                Tuning

                                                                                                                                                                This issue has a mass of 156.

                                                                                                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                                                Refactorings

                                                                                                                                                                Further Reading

                                                                                                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    private static function convertToTypeSetWithNormalizedNonNullableBools(UnionTypeBuilder $builder): void
                                                                                                                                                                    {
                                                                                                                                                                        static $true_type = null;
                                                                                                                                                                        static $false_type = null;
                                                                                                                                                                        static $bool_type = null;
                                                                                                                                                                Severity: Major
                                                                                                                                                                Found in src/Phan/Language/UnionType.php and 1 other location - About 2 hrs to fix
                                                                                                                                                                src/Phan/Language/UnionType.php on lines 5051..5067

                                                                                                                                                                Duplicated Code

                                                                                                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                                                Tuning

                                                                                                                                                                This issue has a mass of 141.

                                                                                                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                                                Refactorings

                                                                                                                                                                Further Reading

                                                                                                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    private static function convertToTypeSetWithNormalizedNullableBools(UnionTypeBuilder $builder): void
                                                                                                                                                                    {
                                                                                                                                                                        static $true_type = null;
                                                                                                                                                                        static $false_type = null;
                                                                                                                                                                        static $bool_type = null;
                                                                                                                                                                Severity: Major
                                                                                                                                                                Found in src/Phan/Language/UnionType.php and 1 other location - About 2 hrs to fix
                                                                                                                                                                src/Phan/Language/UnionType.php on lines 5027..5043

                                                                                                                                                                Duplicated Code

                                                                                                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                                                Tuning

                                                                                                                                                                This issue has a mass of 141.

                                                                                                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                                                Refactorings

                                                                                                                                                                Further Reading

                                                                                                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    private static function applyUnaryNotOperatorToList(array $type_set): array
                                                                                                                                                                    {
                                                                                                                                                                        $contains_falsey = false;
                                                                                                                                                                        $contains_truthy = false;
                                                                                                                                                                        foreach ($type_set as $type) {
                                                                                                                                                                Severity: Major
                                                                                                                                                                Found in src/Phan/Language/UnionType.php and 1 other location - About 2 hrs to fix
                                                                                                                                                                src/Phan/Language/UnionType.php on lines 5690..5711

                                                                                                                                                                Duplicated Code

                                                                                                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                                                Tuning

                                                                                                                                                                This issue has a mass of 128.

                                                                                                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                                                Refactorings

                                                                                                                                                                Further Reading

                                                                                                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    private static function applyBoolCastToList(array $type_set): array
                                                                                                                                                                    {
                                                                                                                                                                        $contains_falsey = false;
                                                                                                                                                                        $contains_truthy = false;
                                                                                                                                                                        foreach ($type_set as $type) {
                                                                                                                                                                Severity: Major
                                                                                                                                                                Found in src/Phan/Language/UnionType.php and 1 other location - About 2 hrs to fix
                                                                                                                                                                src/Phan/Language/UnionType.php on lines 5652..5673

                                                                                                                                                                Duplicated Code

                                                                                                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                                                Tuning

                                                                                                                                                                This issue has a mass of 128.

                                                                                                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                                                Refactorings

                                                                                                                                                                Further Reading

                                                                                                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    public function nonTrueClone(): UnionType
                                                                                                                                                                    {
                                                                                                                                                                        $builder = new UnionTypeBuilder();
                                                                                                                                                                        $did_change = false;
                                                                                                                                                                        foreach ($this->type_set as $type) {
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php and 1 other location - About 55 mins to fix
                                                                                                                                                                src/Phan/Language/UnionType.php on lines 1865..1884

                                                                                                                                                                Duplicated Code

                                                                                                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                                                Tuning

                                                                                                                                                                This issue has a mass of 99.

                                                                                                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                                                Refactorings

                                                                                                                                                                Further Reading

                                                                                                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    public function nonFalseClone(): UnionType
                                                                                                                                                                    {
                                                                                                                                                                        $builder = new UnionTypeBuilder();
                                                                                                                                                                        $did_change = false;
                                                                                                                                                                        foreach ($this->type_set as $type) {
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php and 1 other location - About 55 mins to fix
                                                                                                                                                                src/Phan/Language/UnionType.php on lines 1890..1909

                                                                                                                                                                Duplicated Code

                                                                                                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                                                Tuning

                                                                                                                                                                This issue has a mass of 99.

                                                                                                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                                                Refactorings

                                                                                                                                                                Further Reading

                                                                                                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                                                                                                Open

                                                                                                                                                                    private static function extractTypeParts(string $type_string): array
                                                                                                                                                                    {
                                                                                                                                                                        $parts = [];
                                                                                                                                                                        foreach (\preg_split('@[|&]@', $type_string) as $part) {
                                                                                                                                                                            $parts[] = \trim($part);
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php and 1 other location - About 50 mins to fix
                                                                                                                                                                src/Phan/Language/Element/Comment/Builder.php on lines 1304..1318

                                                                                                                                                                Duplicated Code

                                                                                                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                                                                                                Tuning

                                                                                                                                                                This issue has a mass of 97.

                                                                                                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                                                Refactorings

                                                                                                                                                                Further Reading

                                                                                                                                                                Avoid using short method names like UnionType::of(). The configured minimum method name length is 3.
                                                                                                                                                                Open

                                                                                                                                                                    public static function of(array $type_list, array $real_type_set = []): UnionType
                                                                                                                                                                    {
                                                                                                                                                                        $n = \count($type_list);
                                                                                                                                                                        if ($n === 0) {
                                                                                                                                                                            if ($real_type_set) {
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                ShortMethodName

                                                                                                                                                                Since: 0.2

                                                                                                                                                                Detects when very short method names are used.

                                                                                                                                                                Example

                                                                                                                                                                class ShortMethod {
                                                                                                                                                                    public function a( $index ) { // Violation
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/naming.html#shortmethodname

                                                                                                                                                                Avoid variables with short names like $cb. Configured minimum length is 3.
                                                                                                                                                                Open

                                                                                                                                                                    public function makeFromFilter(Closure $cb): UnionType
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                ShortVariable

                                                                                                                                                                Since: 0.2

                                                                                                                                                                Detects when a field, local, or parameter has a very short name.

                                                                                                                                                                Example

                                                                                                                                                                class Something {
                                                                                                                                                                    private $q = 15; // VIOLATION - Field
                                                                                                                                                                    public static function main( array $as ) { // VIOLATION - Formal
                                                                                                                                                                        $r = 20 + $this->q; // VIOLATION - Local
                                                                                                                                                                        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                                                                                                                                                            $r += $this->q;
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/naming.html#shortvariable

                                                                                                                                                                Avoid variables with short names like $n. Configured minimum length is 3.
                                                                                                                                                                Open

                                                                                                                                                                        $n = \count($union_types);
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                ShortVariable

                                                                                                                                                                Since: 0.2

                                                                                                                                                                Detects when a field, local, or parameter has a very short name.

                                                                                                                                                                Example

                                                                                                                                                                class Something {
                                                                                                                                                                    private $q = 15; // VIOLATION - Field
                                                                                                                                                                    public static function main( array $as ) { // VIOLATION - Formal
                                                                                                                                                                        $r = 20 + $this->q; // VIOLATION - Local
                                                                                                                                                                        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                                                                                                                                                            $r += $this->q;
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/naming.html#shortvariable

                                                                                                                                                                Avoid variables with short names like $n. Configured minimum length is 3.
                                                                                                                                                                Open

                                                                                                                                                                        $n = \count($type_list);
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                ShortVariable

                                                                                                                                                                Since: 0.2

                                                                                                                                                                Detects when a field, local, or parameter has a very short name.

                                                                                                                                                                Example

                                                                                                                                                                class Something {
                                                                                                                                                                    private $q = 15; // VIOLATION - Field
                                                                                                                                                                    public static function main( array $as ) { // VIOLATION - Formal
                                                                                                                                                                        $r = 20 + $this->q; // VIOLATION - Local
                                                                                                                                                                        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                                                                                                                                                            $r += $this->q;
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/naming.html#shortvariable

                                                                                                                                                                Avoid variables with short names like $n. Configured minimum length is 3.
                                                                                                                                                                Open

                                                                                                                                                                        $n = \count($type_list);
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                ShortVariable

                                                                                                                                                                Since: 0.2

                                                                                                                                                                Detects when a field, local, or parameter has a very short name.

                                                                                                                                                                Example

                                                                                                                                                                class Something {
                                                                                                                                                                    private $q = 15; // VIOLATION - Field
                                                                                                                                                                    public static function main( array $as ) { // VIOLATION - Formal
                                                                                                                                                                        $r = 20 + $this->q; // VIOLATION - Local
                                                                                                                                                                        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                                                                                                                                                            $r += $this->q;
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/naming.html#shortvariable

                                                                                                                                                                Avoid variables with short names like $i. Configured minimum length is 3.
                                                                                                                                                                Open

                                                                                                                                                                        $i = \strpos($serialized, "\x00");
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                ShortVariable

                                                                                                                                                                Since: 0.2

                                                                                                                                                                Detects when a field, local, or parameter has a very short name.

                                                                                                                                                                Example

                                                                                                                                                                class Something {
                                                                                                                                                                    private $q = 15; // VIOLATION - Field
                                                                                                                                                                    public static function main( array $as ) { // VIOLATION - Formal
                                                                                                                                                                        $r = 20 + $this->q; // VIOLATION - Local
                                                                                                                                                                        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                                                                                                                                                            $r += $this->q;
                                                                                                                                                                        }
                                                                                                                                                                    }
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/naming.html#shortvariable

                                                                                                                                                                Constant union_type_regex_or_this should be defined in uppercase
                                                                                                                                                                Open

                                                                                                                                                                    public const union_type_regex_or_this =
                                                                                                                                                                        Type::type_regex_or_this
                                                                                                                                                                        . '(\s*[|&]\s*' . Type::type_regex_or_this . ')*';
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                ConstantNamingConventions

                                                                                                                                                                Since: 0.2

                                                                                                                                                                Class/Interface constant names should always be defined in uppercase.

                                                                                                                                                                Example

                                                                                                                                                                class Foo {
                                                                                                                                                                    const MY_NUM = 0; // ok
                                                                                                                                                                    const myTest = ""; // fail
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/naming.html#constantnamingconventions

                                                                                                                                                                Constant union_type_regex should be defined in uppercase
                                                                                                                                                                Open

                                                                                                                                                                    public const union_type_regex =
                                                                                                                                                                        Type::type_regex
                                                                                                                                                                        . '(\s*[|&]\s*' . Type::type_regex . ')*';
                                                                                                                                                                Severity: Minor
                                                                                                                                                                Found in src/Phan/Language/UnionType.php by phpmd

                                                                                                                                                                ConstantNamingConventions

                                                                                                                                                                Since: 0.2

                                                                                                                                                                Class/Interface constant names should always be defined in uppercase.

                                                                                                                                                                Example

                                                                                                                                                                class Foo {
                                                                                                                                                                    const MY_NUM = 0; // ok
                                                                                                                                                                    const myTest = ""; // fail
                                                                                                                                                                }

                                                                                                                                                                Source https://phpmd.org/rules/naming.html#constantnamingconventions

                                                                                                                                                                There are no issues that match your filters.

                                                                                                                                                                Category
                                                                                                                                                                Status