<?php

require_once('functions.php');

echo $_SERVER['QUERY_STRING'];

// Split query string and perform actions based on it with conditional includes

?>

<?php

/* Include Function Library */
require_once('functions.php');

/* Session Authentication
 *
 * Session data is protected by a mutex lock while writable. Free the lock
 * by committing as soon as possible so that concurrent requests complete
 * quickly. */
session_start();
if (empty($_SESSION['userId'])) {
	//require('login.php');
}
session_commit();

/* Query Resolution
 *
 * Split the query string on the slash character to create an array of
 * arguments. Then conditionally include script files to handle requests
 * based on those arguments. */
$query = trim($_SERVER['QUERY_STRING'], '/');
$argv  = explode('/', $query); // $arg will always contain at least one element
$argc  = count($argv);

if ($argv[0] == 'assignment') {
	//require('assignment.php');
} else if ($argv[0] == 'course') {
	//require('course.php');
} else if ($argv[0] == 'report') {
	//require('report.php');
} else if ($argv[0] == 'serve') {
	//require('serve.php');
} else {
	//require('course.php');
}

?>

Add initial structure to authenticate and parse arguments


<?php

namespace jorenvanhocht\Blogify\Commands;

use Illuminate\Console\Command;

class BlogifyMigrateCommand extends Command
{

    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'blogify:migrate';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Run the migrations for the Blogify package';

    /**
     * @var array
     */
    protected $paths;

    /**
     * Construct the class
     */
    public function __construct()
    {
        parent::__construct();

        $this->paths = [
            'vendor/jorenvanhocht/blogify/database/Migrations',
            'vendor/jorenvanhocht/tracert/database/Migrations',
        ];
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function fire()
    {
        foreach ($this->paths as $path) {
            $this->call('migrate', ['--path' => $path]);
        }
    }

}

<?php

namespace jorenvanhocht\Blogify\Commands;

use Illuminate\Console\Command;

class BlogifyMigrateCommand extends Command
{

    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'blogify:migrate';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Run the migrations for the Blogify package';

    /**
     * @var array
     */
    protected $paths;

    /**
     * Construct the class
     */
    public function __construct()
    {
        parent::__construct();

        $this->paths = [
            'packages/jorenvanhocht/blogify/database/Migrations',
            'packages/jorenvanhocht/tracert/database/Migrations',
        ];
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function fire()
    {
        foreach ($this->paths as $path) {
            $this->call('migrate', ['--path' => $path]);
        }
    }

}

Set paths tmp to development. Need to write a env fix for that.


<?php

namespace app\components;

use app\models\Subscription;
use Yii;

/**
 * Description of FavMenuHelper
 *
 * @author charles
 */
class FavMenuHelper
{

    public static function getFavMenuItems()
    {
        $result = [
            [
                'label' => '我的收藏',
                'icon'  => 'fa fa-star',
                'url'   => ['/subscription/list'],
                'items' => [],
            ],
        ];

        $subscriptions = Subscription::findAll(['user_id' => Yii::$app->user->id]);
        foreach ($subscriptions as $s) {
            $result[0]['items'][] = [
                'label' => $s->report->name,
                'icon'  => 'fa fa-circle',
                'url'   => ['/report/view', 'id' => $s->report_id],
            ];
        }

        return $result;
    }
}

<?php

namespace app\components;

use app\models\Subscription;
use Yii;

/**
 * Description of FavMenuHelper
 *
 * @author charles
 */
class FavMenuHelper
{

    public static function getFavMenuItems()
    {
        $result = [
            [
                'label' => '我的收藏',
                'icon'  => 'star',
                'url'   => ['/subscription/list'],
                'items' => [],
            ],
        ];

        $subscriptions = Subscription::findAll(['user_id' => Yii::$app->user->id]);
        foreach ($subscriptions as $s) {
            $result[0]['items'][] = [
                'label' => $s->report->name,
                'icon'  => 'circle',
                'url'   => ['/report/view', 'id' => $s->report_id],
            ];
        }

        return $result;
    }
}

Fix the icons of menu.

Fix the icons of menu.


<?php

namespace Siggy\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
	/**
	 * The Artisan commands provided by your application.
	 *
	 * @var array
	 */
	protected $commands = [
		\Siggy\Console\Commands\EveSystemStatsCommand::class,
		\Siggy\Console\Commands\SignaturesClearCommand::class,
		\Siggy\Console\Commands\BillingChargeCommand::class,
		\Siggy\Console\Commands\SessionsClearCommand::class,
		\Siggy\Console\Commands\BillingPaymentsCommand::class,
		\Siggy\Console\Commands\NotificationsClearCommand::class
	];

	/**
	 * Define the application's command schedule.
	 *
	 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
	 * @return void
	 */
	protected function schedule(Schedule $schedule)
	{
		$schedule->command('sessions:clear')
		          ->hourly();
		$schedule->command('notifications:clear')
		          ->daily();
		$schedule->command('billing:payments')
		          ->hourly();
		$schedule->command('billing:charges')
		          ->dailyAt('00:00');
		$schedule->command('eve:systemstats')
		          ->hourly();
		$schedule->command('signatures:clear')
		          ->daily();
	}

	/**
	 * Register the Closure based commands for the application.
	 *
	 * @return void
	 */
	protected function commands()
	{

	}
}

<?php

namespace Siggy\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
	/**
	 * The Artisan commands provided by your application.
	 *
	 * @var array
	 */
	protected $commands = [
		\Siggy\Console\Commands\EveSystemStatsCommand::class,
		\Siggy\Console\Commands\SignaturesClearCommand::class,
		\Siggy\Console\Commands\BillingChargeCommand::class,
		\Siggy\Console\Commands\SessionsClearCommand::class,
		\Siggy\Console\Commands\BillingPaymentsCommand::class,
		\Siggy\Console\Commands\NotificationsClearCommand::class
	];

	/**
	 * Define the application's command schedule.
	 *
	 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
	 * @return void
	 */
	protected function schedule(Schedule $schedule)
	{
		$schedule->command('sessions:clear')
		          ->hourlyAt(00);
		$schedule->command('notifications:clear')
		          ->daily();
		$schedule->command('billing:payments')
		          ->hourlyAt(05);
		$schedule->command('billing:charges')
		          ->daily();
		$schedule->command('eve:systemstats')
		          ->hourlyAt(01);
		$schedule->command('signatures:clear')
		          ->dailyAt('01:00');
	}

	/**
	 * Register the Closure based commands for the application.
	 *
	 * @return void
	 */
	protected function commands()
	{

	}
}

Set some spread times for tasks.

Set some spread times for tasks.


<?php

namespace Crell\TransformerBundle\Tests;

use Crell\Transformer\Tests\MethodConverterTest;
use Crell\Transformer\Tests\TestA;
use Crell\Transformer\Tests\TestB;
use Crell\Transformer\Tests\TransformerBusTest;
use Crell\TransformerBundle\ContainerAwareTransformerBus;
use Symfony\Component\DependencyInjection\Container;

class ContainerAwareTransformerBusTest extends TransformerBusTest
{
    protected $classToTest = 'Crell\TransformerBundle\ContainerAwareTransformerBus';

    protected function createTransformerBus($target) {
        $container = new Container();
        $bus = new ContainerAwareTransformerBus($target);
        $bus->setContainer($container);
        return $bus;
    }

    /**
     * Defines an array of transformers that convert from TestA to TestB.
     */
    public function transformerDefinitionProvider()
    {
        $defs = parent::transformerDefinitionProvider();

        $defs[] = [TestA::CLASSNAME, TestB::CLASSNAME, MethodConverterTest::CLASSNAME . '::transform'];

        return $defs;
    }
}

<?php

namespace Crell\TransformerBundle\Tests;

use Crell\Transformer\Tests\MethodConverterTest;
use Crell\Transformer\Tests\TestA;
use Crell\Transformer\Tests\TestB;
use Crell\Transformer\Tests\TransformerBusTest;
use Crell\TransformerBundle\ContainerAwareTransformerBus;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class ContainerAwareTransformerBusTest extends TransformerBusTest
{
    protected $classToTest = 'Crell\TransformerBundle\ContainerAwareTransformerBus';

    /**
     * {@inheritdoc}
     */
    protected function createTransformerBus($target)
    {
        $container = $this->createMockContainer();

        $container->expects($this->any())
          ->method('has')
          ->with('foo')
          ->will($this->returnValue(true))
        ;
        $container->expects($this->any())
          ->method('get')
          ->with('foo')
          ->will($this->returnValue(new ServiceTransformer()))
        ;

        $bus = new ContainerAwareTransformerBus($target);
        $bus->setContainer($container);
        return $bus;
    }

    protected function createMockContainer()
    {
        return $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
    }

    /**
     * {@inheritdoc}
     */
    public function transformerDefinitionProvider()
    {
        $defs = parent::transformerDefinitionProvider();

        // Successful transformations.
        $defs[] = [TestA::CLASSNAME, TestB::CLASSNAME, MethodConverterTest::CLASSNAME . '::transform'];
        $defs[] = [TestA::CLASSNAME, TestB::CLASSNAME, 'foo:transform'];

        // Transformations that should fail.
        // @todo I am unclear how to make this work without a custom test method and custom container.
        //$defs[] = [TestA::CLASSNAME, TestB::CLASSNAME, 'no_such_service:transform', 'Crell\Transformer\NoTransformerFoundException'];

        return $defs;
    }
}

class ServiceTransformer
{
    public function transform(TestA $a)
    {
        return new TestB();
    }
}

Add a test to verify service name-based transformers.


<?php namespace Octommerce\Octommerce\Updates;

use DB;
use Schema;
use October\Rain\Database\Updates\Migration;

class AddFulltextIndexToProductsTable extends Migration
{

    public function up()
    {
        DB::statement('ALTER TABLE octommerce_octommerce_products ADD FULLTEXT (name)');
        DB::statement('ALTER TABLE octommerce_octommerce_products ADD FULLTEXT (description)');
        DB::statement('ALTER TABLE octommerce_octommerce_products ADD FULLTEXT (sku)');
        DB::statement('ALTER TABLE octommerce_octommerce_products ADD FULLTEXT (keywords)');
    }

    public function down()
    {
        Schema::table('octommerce_octommerce_products', function($table) {
            $table->dropIndex(['name', 'description', 'sku', 'keywords']);
        });
    }
}

<?php namespace Octommerce\Octommerce\Updates;

use DB;
use Schema;
use Exception;
use October\Rain\Database\Updates\Migration;

class AddFulltextIndexToProductsTable extends Migration
{

    public function up()
    {
        try {
            DB::statement('ALTER TABLE octommerce_octommerce_products ADD FULLTEXT (name)');
            DB::statement('ALTER TABLE octommerce_octommerce_products ADD FULLTEXT (description)');
            DB::statement('ALTER TABLE octommerce_octommerce_products ADD FULLTEXT (sku)');
            DB::statement('ALTER TABLE octommerce_octommerce_products ADD FULLTEXT (keywords)');
        } catch (Exception $e) {
            // MySQL is not supported. Please update to the newer version
        }
    }

