MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / demo

Method demo

examples/demo.php:3245–3275  ·  view source on GitHub ↗
(?Pen $pen, ?User $user)

Source from the content-addressed store, hash-verified

3243class 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

Callers

nothing calls this directly

Calls 6

makePenFunction · 0.85
createUserFunction · 0.85
colorMethod · 0.80
getDisplayNameMethod · 0.80
labelMethod · 0.45
getProfileMethod · 0.45

Tested by

no test coverage detected