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 / 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 / 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 / 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 / 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 / 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 / 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;
<?php
class SomeClass
{
public function resortCsv()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('robot_id, title, address1, city, state, zip, sub_title, description')
->from('#__rv_resorts');
@dongilbert
dongilbert / .profile
Created November 15, 2013 22:06
PHP Quick Switching I've linked up the libphp5.so to a symlinked version in `~/.phpenv/` and also linked up the current version's `bin` folder.
alias php53='brew unlink php53 > /dev/null; brew unlink php54 > /dev/null; brew unlink php55 > /dev/null; brew link php53 > /dev/null; ln -sf /usr/local/Cellar/php53/5.3.26/libexec/apache2/libphp5.so /Users/admin/.phpenv/libphp5.so; ln -sf /usr/local/Cellar/php54/5.3.26/bin /Users/admin/.phpenv/bin; sudo apachectl restart; echo "PHP 5.3 Enabled";'
alias php54='brew unlink php53 > /dev/null; brew unlink php54 > /dev/null; brew unlink php55 > /dev/null; brew link php54 > /dev/null; ln -sf /usr/local/Cellar/php54/5.4.19/libexec/apache2/libphp5.so /Users/admin/.phpenv/libphp5.so; ln -sf /usr/local/Cellar/php54/5.4.19/bin /Users/admin/.phpenv/bin; sudo apachectl restart; echo "PHP 5.4 Enabled";'
alias php55='brew unlink php53 > /dev/null; brew unlink php54 > /dev/null; brew unlink php55 > /dev/null; brew link php55 > /dev/null; ln -sf /usr/local/Cellar/php55/5.5.3/libexec/apache2/libphp5.so /Users/admin/.phpenv/libphp5.so; ln -sf /usr/local/Cellar/php54/5.5.3/bin /Users/admin/.phpenv/bin; sudo apachectl restart; e
@dongilbert
dongilbert / ArrayOf.php
Created January 16, 2014 19:55
Abstract ArrayOf Class
<?php
abstract class ArrayOf implements ArrayAccess, Iterator
{
protected $type = null;
protected $data = [];
protected $index = 0;
@dongilbert
dongilbert / results
Created January 17, 2014 20:15
Benchmark newInstanceWithoutConstructor vs unserialize for object creation
ReflectionClass::newInstanceWithoutConstructor: 0.039168834686279
unserialize: 0.14324808120728