    public function down()
    {
        try {
            Schema::table('octommerce_octommerce_products', function($table) {
                $table->dropIndex(['name', 'description', 'sku', 'keywords']);
            });
        } catch (Exception $e) {
            // MySQL is not supported. Please update to the newer version
        }
    }
}

Add exception when mysql is not support for fulltext index


<?php declare(strict_types=1);
/*
 * This file is part of PHPUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace PHPUnit\Util\Metadata;

/**
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
 */
final class AnnotationParser implements Parser
{
    /**
     * @psalm-param class-string $className
     */
    public function forClass(string $className): MetadataCollection
    {
        $result = [];

        return MetadataCollection::fromArray($result);
    }

    /**
     * @psalm-param class-string $className
     */
    public function forMethod(string $className, string $methodName): MetadataCollection
    {
        $result = [];

        return MetadataCollection::fromArray($result);
    }
}

<?php declare(strict_types=1);
/*
 * This file is part of PHPUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace PHPUnit\Util\Metadata;

use PHPUnit\Util\Metadata\Annotation\Registry as AnnotationRegistry;

/**
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
 */
final class AnnotationParser implements Parser
{
    /**
     * @psalm-param class-string $className
     */
    public function forClass(string $className): MetadataCollection
    {
        $result = [];

        foreach (AnnotationRegistry::getInstance()->forClassName($className)->symbolAnnotations() as $annotation) {
        }

        return MetadataCollection::fromArray($result);
    }

    /**
     * @psalm-param class-string $className
     */
    public function forMethod(string $className, string $methodName): MetadataCollection
    {
        $result = [];

        foreach (AnnotationRegistry::getInstance()->forMethod($className, $methodName)->symbolAnnotations() as $annotation) {
        }

        return MetadataCollection::fromArray($result);
    }
}

Make this slightly less as simple as possible


<?php

namespace Bauhaus\DependencyInjection;

class FakeService
{
    private $privAttr1 = 'someValue';
    private $privAttr2 = null;
    private $privAttr3 = null;
    public $pubAttr1 = 123;
    public $pubAttr2 = 'bla';
    public $pubAttr3 = null;

    public function __construct()
    {
        $this->privAttr2 = 'aeiou';
    }
}

<?php

namespace Bauhaus\DependencyInjection;

class FakeService
{
    private $privAttr1 = null;
    public $pubAttr1 = 123;
    public $pubAttr2 = 'bla';
    public $pubAttr3 = null;

    public function __construct()
    {
        $this->privAttr1 = 'aeiou';
    }
}

Remove unused code (codavy issue)

Remove unused code (codavy issue)


<?php

/*
 * This file is part of Contao Manager.
 *
 * (c) Contao Association
 *
 * @license LGPL-3.0-or-later
 */

namespace Contao\ManagerApi\EventListener;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\KernelEvent;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;

class JsonRequestListener implements EventSubscriberInterface
{
    /**
     * Disallow everything except JSON and convert data to request content.
     *
     * @param KernelEvent $event
     *
     * @throws UnsupportedMediaTypeHttpException
     * @throws BadRequestHttpException
     */
    public function onKernelRequest(KernelEvent $event)
    {
        $request = $event->getRequest();

        $data = [];

        if (($content = $request->getContent()) !== '') {
            if ('json' !== $request->getContentType()) {
                throw new UnsupportedMediaTypeHttpException('Only JSON requests are supported.');
            }

            $data = json_decode($content, true);

            if (!is_array($data)) {
                throw new BadRequestHttpException('Invalid JSON data received.');
            }
        }

        $request->request->replace($data);
    }

    /**
     * {@inheritdoc}
     */
    public static function getSubscribedEvents()
    {
        return ['kernel.request' => ['onKernelRequest', 100]];
    }
}

<?php

/*
 * This file is part of Contao Manager.
 *
 * (c) Contao Association
 *
 * @license LGPL-3.0-or-later
 */

namespace Contao\ManagerApi\EventListener;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\KernelEvent;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;

class JsonRequestListener implements EventSubscriberInterface
{
    /**
     * Disallow everything except JSON and convert data to request content.
     *
     * @param KernelEvent $event
     *
     * @throws UnsupportedMediaTypeHttpException
     * @throws BadRequestHttpException
     */
    public function onKernelRequest(KernelEvent $event)
    {
        $request = $event->getRequest();
        $content = $content = $request->getContent();

        if ($content === '' && $request->attributes->get('form-data')) {
            return;
        }

        $data = [];

        if ($content !== '') {
            if ('json' !== $request->getContentType()) {
                throw new UnsupportedMediaTypeHttpException('Only JSON requests are supported.');
            }

            $data = json_decode($content, true);

            if (!is_array($data)) {
                throw new BadRequestHttpException('Invalid JSON data received.');
            }
        }

        $request->request->replace($data);
    }

    /**
     * {@inheritdoc}
     */
    public static function getSubscribedEvents()
    {
        // Priority must be lower than the router (defaults to 32)
        return ['kernel.request' => ['onKernelRequest', 20]];
    }
}

Allow a controller to accept non-json data by setting route attribute


<?php

namespace App\Http\Controllers;

use App\Repositories\SchemaRepository;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;

class SchemaController extends Controller
{
    /**
     * @var SchemaRepository
     */
    protected $schemaRepository;

    public function __construct(SchemaRepository $schemaRepository)
    {
        $this->schemaRepository = $schemaRepository;
    }

    public function index()
    {
        return $this->jsonResponse($this->schemaRepository->all());
    }

    public function listSchemaVersion($version)
    {
        return $this->jsonResponse($this->schemaRepository->getVersion($version));
    }

    public function getSchema(Filesystem $fs, $version, $entity)
    {
        try {
            $schema = $this->schemaRepository->loadSchemaForEntity($version, $entity);

            return $this->jsonResponse($schema);
        } catch (FileNotFoundException $e) {
            return response('File not found.', 404, ['Content-type' => 'text/plain']);
        }
    }

    protected function jsonResponse(array $responseData): JsonResponse
    {
        return response()->json(
            $responseData,
            Response::HTTP_OK,
            [
                'Content-Type'                => 'application/json; charset=utf-8',
                'Access-Control-Allow-Origin' => '*',
            ],
            JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
        );
    }
}

<?php

namespace App\Http\Controllers;

use App\Repositories\SchemaRepository;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Contracts\Filesystem\Filesystem;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;

class SchemaController extends Controller
{
    /**
     * @var SchemaRepository
     */
    protected $schemaRepository;

    public function __construct(SchemaRepository $schemaRepository)
    {
        $this->schemaRepository = $schemaRepository;
    }

    public function index()
    {
        return $this->jsonResponse($this->schemaRepository->all());
    }

    public function listSchemaVersion($version)
    {
        return $this->jsonResponse($this->schemaRepository->getVersion($version));
    }

    public function getSchema(Filesystem $fs, $version, $entity)
    {
        try {
            $schema = $this->schemaRepository->loadSchemaForEntity($version, $entity);

            return $this->jsonResponse($schema);
        } catch (FileNotFoundException $e) {
            return $this->jsonResponse(['error' => 'File not found'], Response::HTTP_NOT_FOUND);
        }
    }

    protected function jsonResponse(array $responseData, $status = Response::HTTP_OK): JsonResponse
    {
        return response()->json(
            $responseData,
            $status,
            [
                'Content-Type'                => 'application/json; charset=utf-8',
                'Access-Control-Allow-Origin' => '*',
            ],
            JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
        );
    }
}

Return json from all schema controller paths


<?php
namespace Lubos\Wedos\Shell;

use Cake\Console\Shell;
use Cake\Core\Configure;
use Cake\Network\Http\Client;

class WedosShell extends Shell
{

    /**
     * Initial settings on startup
     *
     * @return void
     */
    public function startup()
    {
        $data = Configure::read('Wedos');
        if (!isset($data['user']) || !isset($data['password'])) {
            $this->error('Please set up Wedos user and password');
        }
        $this->client = new Client();
        $this->request = [
            'request' => [
                'user' => $data['user'],
                'auth' => sha1(implode([
                    $data['user'],
                    sha1($data['password']),
                    date('H', time())
                ])),
            ]
        ];
        $this->url = 'https://api.wedos.com/wapi/xml';
    }

    /**
     * Main function Prints out the list of shells.
     *
     * @return void
     */
    public function main()
    {
        $this->out($this->OptionParser->help());
    }
}

<?php
namespace Lubos\Wedos\Shell;

use Cake\Console\Shell;
use Cake\Core\Configure;
use Cake\Network\Http\Client;
use DateTime;
use DateTimeZone;

class WedosShell extends Shell
{

    /**
     * Initial settings on startup
     *
     * @return void
     */
    public function startup()
    {
        $data = Configure::read('Wedos');
        if (!isset($data['user']) || !isset($data['password'])) {
            $this->error('Please set up Wedos user and password');
        }
        $this->client = new Client();
        $date = new DateTime();
        $date->setTimeZone(new DateTimeZone("Europe/Prague"));
        $this->request = [
            'request' => [
                'user' => $data['user'],
                'auth' => sha1(implode([
                    $data['user'],
                    sha1($data['password']),
                    $date->format('H')
                ])),
            ]
        ];
        $this->url = 'https://api.wedos.com/wapi/xml';
    }

    /**
     * Main function Prints out the list of shells.
     *
     * @return void
     */
    public function main()
    {
        $this->out($this->OptionParser->help());
    }
}

Fix auth, using Europe/Prague timezone to get right hour for auth


<?php namespace Pingpong\Admin\Console;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class AdminInstallCommand extends Command {

	/**
	 * The console command name.
	 *
	 * @var string
	 */
	protected $name = 'admin:install';

	/**
	 * The console command description.
	 *
	 * @var string
	 */
	protected $description = 'Install the admin package.';

	/**
	 * Create a new command instance.
	 *
	 * @return void
	 */
	public function __construct()
	{
		parent::__construct();
	}

	/**
	 * Execute the console command.
	 *
	 * @return mixed
	 */
	public function fire()
	{
		$this->call('admin:migration');

		$this->call('migrate:publish', ['package' => 'pingpong/trusty']);

		$this->call('migrate');

		$this->call('db:seed', ['--class' => 'Pingpong\\Admin\\Seeders\\AdminDatabaseSeeder']);

		$this->call('config:publish', ['package' => 'pingpong/admin']);

		$this->call('asset:publish', ['package' => 'pingpong/admin']);

	}

}

<?php namespace Pingpong\Admin\Console;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class AdminInstallCommand extends Command {

	/**
	 * The console command name.
	 *
	 * @var string
	 */
	protected $name = 'admin:install';

	/**
	 * The console command description.
	 *
	 * @var string
	 */
	protected $description = 'Install the admin package.';

	/**
	 * Create a new command instance.
	 *
	 * @return void
	 */
	public function __construct()
	{
		parent::__construct();
	}

	/**
	 * Execute the console command.
	 *
	 * @return mixed
	 */
	public function fire()
	{
		$this->call('admin:migration');

		$this->call('migrate:publish', ['package' => 'pingpong/trusty']);

		$this->call('migrate');

		$this->call('db:seed', ['--class' => 'Pingpong\\Admin\\Seeders\\AdminDatabaseSeeder']);

		$this->call('config:publish', ['package' => 'pingpong/admin']);

		$this->call('asset:publish', ['package' => 'pingpong/admin']);

		$this->call('dump-autoload');
	}

}

