Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Add migration to make all CITI ID fields signed
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; use Symfony\Component\Console\Output\ConsoleOutput; class SignCitiIds extends Migration { public function up() { $output = new ConsoleOutput(); $tables = DB:...
Create factory methods for DynamicIdentifiers
<?php namespace Monospice\SpicyIdentifiers; use Monospice\SpicyIdentifiers\DynamicIdentifier; use Monospice\SpicyIdentifiers\Tools\CaseFormat; use Monospice\SpicyIdentifiers\Tools\Parser; /** * A factory trait to help instantiate a new DynamicIdentifier instance * * @author Cy Rossignol <cy.rossignol@yahoo.com> ...
Fix assertInternalType deprecation in phpunit 9
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests; use Symfony\Contracts\HttpClient\Te...
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpClient\Tests; use Symfony\Bridge\PhpUnit\ForwardC...
Add migration for Specialty entity
<?php use yii\db\Schema; use yii\db\Migration; class m141216_153407_create_specialty_table extends Migration { public function up() { $tableOptions = null; if ($this->db->driverName === 'mysql') { // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-genera...
Add migration to create is_deceased flag
<?php class m160614_085916_patient_is_deceased_flag extends OEMigration { public function up() { $this->addColumn('patient', 'is_deceased', 'tinyint not null default 0'); $this->addColumn('patient_version', 'is_deceased', 'tinyint not null default 0'); $this->update('patient', array('is_deceased' => 1), 'date...
Update migrations to insert sample categories
<?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateForumTableCategories extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('forum_categories', function(Blueprint $table) { $table->increments(...
<?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateForumTableCategories extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('forum_categories', function(Blueprint $table) { $table->increments(...
Introduce marker interface for controllers that require authentication loop throttling
<?php /** * Copyright 2016 SURFnet B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Add unit tests for the violations cache
<?php namespace Tests\Regis\GithubContext\Infrastructure\Inspection; use PHPUnit\Framework\TestCase; use M6Web\Component\RedisMock\RedisMockFactory; use Predis\ClientInterface as RedisClient; use Regis\GithubContext\Application\Inspection\ViolationsCache; use Regis\GithubContext\Domain\Entity; use Regis\GithubContext...
Add a prototype for dependency injection container of my choice
<?php /** * A dependency injection container for lazy-evaluated shared resources. **/ namespace Ob_Ivan\ResourceContainer; use ArrayAccess; class ResourceContainer implements ArrayAccess { /** * @var [<string name> => <mixed(self) factory>] **/ private $factories = []; /** * @var [<string ...
Add the imagine filters annotation.
<?php namespace Glavweb\CoreBundle\Mapping\Annotation; /** * Class ImagineFilters * @package Glavweb\UploaderBundle\Mapping\Annotation * * @Annotation * @Target({"PROPERTY"}) */ class ImagineFilters { /** * @var array */ public $filters; /** * @var string */ public $property...
Create a abstract class 'FormFieldSemanticUI' - responsible to generate html fields using the frontend frameword 'Semanti-ui'
<?php /** * <h1>FormFieldsSemanticUI</h1> * * Project Name: Backfront * Project URI: https://github.com/BackFront/umbrella-packege * Description: Generate the HTML fields * Version: 1.0.0 * Author: Douglas Alves * Author URI: http://alvesdouglas.com.br/ * License: Apache License 2.0 * * @package Backfront ...
Add new service for uploading traits
<?php namespace AppBundle\API\Upload; use AppBundle\Service\DBVersion; use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\HttpKernel\KernelInterface; class Traits { private $dbversion;...
Add missing test for getItem on ItemTooLargeException
<?php /** * Box packing (3D bin packing, knapsack problem) * @package BoxPacker * @author Doug Wright */ declare(strict_types=1); namespace DVDoug\BoxPacker; use DVDoug\BoxPacker\Test\TestItem; use PHPUnit\Framework\TestCase; class ItemTooLargeExceptionTest extends TestCase { function testCanGetItem() { ...
Add function all object test
// SYNTAX TEST "Packages/php-grammar/PHP.tmLanguage" <?php $foo = $this->getRequest(); // ^ meta.function-call.object $foo = $this->request; // ^ variable.other.property
Introduce global view parameters service
<?php /** * Copyright 2016 SURFnet B.V. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Add script to reset admin user passwords
<?php $file = '/shell/abstract.php'; for ($path = '/../../', $i = 0; ! file_exists(dirname(__FILE__) . $path . $file) && $i++ < 10; $path .= '../'); require_once dirname(__FILE__) . $path . $file; class Ikonoshirt_Pbkdf2_Shell_SetAdminPass extends Mage_Shell_Abstract { public function run() { Mage::se...
Add test case for AccountACEinfo
<?php namespace Zimbra\Mail\Tests\Struct; use Zimbra\Mail\Tests\ZimbraMailTestCase; use Zimbra\Enum\AceRightType; use Zimbra\Enum\GranteeType; use Zimbra\Mail\Struct\AccountACEinfo; /** * Testcase class for AccountACEinfo. */ class AccountACEinfoTest extends ZimbraMailTestCase { public function testAccountACEi...
Add some really simple (probably stupid) tests on version.php
<?php require_once dirname( dirname( dirname( __FILE__ ) ) ) . DIRECTORY_SEPARATOR . 'phpunit_bootstrap.php'; class system_classes_VersionTest extends PHPUnit_Framework_TestCase { public function testGet_dbversion() { $this->assertEquals( Version::DB_VERSION, Version::get_dbversion() ); } public ...
Test database connection and access for TDD/sample data.
<?php // Database Test Copyright 2014 by WebIS Spring 2014 License Apache 2.0 require_once 'TDD/validator.php'; class MyTestCase extends WebIS\Validator { protected static $__CLASS__=__CLASS__; function execute($db,$sql){ $stmt=$db->prepare($sql); $this->assertNotEquals(FALSE,$stmt,$db->error); $this->asser...
Add ability to manipulate sources
<?php namespace Stripe; /** * Class Source * * @package Stripe */ class Source extends ApiResource { /** * @param string $id The ID of the Source to retrieve. * @param array|string|null $opts * * @return Source */ public static function retrieve($id, $opts = null) { re...
Add tests for the content extentions themes page
<?php namespace Backend\Modules\ContentBlocks\Tests\Action; use Common\WebTestCase; class ThemesTest extends WebTestCase { public function testAuthenticationIsNeeded(): void { $client = static::createClient(); $this->logout($client); $client->setMaxRedirects(1); $client->requ...
Add a custom twig extension for exposing the raygun api key
<?php /* * This file is part of the Raygunbundle package. * * (c) nietonfir <nietonfir@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Nietonfir\RaygunBundle\Twig; class RaygunSetupExtension extends \Twig_Ex...
Fix sha1 hash length in database
<?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class FixHashLengthForUploadsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('uploads', function (Blueprint $table) { ...
Test case: resolve target document listener
<?php namespace Doctrine\ODM\MongoDB\Tests\Tools; use Doctrine\ODM\MongoDB\Events; use Doctrine\ODM\MongoDB\Tools\ResolveTargetDocumentListener; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; class ResolveTargetDocumentListenerTest extends \Doctrine\ODM\MongoDB\Tests\BaseTest { /** * @var \Doctrine\OD...
Add a default edit form for Shuwee users
<?php namespace Wanjee\Shuwee\AdminBundle\Form; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Extension\Core\Type\RepeatedType; use Wanjee\Shuwee\AdminBundle\Entity\User; use Symfony\Component\Form\AbstractType; use S...
Add basic api server for test purposes
<?php $verb = strtolower($_SERVER['REQUEST_METHOD']); function output($data) { echo json_encode([ "result" => $data ]); } header('Content-Type: application/json'); $users = [ [ "id" => 0, "name" => "Will McKenzie", "email" => "will@komododigital.co.uk" ], [ "id" => 1, "name" => "A...
Add usecase to test an application with the starter disabled
<?php $staq_path = substr( __DIR__, 0, strrpos( __DIR__, '/Staq/' ) + 5 ); require_once( $staq_path . '/util/tests.php' ); include_once( $staq_path . '/include.php' ); // CONTEXT $path = \Staq\util\string_basename( __DIR__, 4 ); $app = new \Staq\Application( $path ); $app->start( ); new \Stack\Coco; // TEST COLLECTI...
Add index on profile_id to races table
<?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class AddIndexOnProfileIdToRacesTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('races', function ($table) { $t...
Add an interface for mutable addresses
<?php declare(strict_types=1); namespace BinSoul\Common\I18n; /** * Represents an address which is mutable. */ interface MutableAddress extends Address { /** * Sets the organization. */ public function setOrganization(?string $value): void; /** * Sets the name prefix / salutation. ...
Add mail form (is not used).
<?php // Check for empty fields if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['message']) || !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) { echo "No arguments Provided!"; return false; } $name = $_POST['name']; $email_address = $_POST['e...
Add sorted set sub key data builder
<?php declare(strict_types=1); namespace hollodotme\Readis\Application\ReadModel\KeyDataBuilders; use hollodotme\Readis\Application\Interfaces\ProvidesKeyInfo; use hollodotme\Readis\Application\ReadModel\Constants\KeyType; use hollodotme\Readis\Application\ReadModel\DTO\KeyData; use hollodotme\Readis\Application\Read...
Fix event_stream table primary key.
<?php namespace Surfnet\StepupMiddleware\Migrations; use Doctrine\DBAL\Migrations\AbstractMigration; use Doctrine\DBAL\Schema\Schema; /** * Drops the UUID primary key, removes the UNIQUE constraint on (uuid, playhead) and make (uuid, playhead) the primary * key. */ class Version20141112094457 extends AbstractMigr...
Create New Image and draw some text
<?php /* * PixLab PHP Client which is just a single class PHP file without any dependency that you can get from Github * https://github.com/symisc/pixlab-php */ require_once "pixlab.php"; # Dynamically create a 300x300 PNG image with a yellow background and draw some text on top of it later. # Refer to https://pi...
Add envoy config file to handle deployments and running memvents:update artisan command remotely
@servers(['prod' => 'memvents@memvents.memphistechnology.org']) @task('deploy:prod', ['on' => 'prod']) cd /home/memvents/memvents/ cp /home/memvents/configs/.env.production /home/memvents/memvents/.env git pull origin master php artisan migrate --force @endtask @task('memvents:update', ['on' => 'prod']) cd /home/memv...
Add type casting syntax tests
// SYNTAX TEST "Packages/php-grammar/PHP.tmLanguage" <?php (bool); // ^ storage.type (boolean); // ^ storage.type (int); // ^ storage.type (integer); // ^ storage.type (float); // ^ storage.type (double); // ^ storage.type (real); // ^ storage.type (string); // ^ storage.type (object); // ^ storage.type (unset); ...
Add option to get file size
<?php namespace Intervention\Image; class File { /** * Mime type * * @var string */ public $mime; /** * Name of directory path * * @var string */ public $dirname; /** * Basename of current file * * @var string */ public $basename; ...
<?php namespace Intervention\Image; class File { /** * Mime type * * @var string */ public $mime; /** * Name of directory path * * @var string */ public $dirname; /** * Basename of current file * * @var string */ public $basename; ...
Add manual update script to use when changing branches
<? require_once dirname(__FILE__) . '/../Kwf/Setup.php'; Kwf_Setup::setUp(); $file = is_file('vkwf_branch') ? 'vkwf_branch' : 'kwf_branch'; file_put_contents($file, "master\n"); echo "Changed $file to master\n"; function glob_recursive($pattern, $flags = 0) { $files = glob($pattern, $flags); foreach (glob(dir...
Add size helper class to the templating
<?php namespace Ivory\GoogleMapBundle\Templating\Helper; use Ivory\GoogleMapBundle\Model\Size; /** * Size helper allows easy rendering * * @author GeLo <geloen.eric@gmail.com> */ class SizeHelper { /** * Renders the size * * @param Ivory\GoogleMapBundle\Model\Size $size * @return string H...
Add the testcase for a returned document with null object fields
<?php /* * This file is part of the ONGR package. * * (c) NFQ Technologies UAB <info@nfq.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace ONGR\ElasticsearchBundle\Tests\Functional\Result; use ONGR\ElasticsearchDSL\Q...
Add legal info for en (UK)
<div class="panel panel-default"> <div class="panel-heading">United Kingdom Computer Misuse Act 1990</div> <div class="panel-body"> <ul> <li>unauthorised access to computer material, punishable by 12 months' imprisonment (or 6 months in Scotland) and/or a fine "not exceeding level 5 on the s...
Add support for various linux flavors
<?php namespace Laravel\Homestead; use Symfony\Component\Process\Process; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class EditCommand extends Command { /** * Configure the command options. * * @retur...
<?php namespace Laravel\Homestead; use Symfony\Component\Process\Process; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class EditCommand extends Command { /** * Configure the command options. * * @retur...
Add Test case for AttachmentsInfo.
<?php namespace Zimbra\Mail\Tests\Struct; use Zimbra\Mail\Tests\ZimbraMailTestCase; use Zimbra\Mail\Struct\AttachmentsInfo; use Zimbra\Mail\Struct\ContactAttachSpec; use Zimbra\Mail\Struct\DocAttachSpec; use Zimbra\Mail\Struct\MimePartAttachSpec; use Zimbra\Mail\Struct\MsgAttachSpec; /** * Testcase class for Attach...
Define interface for AccessToken Generators
<?php /** * This file is part of the Imbo package * * (c) Christer Edvartsen <cogo@starzinger.net> * * For the full copyright and license information, please view the LICENSE file that was * distributed with this source code. */ namespace Imbo\EventListener\AccessToken; /** * Abstract class for Access Token G...
Add unit test for WebDriverContextClickAction
<?php class WebDriverContextClickActionTest extends PHPUnit_Framework_TestCase { /** * @type WebDriverContextClickAction */ private $webDriverContextClickAction; private $webDriverMouse; private $locationProvider; public function setUp() { $this->webDriverMouse = $this->getM...
Add test to check if parentAssociation is available in postLoad
<?php namespace Doctrine\ODM\MongoDB\Tests\Functional\Ticket; use Doctrine\ODM\MongoDB\Event\LifecycleEventArgs; use Doctrine\ODM\MongoDB\Events; use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; class GH1152Test extends \Doctrine\ODM\MongoDB\Tests\BaseTest { public function testParentAssociationsInPostLoad()...
Allow *.sspak extension in SS Filesystem
<?php
<?php // *.sspak is required for data archives $exts = Config::inst()->get('File', 'allowed_extensions'); $exts[] = 'sspak'; Config::inst()->update('File', 'allowed_extensions', $exts);
Add migration for mail template
<?php namespace AppBundle\Migration; use Doctrine\DBAL\Migrations\AbstractMigration; use Doctrine\DBAL\Schema\Schema; /** * Auto-generated Migration: Please modify to your needs! */ class Version20150810070728 extends AbstractMigration { /** * @param Schema $schema */ public function up(Schema $s...
Create stub for loading extension specific implementations
<?php if (extension_loaded('poly1305')) { class Poly1305 { function authenticate($key, $message) { return poly1305_authenticate($key, $message); } function verify($authenticator, $key, $message) { return poly1305_verify($authenticator, $key, $message...
Add a webform for printing given template when match given statuses.
<?php require("dbconnect.php"); # Get fields from GET/POST. $fields = Array(); foreach ($_GET as $k => $v) { $fields[$k] = $v; } foreach ($_POST as $k => $v) { $fields[$k] = $v; } # Some additional formatting. $fields['DATE'] = date('m-d-Y'); $fields['date_of_birth'] = substr($fields['date_of_birth'],5) . '-...
Fix getting registrations error if no project id
<?php namespace MapasCulturais\Repositories; use MapasCulturais\Traits; class Registration extends \MapasCulturais\Repository{ /** * * @param \MapasCulturais\Entities\Project $project * @param \MapasCulturais\Entities\User $user * @return \MapasCulturais\Entities\Registration[] */ func...
<?php namespace MapasCulturais\Repositories; use MapasCulturais\Traits; class Registration extends \MapasCulturais\Repository{ /** * * @param \MapasCulturais\Entities\Project $project * @param \MapasCulturais\Entities\User $user * @return \MapasCulturais\Entities\Registration[] */ func...
Add foreign_key to tag_changes table
<?php use Phinx\Migration\AbstractMigration; class AddForeignKeyToTagChangesTable extends AbstractMigration { public function up() { $this->query('ALTER TABLE tag_changes ALTER COLUMN tag_id DROP NOT NULL'); $screwed_ids = $this->fetchAll('SELECT DISTINCT tag_id FROM tag_changes tc WHERE (SELECT count(id) F...
Add very basic fee waiver payment type.
<?php /** * Apply for a fee waiver */ class FeeWaiverPayment extends ApplyPayment{ const PENDING_TEXT = 'Your application has been received'; const SETTLED_TEXT = 'Your application was approved'; const REJECTED_TEXT = 'Your application was denied'; const REFUNDED_TEXT = 'Your application was withdrawn'; ...
Add php example to authent and call Webservices
<?php require 'OpenveoWSClient.php'; $client = New OpenveoWSClient("65d6247f0293049523d6a5e2efdf49ac07b51600", "8a7b0d43a631b52cf15e89eba7a65f274ccc7f73", "localhost", "3001"); $isAuthenticated = $client->authenticate(); // Autentication succeed if ($isAuthenticated) { $param = [ 'limit' => 2, 'pag...
Create (as yet unused) database config file.
<?php use Illuminate\Database\Capsule\Manager as Capsule; use Sil\PhpEnv\Env; $mysqlHost = Env::get('MYSQL_HOST'); $mysqlDatabase = Env::get('MYSQL_DATABASE'); $mysqlUser = Env::get('MYSQL_USER'); $mysqlPassword = Env::get('MYSQL_PASSWORD'); $capsule = new Capsule; $capsule->addConnection([ 'driver' => 'mysq...
Add a L10n support class
<?php /** * Localization support class * @author Heinz Wiesinger */ class L10n { /** * Static list of supported languages * @var array */ private static $languages; /** * Constructor */ public function __construct() { } /** * Destructor */ publi...
Add helper class to encapsulate Mercury Region data
<?php /** * Helper class to encapsulate Mercury Region data * * @author Jonas Flodén */ namespace Koala\ContentBundle; class MercuryRegions implements \ArrayAccess, \Iterator { var $regions; var $keys; function __construct($content) { $this->regions = json_decode($content, true); } ...
Add a few tests for the DefaultValues class
<?php namespace SitemapGenerator\Tests\Provider; use SitemapGenerator\Entity\ChangeFrequency; use SitemapGenerator\Provider\DefaultValues; class DefaultValuesTest extends \PHPUnit_Framework_TestCase { public function testEmptyDefaultValuesCanBeCreated() { $values = DefaultValues::none(); $th...
Test for set parsedReceivedPayload event
<?php namespace Tests\SlackAPI\Events; use PHPUnit\Framework\TestCase; use SlackPHP\SlackAPI\Events\ParsedReceivedEvent; use SlackPHP\SlackAPI\Models\Methods\GroupsListResponse; /** * @author Dzianis Zhaunerchyk <dzhaunerchyk@gmail.com> * @covers ParsedReceivedEvent */ class ParsedReceivedEventTest extends TestCa...
Add migration for user's Conduit certificates.
<?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class AddConduitCertificateToUser extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('users', function($table) { $table->text('conduit_certificate'); }...
Test access token creation using oAuth2
<?php namespace Slakbal\Gotowebinar\Test\Unit; use Slakbal\Gotowebinar\DirectLogin; use Slakbal\Gotowebinar\Facade\GotoWebinar; use Slakbal\Gotowebinar\Test\BaseTestCase; class DirectLoginTest extends BaseTestCase { /** * Test direct login for access token * * @return void */ public funct...
Add new validation (not finished).
<?php /** * @author Andreas Kummer, w3concepts AG * @copyright Copyright &copy; 2011, w3concepts AG */ class Aitsu_Form_Validation_Expression_Depending implements Aitsu_Form_Validation_Expression_Interface { protected $args; protected function __construct($args) { $this->args = $args; } public static fu...
Add template properties collection parser utility
<?php namespace Aedart\Scaffold\Collections\Utility; use Aedart\Scaffold\Containers\IoC; use Aedart\Scaffold\Contracts\Collections\TemplateProperties; /** * Properties Collection Parser Trait * * Utility that is able to parse an array into a * template properties collection * * @author Alin Eugen Deac <aedart@g...
Add an (unsupported) sample application for the Google Contacts API.
<?php /* * Copyright 2012 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agre...
Add basic TourDates element test
<?php require_once('tests/php/base.php'); require_once('framework/php/classes/elements/TourDates.php'); class ElementTests extends UnitTestCase { function testTourDates(){ $e = new TourDates('blarg',1); $this->assertIsa($e, 'TourDates'); } } ?>
Add frontpage hook with link to user page.
<?php /** * Hook to add the OpenID provider to the authentication tab. * * @param array &$links The links on the frontpage, split into sections. */ function openidProvider_hook_frontpage(&$links) { assert('is_array($links)'); assert('array_key_exists("links", $links)'); $links['auth'][] = array( 'href' => Si...
Move Anqh specific routes from bootstrap
<?php defined('SYSPATH') or die('No direct access allowed.'); /** * Init for Anqh * * @package Anqh * @author Antti Qvickström * @copyright (c) 2010 Antti Qvickström * @license http://www.opensource.org/licenses/mit-license.php MIT license */ Route::set('404', '<file>.<ext>', array('ext' => 'ico|png|...
Set template for contact us page - Display the information from the hours of operations admin configuration
<?php get_header(); ?> <div id="content" class="container"> <div id="inner-content" class="row"> <main id="main" class="col-xs-12" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <article id="post-<?php t...
Check apc.enable_cli for ApcTestCase unit tests
<?php namespace yiiunit\framework\caching; use yii\caching\ApcCache; use yiiunit\TestCase; /** * Class for testing APC cache backend */ class ApcCacheTest extends CacheTest { private $_cacheInstance = null; /** * @return ApcCache */ protected function getCacheInstance() { if(!extension_loaded("apc")) { ...
<?php namespace yiiunit\framework\caching; use yii\caching\ApcCache; use yiiunit\TestCase; /** * Class for testing APC cache backend */ class ApcCacheTest extends CacheTest { private $_cacheInstance = null; /** * @return ApcCache */ protected function getCacheInstance() { if(!extension_loaded("apc")) { ...
Fix issue: Can't delete game which has active servers.
<?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class FixGameForeignKey extends Migration { /** * Run the migrations. * * @return void */ public function up() { // This deletes all servers when a game is deleted Schema::table('servers', function($table) ...
Add the Google Calendar starter application.
<?php require_once '../../src/apiClient.php'; require_once '../../src/contrib/apiCalendarService.php'; session_start(); $client = new apiClient(); $client->setApplicationName("Google Calendar PHP Starter Application"); // Visit https://code.google.com/apis/console?api=calendar to generate your // client id, client se...
Add a bunch of traits to ZF2
<?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Z...
Add sample User model class to illustrate find() functionality.
<?php class User extends Model { var $_table_name = 'users'; var $_key_field = 'user_id'; var $_insert_timestamp_field = 'create_date'; var $_update_timestamp_field = 'update_date'; static function find($criteria, $sort = false, $limitStart = false, $limitEnd = false) { return parent::find('User', 'u...
Add missing tests for SETNX.
<?php /* * This file is part of the Predis package. * * (c) Daniele Alessandri <suppakilla@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Predis\Command; use PHPUnit_Framework_TestCase as StandardTestCase; ...
Add form type to create association via dragging from one tree to another in tree view
<?php namespace CftfBundle\Form\Type; use CftfBundle\Entity\LsAssociation; use CftfBundle\Entity\LsDoc; use Doctrine\ORM\EntityRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Ex...
Add PHP script to display number of visits to a page.
<?php $title = "Visit Count"; $file = "/tmp/ip-lab_2b_count"; $count = 1; if (!file_exists($file)) { $handle = fopen($file, "w"); fwrite($handle, $count); fclose($handle); } else { $handle = fopen($file, "r"); fscanf($handle, "%d", $count); ...
Add processor that will set total deleted items count into response header -- comment fix
<?php namespace Oro\Bundle\ApiBundle\Processor\DeleteList; use Oro\Component\ChainProcessor\ContextInterface; use Oro\Component\ChainProcessor\ProcessorInterface; /** * Unset the "X-Include-Delete-Count" response header * in case if it was requested by "X-Include: deleteCount" request header and an error occurred...
<?php namespace Oro\Bundle\ApiBundle\Processor\DeleteList; use Oro\Component\ChainProcessor\ContextInterface; use Oro\Component\ChainProcessor\ProcessorInterface; /** * Unset the "X-Include-Delete-Count" response header * in case if it was requested by "X-Include: deleteCount" request header but an error occurred...
Add index to oc_cards to assist with searching large number of rows
<?php namespace OCA\dav\Migrations; use Doctrine\DBAL\Schema\Schema; use OCP\Migration\ISchemaMigration; /** * Add index to oc_cards to assist with searching with large numbers of rows */ class Version20170519091921 implements ISchemaMigration { public function changeSchema(Schema $schema, array $options) { $pr...
Load class para carregamento de views e models
<?php class Load{ private $config; public function __construct() { $this->config = new Config; } public function view($name,array $vars = array()){ $file = $name.'View.php'; if($file != 'loginView.php') { if(!isset($_SESSION['is_logged'])) { return header("Location: /login"); } } ...
Create store info template part.
<div class="row store-info"> <?php if ( is_single() ) : ?> <div class="small-12 large-4 columns"> <?php the_post_thumbnail( 'store-image', array( 'class' => 'th' ) ); ?> </div> <div class="small-12 large-8 columns"> <?php else: ?> <div class="small-12 large-2 columns"> <a href="<?php the_permalink(); ?>"> ...
Add additional sample provider for test suite
<?php namespace Benrowe\Formatter\Test\Examples; use Benrowe\Formatter\AbstractFormatterProvider; class NumberSampleProvider extends AbstractFormatterProvider { public function asNumber($value) { return $this->normalise($value); } public function asUnsigned($value) { $value = $th...
Make sure the SVG sprite contains valid XML
<?php namespace App\Test\TestCase\Controller; use Cake\Core\Configure; use Cake\TestSuite\IntegrationTestTrait; use Cake\TestSuite\TestCase; use SimpleXMLElement; class AssetsControllerTest extends TestCase { use IntegrationTestTrait; public function setUp() { parent::setUp(); // Make sure d...
Create a new interface to define a Where clause
<?php /** * @author Michael Collette <mcollette@meetingevolution.net> * @version 1.0 * @package Metrol/DBSql * @copyright (c) 2016, Michael Collette */ namespace Metrol\DBSql; /** * Describes objects that provide where clauses * */ interface WhereInterface { /** * Produce the text ...
Create test case for ContestEntriesController
<?php namespace Tests\Controllers; use App\Models\Contest; use App\Models\User; use DateTime; use Illuminate\Http\Testing\File; use Tests\TestCase; class ContestEntriesControllerTest extends TestCase { private Contest $contest; private User $user; public function testStoreEntryWithWrongFileExtension() ...
Migrate RefCursor data to RefPosition table
<?php $table = new PhabricatorRepositoryRefCursor(); $conn = $table->establishConnection('w'); $map = array(); foreach (new LiskMigrationIterator($table) as $ref) { $repository_phid = $ref->getRepositoryPHID(); $ref_type = $ref->getRefType(); $ref_hash = $ref->getRefNameHash(); $ref_key = "{$repository_phid}...
Add in-memory cache decorated UsersInterface implementation
<?php /** * @file */ namespace CultuurNet\UDB3\UiTID; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use Psr\Log\NullLogger; use ValueObjects\String\String; use ValueObjects\Web\EmailAddress; class InMemoryCacheDecoratedUsers implements UsersInterface, LoggerAwareInterface { use LoggerAwareTra...
Add unit test for RingPHP and Guzzle.
<?php namespace Kshabazz\Tests\Interception; /** * Test for use with Guzzle HTTP client. */ use GuzzleHttp\Client; use GuzzleHttp\Ring\Client\StreamHandler; use Kshabazz\Interception\StreamWrappers\Http; /** * Class GuzzleTest * * @package Kshabazz\Tests\Interception */ class HttpClientTest extends \PHPUnit_Frame...
Add the artisan command to check for security vulns
<?php namespace App\Console\Commands; use Illuminate\Console\Command; use SensioLabs\Security\SecurityChecker; class SecurityCheck extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'security:check'; /** * The console...
Add cronjob for extracting hero usages per mod
<?php require_once('../functions.php'); require_once('../../global_functions.php'); require_once('../../connections/parameters.php'); $db = new dbWrapper($hostname_gds_site, $username_gds_site, $password_gds_site, $database_gds_site, true); if ($db) { //MOD-HERO BREAKDOWN { $db->q("DROP TABLE IF EXIST...
Add indexes to Messages table
<?php use Movim\Migration; use Illuminate\Database\Schema\Blueprint; class AddJidToJidFromIndexesToMessages extends Migration { public function up() { $this->schema->table('messages', function(Blueprint $table) { $table->index(['user_id', 'jidfrom', 'jidto', 'id'])->nullable(); });...
Set default location type for Address, Email, IM, OpenID, Phone
<?php namespace Civi\Api4\Service\Spec\Provider; use Civi\Api4\Service\Spec\RequestSpec; class DefaultLocationTypeProvider implements Generic\SpecProviderInterface { /** * @inheritDoc */ public function modifySpec(RequestSpec $spec) { $locationField = $spec->getFieldByName('location_type_id')->setRequ...
Introduce a trait for event handling delegation to a specific method, for implementing EventListenerInterface of Broadway library
<?php /** * @file */ namespace CultuurNet\UDB3\EventHandling; use Broadway\Domain\DomainMessageInterface; use Broadway\EventHandling\EventListenerInterface; trait DelegateEventHandlingToSpecificMethodTrait { /** * {@inheritDoc} */ public function handle(DomainMessageInterface $domainMessage) ...
Add unit test class for the Menu component
<?php declare(strict_types=1); namespace Tests; use Illuminate\Support\Facades\Artisan; use LaravelZero\Framework\Contracts\Providers\ComposerContract; final class MenuComponentTest extends TestCase { /** @test */ public function it_installs_the_required_packages(): void { $composerMock = $this-...
Increase default token field lengths.
<?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class IncreaseTokenFieldLength extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('users', function (Blueprint $table) { ...
Add a script to fix users with empty email.
<?php /** * Script to set a placeholder email for users with blank mail field. * * to run: * drush --script-path=../scripts/ php-script fix-empty-mail.php */ $troublemakers = db_query('SELECT uid FROM users LEFT JOIN field_data_field_mobile ON uid = entity_id WHERE mail = \'\' AND uid != 0'); $fixed = 0; foreach...
Add new UrlRule for token
<?php /** * Created by PhpStorm. * User: thanh * Date: 13/1/2017 * Time: 10:43 AM */ namespace api\components; use fproject\rest\UrlRule; class TokenUrlRule extends UrlRule { /** @inheritdoc */ public $patterns = [ 'POST generate-private' => 'generate-private', 'POST generate-public' => ...
Make migration to update Characters table name columns
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class UpdateCharactersTableRenameKanjiColumn extends Migration { /** * Run the migrations. * * @return void */ public function up() { if(Schema::hasTable('characters')) { ...
Add a few tests for the random generator
<?php namespace Tests\Regis\Infrastructure\RandomLib; use Regis\Infrastructure\RandomLib\Generator; class GeneratorTest extends \PHPUnit_Framework_TestCase { public function testItCanGenerateRandomStrings() { $generator = new Generator(); $this->assertInternalType('string', $result1 = $gener...
Add test for GET torrents/:hash endpoint
<?php namespace Tests\App\Api\V1; use Tests\Support\TestCase; class GetTorrentsWithHashTest extends TestCase { public function test_responds_with_200() { $this->json('GET', 'torrents/396F31CBA7221279B8E498EB8787D47A598A79DC'); $this->assertResponseOk(); } }
Archive lists new style, tweet button fix, move all JS at page bottom, move req * append to label
<?php /* Taxanomies Template theme: maju by rafaelhigueros.me | scream.ws v: 1.0 */ //Get theme options $options = get_option('maju_theme_options'); get_header(); ?> <script src="<?php bloginfo('template_url'); ?>/js/portfolio.js"></script> <div id="body"> <!-- Projects [BEGIN] --> <secti...
Add base EntryPoint class, not used actually
<?php namespace SLLH\HybridAuthBundle\Security\Http\EntryPoint; use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface, Symfony\Component\Security\Core\Exception\AuthenticationException, Symfony\Component\Security\Http\HttpUtils, Symfony\Component\HttpFoundation\Request; /** * ...