Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View nicolas-grekas's full-sized avatar
✔️
Green-keeping the Symfony CI

Nicolas Grekas nicolas-grekas

✔️
Green-keeping the Symfony CI
View GitHub Profile
@nicolas-grekas
nicolas-grekas / Advanced-HTTP-en.md
Created June 15, 2011 22:03
Advanced handling of HTTP requests in PHP
@nicolas-grekas
nicolas-grekas / Dumper.php
Created July 7, 2011 16:58
Advanced error handling in PHP
<?php /****************** vi: set fenc=utf-8 ts=4 sw=4 et: *****************
*
* Copyright : (C) 2011 Nicolas Grekas. All rights reserved.
* Email : p@tchwork.org
* License : http://www.gnu.org/licenses/lgpl.txt GNU/LGPL
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
Symfony\Component\Cache\Tests\Marshaller\DefaultMarshallerTest::testNativeUnserializeNotFoundClass

Failed asserting that exception of type "UnserializationFailedException" matches expected exception "DomainException". Message was: "An Exception was thrown during unserialization" at src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php:96 src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php:74 src/Symfony/Component/Cache/Tests/Marshaller/DefaultMarshallerTest.php:62

Symfony\Component\Messenger\Tests\Transport\Serialization\PhpSerializerTest::testDecodingFailsWithBadFormat

Failed asserting that exception of type "UnserializationFailedException" matches expected exception "Symfony\Component\Messenger\Exception\MessageDecodingFailedException". Message was: "An Exception was thrown during unserialization" at src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php:78 src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php:54

@nicolas-grekas
nicolas-grekas / unserializing.diff
Created September 20, 2022 17:13
Places where unserialize() is try/catched in Symfony 6.2
diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php
index 003680a5c0..e6b0265a45 100644
--- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php
+++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php
@@ -95,21 +95,21 @@ class Deprecation
break;
}
}
if (!isset($line['object']) && !isset($line['class'])) {
@nicolas-grekas
nicolas-grekas / PhpConverter.php
Created April 16, 2019 14:54
From Yaml to PHP-DSL
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
@nicolas-grekas
nicolas-grekas / WinfsUtf8.php
Last active September 7, 2021 11:14
Unicode/UTF-8 filesystem access on MS-Windows
<?php /****************** vi: set fenc=utf-8 ts=4 sw=4 et: *****************
*
* Copyright : (C) 2012 Nicolas Grekas. All rights reserved.
* Email : p@tchwork.org
* License : http://apache.org/licenses/LICENSE-2.0
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Apache License version 2.
*
***************************************************************************/
@nicolas-grekas
nicolas-grekas / rfc-secure-unserialize.md
Last active July 26, 2020 10:07
RFC for a Secure Unserialization Mechanism in PHP

RFC for a Secure Unserialization Mechanism in PHP

Scope

PHP serialization/unserialization has several drawbacks [^1].

On the serialization side, the Serializable interface:

  • breaks hard and soft references inside serialized data structures;
@nicolas-grekas
nicolas-grekas / Ulid.php
Last active March 5, 2020 21:10
A class to generate compliant "ulid"
<?php
class Ulid
{
private static $time = -1;
private static $rand = [];
public function generate(bool $lowercase = false)
{
if (\PHP_INT_SIZE !== 8) {
@nicolas-grekas
nicolas-grekas / async.php
Last active November 6, 2019 08:30
Symfony HttpClient benchmarks
<?php
require 'vendor/autoload.php';
$start = microtime(true);
/* GUZZLE * /
$client = new GuzzleHttp\Client();
$promises = [];
@nicolas-grekas
nicolas-grekas / secrets.yaml
Created April 6, 2019 13:08
secrets.yaml
parameters:
env(SECRETS_FILE): .secrets.php
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
bind:
$someSecret: '%env(key:KEY3:require:SECRETS_FILE)%'