Call artisan dump-autoload when run admin:install command


<?php

namespace Ovski\FactionStatsBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

class FactionStatsController extends Controller
{
    /**
     * List all factions
     *
<<<<<<< HEAD
     * @Route("/factions", name="factions_stats")
=======
     * @Route("/stats/factions", name="factions_stats")
>>>>>>> 5880bcf4d35ad6034e159fc308a2fad7ee2b0073
     * @Template()
     */
    public function statsAction()
    {
<<<<<<< HEAD
        return array();
    }

    /**
     * Stats of a given faction
     *
     * @Route("/faction/{name}", name="faction_stat")
     * @Template()
     */
    public function statAction($pseudo)
    {
        return array();
=======
        $manager = $this->getDoctrine()->getManager();
        $factions = $manager->getRepository("OvskiFactionStatsBundle:Faction")->findAll();

        return array("factions" => $factions);
    }

    /**
     * Give the stats of a faction
     *
     * @Route("/stats/faction/{name}", name="faction_stats")
     * @Template()
     */
    public function statAction($name)
    {
        $manager = $this->getDoctrine()->getManager();
        $faction = $manager->getRepository("OvskiFactionStatsBundle:Faction")->findOneBy(array("name" => $name));

        if (!$faction) {
            throw new \Exception(sprintf("What are you looking for? I have never heard of the %s faction in my life.", $pseudo));
        }

        return array("faction" => $faction);
>>>>>>> 5880bcf4d35ad6034e159fc308a2fad7ee2b0073
    }
}

<?php

namespace Ovski\FactionStatsBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

class FactionStatsController extends Controller
{
    /**
     * List all factions
     *
     * @Route("/stats/factions", name="factions_stats")
     * @Template()
     */
    public function statsAction()
    {
        $manager = $this->getDoctrine()->getManager();
        $factions = $manager->getRepository("OvskiFactionStatsBundle:Faction")->findAll();

        return array("factions" => $factions);
    }

    /**
     * Give the stats of a faction
     *
     * @Route("/stats/faction/{name}", name="faction_stats")
     * @Template()
     */
    public function statAction($name)
    {
        $manager = $this->getDoctrine()->getManager();
        $faction = $manager->getRepository("OvskiFactionStatsBundle:Faction")->findOneBy(array("name" => $name));

        if (!$faction) {
            throw new \Exception(sprintf("What are you looking for? I have never heard of the %s faction in my life.", $pseudo));
        }

        return array("faction" => $faction);
    }
}

Add missing file for last commit (merge)


<?php

require __DIR__.'/vendor/autoload.php';

$wp = new Worldpay\Worldpay;

var_dump($wp);

<?php
// Require autoload
require __DIR__.'/vendor/autoload.php';

// Create new Worldpay object
$wp = new Worldpay\Worldpay;

// Set the environment
$wp->setConfig(array('env' => 'development'));

Add comments and set environment

Add comments and set environment


<?php
/*
 *	Made by Samerton
 *
 *  https://github.com/NamelessMC/Nameless/
 *  NamelessMC version 2.0.0-pr12
 *
 *  License: MIT
 *
 *  URL related constants
 */

const URL_EXCLUDE_CHARS = [
    '?',
    '&',
    '/',
    '#',
];

<?php
/*
 *	Made by Samerton
 *
 *  https://github.com/NamelessMC/Nameless/
 *  NamelessMC version 2.0.0-pr12
 *
 *  License: MIT
 *
 *  URL related constants
 */

const URL_EXCLUDE_CHARS = [
    '?',
    '&',
    '/',
    '#',
    '.',
];

Add . to list of excluded URL characters


<?php

namespace ActiveCollab\DatabaseStructure\Test;

use ActiveCollab\DatabaseStructure\Field\Scalar\BooleanField;

/**
 * @package ActiveCollab\DatabaseStructure\Test
 */
class BooleanFieldTest extends TestCase
{
    /**
     * @expectedException \LogicException
     */
    public function testExceptionWhenBooleanFieldIsUnique()
    {
        (new BooleanField('should_not_be_required'))->unique();
    }

    /**
     * Test if default value is false
     */
    public function testDefaultValueIsFalse()
    {
        $this->assertFalse((new BooleanField('is_he_a_pirate'))->getDefaultValue());
    }

    /**
     * Test if default value can be changed to NULL
     */
    public function testDefaultValueCanBeChagnedToNull()
    {
        $this->assertNull((new BooleanField('should_be_null_by_default'))->defaultValue(null)->getDefaultValue());
    }
}

Add newline to the end of the file

Add newline to the end of the file


<?php
namespace Craft;

use Guzzle\Http\Client;

class VzUrl_ValidationService extends BaseApplicationComponent
{
    public function check($url)
    {
        if (empty($url)) {
            return false;
        }

        // Store the original, so we can pass it back in the response
        $originalUrl = $url;

        if (substr($url, 0, 1) == '/') {
            // Local URL, add the current domain
            $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
            $host = $protocol . "://" . $_SERVER['HTTP_HOST'];
            $url = $host . $url;
        }

        try {
            // Make the request
            $client = new Client();
            $response = $client->get($url)->send();

            // Get the data we need
            $code = $response->getStatusCode();
            $final = $response->getEffectiveUrl();

            if (isset($host)) {
                $final = str_replace($host, '', $final);
            }

            return array(
                'original'  => $originalUrl,
                'final_url' => $final,
                'http_code' => $code
            );
        } catch (\Exception $e) {
            return false;
        }
    }
}

<?php
namespace Craft;

use Guzzle\Http\Client;

class VzUrl_ValidationService extends BaseApplicationComponent
{
    public function check($url)
    {
        if (empty($url)) {
            return false;
        }

        // Store the original, so we can pass it back in the response
        $originalUrl = $url;

        if (substr($url, 0, 1) == '/') {
            // Local URL, add the current domain
            $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
            $host = $protocol . "://" . $_SERVER['HTTP_HOST'];
            $url = $host . $url;
        }

        try {
            // Make the request
            $client = new Client();
            $client->setUserAgent('VzUrl/1.0 (CraftCMS)');
            $request = $client->get($url, null, array(
                'headers' => array(
                    'Accept' => 'text/html,*/*',
                    'Cache-Control' => 'no-cache',
                ),
                'timeout' => 10,
                'connect_timeout' => 2,
                'verify' => false,
            ));
            $response = $request->send();

            // Get the data we need
            $code = $response->getStatusCode();
            $final = $response->getEffectiveUrl();

            if (isset($host)) {
                $final = str_replace($host, '', $final);
            }

            return array(
                'original'  => $originalUrl,
                'final_url' => $final,
                'http_code' => $code
            );
        } catch (\Exception $e) {
            return false;
        }
    }
}

Adjust cURL headers to avoid certain bot-blockers


<?php

namespace Arseniew\Silex\Service;

class IdiormService
{

    protected $connectionName;
    protected $tables = array();

    public function __construct($connectionName)
    {
        $this->connectionName = $connectionName;
    }

    public function for_table($tableName)
    {
        if (!isset($this->tables[$tableName])) {
            $this->tables[$tableName] = \ORM::for_table($tableName, $this->connectionName);
        }

        return $this->tables[$tableName];
    }

    public static function get_db($connectionName)
    {
        return \ORM::get_db($connectionName);
    }

    public static function raw_execute($query, $parameters = array())
    {
        return \ORM::raw_execute($query, $parameters = array(), $this->connectionName);
    }

    public static function get_last_statement()
    {
        return \ORM::get_last_statement();
    }

    public static function get_last_query()
    {
        return \ORM::get_last_query($this->connectionName);
    }

    public static function get_query_log()
    {
        return \ORM::get_query_log($this->connectionName);
    }

    public static function clear_cache()
    {
        return \ORM::clear_cache();
    }

}

<?php

namespace Arseniew\Silex\Service;

class IdiormService
{

    protected $connectionName;
    protected $tables = array();

    public function __construct($connectionName)
    {
        $this->connectionName = $connectionName;
    }

    public function for_table($tableName)
    {
        if (!isset($this->tables[$tableName])) {
            $this->tables[$tableName] = \ORM::for_table($tableName, $this->connectionName);
        }

        return $this->tables[$tableName];
    }

    public static function get_db($connectionName)
    {
        return \ORM::get_db($connectionName);
    }

    public function raw_execute($query, $parameters = array())
    {
        return \ORM::raw_execute($query, $parameters = array(), $this->connectionName);
    }

    public static function get_last_statement()
    {
        return \ORM::get_last_statement();
    }

    public function get_last_query()
    {
        return \ORM::get_last_query($this->connectionName);
    }

    public function get_query_log()
    {
        return \ORM::get_query_log($this->connectionName);
    }

    public static function clear_cache()
    {
        return \ORM::clear_cache();
    }

}

Fix "Fatal error: Using $this when not in object context"


<?php

function getUser($id)
{
    return null;
}

function getUserHash($id)
{
    global $conn;
    $stmt = $conn->prepare("SELECT * FROM get_user_hash(?)");
    $stmt->execute(array($id));
    $result = $stmt->fetch();
    return $result['get_user_hash'];
}

function getUserInfo($id) {
    global $conn;
    $stmt = $conn->prepare("SELECT Member.name FROM Member WHERE Member.id = ?");
    $stmt->execute(array($id));
    $username = $stmt->fetchAll()[0];

    $stmt = $conn->prepare("SELECT * FROM get_complete_friends_of_member(?)");
    $stmt->execute(array($id));
    $friends = $stmt->fetchAll();

    $stmt = $conn->prepare("SELECT * FROM get_complete_groups_of_member(?)");
    $stmt->execute((array($id)));
    $groups = $stmt->fetchAll();

    $result['userId'] = $id;
    $result['username'] = $username;
    $result['friends'] = $friends;
    $result['groups'] = $groups;

    return $result;
}

<?php

function getUser($id)
{
    return null;
}

function getUserHash($id)
{
    global $conn;
    $stmt = $conn->prepare("SELECT * FROM get_user_hash(?)");
    $stmt->execute(array($id));
    $result = $stmt->fetch();
    return $result['get_user_hash'];
}

function getUserSidebarInfo($id) {
    global $conn;
    $stmt = $conn->prepare("SELECT Member.name FROM Member WHERE Member.id = ?");
    $stmt->execute(array($id));
    $username = $stmt->fetchAll()[0];

    $stmt = $conn->prepare("SELECT * FROM get_complete_friends_of_member(?)");
    $stmt->execute(array($id));
    $friends = $stmt->fetchAll();

    $stmt = $conn->prepare("SELECT * FROM get_complete_groups_of_member(?)");
    $stmt->execute((array($id)));
    $groups = $stmt->fetchAll();

    $userHash = getUserHash($id);

    $result['userId'] = $id;
    $result['username'] = $username;
    $result['userHash'] = $userHash;
    $result['friends'] = $friends;
    $result['groups'] = $groups;

    return $result;
}

