Skip to content

[detector-report] ManufacturedFakeFillDetector #581

Description

@jessegall

Detector: ManufacturedFakeFillDetector

Report (why the flagged code is CORRECT and the detector is wrong):
Binding::from() reads a recorded array whose older versions have no fills key, so absence there means the binding was recorded before the field existed. The real default is declared in the signature as public bool $fills = false and the coalesce hands that same default through a positional call, which is the design the rule prescribes. Every sibling key on the same call reads identically: subscriptions, slot, listens, alias, leaves and takes.

Where: src/View/Reactivity/Binding.php:66

Code (src/View/Reactivity/Binding.php:66):

  63              $recorded['alias'] ?? null,
  64              $recorded['leaves'] ?? [],
  65              $recorded['takes'] ?? [],
→ 66              $recorded['fills'] ?? false,
  67          );
  68      }
  69  
  70      /**
  71       * @param  array<string, mixed>  $recorded
  72       */
  73      public static function recognises(mixed $recorded): bool
  74      {
  75          return is_array($recorded)
  76              && is_string($recorded['composition'] ?? null)
  77              && is_string($recorded['method'] ?? null)
  78              && array_key_exists('parent', $recorded)
  79              && array_key_exists('boundAncestor', $recorded)
  80              && is_array($recorded['keys'] ?? null)
  81              && self::recordsSubscriptions($recorded['subscriptions'] ?? []);
  82      }
  83  
  84      public function sources(): Sources
  85      {
  86          if (! class_exists($this->composition))
  87          {
  88              return Sources::of([]);
  89          }
  90  

Where: src/View/Reactivity/Binding.php:36

Code (src/View/Reactivity/Binding.php:36):

  33          public string | null $slot = null,
  34          public array $listens = [],
  35          public string | null $alias = null,
→ 36          public array $leaves = [],
  37          public array $takes = [],
  38          public bool $fills = false,
  39      ) {}
  40  
  41      /**
  42       * @param  class-string<Composition>  $composition
  43       */
  44      public static function of(string $composition, string $method, string | null $parent = null, string | null $boundAncestor = null, string | null $alias = null): self
  45      {
  46          return new self($composition, $method, $parent, $boundAncestor, alias: $alias);
  47      }
  48  
  49      /**
  50       * @param  array{composition: class-string<Composition>, method: string, parent: string|null, boundAncestor: string|null, keys: list<string>, subscriptions?: list<array<string, mixed>>, slot?: string|null, listens?: list<string>, alias?: string|null, fills?: bool, takes?: list<class-string>}  $recorded
  51       */
  52      public static function from(array $recorded): self
  53      {
  54          return new self(
  55              $recorded['composition'],
  56              $recorded['method'],
  57              $recorded['parent'],
  58              $recorded['boundAncestor'],
  59              $recorded['keys'],
  60              array_map(Subscription::from(...), $recorded['subscriptions'] ?? []),

Where: src/View/Reactivity/Binding.php:60

Code (src/View/Reactivity/Binding.php:60):

  57              $recorded['parent'],
  58              $recorded['boundAncestor'],
  59              $recorded['keys'],
→ 60              array_map(Subscription::from(...), $recorded['subscriptions'] ?? []),
  61              $recorded['slot'] ?? null,
  62              $recorded['listens'] ?? [],
  63              $recorded['alias'] ?? null,
  64              $recorded['leaves'] ?? [],
  65              $recorded['takes'] ?? [],
  66              $recorded['fills'] ?? false,
  67          );
  68      }
  69  
  70      /**
  71       * @param  array<string, mixed>  $recorded
  72       */
  73      public static function recognises(mixed $recorded): bool
  74      {
  75          return is_array($recorded)
  76              && is_string($recorded['composition'] ?? null)
  77              && is_string($recorded['method'] ?? null)
  78              && array_key_exists('parent', $recorded)
  79              && array_key_exists('boundAncestor', $recorded)
  80              && is_array($recorded['keys'] ?? null)
  81              && self::recordsSubscriptions($recorded['subscriptions'] ?? []);
  82      }
  83  
  84      public function sources(): Sources

Filed via commandments report from a consumer project.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions