for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace AHJ\ApprovalTests;
final class ReceivedMap
{
public function create(array $input, array $output): string
$received = [];
foreach ($input as $inputKey => $inputValue) {
if ('array' === gettype($inputValue)) {
$received[$inputKey] = '[';
$received[$inputKey] .= implode(', ', $inputValue);
$received[$inputKey] .= '] -> ';
}
// TODO: make sure this works for objects which do not have a __toString method
if ('object' === gettype($inputValue)) {
$received[$inputKey] = '[' . $inputValue . '] -> ';
$inputValue
object
concatenation
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
$received[$inputKey] = '[' . /** @scrutinizer ignore-type */ $inputValue . '] -> ';
foreach ($output as $outputKey => $outputValue) {
if ('array' === gettype($outputValue)) {
$received[$outputKey] = $received[$outputKey] . '[';
$received[$outputKey] .= implode(', ', $outputValue);
$received[$outputKey] .= ']';
if ('object' === gettype($outputValue)) {
$received[$outputKey] = $received[$outputKey] . '[' . $outputValue . ']';
$outputValue
$received[$outputKey] = $received[$outputKey] . '[' . /** @scrutinizer ignore-type */ $outputValue . ']';
return implode("\n", $received);