function getUserNavbarInfo($id) {
    global $conn;
    $stmt = $conn->prepare("SELECT Member.name FROM Member WHERE Member.id = ?");
    $stmt->execute(array($id));
    $username = $stmt->fetchAll()[0];

    $userHash = getUserHash($id);

    $result['userId'] = $id;
    $result['username'] = $username;
    $result['userHash'] = $userHash;

    return $result;
}

Rename getUserInfo function to getUserSidebarInfo.

Add getUserNavbarInfo function.


<?php

final class DivinerLiveSymbolFulltextEngine
  extends PhabricatorFulltextEngine {

  protected function buildAbstractDocument(
    PhabricatorSearchAbstractDocument $document,
    $object) {

    $atom = $object;
    $book = $atom->getBook();

    $document
      ->setDocumentTitle($atom->getTitle())
      ->setDocumentCreated($book->getDateCreated())
      ->setDocumentModified($book->getDateModified());

    $document->addField(
      PhabricatorSearchDocumentFieldType::FIELD_BODY,
      $atom->getSummary());

    $document->addRelationship(
      PhabricatorSearchRelationship::RELATIONSHIP_BOOK,
      $atom->getBookPHID(),
      DivinerBookPHIDType::TYPECONST,
      PhabricatorTime::getNow());

    $document->addRelationship(
      PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY,
      $atom->getRepositoryPHID(),
      PhabricatorRepositoryRepositoryPHIDType::TYPECONST,
      PhabricatorTime::getNow());

    $document->addRelationship(
      $atom->getGraphHash()
        ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED
        : PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
      $atom->getBookPHID(),
      DivinerBookPHIDType::TYPECONST,
      PhabricatorTime::getNow());
  }

}

<?php

final class DivinerLiveSymbolFulltextEngine
  extends PhabricatorFulltextEngine {

  protected function buildAbstractDocument(
    PhabricatorSearchAbstractDocument $document,
    $object) {

    $atom = $object;
    $book = $atom->getBook();

    $document
      ->setDocumentTitle($atom->getTitle())
      ->setDocumentCreated($book->getDateCreated())
      ->setDocumentModified($book->getDateModified());

    $document->addField(
      PhabricatorSearchDocumentFieldType::FIELD_BODY,
      $atom->getSummary());

    $document->addRelationship(
      PhabricatorSearchRelationship::RELATIONSHIP_BOOK,
      $atom->getBookPHID(),
      DivinerBookPHIDType::TYPECONST,
      PhabricatorTime::getNow());

    $document->addRelationship(
      PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY,
      $atom->getRepositoryPHID(),
      PhabricatorRepositoryRepositoryPHIDType::TYPECONST,
      PhabricatorTime::getNow());

    $document->addRelationship(
      $atom->getGraphHash()
        ? PhabricatorSearchRelationship::RELATIONSHIP_OPEN
        : PhabricatorSearchRelationship::RELATIONSHIP_CLOSED,
      $atom->getBookPHID(),
      DivinerBookPHIDType::TYPECONST,
      PhabricatorTime::getNow());
  }

}

Fix flipped open/closed status for Diviner atoms in search index

Summary: Fixes T12258. I think these constants are just flipped.

Test Plan: Kinda winged it.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12258

Differential Revision: https://secure.phabricator.com/D17346


<?php
	namespace Bolt;

	use Bolt\Interfaces\Adapter;
	use Bolt\Interfaces\Connection;

	abstract class Repository extends Base
	{
		protected Adapter $adapter;

		public function __construct(Connection $connection = null, $data = null)
		{
			$this->adapter($connection);

			if ($data !== null)
			{
				parent::__construct($data);
			}
		}

		public function adapter(Connection $connection = null)
		{
			if ($connection !== null)
			{
				$className = $this->className(false);
				$className = "App\\Adapters\\Repositories\\" . $className . "\\" . $connection->className(false);

				$this->adapter = new $className($connection, $this);

				return $this;
			}

			return $this->adapter;
		}

		public function __call($name, $args)
		{
			return $this->adapter->{$name}($args);
		}
	}
?>

<?php
	namespace Bolt;

	use Bolt\Interfaces\Connection;

	abstract class Repository extends Base
	{
		protected ?Adapter $adapter = null;

		public function __construct(Connection $connection = null, $data = null)
		{
			$this->adapter($connection);

			if ($data !== null)
			{
				parent::__construct($data);
			}
		}

		public function adapter(Connection $connection = null)
		{
			if ($connection !== null)
			{
				$className = $this->className(false);
				$className = "App\\Adapters\\Repositories\\" . $className . "\\" . $connection->className(false);

				$this->adapter = new $className($connection, $this);

				return $this;
			}

			return $this->adapter;
		}

		public function __call($name, $args)
		{
			return $this->adapter->{$name}($args);
		}
	}
?>

Correct adapter type to allow nullable

Correct adapter type to allow nullable


<?php

/**
 * Use in your system.xml to specify source_model
 *
 * <source_model>liip/config_source_target</source_model>
 */
class Liip_Shared_Model_Config_Source_Target
{
    const TEST = 'test';
    const PROD = 'prod';
    const DEV = 'dev';

    public function toOptionArray()
    {
        return array(
            array('value' => self::TEST, 'label' => Mage::helper('liip')->__('Test')),
            array('value' => self::PROD, 'label' => Mage::helper('liip')->__('Production')),
            array('value' => self::DEV, 'label' => Mage::helper('liip')->__('Development')),
        );
    }
}

<?php

/**
 * Use in your system.xml to specify source_model
 *
 * <source_model>liip/config_source_target</source_model>
 */
class Liip_Shared_Model_Config_Source_Target
{
    const TEST = 'test';
    const PROD = 'prod';

    public function toOptionArray()
    {
        return array(
            array('value' => self::TEST, 'label' => Mage::helper('liip')->__('Test')),
            array('value' => self::PROD, 'label' => Mage::helper('liip')->__('Production')),
        );
    }
}

Revert "add `dev' option to source target"

This reverts commit 31ad3634419bd85cf32682ceab1eb504055f0d08.


<?php
require('../mysql-creds.php');

//var_dump($_GET);

function makequery($path) {
    return "SELECT bhm_helpers.* FROM
    bhm_pages, bhm_relationships, bhm_helpers
    WHERE 1=1
    AND bhm_pages.url = '$path'
    AND bhm_pages.id = bhm_relationships.page_id
    AND bhm_relationships.help_id = bhm_helpers.id
    ";
}

$path = $_GET['collection']['pathname'];

$res = $db->query(makequery($path)) or die(mysqli_error($db));

if ($res->num_rows < 1) {
    $index = $_GET['collection']['indexpage'];
    for($i=0; $i < count($index); $i++ ) {
        $p = $path.$index[$i];
        $res = $db->query(makequery($p)) or die(mysqli_error($db));
        if ($res->num_rows > 0) break;
    }
}

echo json_encode($res->fetch_all(MYSQLI_ASSOC), JSON_PRETTY_PRINT);

?>

<?php
require('mysql.php');

//var_dump($_GET);

function makequery($path) {
    return "SELECT bhm_helpers.* FROM
    bhm_pages, bhm_relationships, bhm_helpers
    WHERE 1=1
    AND bhm_pages.url = '$path'
    AND bhm_pages.id = bhm_relationships.page_id
    AND bhm_relationships.help_id = bhm_helpers.id
    ";
}

$path = $_GET['collection']['pathname'];

$res = $db->query(makequery($path)) or die(mysqli_error($db));

if ($res->num_rows < 1) {
    $index = $_GET['collection']['indexpage'];
    if (gettype($index) != 'array') {
        $p = $path.$index;
        $res = $db->query(makequery($p)) or die(mysqli_error($db));
    } else {
        for($i=0; $i < count($index); $i++ ) {
            $p = $path.$index[$i];
            echo $p;
            $res = $db->query(makequery($p)) or die(mysqli_error($db));
            if ($res->num_rows > 0) break;
        }
    }
}

echo json_encode($res->fetch_all(MYSQLI_ASSOC), JSON_PRETTY_PRINT);

?>

Allow $().BHMClient indexpage to be string

Fix issue with client indexpage property having to be an array


<?php

namespace WP_CLI\Bootstrap;

/**
 * Class RegisterDeferredCommands.
 *
 * Registers the deferred commands that for which no parent was registered yet.
 * This is necessary, because we can have sub-commands that have no direct
 * parent, like `wp network meta`.
 *
 * @package WP_CLI\Bootstrap
 */
final class RegisterDeferredCommands implements BootstrapStep {

	/**
	 * Process this single bootstrapping step.
	 *
	 * @param BootstrapState $state Contextual state to pass into the step.
	 *
	 * @return BootstrapState Modified state to pass to the next step.
	 */
	public function process( BootstrapState $state ) {
		$deferred_additions = \WP_CLI::get_deferred_additions();

		foreach ( $deferred_additions as $name => $addition ) {
			\WP_CLI::add_command(
				$name,
				$addition['callable'],
				$addition['args']
			);
		}

		return $state;
	}
}

<?php

namespace WP_CLI\Bootstrap;

/**
 * Class RegisterDeferredCommands.
 *
 * Registers the deferred commands that for which no parent was registered yet.
 * This is necessary, because we can have sub-commands that have no direct
 * parent, like `wp network meta`.
 *
 * @package WP_CLI\Bootstrap
 */
final class RegisterDeferredCommands implements BootstrapStep {

	/**
	 * Process this single bootstrapping step.
	 *
	 * @param BootstrapState $state Contextual state to pass into the step.
	 *
	 * @return BootstrapState Modified state to pass to the next step.
	 */
	public function process( BootstrapState $state ) {
		\WP_CLI::add_hook(
			'after_wp_load',
			array( $this, 'add_deferred_commands' )
		);

		return $state;
	}

	/**
	 * Add deferred commands that are still waiting to be processed.
	 */
	public function add_deferred_commands() {
		$deferred_additions = \WP_CLI::get_deferred_additions();

		foreach ( $deferred_additions as $name => $addition ) {
			\WP_CLI::add_command(
				$name,
				$addition['callable'],
				$addition['args']
			);
		}
	}
}

Move deferred command additions to be processed after `'after_wp_load'` hook.

For the command additions within (mu-)plugins to work, they need to be processed after all plugins have actually been loaded.

Fixes #4122


<?php

namespace SimplyTestable\WebClientBundle\Tests\Controller\View\User\SignUp\Confirm\IndexAction;

use SimplyTestable\WebClientBundle\Tests\Controller\Base\ActionTest as BaseActionTest;

class ActionTest extends BaseActionTest {

    protected function getHttpFixtureItems() {
        return array(
            "HTTP/1.0 200 OK"
        );
    }

