Skip to content

Instantly share code, notes, and snippets.

View astorm's full-sized avatar

Alana Storm astorm

View GitHub Profile
> loading Oro\Bundle\UserBundle\Migrations\Data\ORM\LoadEmailTemplates
PHP Warning: require(/Users/alanstorm/Documents/github/orocommerce-application/app/cache/prod/doctrine/orm/Proxies/__CG__OroBundleOrganizationBundleEntityBusinessUnit.php): failed to open stream: No such file or directory in /Users/alanstorm/Documents/github/orocommerce-application/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 209
PHP Stack trace:
PHP 1. {main}() /Users/alanstorm/Documents/github/orocommerce-application/app/console:0
PHP 2. Symfony\Component\Console\Application->run() /Users/alanstorm/Documents/github/orocommerce-application/app/console:23
PHP 3. JMS\JobQueueBundle\Console\Application->doRun() /Users/alanstorm/Documents/github/orocommerce-application/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
PHP 4. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /Users/alanstorm/Documents/github/orocommerce-application/vend
app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php
app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php
app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php
app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php
app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php
app/code/Magento/AdvancedPricingImportExport/Controller/Adminhtml/Export/GetFilter.php
app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Place.php
app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/Redirect.php
app/code/Magento/Authorizenet/Controller/Adminhtml/Authorizenet/Directpost/Payment/ReturnQuote.php
app/code/Magento/Authorizenet/Controller/Directpost/Payment/ReturnQuote.php
@astorm
astorm / answer.md
Created August 3, 2015 22:28
Answer to: http://stackoverflow.com/questions/31797607/undefined-variable-get, obnoxious closed because it wasn't in english.

Apologies for the English, but I don't speak or read your language (Russian?). This answer is based on Google translate's version of what you asked.

PHP's super globals ($_GET, $_POST, etc.) are special variables, and it looks like you can't use these variables with PHP's variable variable feature. For example, this works

$foo = ['Hello'];    
$var_name = 'foo';
var_dump($$var_name);

The "variable variable" $$var_name expands as $'foo'/$foo, and the variable dumps correctly.

The worst one act play ever.

New User:   Hello Magento Site, give me a catalog listing page

Varnish:    Someone wants a page, do I have it cached?  Yes! Since I
            have it cached, I don't need to talk to Magento, I can just sent
            the user this page.

            [Varnish grabs the page]
<?php
//never do this for read, use __construct dependency injection
$r = new ReflectionObject($app);
$prop = $r->getProperty('_objectManager');
$prop->setAccessible(true);
$manager = $prop->getValue($app);
//generates a factory, assuming `Pulsestorm\Helloworld\Test` exists
$factory = $manager->get('Pulsestorm\Helloworld\TestFactory');
$value = array_key_exists('test', $_COOKIE) ? $_COOKIE['test'] : 0;
$value++;
setcookie('test', $value);
var_dump($value);
session_start();
$value = array_key_exists('test2', $_SESSION) ? $_SESSION['test2'] : 0;
$value = $value ? $value : 0;
$value++;
#!/usr/bin/php
<?php
namespace Pulsestorm\Stackexchange\Magento\Noupvotes;
/**
* A simple shell script for returning a list of questions
* with an answer or have answers with no upvotes. Suffers
* from "thrown together for my own use" syndrome, but it
* does the job.
*
* @author Alan Storm http://alanstorm.com
@astorm
astorm / gist:972291eb28b148a80799
Created July 28, 2014 15:48
Why I Call the Files in app/etc/modules "Declaration Files"
#File: app/code/core/Mage/Core/Model/Config.php    
/**
 * Load declared modules configuration
 *
 * @param   null $mergeConfig depricated
 * @return  Mage_Core_Model_Config
 */

protected function _loadDeclaredModules($mergeConfig = null)

Assuming

$method = array('I am','sparticus');

In the statment

$oneMethod = count($methods) <= 1;

The call to count($methods) always returns an int (see its return type on the count page), In our example that int is 2

It's been 9 years since the release of PHP, but my muscle memory still wants a double beat (as opposed to tripple) when I type function definitions.

class Baz
{
    function getSomething()
    {
    }

}