Skip to content

Instantly share code, notes, and snippets.

View weierophinney's full-sized avatar
⏯️

Matthew Weier O'Phinney weierophinney

⏯️
View GitHub Profile
Acl/AclTest.php
Amf/AllTests.php
Application/AllTests.php
Auth/AllTests.php
Barcode/AllTests.php
Cache/AllTests.php
Captcha/AllTests.php
CodeGenerator/AllTests.php
Config/AllTests.php
Console/AllTests.php
<?php
array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
@weierophinney
weierophinney / GuestModule.php
Created December 5, 2011 22:34
Example listener for changing layouts
<?php
namespace Guest;
use Zend\EventManager\StaticEventManager;
class Module
{
public function init()
{
$events = StaticEventManager::getInstance();
<?php
if (!($env = getenv('APPLICATION_ENV'))) {
$env = 'local';
}
$glob = glob(__DIR__ . "/config/autoload/config.{global,$env}.php");
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);
@weierophinney
weierophinney / benchmarks-v2.log
Last active September 28, 2015 20:25
Athletic benchmark results of zend-eventmanager, to detail performance improvements from v2 to v3. Two separate benchmarks are shown for v3, one detailing the original strategy of "prepare shared listeners only on the first trigger" and one detailing the strategy where shared listeners are prepared on every trigger, demonstrating we can do so wi…
Benchmarks from current v2 master.
ZendBench\EventManager\MultipleEventIndividualSharedListener
Method Name Iterations Average Time Ops/second
------------ ------------ ----------------- -------------
trigger : [ 5,000] [0.0001748194695] [5,720.18668]
ZendBench\EventManager\MultipleEventLocalListener
Method Name Iterations Average Time Ops/second