    protected function getExpectedResponseStatusCode() {
        return 200;
    }

    protected function getRequestQueryData() {
        return array(
            'email' => 'user@example.com'
        );
    }

    protected function getActionMethodArguments() {
        return array(
            'email' => 'user@example.com'
        );
    }

}

<?php

namespace SimplyTestable\WebClientBundle\Tests\Controller\View\User\SignUp\Confirm\IndexAction;

use SimplyTestable\WebClientBundle\Tests\Controller\Base\ActionTest as BaseActionTest;

class ActionTest extends BaseActionTest {

    protected function getHttpFixtureItems() {
        return array(
            "HTTP/1.0 200 OK"
        );
    }

    protected function getExpectedResponseStatusCode() {
        return 200;
    }

    protected function getRequestQueryData() {
        return array(
            'email' => 'user@example.com'
        );
    }

    protected function getActionMethodArguments() {
        return array(
            'email' => 'user@example.com'
        );
    }

    protected function getRequestAttributes() {
        return array(
            'email' => 'user@example.com'
        );
    }

}

Fix signup confirm action test

Fix signup confirm action test


<?php

/*
 * This file is part of Cachet.
 *
 * (c) Alt Three Services Limited
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CachetHQ\Cachet\Http\Controllers\Api;

use CachetHQ\Cachet\Integrations\Contracts\Releases;
use CachetHQ\Cachet\Integrations\Contracts\System;

/**
 * This is the general api controller.
 *
 * @author James Brooks <james@bluebaytravel.co.uk>
 */
class GeneralController extends AbstractApiController
{
    /**
     * Ping endpoint allows API consumers to check the version.
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function ping()
    {
        return $this->item('Pong!');
    }

    /**
     * Endpoint to show the Cachet version.
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function version()
    {
        $latest = app()->make(Releases::class)->latest();

        return $this->setMetaData([
            'on_latest' => version_compare(CACHET_VERSION, $latest['tag_name']) === 1,
            'latest'    => $latest,
        ])->item(CACHET_VERSION);
    }

    /**
     * Get the system status message.
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function status()
    {
        $system = app()->make(System::class)->getStatus();

        return $this->item($system['system_message']);
    }
}

<?php

/*
 * This file is part of Cachet.
 *
 * (c) Alt Three Services Limited
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CachetHQ\Cachet\Http\Controllers\Api;

use CachetHQ\Cachet\Integrations\Contracts\Releases;
use CachetHQ\Cachet\Integrations\Contracts\System;

/**
 * This is the general api controller.
 *
 * @author James Brooks <james@bluebaytravel.co.uk>
 */
class GeneralController extends AbstractApiController
{
    /**
     * Ping endpoint allows API consumers to check the version.
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function ping()
    {
        return $this->item('Pong!');
    }

    /**
     * Endpoint to show the Cachet version.
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function version()
    {
        $latest = app()->make(Releases::class)->latest();

        return $this->setMetaData([
            'on_latest' => version_compare(CACHET_VERSION, $latest['tag_name']) === 1,
            'latest'    => $latest,
        ])->item(CACHET_VERSION);
    }

    /**
     * Get the system status message.
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function status()
    {
        $system = app()->make(System::class)->getStatus();

        return $this->item([
            'status'  => $system['system_status'],
            'message' => $system['system_message']
        ]);
    }
}

Add system status to /status endpoint

Add system status to /status endpoint


<?php
/*
 * HiPay fullservice SDK
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the MIT License
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/mit-license.php
 *
 * @copyright      Copyright (c) 2016 - HiPay
 * @license        http://opensource.org/licenses/mit-license.php MIT License
 *
 */
namespace HiPay\Fullservice\Model;

/**
 * Model Interface
 *
 * Created for futhers features.
 * Not used for the moment but implemented
 *
 * @package     HiPay\Fullservice
 * @author 		Kassim Belghait <kassim@sirateck.com>
 * @copyright   Copyright (c) 2016 - HiPay
 * @license     http://opensource.org/licenses/mit-license.php MIT License
 * @link 		https://github.com/hipay/hipay-fullservice-sdk-php
 */
interface ModelInterface {

	/**
	 * Return Json representation of public attributes
	 * @return string Json representation
	 */
	public function toJson(){

	}

	/**
	 * Return public attributes accessible by getter in ARRAY format
	 * @return array public attributes array
	 */
	public function toArray(){

	}

}

<?php
/*
 * HiPay fullservice SDK
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the MIT License
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/mit-license.php
 *
 * @copyright      Copyright (c) 2016 - HiPay
 * @license        http://opensource.org/licenses/mit-license.php MIT License
 *
 */
namespace HiPay\Fullservice\Model;

/**
 * Model Interface
 *
 * Created for futhers features.
 * Not used for the moment but implemented
 *
 * @package     HiPay\Fullservice
 * @author 		Kassim Belghait <kassim@sirateck.com>
 * @copyright   Copyright (c) 2016 - HiPay
 * @license     http://opensource.org/licenses/mit-license.php MIT License
 * @link 		https://github.com/hipay/hipay-fullservice-sdk-php
 */
interface ModelInterface {

	/**
	 * Return Json representation of public attributes
	 * @return string Json representation
	 */
	public function toJson();

	/**
	 * Return public attributes accessible by getter in ARRAY format
	 * @return array public attributes array
	 */
	public function toArray();

}

Remove body from methods interface

Remove body from methods interface


<?php
declare(strict_types=1);

namespace LaraQuiz\Exceptions;

use Illuminate\Validation\ValidationException;
use LaraQuiz\Helpers\Api;

/**
 * Class CustomValidationException
 *
 * @package LaraQuiz\Exceptions
 */
class CustomValidationException extends ValidationException
{
    /**
     * @param \Illuminate\Validation\Validator $validator
     * @param \Illuminate\Http\Response $response
     */
    public function __construct(\Illuminate\Validation\Validator $validator, ?\Illuminate\Http\Response $response = null)
    {
        if ($response === null) {
            $response = Api::respondBadRequest($validator->errors()->all());
        }

        parent::__construct($validator, $response);
    }
}

<?php
declare(strict_types=1);

namespace LaraQuiz\Exceptions;

use Illuminate\Validation\ValidationException;
use Illuminate\Validation\Validator;
use LaraQuiz\Helpers\Api;

/**
 * Class CustomValidationException
 *
 * @package LaraQuiz\Exceptions
 */
class CustomValidationException extends ValidationException
{
    /**
     * @param \Illuminate\Validation\Validator $validator
     * @param \Illuminate\Http\Response|\Illuminate\Http\JsonResponse|null $response
     */
    public function __construct(Validator $validator, $response = null)
    {
        if ($response === null) {
            $response = Api::respondBadRequest($validator->errors()->all());
        }

        parent::__construct($validator, $response);
    }
}

Allow Illuminate\Http\JsonResponse as response type


<?php

namespace Lstr\Postgres\DbMgmt\Service;

use Hodor\JobQueue\JobQueue;

class DbMgmtJobService
{
    /**
     * @var object
     */
    private $db_host_manager;

    /**
     * @var JobQueue
     */
    private $job_queue;

    /**
     * @param object $db_host_manager
     */
    public function __construct($db_host_manager, JobQueue $job_queue)
    {
        $this->db_host_manager = $db_host_manager;
        $this->job_queue = $job_queue;
    }

    /**
     * @param string $host_key
     * @param string $database
     * @param string $dest_path
     * @param string $callback_url
     */
    public function dump($host_key, $database, $dest_path, $callback_url = null)
    {
        $this->job_queue->push(
            'postgres.db-mgmt-sync.dump',
            [
                'host_key'         => $host_key,
                'database'         => $database,
                'destination_path' => $dest_path,
                'callback_url'     => $callback_url,
            ]
        );
    }
}

<?php

namespace Lstr\Postgres\DbMgmt\Service;

use Hodor\JobQueue\JobQueue;

class DbMgmtJobService
{
    /**
     * @var DbHostManagerService
     */
    private $db_host_manager;

    /**
     * @var JobQueue
     */
    private $job_queue;

    /**
     * @param object $db_host_manager
     */
    public function __construct(DbHostManagerService $db_host_manager, JobQueue $job_queue)
    {
        $this->db_host_manager = $db_host_manager;
        $this->job_queue = $job_queue;
    }

    /**
     * @param string $host_key
     * @param string $database
     * @param string $dest_path
     * @param string $callback_url
     */
    public function dump($host_key, $database, $dest_path, $callback_url = null)
    {
        $this->job_queue->push(
            'postgres.db-mgmt-sync.dump',
            [
                'host_key'         => $host_key,
                'database'         => $database,
                'destination_path' => $dest_path,
                'callback_url'     => $callback_url,
            ]
        );
    }
}

Update type-hint to use DbHostManagerService


<?php
declare(strict_types=1);

namespace LotGD\Core;

/**
 * A representation of an action the user can take to affect the game
 * state. An encapsulation of a navigation menu option.
 */
class Action
{
    private $id;
    private $destinationSceneId;

    /**
     * Construct a new action with the specified Scene as its destination.
     * @param int $destinationSceneId
     */
    public function __construct(int $destinationSceneId)
    {
        $this->id = bin2hex(random_bytes(8));
        $this->destinationSceneId = $destinationSceneId;
    }

    /**
     * Returns the unique, automatically generated identifier for this action.
     * Use this ID to refer to this action when calling Game::takeAction().
     * @return string
     */
    public function getId(): string
    {
        return $this->id;
    }

    /**
     * Return the database ID of the destination scene, where the user will
     * go if they take this action.
     * @return string
     */
    public function getDestinationSceneId(): int
    {
        return $this->destinationSceneId;
    }
}

<?php
declare(strict_types=1);

namespace LotGD\Core;

/**
 * A representation of an action the user can take to affect the game
 * state. An encapsulation of a navigation menu option.
 */
class Action
{
    protected $id;
    protected $destinationSceneId;

    /**
     * Construct a new action with the specified Scene as its destination.
     * @param int $destinationSceneId
     */
    public function __construct(int $destinationSceneId)
    {
        $this->id = bin2hex(random_bytes(8));
        $this->destinationSceneId = $destinationSceneId;
    }

    /**
     * Returns the unique, automatically generated identifier for this action.
     * Use this ID to refer to this action when calling Game::takeAction().
     * @return string
     */
    public function getId(): string
    {
        return $this->id;
    }

    /**
     * Return the database ID of the destination scene, where the user will
     * go if they take this action.
     * @return string
     */
    public function getDestinationSceneId(): int
    {
        return $this->destinationSceneId;
    }
}

Change action properties to be protected so it will serialize


<?php namespace GeneaLabs\LaravelCasts;

class Button extends Component
{
    public function __construct(string $value, array $options = [])
    {
        parent::__construct('', $value, $options);

        if (in_array($this->framework, ['bootstrap3', 'bootstrap4'])) {
            $this->classes = 'btn';
        }

        $this->excludedClasses = $this->excludedKeys->merge(collect([
            'form-control' => '',
        ]));
        $this->excludedKeys = $this->excludedKeys->merge(collect([
            'placeholder' => '',
        ]));
    }

