Skip to content

Instantly share code, notes, and snippets.

View weierophinney's full-sized avatar
⏯️

Matthew Weier O'Phinney weierophinney

⏯️
View GitHub Profile
1003 test:master % php ~/Downloads/phpunit-3.6.4.phar
PHP Warning: Missing argument 1 for text_template_autoload(), called in phar:///home/matthew/Downloads/phpunit-3.6.4.phar/PHP/CodeCoverage/Filter.php on line 96 and defined in /usr/local/zend/share/pear/Text/Template/Autoload.php on line 46
Warning: Missing argument 1 for text_template_autoload(), called in phar:///home/matthew/Downloads/phpunit-3.6.4.phar/PHP/CodeCoverage/Filter.php on line 96 and defined in /usr/local/zend/share/pear/Text/Template/Autoload.php on line 46
PHP Notice: Undefined variable: class in /usr/local/zend/share/pear/Text/Template/Autoload.php on line 58
Notice: Undefined variable: class in /usr/local/zend/share/pear/Text/Template/Autoload.php on line 58
PHP Catchable fatal error: Argument 1 passed to PHP_CodeCoverage_Filter::addFilesToBlacklist() must be an array, null given, called in phar:///home/matthew/Downloads/phpunit-3.6.4.phar/PHP/CodeCoverage/Filter.php on line 96 and defined in phar:///home/matthew/Downloads/phpunit-
<?php
function($e) use ($validator) {
$manager = $e->getTarget();
foreach ($manager->getLoadedModules() as $module) {
if (!$module instanceof ServiceConsumer) {
continue;
}
$validator->merge($module->getServiceValidatorMap());
}
<?php
if ($foo == 'bar'
|| $bar == 'baz'
&& (!isset($baz) || empty($bat))
) {
}
$constants = get_defined_constants();
array_walk(array_keys($constants), function($key) use (&$constants) {
if ('T_' != substr($key, 0, 2)) {
unset($constants[$key]);
}
});
var_export($constants);
@weierophinney
weierophinney / ClassMethod.php
Created December 14, 2011 18:22
resolveClass from import statements
/**
* Attempt to resolve a class or namespace based on imports
*
* @param string $class
* @return string String namespace/classname
*/
protected function resolveClass($class)
{
if ('\\' == substr($class, 0, 1)) {
return substr($class, 1);
<!--
Basically, you declare a link with a linkend value. The value should be a valid
xml:id from within another document.
-->
<link linkend="zend.event-manager.foo">EventManager</link>
<?php
$events->attach(
'EdpUser\Authentication\Adapter\AdapterChain',
'authenticate',
function($e) use ($request, $config) {
$chain = $e->getTarget();
$adapter = new My\Custom\Adapter($config['auth']);
$adapter->setCredentialsFromRequest($request);
$chain->register($adapter);
}
@weierophinney
weierophinney / Zf2ViewRfc.wiki
Created January 10, 2012 20:09
ZF2 View RFC

Views RFC

Zend Framework 1.X conflated the View with the Renderer -- in other words, one was not done without the other.

This leads to anti-patterns like:

 * !ContextSwitch plugin, which simply changes the file extension of the view
   script to use. Which in turn leads to: 
    * View-related request-parsing within the controller.

<?php
return array('di' => array(
'definition' => array('class' => array(
'Zend\Mvc\Controller\PluginLoader' => array(
'__construct' => array(
'map' => array(
'type' => false, // allows scalars and arrays
'required' => false,
),
),
<?php
namespace Foo;
use Zend\EventManager\StaticEventManager;
class Module
{
protected $manager;
public function init($manager)