isset() on hooks doesn't respect backing value
Nobody has claimed this yet.
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
Description
The following code:
<?php
class User {
public ?string $id {
get => $this->id; // get => $this->id ?? null; works
set => $this->id = $value;
}
}
class User2 {
public string $id;
}
$u = new User();
$u2 = new User2();
var_dump(isset($u2->id));//false OK
var_dump(isset($u->id));//error
Resulted in this output:
First var_dump retuns false and this is ok, second - produces Fatal error: Uncaught Error: Typed property User::$id must not be accessed before initialization
But I expected this output instead:
false two times
This suggests that isset() on hooked properties may incorrectly trigger property access instead of checking initialization state, unlike regular typed properties.
PHP Version
PHP 8.5.0 (cli) (built: Nov 20 2025 19:17:11) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.5.0, Copyright (c) Zend Technologies
with Zend OPcache v8.5.0, Copyright (c), by Zend Technologies
PHP 8.4.15 (cli) (built: Nov 20 2025 17:43:25) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.4.15, Copyright (c) Zend Technologies
with Zend OPcache v8.4.15, Copyright (c), by Zend Technologies
with Xdebug v3.4.7, Copyright (c) 2002-2025, by Derick Rethans
Operating System
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the supplied hooked-property example on PHP 8.4 and 8.5, then determine whether the behavior is a PHP runtime defect or a documentation gap. Check the relevant PHP documentation for hooked properties and isset(); done means the issue is routed to the appropriate fix with the expected behavior and a regression or documentation update identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100