laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.64k stars 11.04k forks source link

Fix `unless` code comment #53529

Closed fritz-c closed 6 days ago

fritz-c commented 6 days ago

The existing code comment was copied from when, and therefore mistakenly explains the callback is called when the value is truthy.

And just for reference, here was my own sanity check, done in tinker:

> collect([1,2,3,4])->unless(false,fn($a)=>$a->prepend(62362))
= Illuminate\Support\Collection {#7422
    all: [
      62362,
      1,
      2,
      3,
      4,
    ],
  }

> collect([1,2,3,4])->unless(true,fn($a)=>$a->prepend(62362))
= Illuminate\Support\Collection {#7351
    all: [
      1,
      2,
      3,
      4,
    ],
  }