Skip to content

Instantly share code, notes, and snippets.

@eddieajau
eddieajau / test.php
Created March 11, 2013 04:32
A strategy for mocking a PSR-3 logger. This assume the class being tested has a `log` method which probably checks if the logger has been set and then proxies to `$this->logger->log`.
use Psr\Log;
class TheTest extends \PHPUnit_Framework_TestCase
{
/**
* The class we are testing.
*/
protected $instance;
/**
@eddieajau
eddieajau / gist:4980010
Last active December 13, 2015 21:48
Draft Documentation Guide

Documentation Guide

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

@eddieajau
eddieajau / packaging.xml
Created January 28, 2013 01:44
Eclipse snippet category for packaging Joomla extensions. Includes: Basic installer class, SQL installation file header, XML installation supplement, XML administrator files, XML build file. Updated 2013-01-24
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1311161288555" initial_state="1" label="Packaging" largeicon="" smallicon="">
<description><![CDATA[Snippets to assist with creating extension packages for distribution.]]></description>
<item category="category_1311161288555" class="" editorclass="" id="item_1311161491543" label="Basic installer class" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[The basic installer class that can be created in a installer.php file in the main directory of the extension.]]></description>
<content><![CDATA[/**
* @package ${PACKAGE}
* @subpackage ${SUBPACKAGE}
* @since ${SINCE}
@eddieajau
eddieajau / joomla_plugins.xml
Created January 28, 2013 01:37
Eclipse snippet category for Joomla plugins. Includes: Master Plugin File, XML Installation File (Plugin), Plugin method, Trigger plugin. Updated 2013-01-24
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1278465230540" initial_state="1" label="Joomla Plugins" largeicon="" smallicon="">
<description><![CDATA[Snippets specifically for support Joomla modules.]]></description>
<item category="category_1278465230540" class="" editorclass="" id="item_1278465575233" label="Master Plugin File" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[Unnamed Template]]></description>
<content><![CDATA[jimport('joomla.plugin.plugin');
/**
* ${GROUP} ${NAME} Plugin.
@eddieajau
eddieajau / backend_support.xml
Created January 28, 2013 01:18
Eclipse snippet category for backend component support code in Joomla 2.5 (all except CSS should be applicable for Joomla 3.0). Includes: Add submenu method for backend component helper, Add submenu call to master backend controller, Adds a call to JSubMenuHelper that will show a link to the categories view., Text prefix for item subcontroller, …
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1303255935762" initial_state="1" label="Backend Support" largeicon="" smallicon="">
<description><![CDATA[Additional snippets that support backend components.]]></description>
<item category="category_1303255935762" class="" editorclass="" id="item_1303256255316" label="Add submenu method for backend component helper" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[This snippet provides the addSubmenu method that should be added to the backend helper class (usually found in /com_{component}/helpers/{component}.php). One sub-menu entry is provided - copy and paste to suit the number of views that need to be supported. Remember to add the hook into the controller to invoke this method.]]></description>
<content><![CDATA[ /**
* Configure the Linkbar.
*
* @param string $vName The name of
@eddieajau
eddieajau / backend_edit_pages.xml
Created January 28, 2013 00:05
Eclipse snippet category for backend component edit pages in Joomla 2.5 (all except view layouts are applicable for Joomla 3.0). Includes: Backend Item Sub-controller, Backend Item Model, Backend Item XML Form, Backend Item Edit View, backend Item Edit Layout, Backend Item Edit Params Sub-layout, Backend Item Edit Metadata Sub-layout, Backend It…
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1276571442053" initial_state="1" label="Backend Edit Pages" largeicon="" smallicon="">
<description><![CDATA[Snippets specifically for creating backend edit views.]]></description>
<item category="category_1276571442053" class="" editorclass="" id="item_1276505902148" label="Backend Item Subcontroller" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[This snippet adds the basic sub-controller for single item.]]></description>
<content><![CDATA[jimport('joomla.application.component.controllerform');
/**
* ${VIEW} Subcontroller.
@eddieajau
eddieajau / backend_lists_20130124.xml
Created January 27, 2013 23:58
Eclipse snippet category for backend component lists in Joomla 2.5 (all except view layouts are applicable for Joomla 3.0). Includes: Controller Set Default View, Backend List View, Backend List Layout, Backend List Model, Backend List Layout Search Filter, Backend List Model Search Filters (state), Backend List Model Search Filters (query), Bac…
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1276571415504" initial_state="1" label="Backend Lists" largeicon="" smallicon="">
<description><![CDATA[Snippets specifically for creating backend list views.]]></description>
<item category="category_1276571415504" class="" editorclass="" id="item_1276485904815" label="Controller Set Default View" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[This snippet is intended for the master controller and adds the "default_view" property to class definition. The default view is assumed to be the name of the component (less the com_ prefix). If you want to change the default view then add this snippet.]]></description>
<content><![CDATA[ /**
* @var string The default view.
* @since ${SINCE}
*/
@eddieajau
eddieajau / joomla_components.xml
Created January 27, 2013 23:44
Eclipse snippet category for general purpose Joomla 2.5/3 Component snippets. Includes: * PHP File Header * XML Installation File (Component) * INI File Header * Master Component File * Master Controller * Basic View * Basic Model * Basic View with Toolbar * Basic Controller Display Override * Basic Component Helper * Basic config.xml * Basic ac…
<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<snippets>
<category filters="*" id="category_1275479375591" initial_state="1" label="Joomla Components" largeicon="" smallicon="">
<description><![CDATA[Snippets that support the general needs for any Joomla component.]]></description>
<item category="category_1275479375591" class="" editorclass="" id="item_1275479460203" label="PHP File Header" largeicon="" smallicon="" snippetProvider="org.eclipse.wst.common.snippets.ui.TextSnippetProvider">
<description><![CDATA[The standard header for a PHP file.]]></description>
<content><![CDATA[<?php
/**
* @version $Id$
* @package ${PACKAGE}
@eddieajau
eddieajau / libraries_cms_version_compatibility.php
Created December 13, 2012 04:33
Joomla version compatibility class.
<?php
class JVersionCompatibility
{
/**
* Class constructor.
*
* @param SimpleXmlElement $node The compatibility node from a manifest file.
*
* @see https://github.com/joomla/joomla-cms/issues/598 for XML specification.
*/
@eddieajau
eddieajau / debug.php
Created May 10, 2012 05:18
Printing a clean debug backtrace in PHP.
// PHP < 5.3.6
foreach (debug_backtrace() as $trace)
{
echo sprintf("\n%s:%s %s::%s", $trace['file'], $trace['line'], $trace['class'], $trace['function']);
}
die;
// PHP >= 5.3.6
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
die;