---
title: "lint/style/no-array-push"
pagination: false
---

{/* Generated by scripts/gen-rule-docs.py. Edit mapping.toml, not this file. */}

<RuleId id="lint/style/no-array-push" />

In the [`code-quality`](/docs/rules/sets/code-quality) set. Unsafe fix: it can change behaviour.

## What it does

Converts simple usages of `array_push($x, $y);` to `$x[] = $y;`.

## Configuration

```toml title="pun.toml"
[lint.rules]
"style/no-array-push" = "error"
```

To skip it in some files, add an [override](/docs/configuration/pun-toml#lint) or a [`@pun-ignore-file`](/docs/configuration/ignore-comments) comment.

## Replaces

- [`array_push`](https://cs.symfony.com/doc/rules/alias/array_push.html) (php-cs-fixer, risky)
- [`ChangeArrayPushToArrayAssign`](https://getrector.com/rule-detail/change-array-push-to-array-assign-rector) (rector)

## Merged rules

These old IDs are now this rule. A config that still names one stops with an error. See [merged rules](/docs/migrate/merged-rules).

- `lint/arrays/prefer-array-append`

[More lint/style rules](/docs/rules/lint/style) · [Edit this page](https://github.com/shipfastlabs/pun/edit/main/crates/pun-config/rules/mapping.toml)
