compact() is a problematic construct that breaks the direct code link between variable definition and variable consumption.
$someVar = 123;
return compact('someVar');
This is equivalent to
| #pragma once | |
| #include "lend-forward.h" | |
| #include "lend-type.h" // NOLINT(build/include_directory) | |
| #include "lend-internal.h" // NOLINT(build/include_directory) | |
| #include "lend-handle.h" // NOLINT(build/include_directory) | |
| #include "lendconfig.h" // NOLINT(build/include_directory) | |
| #include <cstdint> | |
| namespace lend { | |
| /** | |
| * @class HeapObject |
compact() is a problematic construct that breaks the direct code link between variable definition and variable consumption.
$someVar = 123;
return compact('someVar');
This is equivalent to
I had an interesting use-case with a customer for which I provide consulting services: they needed multiple fields to be marked as "optional".
We will take a CRUD-ish example, for the sake of simplicity.
For example, in the following scenario, does a null $description mean "remove the description",
A list of requirements:
| git checkout -b master | |
| git log -1 | |
| # commit 65345471c1040ceb90b1817d7427d58d7b09fdca (HEAD -> master) | |
| git checkout -b develop | |
| git log -1 | |
| # both branches are at the same ref: | |
| # commit 65345471c1040ceb90b1817d7427d58d7b09fdca (HEAD -> develop, master) | |
| echo "a feature" > feature.txt |
| #!/usr/bin/env bash | |
| export TARGET_REF=${TARGET_REF:-HEAD} | |
| git show "$TARGET_REF:psalm-baseline.xml" | xmllint --xpath 'count(//file[not(starts-with(@src, "test"))]/*/code)' - |
| <?php | |
| declare(strict_types=1); | |
| namespace Tests\Integration; | |
| use PHPUnit\Framework\TestCase; | |
| use ReflectionClass; | |
| use ReflectionProperty; | |
| use Webmozart\Assert\Assert; |
| <?php | |
| declare(strict_types=1); | |
| namespace Core\Domain\Time; | |
| use DateTimeImmutable; | |
| use DateTimeZone; | |
| use Generator; | |
| use Iterator; |
| <?php | |
| // -- types are a compile-time propagated concept | |
| // https://psalm.dev/r/338f74a96c | |
| class TheType | |
| { | |
| /** @var string */ | |
| public $foo = 'bar'; | |
| } |
| #!/usr/bin/env php | |
| <?php | |
| declare(strict_types=1); | |
| namespace WaitForElasticsearch; | |
| use InvalidArgumentException; | |
| use UnexpectedValueException; | |
| use function curl_close; |