(?Pen $pen, ?User $user)
| 3243 | class SimplifyNullDemo |
| 3244 | { |
| 3245 | public function demo(?Pen $pen, ?User $user): void |
| 3246 | { |
| 3247 | // ── isset → ?? ───────────────────────────────────────────── |
| 3248 | // Code action: "Simplify to ??" → $pen ?? makePen() |
| 3249 | $tool = isset($pen) ? $pen : makePen(); |
| 3250 | |
| 3251 | // ── !== null → ?? ────────────────────────────────────────── |
| 3252 | // Code action: "Simplify to ??" → $pen ?? makePen() |
| 3253 | $tool2 = $pen !== null ? $pen : makePen(); |
| 3254 | |
| 3255 | // ── === null (reversed) → ?? ─────────────────────────────── |
| 3256 | // Code action: "Simplify to ??" → $user ?? createUser() |
| 3257 | $fallback = $user === null ? createUser() : $user; |
| 3258 | |
| 3259 | // ── !== null + method call → ?-> ─────────────────────────── |
| 3260 | // Code action: "Simplify to ?->" → $pen?->color() |
| 3261 | $color = $pen !== null ? $pen->color() : null; |
| 3262 | |
| 3263 | // ── !== null + property access → ?-> ─────────────────────── |
| 3264 | // Code action: "Simplify to ?->" → $user?->email |
| 3265 | $email = $user !== null ? $user->email : null; |
| 3266 | |
| 3267 | // ── === null + method (reversed) → ?-> ───────────────────── |
| 3268 | // Code action: "Simplify to ?->" → $pen?->label() |
| 3269 | $label = $pen === null ? null : $pen->label(); |
| 3270 | |
| 3271 | // ── Compound subject → correct ?-> placement ─────────────── |
| 3272 | // Code action: "Simplify to ?->" → $user->getProfile()?->getDisplayName() |
| 3273 | $profile = $user->getProfile(); |
| 3274 | $name = $profile !== null ? $profile->getDisplayName() : null; |
| 3275 | } |
| 3276 | } |
| 3277 | |
| 3278 |
nothing calls this directly
no test coverage detected