    protected function renderBaseControl() : string
    {
        return app('form')->callParentMethod(
            $this->type,
            $this->value,
            $this->options
        );
    }

    public function getTypeAttribute() : string
    {
        return 'button';
    }
}

<?php namespace GeneaLabs\LaravelCasts;

class Button extends Component
{
    public function __construct(string $value, array $options = [])
    {
        parent::__construct('', $value, $options);

        if (in_array($this->framework, ['bootstrap3', 'bootstrap4'])) {
            $this->classes = 'btn';
        }

        if ($this->framework === 'bootstrap3') {
            $options['offsetClass'] = ($options['label'] ?? '') === ''
                ? ' col-sm-offset-' . $this->labelWidth
                : '';
        }

        if ($this->framework === 'bootstrap4') {
            $options['offsetClass'] = ($options['label'] ?? '') === ''
                ? ' offset-sm-' . $this->labelWidth
                : '';
        }

        $this->attributes['options'] = $options;
        $this->excludedClasses = $this->excludedKeys->merge(collect([
            'form-control' => '',
        ]));
        $this->excludedKeys = $this->excludedKeys->merge(collect([
            'placeholder' => '',
        ]));
    }

    protected function renderBaseControl() : string
    {
        return app('form')->callParentMethod(
            $this->type,
            $this->value,
            $this->options
        );
    }

    public function getTypeAttribute() : string
    {
        return 'button';
    }
}

Fix offset calculations for buttons without labels


<?php
/**
 * @author    Igor Nikolaev <igor.sv.n@gmail.com>
 * @copyright Copyright (c) 2015, Darvin Studio
 * @link      https://www.darvin-studio.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Darvin\AdminBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

/**
 * View widget generator aliases list command
 */
class WidgetGeneratorsListCommand extends ContainerAwareCommand
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this
            ->setName('darvin:admin:widget:list')
            ->setDescription('Displays list of aliases of existing view widget generators.');
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);

        $io->table(array('Alias'), array_map(function ($alias) {
            return array($alias);
        }, $this->getViewWidgetGeneratorPool()->getAllWidgetGeneratorAliases()));
    }

    /**
     * @return \Darvin\AdminBundle\View\WidgetGenerator\WidgetGeneratorPool
     */
    private function getViewWidgetGeneratorPool()
    {
        return $this->getContainer()->get('darvin_admin.view.widget_generator.pool');
    }
}

<?php
/**
 * @author    Igor Nikolaev <igor.sv.n@gmail.com>
 * @copyright Copyright (c) 2015, Darvin Studio
 * @link      https://www.darvin-studio.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Darvin\AdminBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

/**
 * View widget generator aliases list command
 */
class WidgetGeneratorsListCommand extends ContainerAwareCommand
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this
            ->setName('darvin:admin:widget:list')
            ->setDescription('Displays list of aliases of existing view widget generators.');
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);

        $io->listing($this->getViewWidgetGeneratorPool()->getAllWidgetGeneratorAliases());
    }

    /**
     * @return \Darvin\AdminBundle\View\WidgetGenerator\WidgetGeneratorPool
     */
    private function getViewWidgetGeneratorPool()
    {
        return $this->getContainer()->get('darvin_admin.view.widget_generator.pool');
    }
}

Simplify widget generators list command class.


<?php

namespace BudgeIt\ComposerBuilder;

use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Package\PackageInterface;

class Runner
{

    /**
     * @var Composer
     */
    private $composer;
    /**
     * @var IOInterface
     */
    private $io;
    /**
     * @var InstallerInterface[]
     */
    private $installers = [];
    /**
     * @var BuildToolInterface[]
     */
    private $buildTools = [];

    /**
     * Runner constructor.
     */
    public function __construct(Composer $composer, IOInterface $io)
    {
        $this->composer = $composer;
        $this->io = $io;
    }

    /**
     * Register a new installer object
     *
     * @param InstallerInterface $installer
     */
    public function registerInstaller(InstallerInterface $installer)
    {
        $this->installers[$installer->getName()] = $installer;
    }

    /**
     * Register a new build tool object
     *
     * @param BuildToolInterface $buildTool
     */
    public function registerBuildTool(BuildToolInterface $buildTool)
    {
        $this->buildTools[$buildTool->getName()] = $buildTool;
    }

    /**
     * Run the installers for a package
     *
     * @param PackageInterface $package
     */
    public function runInstallers(PackageInterface $package)
    {
    }

    /**
     * Run the build tools for a package
     *
     * @param PackageInterface $package
     */
    public function runBuildTools(PackageInterface $package)
    {
    }

}

<?php

namespace BudgeIt\ComposerBuilder;

use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Package\PackageInterface;

class Runner
{

    /**
     * @var Composer
     */
    private $composer;
    /**
     * @var IOInterface
     */
    private $io;
    /**
     * @var InstallerInterface[]
     */
    private $installers = [];
    /**
     * @var BuildToolInterface[]
     */
    private $buildTools = [];

    /**
     * Runner constructor.
     */
    public function __construct(Composer $composer, IOInterface $io)
    {
        $this->composer = $composer;
        $this->io = $io;
    }

    /**
     * Register a new installer object
     *
     * @param InstallerInterface $installer
     */
    public function registerInstaller(InstallerInterface $installer)
    {
        $this->installers[$installer->getName()] = $installer;
    }

    /**
     * Register a new build tool object
     *
     * @param BuildToolInterface $buildTool
     */
    public function registerBuildTool(BuildToolInterface $buildTool)
    {
        $this->buildTools[$buildTool->getName()] = $buildTool;
    }

    /**
     * Run the installers for a package
     *
     * @param PackageInterface $package
     */
    public function runInstallers(PackageInterface $package)
    {
        foreach ($this->installers as $installer) {
            if ($installer->supports($package)) {
                $installer->install($package);
            }
        }
    }

    /**
     * Run the build tools for a package
     *
     * @param PackageInterface $package
     */
    public function runBuildTools(PackageInterface $package)
    {
    }

}

Add logic to install for all installers

Add logic to install for all installers


<?php
/**
 * The template for displaying the header
 *
 */
?><!DOCTYPE html>
<html <?php language_attributes(); ?> class="no-js">

	<meta charset="<?php bloginfo( 'charset' ); ?>">
	<meta name="viewport" content="width=device-width, initial-scale=1">

	<?php wp_head(); ?>

	<?php if ( ! is_home() ) : ?>

        Katherine Anne Porter Correspondence

	<?php endif; ?>

Use h1 for site "logo"

Use h1 for site "logo"


<?php
namespace GraphQL\Error;

final class Warning
{
    const NAME_WARNING = 1;
    const ASSIGN_WARNING = 2;
    const CONFIG_WARNING = 4;

    const ALL = self::NAME_WARNING | self::ASSIGN_WARNING | self::CONFIG_WARNING;

    static $enableWarnings = self::ALL;

    static $warned = [];

    static function suppress($suppress = true)
    {
        if (true === $suppress) {
            self::$enableWarnings = 0;
        } else if (false === $suppress) {
            self::$enableWarnings = self::ALL;
        } else {
            $suppress = (int) $suppress;
            self::$enableWarnings &= ~$suppress;
        }
    }

    static function warnOnce($errorMessage, $warningId)
    {
        if ((self::$enableWarnings & $warningId) > 0 && !isset(self::$warned[$warningId])) {
            self::$warned[$warningId] = true;
            trigger_error($errorMessage, E_USER_WARNING);
        }
    }

    static function warn($errorMessage, $warningId)
    {
        if ((self::$enableWarnings & $warningId) > 0) {
            trigger_error($errorMessage, E_USER_WARNING);
        }
    }
}

<?php
namespace GraphQL\Error;

final class Warning
{
    const NAME_WARNING = 1;
    const ASSIGN_WARNING = 2;
    const CONFIG_WARNING = 4;

    const ALL = 7;

    static $enableWarnings = self::ALL;

    static $warned = [];

    static function suppress($suppress = true)
    {
        if (true === $suppress) {
            self::$enableWarnings = 0;
        } else if (false === $suppress) {
            self::$enableWarnings = self::ALL;
        } else {
            $suppress = (int) $suppress;
            self::$enableWarnings &= ~$suppress;
        }
    }

    static function warnOnce($errorMessage, $warningId)
    {
        if ((self::$enableWarnings & $warningId) > 0 && !isset(self::$warned[$warningId])) {
            self::$warned[$warningId] = true;
            trigger_error($errorMessage, E_USER_WARNING);
        }
    }

    static function warn($errorMessage, $warningId)
    {
        if ((self::$enableWarnings & $warningId) > 0) {
            trigger_error($errorMessage, E_USER_WARNING);
        }
    }
}

Fix for broken build on PHP < 5.6

Fix for broken build on PHP < 5.6


<?php
use yii\helpers\Html;

/* @var $model ShortCirquit\LinkoScopeApi\models\Link */
?>

        <?= ($index + 1) ?>:
        <?= Html::a('', ['up', 'id' => $model->id,], ['title' => 'Up']) ?>
        <?= Html::a('', ['down', 'id' => $model->id,], ['title' => 'Down']) ?>
        [<?= Html::a($model->title, $model->url, ['target' => '_blank',]); ?>]
        (<?= parse_url($model->url, PHP_URL_HOST) ?>)

<?php if (!Yii::$app->user->isGuest) : ?>

        <?= '' /* Html::a('', ['delete', 'id' => $model->id,], ['title' => 'Delete']) */ ?>

<?php endif; ?>

    <?=
        "$model->authorName | " .
        date('D d M Y', strtotime($model->date)) .
        " | $model->votes votes | " .
        Html::a($model->comments == 0 ? "discuss" : "$model->comments comments", ['link/view', 'id' => $model->id])
    ?>

<?php
use yii\helpers\Html;

/* @var $model ShortCirquit\LinkoScopeApi\models\Link */
?>

        <?= ($index + 1) ?>:
<?php if (!Yii::$app->user->isGuest) : ?>
        <?= Html::a('', ['up', 'id' => $model->id,], ['title' => 'Up']) ?>
        <?= Html::a('', ['down', 'id' => $model->id,], ['title' => 'Down']) ?>
<?php endif; ?>
        [<?= Html::a($model->title, $model->url, ['target' => '_blank',]); ?>]
        (<?= parse_url($model->url, PHP_URL_HOST) ?>)

<?php if (!Yii::$app->user->isGuest) : ?>

        <?= '' /* Html::a('', ['delete', 'id' => $model->id,], ['title' => 'Delete']) */ ?>

<?php endif; ?>

    <?=
        "$model->authorName | " .
        date('D d M Y', strtotime($model->date)) .
        " | $model->votes votes | " .
        Html::a($model->comments == 0 ? "discuss" : "$model->comments comments", ['link/view', 'id' => $model->id])
    ?>

Hide vote buttons if user is not logged in.


<?php
namespace Ray\Di\Sample;

