Skip to content

Instantly share code, notes, and snippets.

View jwage's full-sized avatar
I am still here.

Jonathan H. Wage jwage

I am still here.
View GitHub Profile
jwage / MessageBus.php
Created March 6, 2024 18:52
Symfony MessageBusInterface implementation that handles AMQPConnectionException and retries
namespace App\Messenger;
use AMQPConnectionException;
use App\Event\Messenger\WorkerMessageDispatchedEvent;
use App\Messenger\Stamp\DispatchedAtStamp;
use Psr\Log\LoggerInterface;
jwage / fixmocks.php
Created November 7, 2022 23:29
Add PHPUnit MockObject type hints to satisfy static analysis
$file = $argv[1];
$code = file_get_contents($file);
preg_match_all('/\$this->(.*)\s+=\s+\$this->createMock\((.*)::class\);/', $code, $matches);
foreach ($matches[2] as $key => $className) {
$propertyName = trim($matches[1][$key]);
jwage / Banks.php
Last active November 12, 2018 02:42
namespace Banks\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
// original
foreach ($this->migrationTable->getColumnNames() as $columnName) {
if (! $table->hasColumn($columnName)) {
$this->upToDate = false;
namespace MyProject\Bundle\MainBundle\Security\Authorization\Voter;
use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolverInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
jwage / pre-commit
Last active February 6, 2018 16:49
#!/usr/bin/env bash
echo "OpenSky pre commit hook start"
jwage / .php_cs
Last active May 3, 2023 06:42
php-cs-fixer git pre commit hook
return Symfony\CS\Config\Config::create()
class SmartSquareFilter extends AbstractImagickFilter
protected function doApply(\Imagick $im)
$target = $im->getImageGeometry();
if ($target['width'] === $target['height']) {
// return early if already square
use PHPUnit_Framework_TestCase;
use Symfony\Component\DomCrawler\Crawler;
class SimpleHttpTest extends PHPUnit_Framework_TestCase
public function testHttp()
$crawler = new Crawler(file_get_contents('http://myapp.lcl/hello/Jon'));
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Persistence\ObjectManager;
class ObjectSerializer
private $om;
public function __construct(ObjectManager $om)