Skip to content

Instantly share code, notes, and snippets.

View dongilbert's full-sized avatar
😍
Mautic WOOOO

Don Gilbert dongilbert

😍
Mautic WOOOO
View GitHub Profile
@dongilbert
dongilbert / PhpLint.php
Last active March 22, 2016 09:40
PhpLint Plugin for PHPCI
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2013, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
*/
namespace PHPCI\Plugin;
@dongilbert
dongilbert / Codeception.php
Created August 8, 2013 15:09
Codeception plugin for PHPCI
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2013, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
*/
namespace PHPCI\Plugin;
@dongilbert
dongilbert / soap.md
Created August 5, 2013 18:50
SOAP :(

I'm have a camping/resort/rv website that uses PHP's native SoapClient class to request availability for units within a resort. The end users fill out a form indicating the type of unit they would like, dates, number of adults, etc things like that, and then we use that data in the SOAP request. Most of the time, it works as expected.

There have been reports where a user is checking availability on a unit but the data returned indicates none are available. Then, if they switch to a new browser, and do the same search over, it's showing that they ARE in fact available.

@dongilbert
dongilbert / modellegacy.php
Last active October 27, 2018 18:04
Joomla getName() method to strip format from returned view name.
<?php
class JModelLegacy
{
/**
* Method to get the view name
*
* The view name by default parsed using the classname, or it can be set
* by passing a $config['name'] in the class constructor
*
@dongilbert
dongilbert / wtf.php
Created June 11, 2013 21:16
PHP Scope Issues? or is this expected? I don't understand why the `$this` in `Foo::bar()` is being treated as though it is referencing the `$bar` instance. If I declare `Foo::bar()` as static, then I get the expected error of `Using $this when not in object context.` How can you call a method from another object if `$this` in that object refers …
<?php
class Foo
{
public function bar()
{
return $this->baz();
}
public function baz()
@dongilbert
dongilbert / oops.php
Last active December 17, 2015 12:59
Don't override your variables. Can't you spot the error?
<?php
class Foo
{
public function save($key = null, $urlVar = null)
{
if (!empty($_FILES['form']))
{
foreach($_FILES['form']['name'] as $field => $val)
@dongilbert
dongilbert / Container.php
Last active December 17, 2015 03:19
Joomla\DI\Container
<?php
/**
* Potentially Part of the Joomla Framework DI Package
*
* @copyright Copyright (C) 2013 Don Gilbert. All rights reserved.
* @license LGPL version 2 or later; see http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html
*/
namespace Joomla\DI;
@dongilbert
dongilbert / test.php
Last active December 17, 2015 02:28
DateTime weirdness. When passing a timestamp to the constructor, if it's a Unix timestamp, you must prepend it with an @.
<?php
print_r(new DateTime('01/01/2012'));
/*
Good
DateTime Object
(
[date] => 2012-01-01 00:00:00
[timezone_type] => 3
[timezone] => America/Chicago
@dongilbert
dongilbert / loadClass.php
Last active December 14, 2015 16:09
An (potentially) improved loadClass method for the PSR-0 autoloader that eliminates naming collisions at the (potential) sake of performance. Untested.
<?php
public function loadClass($className)
{
if (null === $this->_namespace || $this->_namespace.$this->_namespaceSeparator === substr($className, 0, strlen($this->_namespace.$this->_namespaceSeparator))) {
$fileName = '';
$namespace = '';
if (false !== ($lastNsPos = strripos($className, $this->_namespaceSeparator))) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
foreach (array_chunk($this->item->sizes, 5) as $chunk)
{
$chunk = array_pad($chunk, 5);
echo '<tr>';
for ($i=0;$i<5;$i++)
{
$s = $chunk[$i];
$link = JRoute::_('index.php');
echo '<td><a href="">' . $s->size . '</a></td>';