use Ray\Di\Di\Inject;
use Ray\Di\Di\Named;

use Ray\Di\Sample\Transactional;
use Ray\Di\Sample\Template;

class User
{
    private $db;

    /**
     * @Inject
     * @Named("pdo=pdo_user")
     */
    public function __construct(\PDO $pdo)
    {
        $this->db = $pdo;
    }

    /**
     * @PostConstruct
     */
    public function init()
    {
        // if not exist...
        $this->db->query("CREATE TABLE User (Id INTEGER PRIMARY KEY, Name TEXT, Age INTEGER)");
    }

    /**
     * @Transactional
     */
    public function createUser($name, $age)
    {
        $sth = $this->db->prepare("INSERT INTO User (Name, Age) VALUES (:name, :age)");
        $sth->execute([':name' => $name, ':age' => $age]);
    }

    /**
     * @Template
     */
    public function readUsers()
    {
        $sth = $this->db->query("SELECT name, age FROM User");
        $result = $sth->fetchAll(\PDO::FETCH_ASSOC);

        return $result;
    }
}

<?php
namespace Ray\Di\Sample;

use Ray\Di\Di\Inject;
use Ray\Di\Di\Named;
use Ray\Di\Di\PostConstruct;

use Ray\Di\Sample\Transactional;
use Ray\Di\Sample\Template;

class User
{
    private $db;

    /**
     * @Inject
     * @Named("pdo=pdo_user")
     */
    public function __construct(\PDO $pdo)
    {
        $this->db = $pdo;
    }

    /**
     * @PostConstruct
     */
    public function init()
    {
        // if not exist...
        $this->db->query("CREATE TABLE User (Id INTEGER PRIMARY KEY, Name TEXT, Age INTEGER)");
    }

    /**
     * @Transactional
     */
    public function createUser($name, $age)
    {
        $sth = $this->db->prepare("INSERT INTO User (Name, Age) VALUES (:name, :age)");
        $sth->execute([':name' => $name, ':age' => $age]);
    }

    /**
     * @Template
     */
    public function readUsers()
    {
        $sth = $this->db->query("SELECT name, age FROM User");
        $result = $sth->fetchAll(\PDO::FETCH_ASSOC);

        return $result;
    }
}

Add use statement for annotation.

Add use statement for annotation.


<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMachinephotosTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('machinephotos', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('machine_id')->unsigned()->default(0);
            $table->string('machine_photo')->nullable();
            $table->softDeletes();
            $table->timestamps();
            $table->foreign('machine_id')->references('id')->on('machines');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('machinephotos');
    }
}

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMachinephotosTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('machinephotos', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('machine_id')->unsigned()->default(0);
            $table->string('machine_photo_path')->nullable();
            $table->string('machine_photo_thumb')->nullable();
            $table->string('photo_description')->nullable();
            $table->softDeletes();
            $table->timestamps();
            $table->foreign('machine_id')->references('id')->on('machines');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('machinephotos');
    }
}

Add new fields to photo table

Add new fields to photo table


<?php

/*
 * This file is part of the CFDI project.
 *
 * (c) Orlando Charles <me@orlandocharles.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Charles\CFDI\Node\Complemento;

/**
 * This is the timbre fiscal class.
 *
 * @author Orlando Charles <me@orlandocharles.com>
 */
class TimbreFiscal extends Complemento
{
    /**
     * Node name.
     *
     * @var string
     */
    protected $nodeName = 'tfd:TimbreFiscalDigital';
}

<?php

/*
 * This file is part of the CFDI project.
 *
 * (c) Orlando Charles <me@orlandocharles.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Charles\CFDI\Node\Complemento;

/**
 * This is the timbre fiscal class.
 *
 * @author Orlando Charles <me@orlandocharles.com>
 */
class TimbreFiscalDigital extends Complemento
{
    /**
     * Node name.
     *
     * @var string
     */
    protected $nodeName = 'tfd:TimbreFiscalDigital';
}

Rename TimbreFiscal to match with file name


<?php

namespace DevGroup\Users\social;

use DevGroup\ExtensionsManager\models\BaseConfigurationModel;
use \yii\authclient\clients\GoogleOAuth as BaseGoogle;

class Google extends BaseGoogle implements SocialServiceInterface
{

    /**
     * @return string Path to configuration view for this social service(used in backend)
     */
    public static function configurationView()
    {
        return 'TBD';
    }

    /**
     * @return BaseConfigurationModel Instance of configuration model
     */
    public static function configurationModel()
    {
        return null;
    }

    /**
     * Retrieves additional data from social network and puts it to client.
     */
    public function retrieveAdditionalData()
    {

    }

}

<?php

namespace DevGroup\Users\social;

use DevGroup\ExtensionsManager\models\BaseConfigurationModel;
use \yii\authclient\clients\GoogleOAuth as BaseGoogle;
use yii\helpers\Url;

class Google extends BaseGoogle implements SocialServiceInterface
{

    /**
     * @return string Path to configuration view for this social service(used in backend)
     */
    public static function configurationView()
    {
        return 'TBD';
    }

    /**
     * @return BaseConfigurationModel Instance of configuration model
     */
    public static function configurationModel()
    {
        return null;
    }

    /**
     * Retrieves additional data from social network and puts it to client.
     */
    public function retrieveAdditionalData()
    {

    }

    public function setReturnUrl($returnUrl)
    {
        // google oauth can't redirect with redirectUrl param
        return parent::setReturnUrl(preg_replace('/\\?returnUrl=[^&]*&/s', '?', $returnUrl));
    }

}

Set returnUrl without returnUrl param for google oauth


<?php

/**
 * @loadSharedFixture
 * @group 54
 */
class SPM_ShopyMind_Test_Lib_ShopymindClient_Callback_Get_Products extends EcomDev_PHPUnit_Test_Case
{
    protected function tearDown()
    {
        parent::tearDown();
        Mage::unregister('_resource_singleton/catalog/product_flat');
    }

    public function testCanGetRandomProducts()
    {
        Mage::app()->setCurrentStore(1);
        $products = ShopymindClient_Callback::getProducts('store-1', false, false, true, 1);

        $this->assertRegExp('#catalog/product/view/id/[1-2]/#', $products[0]['product_link']);

        Mage::app()->setCurrentStore(0);
    }

    public function testIfAStoreHasNoProductsNothingIsReturned()
    {
        $products = ShopymindClient_Callback::getProducts('store-2', false, false, true, 1);

        $this->assertEmpty($products);
    }

    public function testCanGetRandomProductsIfNoStoreIsDefined()
    {
        $products = ShopymindClient_Callback::getProducts(null, false, false, true, 1);

        $this->assertRegExp('#catalog/product/view/id/[1-2]/#', $products[0]['product_link']);
    }

    public function testCanGetRandomProductsInSpecificsProductsIds()
    {
        $products = ShopymindClient_Callback::getProducts(null, false, array(1), true, 1);

        $this->assertRegExp('#catalog/product/view/id/1/#', $products[0]['product_link']);
    }
}

<?php

/**
 * @loadSharedFixture
 * @group 54
 */
class SPM_ShopyMind_Test_Lib_ShopymindClient_Callback_Get_Products extends EcomDev_PHPUnit_Test_Case
{
    protected function tearDown()
    {
        parent::tearDown();
        Mage::unregister('_resource_singleton/catalog/product_flat');
    }

    public function testCanGetRandomProducts()
    {
        $products = ShopymindClient_Callback::getProducts('store-1', false, false, true, 1);

        $this->assertRegExp('#catalog/product/view/id/[1-2]/#', $products[0]['product_link']);
    }

    public function testIfAStoreHasNoProductsNothingIsReturned()
    {
        $products = ShopymindClient_Callback::getProducts('store-2', false, false, true, 1);

        $this->assertEmpty($products);
    }

    public function testCanGetRandomProductsIfNoStoreIsDefined()
    {
        $products = ShopymindClient_Callback::getProducts(null, false, false, true, 1);

        $this->assertRegExp('#catalog/product/view/id/[1-2]/#', $products[0]['product_link']);
    }

    public function testCanGetRandomProductsInSpecificsProductsIds()
    {
        $products = ShopymindClient_Callback::getProducts(null, false, array(1), true, 1);

        $this->assertRegExp('#catalog/product/view/id/1/#', $products[0]['product_link']);
    }
}

Remove uneeded app store modification since there is app emulation.


<?php
/**
 * OpenWeatherMap-PHP-API — A php api to parse weather data from http://www.OpenWeatherMap.org .
 *
 * @license MIT
 *
 * Please see the LICENSE file distributed with this source code for further
 * information regarding copyright and licensing.
 *
 * Please visit the following links to read about the usage policies and the license of
 * OpenWeatherMap before using this class:
 *
 * @see http://www.OpenWeatherMap.org
 * @see http://www.OpenWeatherMap.org/terms
 * @see http://openweathermap.org/appid
 */

namespace Cmfcmf\OpenWeatherMap\Fetcher;

/**
 * Class CurlFetcher.
 *
 * @internal
 */
class CurlFetcher implements FetcherInterface
{
    /**
     * {@inheritdoc}
     */
    public function fetch($url)
    {
        $ch = curl_init($url);
        $timeout = 5;
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $content = curl_exec($ch);
        curl_close($ch);

        return $content;
    }
}

<?php
/**
 * OpenWeatherMap-PHP-API — A php api to parse weather data from http://www.OpenWeatherMap.org .
 *
 * @license MIT
 *
 * Please see the LICENSE file distributed with this source code for further
 * information regarding copyright and licensing.
 *
 * Please visit the following links to read about the usage policies and the license of
 * OpenWeatherMap before using this class:
 *
 * @see http://www.OpenWeatherMap.org
 * @see http://www.OpenWeatherMap.org/terms
 * @see http://openweathermap.org/appid
 */

namespace Cmfcmf\OpenWeatherMap\Fetcher;

/**
 * Class CurlFetcher.
 *
 * @internal
 */
class CurlFetcher implements FetcherInterface
{
    /**
     * @var array The Curl options to use.
     */
    private $curlOptions;

    /**
     * Create a new CurlFetcher instance.
     *
     * @param array $curlOptions The Curl options to use. See http://php.net/manual/de/function.curl-setopt.php
     * for a list of available options.
     */
    public function __construct($curlOptions = [])
    {
        $this->curlOptions = $curlOptions;
    }

    /**
     * {@inheritdoc}
     */
    public function fetch($url)
    {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt_array($ch, $this->curlOptions);

        $content = curl_exec($ch);
        curl_close($ch);

        return $content;
    }
}

Allow to set additional Curl options.

Allow to set additional Curl options.


<?php
$classLoader = new \Composer\Autoload\ClassLoader();
$classLoader->addPsr4("TestHelpers\\", __DIR__. "/../../../../../../tests/TestHelpers/", true);
$classLoader->register();

<?php
$classLoader = new \Composer\Autoload\ClassLoader();
$classLoader->addPsr4("TestHelpers\\", __DIR__. "/../../../../../../tests/TestHelpers", true);
$classLoader->register();

