php / php/php-src

Proposal: Dump circular references in var_export() using IIFE

Open
#14,980 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Extension: standard Feature Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

When having $a = array(&$a) and calling var_export($a), instead of getting

PHP Warning:  var_export does not handle circular references in php shell code on line 1
array (
  0 => NULL,
)

we could make it return an IIFE like ((function(){$a = array(&$a);return $a;})()) so we can declare that circular reference using a variable without the risk to change variables in the code where the output of var_export() will be used.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the circular-reference example with var_export() and inspect its implementation and existing tests for circular references. Done means var_export() can represent the self-reference using the proposed IIFE form without the warning or loss of the reference.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.