Skip to content

Instantly share code, notes, and snippets.

View BackEndTea's full-sized avatar

Gert de Pagter BackEndTea

View GitHub Profile
@BackEndTea
BackEndTea / unused.php
Last active February 11, 2020 08:56
Find unused dependencies in your composer.json
<?php
class Node
{
/** @var string */
public $name;
/** @var bool */
public $visited = false;
public function __construct(string $name)
@BackEndTea
BackEndTea / why.php
Last active May 30, 2020 21:05
Query busses dont make sense to me
<?php
final class FindUserByIdHandler
{
private UserRepository $userRepository;
public function __construct(UserRepository $userRepository)
{
$this->userRepository = $userRepository;
}
@BackEndTea
BackEndTea / TraversalTest.php
Created January 3, 2021 12:07
Traversal Test
<?php
final class TraversalTest extends TestCase
{
public function testTraversal(): void
{
$parser = new TokenParser(new Lexer());
$ast = $parser->parse('/foo|bar{2,}/i');
$traverser = new Traverser([new RemoveQuantifierVisitor()]);
function env(string $param): string
{
return sprintf('%env(%s)%', $param);
}
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Security;
use Twig\Environment;
class AccountPageActionV1
{
interface Foo {
foo(): void;
}
// One
type FooBag = {
one: Foo,
two: Foo,
three: Foo
};
@BackEndTea
BackEndTea / arr.php
Last active March 13, 2021 18:31
array of strings to int
<?php
/**
* @param array<string> $in
*
* @return array<int>
*/
function withIntval(array $in): array
{
return array_map('intval', $in);
}
<?php
// Entity
/**
* @ORM\Repository(DoctrinePricesRepository::class)
*/
class Price {
public function __construct(
<?php
// OPTION A:
class MyController
{
//constructor, properties etc
/**
* @Route("/my/path")
*/
<?php
function connect_while(ApiClient $client): string
{
$tries = 0;
while(true) {
$tries++;
try {
$result = $client->doThing();