Standardize addPSR4 target folder format


<?php namespace Modules\Dashboard\Http\Controllers\Admin;

use Illuminate\Support\Facades\View;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;

class DashboardController extends AdminBaseController
{
    public function index()
    {
        $this->assetPipeline->requireJs('gridstack.js');
        $this->assetPipeline->requireCss('gridstack.css')->before('asgard.css');

        return View::make('dashboard::admin.dashboard');
    }
}

<?php namespace Modules\Dashboard\Http\Controllers\Admin;

use Illuminate\Support\Facades\View;
use Modules\Core\Http\Controllers\Admin\AdminBaseController;

class DashboardController extends AdminBaseController
{
    public function index()
    {
        $this->assetPipeline->requireJs('gridstack.js');
        $this->assetPipeline->requireCss('gridstack.css')->before('asgard.css');

        return view('dashboard::admin.dashboard');
    }
}

Use the view helper method

Use the view helper method


<?php

namespace Rogue\Http\Requests\Three;

use Rogue\Http\Requests\Request;

class PostRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'campaign_id' => 'required',
            'campaign_run_id' => 'required_with:campaign_id|integer',
            'northstar_id' => 'nullable|objectid',
            'why_participated' => 'nullable|string',
            'caption' => 'required|nullable|string|max:140',
            'quantity' => 'nullable|integer',
            'file' => 'image|dimensions:min_width=400,min_height=400',
            'status' => 'in:pending,accepted,rejected',
        ];
    }
}

<?php

namespace Rogue\Http\Requests\Three;

use Rogue\Http\Requests\Request;

class PostRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'campaign_id' => 'required',
            'campaign_run_id' => 'required_with:campaign_id|integer',
            'northstar_id' => 'nullable|objectid',
            'type' => 'required|string',
            'action' => 'required|string',
            'why_participated' => 'nullable|string',
            'caption' => 'required|nullable|string|max:140',
            'quantity' => 'nullable|integer',
            'file' => 'image|dimensions:min_width=400,min_height=400',
            'status' => 'in:pending,accepted,rejected',
            'details'=> 'json',
        ];
    }
}

Add validation for new columns

Add validation for new columns


<?php

class UsersTableSeeder extends Seeder {

    public function run()
    {
        DB::table('users')->delete();

        $users = array(
            array(
                'username'      => 'admin',
                'email'      => 'admin@test.com',
                'password'   => Hash::make('admin'),
                'confirmed'   => 0,
                'confirmation_code' => md5(microtime().Config::get('app.key')),
                'created_at' => new DateTime,
                'updated_at' => new DateTime,
            ),
            array(
                'username'      => 'user',
                'email'      => 'user@test.com',
                'password'   => Hash::make('user'),
                'confirmed'   => 0,
                'confirmation_code' => md5(microtime().Config::get('app.key')),
                'created_at' => new DateTime,
                'updated_at' => new DateTime,
            )
        );

        DB::table('users')->insert( $users );
    }

}

<?php

class UsersTableSeeder extends Seeder {

    public function run()
    {
        DB::table('users')->delete();

        $users = array(
            array(
                'username'      => 'admin',
                'email'      => 'admin@test.com',
                'password'   => Hash::make('admin'),
                'confirmed'   => 1,
                'confirmation_code' => md5(microtime().Config::get('app.key')),
                'created_at' => new DateTime,
                'updated_at' => new DateTime,
            ),
            array(
                'username'      => 'user',
                'email'      => 'user@test.com',
                'password'   => Hash::make('user'),
                'confirmed'   => 1,
                'confirmation_code' => md5(microtime().Config::get('app.key')),
                'created_at' => new DateTime,
                'updated_at' => new DateTime,
            )
        );

        DB::table('users')->insert( $users );
    }

}

Update user to be confirmed by default.

Update user to be confirmed by default.


<?php

/*
 * Bear CMS addon for Bear Framework
 * https://bearcms.com/
 * Copyright (c) 2016 Amplilabs Ltd.
 * Free to use under the MIT license.
 */

namespace BearCMS\Internal;

use BearFramework\App;

class TempClientData
{

    static function get($key)
    {
        $app = App::get();
        $dataHash = substr($key, 0, 32);
        try {
            $data = gzuncompress($app->encryption->decrypt(base64_decode(substr($key, 32))));
        } catch (\Exception $e) {
            return;
        }
        if (md5($data) !== $dataHash) {
            return;
        }
        $data = json_decode($data);
        if (is_array($data) && isset($data[0], $data[1]) && $data[0] === 'bearcms') {
            return $data[1];
        }
        return false;
    }

    static function set($data)
    {
        $app = App::get();
        $encodedData = json_encode(['bearcms', $data]);
        return md5($encodedData) . base64_encode($app->encryption->encrypt(gzcompress($encodedData)));
    }

}

<?php

/*
 * Bear CMS addon for Bear Framework
 * https://bearcms.com/
 * Copyright (c) 2016 Amplilabs Ltd.
 * Free to use under the MIT license.
 */

namespace BearCMS\Internal;

use BearFramework\App;

class TempClientData
{

    static function get($key)
    {
        $app = App::get();
        $dataHash = substr($key, 0, 32);
        try {
            $data = gzuncompress($app->encryption->decrypt(base64_decode(substr($key, 32))));
        } catch (\Exception $e) {
            return;
        }
        if (md5($data) !== $dataHash) {
            return;
        }
        $data = json_decode($data, true);
        if (is_array($data) && isset($data[0], $data[1]) && $data[0] === 'bearcms') {
            return $data[1];
        }
        return false;
    }

    static function set($data)
    {
        $app = App::get();
        $encodedData = json_encode(['bearcms', $data]);
        return md5($encodedData) . base64_encode($app->encryption->encrypt(gzcompress($encodedData)));
    }

}

Fix in temp client data.

Fix in temp client data.


<?php
// Disable unused headings and pre formatting
function wpa_45815($arr){
    $arr['block_formats'] = 'Huge=h2;Heading=h3;Paragraph=p';
    return $arr;
  }
add_filter('tiny_mce_before_init', 'wpa_45815');

// Add new styles to the TinyMCE "formats" menu dropdown
if ( ! function_exists( 'wpex_styles_dropdown' ) ) {
  function wpex_styles_dropdown( $settings ) {

    // Create array of new styles
    $new_styles = array(
      array(
        'title' => __( 'Styling', 'wpex' ),
        'items' => array(
          array(
            'title'     => __('Video','wpex'),
            'wrapper'  => true,
            'block'    => 'div',
            'classes'   => 'flex-video widescreen'
          )
        )
      )
    );
    // Merge old & new styles
    $settings['style_formats_merge'] = false;
    // Add new styles
    $settings['style_formats'] = json_encode( $new_styles );
    // Return New Settings
    return $settings;
  }
}
add_filter( 'tiny_mce_before_init', 'wpex_styles_dropdown' );
?>

<?php
// Disable unused headings and pre formatting
function wpa_45815($arr){
    $arr['block_formats'] = 'Huge=h2;Heading=h3;Paragraph=p';
    return $arr;
  }
add_filter('tiny_mce_before_init', 'wpa_45815');

// Add new styles to the TinyMCE "formats" menu dropdown
if ( ! function_exists( 'wpex_styles_dropdown' ) ) {
  function wpex_styles_dropdown( $settings ) {

    // Create array of new styles
    $new_styles = array(
      array(
        'title' => __( 'Embed', 'wpex' ),
        'items' => array(
          array(
            'title'     => __('Youtube/Vimeo','wpex'),
            'wrapper'  => true,
            'block'    => 'div',
            'classes'   => 'flex-video widescreen'
          ),
          array(
            'title'     => __('Instagram/Twitter/Vine','wpex'),
            'wrapper'  => true,
            'block'    => 'div',
            'classes'   => 'text-center'
          )
        )
      )
    );
    // Merge old & new styles
    $settings['style_formats_merge'] = false;
    // Add new styles
    $settings['style_formats'] = json_encode( $new_styles );
    // Return New Settings
    return $settings;
  }
}
add_filter( 'tiny_mce_before_init', 'wpex_styles_dropdown' );
?>

Add embed stuff in the editor

Add embed stuff in the editor


<?php

	Class migration_260 extends Migration {

		static function getVersion(){
			return '2.6.0-beta.2';
		}

		static function getReleaseNotes(){
			return 'http://getsymphony.com/download/releases/version/2.6.0/';
		}

		static function upgrade() {
			// Add date field options
			try {
				Symphony::Database()->query('
					ALTER TABLE `tbl_fields_date`
					ADD `calendar` enum("yes","no") COLLATE utf8_unicode_ci NOT NULL DEFAULT "no",
					ADD `time` enum("yes","no") COLLATE utf8_unicode_ci NOT NULL DEFAULT "yes";
				');
			}
			catch (Exception $ex) {}

			// Add namespace field to the cache table. RE: #2162
			try {
				Symphony::Database()->query('
					ALTER TABLE `tbl_cache` ADD `namespace` VARCHAR(255) COLLATE utf8_unicode_ci;
				');
			}
			catch (Exception $ex) {}

			// Add UNIQUE key constraint to the `hash` RE: #2163
			try {
				Symphony::Database()->import('
					ALTER TABLE `tbl_cache` DROP INDEX `hash`;
					ALTER TABLE `tbl_cache` ADD UNIQUE INDEX `hash` (`hash`)
				');
			}
			catch (Exception $ex) {}

			// Update the version information
			return parent::upgrade();
		}
	}

<?php

	Class migration_260 extends Migration {

		static function getVersion(){
			return '2.6.0-beta.2';
		}

		static function getReleaseNotes(){
			return 'http://getsymphony.com/download/releases/version/2.6.0/';
		}

		static function upgrade() {
			// Add date field options
			try {
				Symphony::Database()->query('
					ALTER TABLE `tbl_fields_date`
					ADD `calendar` enum("yes","no") COLLATE utf8_unicode_ci NOT NULL DEFAULT "no",
					ADD `time` enum("yes","no") COLLATE utf8_unicode_ci NOT NULL DEFAULT "yes";
				');
			}
			catch (Exception $ex) {}

			// Add namespace field to the cache table. RE: #2162
			try {
				Symphony::Database()->query('
					ALTER TABLE `tbl_cache` ADD `namespace` VARCHAR(255) COLLATE utf8_unicode_ci;
				');
			}
			catch (Exception $ex) {}

			// Add UNIQUE key constraint to the `hash` RE: #2163
			try {
				Symphony::Database()->import('
					ALTER TABLE `tbl_cache` DROP INDEX `hash`;
					ALTER TABLE `tbl_cache` ADD UNIQUE INDEX `hash` (`hash`)
				');
			}
			catch (Exception $ex) {}

			if(version_compare(self::$existing_version, self::getVersion(), '<=')) {
				// [#] Add weekoffset to configuration
				Symphony::Configuration()->set('weekoffset', 0, 'region');
			}

			// Update the version information
			return parent::upgrade();
		}
	}

Add weekoffset to configuration in migration

See #2312