Skip to content

Instantly share code, notes, and snippets.

@LeonardoCA
LeonardoCA / SummaryErrorFormatter.php
Last active October 6, 2020 16:21
PHPStan formatter grouping errors by error type
<?php declare(strict_types = 1);
namespace App\PHPStan;
use PHPStan\Command\AnalysisResult;
use PHPStan\Command\ErrorFormatter\ErrorFormatter;
use Symfony\Component\Console\Style\OutputStyle;
class SummaryErrorFormatter implements ErrorFormatter
{
public function formatErrors(
AnalysisResult $analysisResult,
OutputStyle $style
@LeonardoCA
LeonardoCA / renderer.php
Created November 9, 2012 18:12
bootstrap renderer partial optimalization
/**
* @param \Nette\Templating\FileTemplate $template
*/
public function __construct(FileTemplate $template = NULL)
{
if ($template === NULL) {
$template = new FileTemplate();
$template->registerFilter(new Nette\Latte\Engine());
@LeonardoCA
LeonardoCA / RedisExtension.php
Created November 3, 2012 18:21
Nette RedisExtension with fallback if redis not runing
<?php
/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008, 2012 Filip Procházka (filip@prochazka.su)
*
* For the full copyright and license information, please view the file license.md that was distributed with this source code.
*/
@LeonardoCA
LeonardoCA / Replicator.php
Created October 17, 2012 11:44
Replicator
<?php
/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008, 2012 Filip Procházka (filip@prochazka.su)
*
* For the full copyright and license information, please view the file license.md that was distributed with this source code.
*/
@LeonardoCA
LeonardoCA / dumpHtml.php
Created September 30, 2012 21:31
dumpHtml - Nette dump combined with Tidy html formating and prettyPrint to make debuging Html code easier
<?php
use Nette\Diagnostics\Debugger;
/**
* Dump rendered Html element or code and inteded output generated by tidy and optional also Html element structure
* @param Html|string Html element or string
* @param bool Return output in string and don't send it to output?
* @param int MaxDepth for Debugger::Dump output - to see how is the Html element built
* @param bool Send along javascript code for prettyPrint activation?
(function($, undefined) {
/**
* Shows info on Ajax request
*/
$.nette.ext('diagnostics.jsonpanel', {
start: function (xhr, settings) {
var $panel = this.getPanel();
if (!$panel) return;
if (this.singleReport) this.clear();
$(this.getTitle(++this.counter, 'request')).appendTo($panel);
@LeonardoCA
LeonardoCA / AjaxPanels.php
Created July 13, 2012 21:22
AjaxPanelsCompilerExtension
<?php
/**
* This file is part of the AjaxPanels Nette Addon
*
* Copyright (c) 2012 Leonard Odlozilik
*
* For the full copyright and license information, please view
* the file license.txt that was distributed with this source code.
*/
@LeonardoCA
LeonardoCA / firelogger.ajax.js
Created June 18, 2012 05:21
nette.ajax.js Experimental Extension - displays some FireLogger info as flash message
(function($, undefined) {
/**
* Shows HTTP Error Statuses and some FireLogger info from Ajax request
*/
$.nette.ext('httpStatusToFlash', {
start: function (xhr) {
xhr.setRequestHeader("X-FireLogger", '1.2');
return xhr;
},
error: function (payload) {