Skip to content

Instantly share code, notes, and snippets.

View stefanfisk's full-sized avatar

Stefan Fisk stefanfisk

  • Stockholm, Sweden
View GitHub Profile
@stefanfisk
stefanfisk / NullToEmptyStringObjectNormalizer.php
Last active November 14, 2024 12:42
Custom symfony/serialization object normalizer that maps null or missing keys to "" for string properties
<?php
declare(strict_types=1);
namespace App\Serializer\Normalizer;
use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
<html>
<body>
<img
src="https://via.placeholder.com/1920x1080/?text=A%20comma,%20this%20image%20has"
srcset="https://via.placeholder.com/1920x1080/?text=A%20comma,%20this%20image%20has 1920w, https://via.placeholder.com/640x480/?text=A%20comma,%20this%20image%20has 640w">
</body>
</html>
@stefanfisk
stefanfisk / AssetManifest.php
Created May 11, 2022 11:58
PHP parser for `@wordpress/dependency-extraction-webpack-plugin` / `'webpack-bundle-analyzer`
<?php
namespace App\Support\Assets;
use Illuminate\Support\Str;
use InvalidArgumentException;
use RuntimeException;
use function base64_encode;
use function file_exists;

Keybase proof

I hereby claim:

  • I am stefanfisk on github.
  • I am stefanfisk (https://keybase.io/stefanfisk) on keybase.
  • I have a public key ASCnl1c8sCrpG6jR6TvD5gOJO82mACnYzfzEEd0F39-8ZAo

To claim this, I am signing this object: