Skip to content

Instantly share code, notes, and snippets.

View XedinUnknown's full-sized avatar
💻
WP OOP

Anton Ukhanev XedinUnknown

💻
WP OOP
View GitHub Profile
@cdalsass
cdalsass / jira_make_unresolved.js
Last active May 28, 2018 14:12
Mark Jira issue "Unresolved" (or Null in database)
/* Copyright (c) 2017 iQtransit, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@VladaHejda
VladaHejda / Phpunit-assert_exception.php
Last active December 28, 2022 03:59
Phpunit Exception assertion. For easy multiple testing if Exception is thrown in one test method. For PHP >= 5.5 you can use package with trait: https://packagist.org/packages/vladahejda/phpunit-assert-exception
<?php
abstract class TestCase extends \PHPUnit_Framework_TestCase
{
protected function assertException(callable $callback, $expectedException = 'Exception', $expectedCode = null, $expectedMessage = null)
{
$expectedException = ltrim((string) $expectedException, '\\');
if (!class_exists($expectedException) && !interface_exists($expectedException)) {
$this->fail(sprintf('An exception of type "%s" does not exist.', $expectedException));
}
@mageekguy
mageekguy / psr4.php
Last active July 8, 2020 19:48
Very simple PSR-4 autoloader
<?php
namespace your\namespace\here;
spl_autoload_register(function($class) {
if (stripos($class, __NAMESPACE__) === 0)
{
@include(__DIR__ . DIRECTORY_SEPARATOR . 'classes' . str_replace('\\', DIRECTORY_SEPARATOR, strtolower(substr($class, strlen(__NAMESPACE__)))) . '.php');
}
}
@AmyStephen
AmyStephen / PSR-0 and Composer.md
Last active December 12, 2015 10:09
Documentation of how the environment and how utilizing Composer parameters and the package repository structure, itself, impact the installation path and provide options for how best to implement the PSR-0 for your package.

PSR-0 and Composer

It's helpful to understand how Composer works and how to best utilize the environment as you implement your PSR-0 Namespace. There are factors that you, where you, as a user of the environment, will not be able to change and you should be aware of those points. There are areas where your choices directly impact the folder path and the implementation of your namespace.

##1. Composer Name Parameter##

The first data relevant to the package install path is the name you provide to Composer.

###What is the purpose of the name parameter?###

@Ocramius
Ocramius / Notes
Created October 15, 2011 20:09
PHP Benchmark for array_search against foreach
Tested on PHP 5.3.8 on Mac OS 10.6.8.
These results are just micro-optimization, which is quite useless, but the foreach construct seems to be always slower than array_search.
I expected much better results, but I frankly don't know why I didn't get them this time. Unfortunately I don't have the previous benchmark anymore.