Skip to content
This repository was archived by the owner on Jul 30, 2026. It is now read-only.

NoArrayAccessOnObjectRule: Skip Symfony DomCrawler AbstractUriElement and child types - #77

Merged
TomasVotruba merged 1 commit into
mainfrom
skip-uri-element-array-access
Jul 13, 2026
Merged

NoArrayAccessOnObjectRule: Skip Symfony DomCrawler AbstractUriElement and child types#77
TomasVotruba merged 1 commit into
mainfrom
skip-uri-element-array-access

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Array access on Symfony\Component\DomCrawler\AbstractUriElement (and its children Link, Form) is a valid, intended API — it reads the underlying node attributes. This rule wrongly flagged it.

Now skipped, same as other allowed classes.

 private const ALLOWED_CLASSES = [
     'SplFixedArray',
     'SimpleXMLElement',
     'Iterator',
     'WeakMap',
     'Aws\ResultInterface',
+    'Symfony\Component\DomCrawler\AbstractUriElement',
     'Symfony\Component\Form\FormInterface',
     'Symfony\Component\OptionsResolver\Options',
 ];

Before/after on a child type (Link extends AbstractUriElement):

public function run(\Symfony\Component\DomCrawler\Link $link)
{
    return $link['href']; // before: "Use explicit methods over array access on object"
                          // after:  allowed, no error
}

The isInstanceOf() check covers AbstractUriElement and all child types.

@TomasVotruba
TomasVotruba merged commit 255b323 into main Jul 13, 2026
6 checks passed
@TomasVotruba
TomasVotruba deleted the skip-uri-element-array-access branch July 13, 2026 21:59
TomasVotruba added a commit to TomasVotruba/type-coverage that referenced this pull request Jul 28, 2026
- NoArrayAccessOnObjectRule: skip Symfony\Component\DomCrawler\AbstractUriElement (rectorphp/type-perfect#77)
- add symfony/dom-crawler dev dep for the fixture
- rector workflow: ACCESS_TOKEN expired (2023), use WORKFLOWS_TOKEN with github.token fallback
TomasVotruba added a commit to TomasVotruba/type-coverage that referenced this pull request Jul 28, 2026
* merge rector/type-perfect into packages/type-perfect

* ignore cda errors in type-perfect test fixtures

* sync type-perfect to upstream 255b323, fix rector workflow token

- NoArrayAccessOnObjectRule: skip Symfony\Component\DomCrawler\AbstractUriElement (rectorphp/type-perfect#77)
- add symfony/dom-crawler dev dep for the fixture
- rector workflow: ACCESS_TOKEN expired (2023), use WORKFLOWS_TOKEN with github.token fallback

* bump dev deps: phpunit ^13.2, ecs ^13.2, rector ^2.5
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant