<?php

namespace App\Providers;

use Timegridio\Concierge\Models\Appointment;
use Timegridio\Concierge\Models\Business;
use Timegridio\Concierge\Models\Contact;
use Timegridio\Concierge\Models\Service;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Routing\Router;

class RouteServiceProvider extends ServiceProvider
{
    /**
     * This namespace is applied to the controller routes in your routes file.
     *
     * In addition, it is set as the URL generator's root namespace.
     *
     * @var string
     */
    protected $namespace = 'App\Http\Controllers';

    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @param \Illuminate\Routing\Router $router
     *
     * @return void
     */
    public function boot(Router $router)
    {
        parent::boot($router);

        $router->model('contact', Contact::class);
        $router->model('service', Service::class);
        $router->model('appointment', Appointment::class);
    }

    /**
     * Define the routes for the application.
     *
     * @param \Illuminate\Routing\Router $router
     *
     * @return void
     */
    public function map(Router $router)
    {
        $router->group(['namespace' => $this->namespace], function ($router) {
            require app_path('Http/routes.php');
        });
    }
}

<?php

namespace App\Providers;

use Timegridio\Concierge\Models\Appointment;
use Timegridio\Concierge\Models\Business;
use Timegridio\Concierge\Models\Contact;
use Timegridio\Concierge\Models\Service;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Routing\Router;

class RouteServiceProvider extends ServiceProvider
{
    /**
     * This namespace is applied to the controller routes in your routes file.
     *
     * In addition, it is set as the URL generator's root namespace.
     *
     * @var string
     */
    protected $namespace = 'App\Http\Controllers';

    /**
     * Define the routes for the application.
     *
     * @param \Illuminate\Routing\Router $router
     *
     * @return void
     */
    public function map(Router $router)
    {
        $router->group(['namespace' => $this->namespace], function ($router) {
            require app_path('Http/routes.php');
        });
    }
}

Remove explicit binding in favor of implicit


<?php
/**
 * Default entry content template.
 *
 * @package BLR\Base_Theme\Templates
 */

?>

<article <?php post_class( 'entry' ); ?>>

	<header class="entry__header">
		<?php get_template_part( 'template/entry-title' ); ?>
		<?php get_template_part( 'templates/entry-meta' ); ?>
	</header><!-- /.entry__header -->

	<div class="entry__content entry__content--summary">
		<?php the_excerpt(); ?>
	</div><!-- /.entry__content -->

</article>

<?php
/**
 * Default entry content template.
 *
 * @package BLR\Base_Theme\Templates
 */

?>

<article <?php post_class( 'entry' ); ?>>

	<header class="entry__header">
		<?php get_template_part( 'templates/entry-title' ); ?>
		<?php get_template_part( 'templates/entry-meta' ); ?>
	</header><!-- /.entry__header -->

	<div class="entry__content entry__content--summary">
		<?php the_excerpt(); ?>
	</div><!-- /.entry__content -->

</article>

Fix typo in template part include

Fix typo in template part include


<?php

// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);

// this check prevents access to debug front controllers that are deployed by accident to production servers.
// feel free to remove this, extend it, or make something more sophisticated.
if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
    '127.0.0.1',
    '::1',
))) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

const CLASS_CACHING = true;

if (false == CLASS_CACHING) {
    require_once __DIR__.'/../app/bootstrap.php.cache';
    $kernel->loadClassCache();
} else {
    require_once __DIR__.'/../vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
    require_once __DIR__.'/../app/autoload.php';
}

use Symfony\Component\HttpFoundation\Request;

require_once __DIR__.'/../app/AppKernel.php';

$kernel = new AppKernel('dev', true);

$kernel->handle(Request::createFromGlobals())->send();

<?php

// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);

// this check prevents access to debug front controllers that are deployed by accident to production servers.
// feel free to remove this, extend it, or make something more sophisticated.
if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
    '127.0.0.1',
    '::1',
))) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';

use Symfony\Component\HttpFoundation\Request;

$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$kernel->handle(Request::createFromGlobals())->send();

Revert "turn off class caching"

Revert "turn off class caching"

This reverts commit 9bc61608d5739642bbea5afa9f66ea2f2c835b82.


<?php defined('C5_EXECUTE') or die("Access Denied.");

$is_concrete5 = TRUE;

Loader::element('header_required');

include('/var/www/html/intranet/application/elements/theme/global/ResponsiveLoginDesign/concrete5.php');

Loader::element('footer_required');

<?php defined('C5_EXECUTE') or die("Access Denied.");

$is_concrete5 = TRUE; ?>

<!-- Jquery Order Matters -->
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.js"></script>

<?php Loader::element('header_required');

include('/var/www/html/intranet/application/elements/theme/global/ResponsiveLoginDesign/concrete5.php');

Loader::element('footer_required');

Fix Jquery issue at login

Fix Jquery issue at login


<?php

class ExampleTest extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */
    public function testBasicExample()
    {
        $this->visit('/')
             ->see('Submit');
    }
}

<?php

class ExampleTest extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */
    public function testLoggedOutUser()
    {
        $this->visit('/')
             ->see('Log in with Pocket');
    }
}

Test to check for logged out button

Test to check for logged out button


@extends("layout.base")

@section("title", "Wdi Paste - {$language->name}")

@section("container")

{{ $language->name }}

        Possibili estensioni:
        {{ $language->extensionsToString }}

        @forelse($language->pastes as $paste)

{{ $paste->fileName }}

{{ $paste->description }}

                    slug) }}" class="card-link">Visualizza

        @empty

Opps nessuno paste per {{ $language->name }}

{{ $language->name }} è senza paste

Questo è dovuto al fatto che questo linguaggio non è stato ancora utilizzato per creare dei paste, vuoi essere il primo?

                    Crea il primo paste per {{ $language->name }}

        @endforelse

@endsection

@extends("layout.base")

@section("title", "Wdi Paste - {$language->name}")

@section("container")

{{ $language->name }}

        Possibili estensioni:
        {{ $language->extensionsToString }}

    @if($language->hasPastes())

            @foreach($language->pastes as $paste)

{{ $paste->fileName }}

{{ $paste->description }}

                        slug) }}" class="card-link">Visualizza

            @endforeach

    @else

Opps nessuno paste per {{ $language->name }}

{{ $language->name }} è senza paste

Questo è dovuto al fatto che questo linguaggio non è stato ancora utilizzato per creare dei paste, vuoi essere il primo?

                Crea il primo paste per {{ $language->name }}

    @endif

@endsection

Improve language show view UX

Improve language show view UX


<?php

declare (strict_types = 1);

namespace Mihaeu\PhpDependencies;

use PhpParser\Parser as BaseParser;

class Parser
{
    /** @var BaseParser */
    private $parser;

    /**
     * Parser constructor.
     *
     * @param $parser
     */
    public function __construct(BaseParser $parser)
    {
        $this->parser = $parser;
    }

    public function parse(PhpFileCollection $files) : Ast
    {
        $ast = new Ast();
        $files->each(function (PhpFile $file) use ($ast) {
            $node = $this->parser->parse($file->code());
            $ast->add($file, $node);
        });

        return $ast;
    }
}

<?php

declare (strict_types = 1);

namespace Mihaeu\PhpDependencies;

use PhpParser\Parser as BaseParser;

class Parser
{
    /** @var BaseParser */
    private $parser;

    /**
     * @param $parser
     */
    public function __construct(BaseParser $parser)
    {
        $this->parser = $parser;
    }

    /**
     * @param PhpFileCollection $files
     *
     * @return Ast
     */
    public function parse(PhpFileCollection $files) : Ast
    {
        $ast = new Ast();
        $files->each(function (PhpFile $file) use ($ast) {
            $node = $this->parser->parse($file->code());
            $ast->add($file, $node);
        });

        return $ast;
    }
}

Add missing comment and remove another redundant one


<?php
defined('BASEPATH') OR exit('No direct script access allowed');

$config['install_image_id'] = "e2bf2887-c8c5-429b-8951-e869c388830a";

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

$config['install_image_id'] = "d0c50b37-f0f5-4924-97b0-1fd40c457efe";

Use the Scaleway Docker image

Use the Scaleway Docker image


<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>

<span id="sympal_content_slot_<?php echo $contentSlot->getId() ?>_editor_form" class="sympal_<?php echo sfInflector::tableize($contentSlot->getType()) ?>_content_slot_editor_form">
  <?php echo $form->renderHiddenFields() ?>

  <?php if ($contentSlot->getIsColumn()): ?>
    <?php if (sfSympalConfig::isI18nEnabled('sfSympalContentSlot') && !isset($form[$contentSlot->getName()])): ?>
      <?php echo $form[$sf_user->getCulture()][$contentSlot->getName()] ?>
    <?php else: ?>
      <?php echo $form[$contentSlot->getName()] ?>
    <?php endif; ?>
  <?php else: ?>
    <?php if (sfSympalConfig::isI18nEnabled('sfSympalContentSlot')): ?>
      <?php echo $form[$sf_user->getCulture()]['value'] ?>
    <?php else: ?>
      <?php echo $form['value'] ?>
    <?php endif; ?>
  <?php endif; ?>
</span>

<script type="text/javascript">
$('#sympal_content_slot_<?php echo $contentSlot->getId() ?>_editor_form textarea').markItUp(mySettings);
$('#sympal_content_slot_<?php echo $contentSlot->getId() ?>_editor_form').elastic();
</script>

<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>

<span id="sympal_content_slot_<?php echo $contentSlot->getId() ?>_editor_form" class="sympal_<?php echo sfInflector::tableize($contentSlot->getType()) ?>_content_slot_editor_form">
  <?php echo $form->renderHiddenFields() ?>

  <?php if ($contentSlot->getIsColumn()): ?>
    <?php if (sfSympalConfig::isI18nEnabled('sfSympalContentSlot') && !isset($form[$contentSlot->getName()])): ?>
      <?php echo $form[$sf_user->getCulture()][$contentSlot->getName()] ?>
    <?php else: ?>
      <?php echo $form[$contentSlot->getName()] ?>
    <?php endif; ?>
  <?php else: ?>
    <?php if (sfSympalConfig::isI18nEnabled('sfSympalContentSlot')): ?>
      <?php echo $form[$sf_user->getCulture()]['value'] ?>
    <?php else: ?>
      <?php echo $form['value'] ?>
    <?php endif; ?>
  <?php endif; ?>
</span>

<script type="text/javascript">

<?php if ($contentSlot->getType() == 'Markdown'): ?>
$('#sympal_content_slot_<?php echo $contentSlot->getId() ?>_editor_form textarea').markItUp(mySettings);
<?php endif; ?>

$('#sympal_content_slot_<?php echo $contentSlot->getId() ?>_editor_form textarea').elastic();
</script>

[1.4][sfSympalPlugin][0.7] Fix so we only enable markdown editor for Markdown slot types

git-svn-id: fb4b88f168106301dda01b59a7b997f753c86fb4@25946 ee427ae8-e902-0410-961c-c3ed070cd9f9


<?php
namespace Mouf\Integration\Magento;

use Mouf\Security\UserService\UserInterface;

/**
 * A user in magento, represented as a UserInterface
 */
class MagentoUser implements UserInterface {

    private $customer;

    public function __construct(\Mage_Customer_Model_Customer $customer)
    {
        $this->customer = $customer;
    }

    /**
     * Returns the ID for the current user.
     *
     * @return string
     */
    public function getId()
    {
        return $this->customer->getId();
    }

    /**
     * Returns the login for the current user.
     *
     * @return string
     */
    public function getLogin()
    {
        return $this->customer->getEmail();
    }
}

<?php
namespace Mouf\Integration\Magento;

use Mouf\Security\UserService\UserInterface;

/**
 * A user in magento, represented as a UserInterface
 */
class MagentoUser implements UserInterface {

    private $customer;

    public function __construct(\Mage_Customer_Model_Customer $customer)
    {
        $this->customer = $customer;
    }

    /**
     * Returns the Object for the current user.
     *
     * @return \Mage_Customer_Model_Customer
     */
    public function getCustomer()
    {
        return $this->customer;
    }

    /**
     * Returns the ID for the current user.
     *
     * @return string
     */
    public function getId()
    {
        return $this->customer->getId();
    }

    /**
     * Returns the login for the current user.
     *
     * @return string
     */
    public function getLogin()
    {
        return $this->customer->getEmail();
    }
}

Add function to retrieve Magento Customer Object


<?php
/** @var object $loader - defined in composer Autoload */
// check if loader is initialized
if (!defined('root')) {
    die('Hack attempt');
}

// global environment
define('env_name', 'Front');
define('env_no_uri', true);
define('env_type', 'html');

require_once(root . '/Loader/Autoload.php');

// make fast-access alias \App::$Object
// class_alias('Ffcms\Core\App', 'App');
class App extends Ffcms\Core\App {}
/**
 * Alias for translate function for fast usage. Example: __('Welcome my friend')
 * @param string $text
 * @param array $params
 * @return string
 */
function __($text, array $params = []) {
    return \App::$Translate->translate($text, $params);
}

try {
    $app = \App::factory([
        'Database' => true,
        'Session' => true,
        'Debug' => true,
        'User' => true,
        'Mailer' => true,
        'Captcha' => true,
        'Cache' => true
    ]);
    $app->run();
} catch (Exception $e) {
    (new \Ffcms\Core\Exception\NativeException($e->getMessage()))->display();
}

<?php
/** @var object $loader - defined in composer Autoload */
// check if loader is initialized
if (!defined('root')) {
    die('Hack attempt');
}

// global environment
define('env_name', 'Front');
define('env_no_uri', true);
define('env_type', 'html');

require_once(root . '/Loader/Autoload.php');

// make fast-access alias \App::$Object
// class_alias('Ffcms\Core\App', 'App');
class App extends Ffcms\Core\App {}
/**
 * Alias for translate function for fast usage. Example: __('Welcome my friend')
 * @param string $text
 * @param array $params
 * @return string
 */
function __($text, array $params = []) {
    return \App::$Translate->translate($text, $params);
}

try {
    $app = \App::factory([
        'Database' => true,
        'Session' => true,
        'Debug' => true,
        'User' => true,
        'Mailer' => true,
        'Captcha' => true,
        'Cache' => true
    ], $loader);
    $app->run();
} catch (Exception $e) {
    (new \Ffcms\Core\Exception\NativeException($e->getMessage()))->display();
}

Fix - pass composer loader inside app factory


<?php

Route::get('/', function()
{
	return View::make('flarum.web::index')
		->with('title', Config::get('flarum::forum_title', 'Flarum Support Forum'));
});

<?php

Route::get('/', function()
{
	return View::make('flarum.web::index')
		->with('title', Config::get('flarum::forum_title', 'Flarum Demo Forum'));
});

Change another instance of forum title

Change another instance of forum title


#!/usr/bin/env php
<?php

include_once 'common.php';

if (isLatestPhp() && isLatestSymfony()) {
    // Make sure composer.json references all necessary components by having one
    // job run a `composer update`. Since `composer update` will install the
    // latest Symfony, this should be done for the job corresponding to the
    // latest symfony version.
    run('composer update --prefer-dist');
} else {
    run('composer require --prefer-dist symfony/symfony:'.getSymfonyVersion());
}

if (shouldBuildDocs()) {
    run('sudo apt-get -qq update');
    run('sudo apt-get install -y graphviz');
    run('sudo -H pip install -r requirements.txt');
}

#!/usr/bin/env php
<?php

include_once 'common.php';

if (isLatestPhp() && isLatestSymfony()) {
    // Make sure composer.json references all necessary components by having one
    // job run a `composer update`. Since `composer update` will install the
    // latest Symfony, this should be done for the job corresponding to the
    // latest symfony version.
    run('COMPOSER_MEMORY_LIMIT=-1 composer update --prefer-dist');
} else {
    run('COMPOSER_MEMORY_LIMIT=-1 composer require --prefer-dist symfony/symfony:'.getSymfonyVersion());
}

if (shouldBuildDocs()) {
    run('sudo apt-get -qq update');
    run('sudo apt-get install -y graphviz');
    run('sudo -H pip install -r requirements.txt');
}

Fix OOM errors on CI

Fix OOM errors on CI


<?php

namespace OpenCFP\Tests\Domain\Services;

use OpenCFP\Domain\Services\ResetEmailer;

class EmailerTest extends \PHPUnit_Framework_TestCase
{
    private $mailer;
    private $template;
    private $config_email;
    private $config_title;

    private $user_id;
    private $user_email;
    private $reset_code;

    public function setUp()
    {
        $this->mailer = \Mockery::mock('mailer')->shouldReceive('send')->once()
            ->with(\Mockery::on($this->validateEmail()))->getMock();

        $this->template = \Mockery::mock('template')->shouldIgnoreMissing();
        $this->config_email = 'admin@example.com';
        $this->config_title = 'Reset';

        $this->user_email = 'user@example.com';
        $this->user_id = 123;
        $this->reset_code = '987abc';

        $this->mailer = new ResetEmailer($this->mailer, $this->template, $this->config_email, $this->config_title);
    }

    public function tearDown()
    {
        \Mockery::close();
    }

    /** @test */
    public function it_sends_the_expected_email()
    {
        $this->mailer->send($this->user_id, $this->user_email, $this->reset_code);
    }

    private function validateEmail()
    {
        return function ($message) {
            return $message->getTo() === array($this->user_email => null);
        };
    }
}

<?php

namespace OpenCFP\Tests\Domain\Services;

use OpenCFP\Domain\Services\ResetEmailer;

class EmailerTest extends \PHPUnit_Framework_TestCase
{
    private $swift_mailer;
    private $template;
    private $config_email;
    private $config_title;

    private $user_id;
    private $user_email;
    private $reset_code;
    private $mailer;

    public function setUp()
    {
        $this->swift_mailer = \Mockery::mock('mailer')->shouldReceive('send')->once()
            ->with(\Mockery::on($this->validateEmail()))->getMock();

        $this->template = \Mockery::mock('template')->shouldIgnoreMissing();
        $this->config_email = 'admin@example.com';
        $this->config_title = 'Reset';

        $this->user_email = 'user@example.com';
        $this->user_id = 123;
        $this->reset_code = '987abc';

        $this->mailer = new ResetEmailer($this->swift_mailer, $this->template, $this->config_email, $this->config_title);
    }

    public function tearDown()
    {
        \Mockery::close();
    }

    /** @test */
    public function it_sends_the_expected_email()
    {
        $this->mailer->send($this->user_id, $this->user_email, $this->reset_code);
    }

    private function validateEmail()
    {
        return function ($message) {
            return $message->getTo() === array($this->user_email => null);
        };
    }
}

Fix naming in test case

Fix naming in test case


<?php

namespace Phive\Tests\Queue\Db\Pdo;

class SqliteQueueTest extends PdoQueueTest
{
    public static function createHandler()
    {
        // Generate a new db file on every method call to prevent
        // a "Database schema has changed" error which occurs if any
        // other process (e.g. worker) is still using the old db file.
        // We also can't use the shared cache mode due to
        // @link http://stackoverflow.com/questions/9150319/enable-shared-pager-cache-in-sqlite-using-php-pdo

        return new PdoHandler(array(
            'dsn'           => 'sqlite:'.tempnam(sys_get_temp_dir(), 'q_').'.sq3',
            'username'      => null,
            'password'      => null,
            'table_name'    => 'queue',
        ));
    }
}

<?php

namespace Phive\Tests\Queue\Db\Pdo;

class SqliteQueueTest extends PdoQueueTest
{
    public static function createHandler()
    {
        // Generate a new db file on every method call to prevent
        // a "Database schema has changed" error which occurs if any
        // other process (e.g. worker) is still using the old db file.
        // We also can't use the shared cache mode due to
        // @link http://stackoverflow.com/questions/9150319/enable-shared-pager-cache-in-sqlite-using-php-pdo

        return new PdoHandler(array(
            'dsn'           => sprintf('sqlite:%s/%s.sq3', sys_get_temp_dir(), uniqid('phive_tests_')),
            'username'      => null,
            'password'      => null,
            'table_name'    => 'queue',
        ));
    }
}

Fix sqlite db filename generation

Fix sqlite db filename generation


<?php
namespace Recras;

class Editor
{
    /**
     * Add the shortcode generator buttons to TinyMCE
     */
    public static function addButtons()
    {
        add_filter('mce_buttons', ['Recras\Editor', 'registerButtons']);
        add_filter('mce_external_plugins', ['Recras\Editor', 'addScripts']);
        add_thickbox();
    }

    /**
     * Load the script needed for TinyMCE
     *
     * @param array $plugins
     *
     * @return array
     */
    public function addScripts($plugins)
    {
        global $recras;

        $plugins['recras'] = $recras->baseUrl . '/editor/plugin.js';
        return $plugins;
    }

    /**
     * Load the TinyMCE translation
     *
     * @param array $locales
     *
     * @return array
     */
    public function loadTranslations($locales)
    {
        $locales['recras'] = plugin_dir_path(__FILE__) . '/editor/translation.php';
        return $locales;
    }

    /**
     * Register TinyMCE buttons
     *
     * @param array $buttons
     *
     * @return array
     */
    public function registerButtons($buttons)
    {
        array_push($buttons, 'recras-arrangement', 'recras-booking', 'recras-contact', 'recras-product');
        return $buttons;
    }
}

<?php
namespace Recras;

class Editor
{
    /**
     * Add the shortcode generator buttons to TinyMCE
     */
    public static function addButtons()
    {
        add_filter('mce_buttons', ['Recras\Editor', 'registerButtons']);
        add_filter('mce_external_plugins', ['Recras\Editor', 'addScripts']);
        add_thickbox();
    }

    /**
     * Load the script needed for TinyMCE
     *
     * @param array $plugins
     *
     * @return array
     */
    public static function addScripts($plugins)
    {
        global $recras;

        $plugins['recras'] = $recras->baseUrl . '/editor/plugin.js';
        return $plugins;
    }

    /**
     * Load the TinyMCE translation
     *
     * @param array $locales
     *
     * @return array
     */
    public static function loadTranslations($locales)
    {
        $locales['recras'] = plugin_dir_path(__FILE__) . '/editor/translation.php';
        return $locales;
    }

    /**
     * Register TinyMCE buttons
     *
     * @param array $buttons
     *
     * @return array
     */
    public static function registerButtons($buttons)
    {
        array_push($buttons, 'recras-arrangement', 'recras-booking', 'recras-contact', 'recras-product');
        return $buttons;
    }
}

Make functions static to prevent deprecated warnings


<?php
declare(strict_types=1);
namespace Onion\Framework\Http\Middleware;

use Interop\Http\Middleware\DelegateInterface;
use Interop\Http\Middleware\ServerMiddlewareInterface;
use Psr\Http\Message;

final class Delegate implements DelegateInterface
{
    /**
     * @var ServerMiddlewareInterface
     */
    protected $middleware;

    /**
     * @var Message\ResponseInterface
     */
    protected $response;

    /**
     * MiddlewareDelegate constructor.
     *
     * @param ServerMiddlewareInterface[] $middleware Middleware of the frame
     */
    public function __construct(array $middleware, Message\ResponseInterface $response = null)
    {
        $this->middleware = $middleware;
        $this->response = $response;
    }

    /**
     * @param Message\RequestInterface $request
     *
     * @throws Exceptions\MiddlewareException if returned response is not instance of ResponseInterface
     * @return Message\ResponseInterface
     */
    public function process(Message\ServerRequestInterface $request): Message\ResponseInterface
    {
        if ($this->middleware !== []) {
            $middleware = array_shift($this->middleware);

            if ($middleware !== null) {
                if (!$middleware instanceof ServerMiddlewareInterface) {
                    throw new \TypeError(
                        'All members of middleware must implement ServerMiddlewareInterface'
                    );
                }
            }

            return $middleware->process($request, $this);
        }

        return $this->response;
    }
}

<?php
declare(strict_types=1);
namespace Onion\Framework\Http\Middleware;

use Interop\Http\Middleware\DelegateInterface;
use Interop\Http\Middleware\ServerMiddlewareInterface;
use Psr\Http\Message;

final class Delegate implements DelegateInterface
{
    /**
     * @var ServerMiddlewareInterface
     */
    protected $middleware;

    /**
     * @var Message\ResponseInterface
     */
    protected $response;

    /**
     * MiddlewareDelegate constructor.
     *
     * @param ServerMiddlewareInterface[] $middleware Middleware of the frame
     */
    public function __construct(array $middleware, Message\ResponseInterface $response = null)
    {
        $this->middleware = $middleware;
        $this->response = $response;
    }

    /**
     * @param Message\RequestInterface $request
     *
     * @throws Exceptions\MiddlewareException if returned response is not instance of ResponseInterface
     * @return Message\ResponseInterface
     */
    public function process(Message\ServerRequestInterface $request): Message\ResponseInterface
    {
        if ($this->middleware !== []) {
            $middleware = array_shift($this->middleware);

            if ($middleware !== null) {
                if (!$middleware instanceof ServerMiddlewareInterface) {
                    throw new \TypeError(
                        'All members of middleware must implement ServerMiddlewareInterface'
                    );
                }

                return $middleware->process($request, $this);
            }
        }

        if (null === $this->response) {
            throw new \RuntimeException('No response template provide');
        }

        return $this->response;
    }
}

Change delegate to make it safer

Change delegate to make it safer

    Up till now the delegate would've failed without any error if there was no response or if the middleware it was supposed to trigger was null (end of stack)


<?php

namespace WP_CLI\Bootstrap;

/**
 * Class DefineProtectedCommands.
 *
 * Define the commands that are "protected", meaning that they shouldn't be able
 * to break due to extension code.
 *
 * @package WP_CLI\Bootstrap
 */
final class DefineProtectedCommands 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 ) {
		$commands        = $this->get_protected_commands();
		$current_command = $this->get_current_command();

		if ( in_array( $current_command, $commands, true ) ) {
			$state->setValue( BootstrapState::IS_PROTECTED_COMMAND, true );
		}

		return $state;
	}

	/**
	 * Get the lost of protected commands.
	 *
	 * @return array
	 */
	private function get_protected_commands() {
		return array(
			'cli info',
		);
	}

	/**
	 * Get the current command as a string.
	 *
	 * @return string Current command to be executed.
	 */
	private function get_current_command() {
		$runner = new RunnerInstance();

		return implode( ' ', (array) $runner()->arguments );
	}
}

<?php

namespace WP_CLI\Bootstrap;

/**
 * Class DefineProtectedCommands.
 *
 * Define the commands that are "protected", meaning that they shouldn't be able
 * to break due to extension code.
 *
 * @package WP_CLI\Bootstrap
 */
final class DefineProtectedCommands 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 ) {
		$commands        = $this->get_protected_commands();
		$current_command = $this->get_current_command();

		foreach ( $commands as $command ) {
			if ( 0 === strpos( $current_command, $command ) ) {
				$state->setValue( BootstrapState::IS_PROTECTED_COMMAND, true );
			}
		}

		return $state;
	}

	/**
	 * Get the lost of protected commands.
	 *
	 * @return array
	 */
	private function get_protected_commands() {
		return array(
			'cli info',
		    'package',
		);
	}

	/**
	 * Get the current command as a string.
	 *
	 * @return string Current command to be executed.
	 */
	private function get_current_command() {
		$runner = new RunnerInstance();

		return implode( ' ', (array) $runner()->arguments );
	}
}

Add `package *` commands to the list of protected commands.

See https://github.com/wp-cli/package-command/issues/10


<?php

namespace Outlandish\Wpackagist\EventListener;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;

class ExceptionListener
{
    public function onKernelException(ExceptionEvent $event)
    {
        // Let Symfony's default error tracing happen in dev.
        if (getenv('APP_ENV') === 'dev') {
            return;
        }

        $message = 'Something went wrong.';
        $exception = $event->getThrowable();
        $response = new Response();

        if ($exception instanceof HttpExceptionInterface) {
            $response->setStatusCode($exception->getStatusCode());
            $response->headers->replace($exception->getHeaders());

            if ($exception->getStatusCode() === 404) {
                $message = 'The requested page could not be found.';
            }
        } else {
            $response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);
        }

        $response->setContent($message);

        $event->setResponse($response);
    }
}

<?php

namespace Outlandish\Wpackagist\EventListener;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;

class ExceptionListener
{
    public function onKernelException(ExceptionEvent $event)
    {
        // Let Symfony's default error tracing happen in dev.
        if ($_SERVER['APP_ENV'] === 'dev') {
            return;
        }

        $message = 'Something went wrong.';
        $exception = $event->getThrowable();
        $response = new Response();

        if ($exception instanceof HttpExceptionInterface) {
            $response->setStatusCode($exception->getStatusCode());
            $response->headers->replace($exception->getHeaders());

            if ($exception->getStatusCode() === 404) {
                $message = 'The requested page could not be found.';
            }
        } else {
            $response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);
        }

        $response->setContent($message);

        $event->setResponse($response);
    }
}

Fix `APP_ENV` not set in some runtime contexts


<?php
/*
 * DPTechnics CMS
 * Logging page for warnings, info and error
 * Author: Daan Pape
 * Date: 04-09-2014
 */

// Load required files
require_once('config.php');

class Logger {

    public static function logInfo($nice, $raw = '')
    {
        error_log('['.date("Y-m-d H:i:s")."][INFO] ".$nice." ".$raw."\r\n", 3, Config::$logfile);
    }

    public static function logWarning($nice, $raw = '')
    {
        error_log('['.date("Y-m-d H:i:s")."][WARNING] ".$nice." ".$raw."\r\n", 3, Config::$logfile);
    }

    public static function logError($nice, $raw = '')
    {
        error_log('['.date("Y-m-d H:i:s")."][ERROR] ".$nice." ".$raw."\r\n", 3, Config::$logfile);
    }
}

?>

<?php
/*
 * DPTechnics CMS
 * Logging page for warnings, info and error
 * Author: Daan Pape
 * Date: 04-09-2014
 */

// Load required files
require_once('config.php');

/**
 * @notes This is a messy class. It should be refactored.
 */
class Logger {

    public static function logInfo($nice, $raw = '')
    {
        if(Config::$logDestination == 'syslog')
        {
            error_log('['.date("Y-m-d H:i:s")."][INFO] ".$nice." ".$raw."\r\n");
        }
        else
        {
            error_log('['.date("Y-m-d H:i:s")."][INFO] ".$nice." ".$raw."\r\n", 3, Config::$logfile);
        }
    }

    public static function logWarning($nice, $raw = '')
    {
        if(Config::$logDestination == 'syslog')
        {
            error_log('['.date("Y-m-d H:i:s")."][WARNING] ".$nice." ".$raw."\r\n");
        }
        else
        {
            error_log('['.date("Y-m-d H:i:s")."][WARNING] ".$nice." ".$raw."\r\n", 3, Config::$logfile);
        }
    }

    public static function logError($nice, $raw = '')
    {
        if(Config::$logDestination == 'syslog')
        {
            error_log('['.date("Y-m-d H:i:s")."][ERROR] ".$nice." ".$raw."\r\n");
        }
        else
        {
            error_log('['.date("Y-m-d H:i:s")."][ERROR] ".$nice." ".$raw."\r\n", 3, Config::$logfile);
        }
    }
}

?>

Implement (crappily) logging to syslog in addition to logging to file


<?php namespace Anomaly\FilesModule\File\Command;

/**
 * Class GetSystemMaxUploadSize
 *
 * @link          http://pyrocms.com/
 * @author        PyroCMS, Inc. <support@pyrocms.com>
 * @author        Ryan Thompson <ryan@pyrocms.com>
 */
class GetSystemMaxUploadSize
{

    /**
     * Handle the command.
     *
     * @return int
     */
    public function handle()
    {
        $post = str_replace('M', '', ini_get('post_max_size'));
        $file = str_replace('M', '', ini_get('upload_max_filesize'));

        return $file > $post ? $post : $file;
    }
}

<?php namespace Anomaly\FilesModule\File\Command;

/**
 * Class GetSystemMaxUploadSize
 *
 * @link          http://pyrocms.com/
 * @author        PyroCMS, Inc. <support@pyrocms.com>
 * @author        Ryan Thompson <ryan@pyrocms.com>
 */
class GetSystemMaxUploadSize
{

    /**
     * Handle the command.
     *
     * @return int
     */
    public function handle()
    {
        $post = $this->getSize('post_max_size');
        $file = $this->getSize('upload_max_filesize');

        return $file > $post ? $post : $file;
    }

    /**
     * Get php.ini value and convert it to Mb if needed.
     *
     * @param $key
     * @return float|int
     */
    protected function getSize($key)
    {
        preg_match('/([0-9]*)(K|M|G)?/im', ini_get($key), $matches);

        if ($matches[2] === 'G') {
            return $matches[1] * 1024;
        }

        if ($matches[2] === 'M') {
            return $matches[1];
        }

        if ($matches[2] === 'K') {
            return $matches[1] / 1024;
        }

        return $matches[1] / (1024 * 1024);
    }
}

Fix issue with max size being G

Fix issue with max size being G


<?php

namespace Vela\Core;

/**
 * Config class
 *
 * Simple class to store or get elements from configuration registry
 */

class Config
{

    /** @var array $data Data configuration array */
    private $data = [];

    /**
     * Class constructor
     * @param array $data List of values to add to the configuration registry
     */
    public function __construct(array $data = [])
    {
        $this->data = $data;
    }

    /**
     * Retrieves elements from config array
     *
     * @param string $key The configuration key to find. Supports dot notation
     * @return string|array returns a config value
     * @throws \InvalidArgumentException when no $key found
     */
    public function get($key)
    {
        $data  = $this->data;
        $parts = explode('.', $key);

        foreach ($parts as $part)
        {
            if (isset($data[$part]))
            {
                $data = $data[$part];
            } else {
                throw new \InvalidArgumentException('Cannot find configuration key: ' . $key);
            }
        }
        return $data;
    }

    /**
     * Return true if value is empty for given key
     *
     * @param string $key
     * @return bool
     */
    public function isEmpty($key)
    {
        return empty($this->data[$key]);
    }

}

<?php

namespace Vela\Core;

/**
 * Config class
 *
 * Simple class to store or get elements from configuration registry
 */

class Config
{

    /** @var array $data Data configuration array */
    private $data = [];

    /**
     * Class constructor
     * @param array $data List of values to add to the configuration registry
     */
    public function __construct(array $data = [])
    {
        $this->data = $data;
    }

    /**
     * Add another array to original configuration array
     * @param array
     * @throw \Exception
     */
    public function add(array $array)
    {
        if (!empty(array_intersect_key($this->data, $array)))
        {
            throw new \Exception ('Duplicate config key');
        }

        return array_merge($this->data, $array);
    }

    /**
     * Retrieves elements from config array
     *
     * @param string $key The configuration key to find. Supports dot notation
     * @return string|array returns a config value
     * @throws \InvalidArgumentException when no $key found
     */
    public function get($key)
    {
        $data  = $this->data;
        $parts = explode('.', $key);

        foreach ($parts as $part)
        {
            if (isset($data[$part]))
            {
                $data = $data[$part];
            } else {
                throw new \InvalidArgumentException('Cannot find configuration key: ' . $key);
            }
        }
        return $data;
    }

    /**
     * Return true if value is empty for given key
     *
     * @param string $key
     * @return bool
     */
    public function isEmpty($key)
    {
        return empty($this->data[$key]);
    }

}

Add another configuration array to the orginal


<?php
header('Content-Type: application/json; charset=utf-8');
$response = array(
    'name' => $_POST['user'],
    'password' => $_POST['pwd'],
);
echo json_encode($response, true);
?>

<?php
function cors() {

    // Allow from any origin
    if (isset($_SERVER['HTTP_ORIGIN'])) {
        // Decide if the origin in $_SERVER['HTTP_ORIGIN'] is one
        // you want to allow, and if so:
        header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
        header('Access-Control-Allow-Credentials: true');
        // header('Access-Control-Max-Age: 86400');    // cache for 1 day
    }

    // Access-Control headers are received during OPTIONS requests
    if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {

        if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
            header("Access-Control-Allow-Methods: GET, POST, OPTIONS, DELETE, PUT");

        if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
            header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");

        exit(0);
    }

}

cors();

header('Content-Type: application/json; charset=utf-8');
$response = array(
    'name' => $_POST['user'],
    'password' => $_POST['pwd'],
);
echo json_encode($response, true);
?>

Add CORS code in php.

[dev] Add CORS code in php.


<?php

namespace Cffie\Console;

use Cffie\Command\QueryCommand;
use Symfony\Component\Console\Application as BaseApplication;

class Application extends BaseApplication
{
    private $logo = '   ____ _____ _____ _
  / ___|  ___|  ___(_) ___
 | |   | |_  | |_  | |/ _ \
 | |___|  _| |  _| | |  __/
  \____|_|   |_|   |_|\___|

';

    public function __construct()
    {
        parent::__construct('CFFie', '0.1.1');
    }

    protected function getDefaultCommands()
    {
        $commands = parent::getDefaultCommands();
        $commands[] = new QueryCommand();

        return $commands;
    }

    public function getHelp()
    {
        return $this->logo.parent::getHelp();
    }
}

<?php

namespace Cffie\Console;

use Cffie\Command\QueryCommand;
use Symfony\Component\Console\Application as BaseApplication;

class Application extends BaseApplication
{
    private $logo = '   ____ _____ _____ _
  / ___|  ___|  ___(_) ___
 | |   | |_  | |_  | |/ _ \
 | |___|  _| |  _| | |  __/
  \____|_|   |_|   |_|\___|

';

    public function __construct()
    {
        parent::__construct('CFFie', '0.2.0');
    }

    protected function getDefaultCommands()
    {
        $commands = parent::getDefaultCommands();
        $commands[] = new QueryCommand();

        return $commands;
    }

    public function getHelp()
    {
        return $this->logo.parent::getHelp();
    }

    public function getLongVersion()
    {
        return parent::getLongVersion().' by <comment>Dany Maillard</comment>';
    }
}

Update version app to v0.2.0

Update version app to v0.2.0


<?php namespace Jenssegers\Date;

use Illuminate\Support\ServiceProvider;

class DateServiceProvider extends ServiceProvider
{
    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var bool
     */
    protected $defer = false;

    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        $locale = $this->app['translator']->getLocale();

        Date::setLocale($locale);
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        // Nothing.
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return ['Date'];
    }
}

<?php namespace Jenssegers\Date;

use Illuminate\Support\ServiceProvider;

class DateServiceProvider extends ServiceProvider
{
    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var bool
     */
    protected $defer = false;

    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        $this->app['events']->listen('locale.changed', function() {
            $this->setLocale();
        });

        $this->setLocale();
    }

    /**
     * Set the locale.
     *
     */
    protected function setLocale()
    {
        $locale = $this->app['translator']->getLocale();

        Date::setLocale($locale);
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        // Nothing.
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return ['Date'];
    }
}

Fix changing locale after app has booted


<?php

namespace Orchestra\Support\Providers;

use Illuminate\Support\ServiceProvider as BaseServiceProvider;

abstract class ServiceProvider extends BaseServiceProvider
{
    use Traits\PackageProvider;

    /**
     * Register a database migration path.
     *
     * @param  array|string  $paths
     *
     * @return void
     */
    protected function loadMigrationsFrom($paths)
    {
        if ($this->app->bound('migrator')) {
            parent::loadMigrationsFrom($paths);
        }
    }
}

<?php

namespace Orchestra\Support\Providers;

use Illuminate\Support\ServiceProvider as BaseServiceProvider;

abstract class ServiceProvider extends BaseServiceProvider
{
    use Traits\PackageProvider;
}

Remove redundant method. Laravel core have solve the underlying issue.

Signed-off-by: crynobone <e1a543840a942eb68427510a8a483282a7bfeddf@gmail.com>


<?php

namespace Showpad;

use Buzz\Browser;

final class BuzzAdapter implements Adapter
{
    /**
     * @var Browser
     */
    private $browser;

    /**
     * Constructor
     *
     * @param Browser $browser A Buzz browser instance
     */
    public function __construct(Browser $browser)
    {
        $this->browser = $browser;
    }

    /**
     * Send an http request
     *
     * @param string $method     The HTTP method
     * @param string $url        The url to send the request to
     * @param array  $parameters The parameters for the request (assoc array)
     * @param array  $headers    The headers for the request (assoc array)
     *
     * return mixed
     */
    public function request($method, $url, array $parameters = null, array $headers = null)
    {
        // add query parameters to the url if needed
        if (isset($parameters['query']) && is_array($parameters['query'])) {
            $query = parse_url($url, PHP_URL_QUERY);

            $url .= ($query === null ? '?' : '&') . http_build_query($parameters['query']);
        }

        $response = $this->browser->submit($url, $parameters, $method, $headers);

        return json_decode($response->getContent(), true);
    }
}

<?php

namespace Showpad;

use Buzz\Browser;
use Buzz\Message\Form\FormUpload;

final class BuzzAdapter implements Adapter
{
    /**
     * @var Browser
     */
    private $browser;

    /**
     * Constructor
     *
     * @param Browser $browser A Buzz browser instance
     */
    public function __construct(Browser $browser)
    {
        $this->browser = $browser;
    }

    /**
     * Send an http request
     *
     * @param string $method     The HTTP method
     * @param string $url        The url to send the request to
     * @param array  $parameters The parameters for the request (assoc array)
     * @param array  $headers    The headers for the request (assoc array)
     *
     * return mixed
     */
    public function request($method, $url, array $parameters = null, array $headers = null)
    {
        // add query parameters to the url if needed
        if (isset($parameters['query']) && is_array($parameters['query'])) {
            $query = parse_url($url, PHP_URL_QUERY);

            $url .= ($query === null ? '?' : '&') . http_build_query($parameters['query']);
        }

        // make sure files are added as a form upload
        if ($method === 'POST') {
            foreach ($parameters as $key => $value) {
                if (is_string($value) && substr($value, 0, 1) == '@') {
                    $value = ltrim($value, '@');
                    $parameters[$key] = new FormUpload($value);
                }
            }
        }

        $response = $this->browser->submit($url, $parameters, $method, $headers);

        return json_decode($response->getContent(), true);
    }
}

Make sure form uploads work.

Make sure form uploads work.


<?php if (!$_SKIP_HEADER) {?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
	<head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
	<?php require_once(VIEW_DIR.'/_core/header_meta.php');?>
        <!--[if lte IE 8]><script src="assets/css/ie/html5shiv.js"></script><![endif]-->
	<?php require_once(VIEW_DIR.'/_core/header_css.php');?>
        <!--[if lte IE 8]><link rel="stylesheet" href="assets/css/ie/v8.css" /><![endif]-->
        <!--[if lte IE 8]><script src="assets/css/ie/respond.min.js"></script><![endif]-->
        <script type="text/javascript">
        	// this special function can only be declared here
        	var ValidateSubmit = {
		        isSubmitted: false,
		        submit: function() {
	                if (ValidateSubmit.isSubmitted) {
			            return false;
		            }
		            ValidateSubmit.isSubmitted = true;
		            $("input[type=submit]").attr("disabled", "disabled");
		            form.submit();
	            },
		        END: null
	        };
        </script>
	</head>
<?php }?>

<?php if (!$_SKIP_HEADER) {?>
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
	<head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
	<?php require_once(VIEW_DIR.'/_core/header_meta.php');?>
        <!--[if lte IE 8]><script src="assets/css/ie/html5shiv.js"></script><![endif]-->
	<?php require_once(VIEW_DIR.'/_core/header_css.php');?>
        <!--[if lte IE 8]><link rel="stylesheet" href="assets/css/ie/v8.css" /><![endif]-->
        <!--[if lte IE 8]><script src="assets/css/ie/respond.min.js"></script><![endif]-->
        <script type="text/javascript" nonce="29af2i">
        	// this special function can only be declared here
        	var ValidateSubmit = {
		        isSubmitted: false,
		        submit: function() {
	                if (ValidateSubmit.isSubmitted) {
			            return false;
		            }
		            ValidateSubmit.isSubmitted = true;
		            $("input[type=submit]").attr("disabled", "disabled");
		            form.submit();
	            },
		        END: null
	        };
        </script>
	</head>
<?php }?>

Fix big preventing some JS from executing


<?php
/*
 * This file is part of the GitSSH2\NotificationBundle package.
 *
 * (c) Paul Schweppe <paulschweppe@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
if (!($loader = @include __DIR__.'/../../../../vendor/autoload.php')) {
    echo <<<'EOT'
You need to install the project dependencies using Composer:
$ wget http://getcomposer.org/composer.phar
OR
$ curl -s https://getcomposer.org/installer | php
$ php composer.phar install --dev
$ phpunit
EOT;
    exit(1);
}

<?php
/*
 * This file is part of the GitSSH2\NotificationBundle package.
 *
 * (c) Paul Schweppe <paulschweppe@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
if (!($loader = @include __DIR__.'/../../../../vendor/autoload.php') && !($loader = @include __DIR__.'/../vendor/autoload.php')) {
    echo <<<'EOT'
You need to install the project dependencies using Composer:
$ wget http://getcomposer.org/composer.phar
OR
$ curl -s https://getcomposer.org/installer | php
$ php composer.phar install --dev
$ phpunit
EOT;
    exit(1);
}

Update directory of vendor autoloader

Update directory of vendor autoloader


<?php

namespace League\Plates\Extension;

class AssetTest extends \PHPUnit_Framework_TestCase
{
    private $extension;

    public function setUp()
    {
        $this->extension = new Asset(realpath('tests/assets'));
    }

    public function testCanCreateExtension()
    {
        $this->assertInstanceOf('League\Plates\Extension\Asset', $this->extension);
    }

    public function testGetFunctionsReturnsAnArray()
    {
        $this->assertInternalType('array', $this->extension->getFunctions());
    }

    public function testGetFunctionsReturnsAtLeastOneRecord()
    {
        $this->assertTrue(count($this->extension->getFunctions()) > 0);
    }

    public function testCachedAssetUrl()
    {
        $this->assertTrue($this->extension->cachedAssetUrl('styles.css') === 'styles.css?v=1384813172');
    }

    public function testCachedAssetUrlUsingFilenameMethod()
    {
        $this->extension = new Asset(realpath('tests/assets'), true);
        $this->assertTrue($this->extension->cachedAssetUrl('styles.css') === 'styles.1384813172.css');
    }

    public function testFileNotFoundException()
    {
        $this->setExpectedException('LogicException');
        $this->extension->cachedAssetUrl('404.css');
    }
}

<?php

namespace League\Plates\Extension;

class AssetTest extends \PHPUnit_Framework_TestCase
{
    private $extension;

    public function setUp()
    {
        $this->extension = new Asset(realpath('tests/assets'));
    }

    public function testCanCreateExtension()
    {
        $this->assertInstanceOf('League\Plates\Extension\Asset', $this->extension);
    }

    public function testGetFunctionsReturnsAnArray()
    {
        $this->assertInternalType('array', $this->extension->getFunctions());
    }

    public function testGetFunctionsReturnsAtLeastOneRecord()
    {
        $this->assertTrue(count($this->extension->getFunctions()) > 0);
    }

    public function testCachedAssetUrl()
    {
        $this->assertTrue($this->extension->cachedAssetUrl('styles.css') === 'styles.css?v=' . filemtime(realpath('tests/assets/styles.css')));
    }

    public function testCachedAssetUrlUsingFilenameMethod()
    {
        $this->extension = new Asset(realpath('tests/assets'), true);
        $this->assertTrue($this->extension->cachedAssetUrl('styles.css') === 'styles.' . filemtime(realpath('tests/assets/styles.css')) . '.css');
    }

    public function testFileNotFoundException()
    {
        $this->setExpectedException('LogicException');
        $this->extension->cachedAssetUrl('404.css');
    }
}

Fix bug in Asset Extension tests.

Fix bug in Asset Extension tests.


<?php

namespace Coosos\TagBundle\Form\Type;

use Coosos\TagBundle\Form\DataTransformer\TagsTransformer;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class TagsType extends AbstractType
{
    /**
     * @var ObjectManager
     */
    private $manager;

    /**
     * TagsType constructor.
     * @param ObjectManager $manager
     */
    public function __construct(ObjectManager $manager)
    {
        $this->manager = $manager;
    }

    /**
     * @param FormBuilderInterface $builder
     * @param array                $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->addModelTransformer(new CollectionToArrayTransformer(), true)
            ->addModelTransformer(new TagsTransformer($this->manager), true);
    }

    /**
     * @param OptionsResolver $resolver
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            "required" => false,
        ]);
    }

    /**
     * @return string
     */
    public function getParent(): string {
        return TextType::class;
    }
}

<?php

namespace Coosos\TagBundle\Form\Type;

use Coosos\TagBundle\Form\DataTransformer\TagsTransformer;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Bridge\Doctrine\Form\DataTransformer\CollectionToArrayTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;

class TagsType extends AbstractType
{
    /**
     * @var ObjectManager
     */
    private $manager;

    /**
     * TagsType constructor.
     * @param ObjectManager $manager
     */
    public function __construct(ObjectManager $manager)
    {
        $this->manager = $manager;
    }

    public function buildView(FormView $view, FormInterface $form, array $options)
    {
        $view->vars = array_merge($view->vars, $options);
    }

    /**
     * @param FormBuilderInterface $builder
     * @param array                $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->addModelTransformer(new CollectionToArrayTransformer(), true)
            ->addModelTransformer(new TagsTransformer($this->manager), true);
    }

    /**
     * @param OptionsResolver $resolver
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            "required" => false,
            "coosos_tag_auto_complete" => true,
            "coosos_tag_persist_new"  => true,
        ]);
    }

    /**
     * @return string
     */
    public function getParent(): string {
        return TextType::class;
    }
}

Add 2 form configuration (coosos_tag_auto_complete, coosos_tag_persist_new)


<?php

require_once('Socks4.class.php');
require_once('Socks4a.class.php');
require_once('Socks5.class.php');

class Socks4Test extends PHPUnit_Framework_TestCase{

    public function testSocks4(){
        $socks = new Socks4(9050);
        $this->http($socks);
    }

    public function testSocks4a(){
        $socks = new Socks4a(NULL,9050);
        $this->http($socks);
    }

    public function testSocks5(){
        $socks = new Socks5('localhost',9050);
        $this->http($socks);
    }

    protected function http($socks){
        $host = 'google.com';
        $fp = $socks->connect($host,80);

        fwrite($fp,"GET / HTTP/1.0\r\nHost: '.$host.'\r\n\r\n");

        $ret = stream_get_contents($fp);

        //var_dump($ret);

        $this->assertStringStartsWith('HTTP/1.',$ret);

        return $ret;
    }
}

<?php

require_once('Socks4.class.php');
require_once('Socks4a.class.php');
require_once('Socks5.class.php');

class Socks4Test extends PHPUnit_Framework_TestCase{
    public function testSocks4(){
        $socks = new Socks4(9050);
        $this->httpHostname($socks);
        $this->httpIpv4($socks);
    }

    public function testSocks4a(){
        $socks = new Socks4a(NULL,9050);
        $this->httpHostname($socks);
        $this->httpIpv4($socks);
    }

    public function testSocks5(){
        $socks = new Socks5('localhost',9050);
        $this->httpHostname($socks);
        $this->httpIpv4($socks);
    }

    protected function httpHostname($socks){
        return $this->http($socks,'google.com');
    }

    protected function httpIpv4($socks){
        return $this->http($socks,'209.85.148.104'); // nslookup google.com (2011-05-30)
    }

    protected function http($socks,$host){
        $fp = $socks->connect($host,80);

        fwrite($fp,"GET / HTTP/1.0\r\nHost: '.$host.'\r\n\r\n");

        $ret = stream_get_contents($fp);

        //var_dump($ret);

        $this->assertStringStartsWith('HTTP/1.',$ret);

        return $ret;
    }
}

Test connection to hostnames and IPv4 addresses


<?php

/*
 * This file is part of Alt Three Validator.
 *
 * (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 AltThree\Validator;

use Illuminate\Contracts\Support\MessageBag;
use Illuminate\Contracts\Support\MessageProvider;
use RuntimeException;

/**
 * This is the validating exception class.
 *
 * @author Graham Campbell <graham@alt-three.com>
 */
class ValidationException extends RuntimeException implements MessageProvider
{
    /**
     * The validation errors.
     *
     * @var \Illuminate\Contracts\Support\MessageBag
     */
    protected $errors;

    /**
     * Make a new validation exception instance.
     *
     * @param \Illuminate\Contracts\Support\MessageBag $errors
     *
     * @return void
     */
    public function __construct(MessageBag $errors)
    {
        $this->errors = $errors;

        parent::__construct('Validation has failed.');
    }

    /**
     * Get the messages for the instance.
     *
     * @return \Illuminate\Contracts\Support\MessageBag
     */
    public function getMessageBag()
    {
        return $this->errors;
    }
}

<?php

/*
 * This file is part of Alt Three Validator.
 *
 * (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 AltThree\Validator;

use Illuminate\Contracts\Support\MessageBag;
use Illuminate\Contracts\Support\MessageProvider;
use RuntimeException;

/**
 * This is the validating exception class.
 *
 * @author Graham Campbell <graham@alt-three.com>
 */
class ValidationException extends RuntimeException implements MessageProvider
{
    /**
     * The validation errors.
     *
     * @var \Illuminate\Contracts\Support\MessageBag
     */
    protected $errors;

    /**
     * Make a new validation exception instance.
     *
     * @param \Illuminate\Contracts\Support\MessageBag $errors
     *
     * @return void
     */
    public function __construct(MessageBag $errors)
    {
        $this->errors = $errors;

        parent::__construct('Validation has failed.');
    }

    /**
     * Get the messages for the instance.
     *
     * @return \Illuminate\Contracts\Support\MessageBag
     */
    public function getMessageBag()
    {
        return $this->errors;
    }

    /**
     * Get the string representation of the exception.
     *
     * @return string
     */
    public function __toString()
    {
        $lines = explode("\n", parent::__toString());

        return array_shift($lines)." \nValidation errors:\n".implode($this->errors->all(), "\n")."\n".implode($lines, "\n");
    }
}

Include validation errors in the string representation of the exception


<?php

namespace Kunstmaan\NodeBundle\Event;

use Kunstmaan\AdminBundle\Event\BcEvent;

final class SlugSecurityEvent extends BcEvent
{
    private $node;

    private $nodeTranslation;

    private $entity;

    private $request;

    /**
     * @return mixed
     */
    public function getNode()
    {
        return $this->node;
    }

    /**
     * @param mixed $node
     */
    public function setNode($node)
    {
        $this->node = $node;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getNodeTranslation()
    {
        return $this->nodeTranslation;
    }

    /**
     * @param mixed $nodeTranslation
     */
    public function setNodeTranslation($nodeTranslation)
    {
        $this->nodeTranslation = $nodeTranslation;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getEntity()
    {
        return $this->entity;
    }

    /**
     * @param mixed $entity
     */
    public function setEntity($entity)
    {
        $this->entity = $entity;

        return $this;
    }

    /**
     * @return mixed
     */
    public function getRequest()
    {
        return $this->request;
    }

    /**
     * @param mixed $request
     */
    public function setRequest($request)
    {
        $this->request = $request;

        return $this;
    }
}

<?php

namespace Kunstmaan\NodeBundle\Event;

use Kunstmaan\AdminBundle\Event\BcEvent;
use Kunstmaan\NodeBundle\Entity\HasNodeInterface;
use Kunstmaan\NodeBundle\Entity\Node;
use Kunstmaan\NodeBundle\Entity\NodeTranslation;
use Symfony\Component\HttpFoundation\Request;

final class SlugSecurityEvent extends BcEvent
{
    /** @var Node|null */
    private $node;
    /** @var NodeTranslation|null */
    private $nodeTranslation;
    /** @var HasNodeInterface|null */
    private $entity;
    /** @var Request|null */
    private $request;

    /**
     * @return Node|null
     */
    public function getNode()
    {
        return $this->node;
    }

    /**
     * @param Node $node
     */
    public function setNode($node)
    {
        $this->node = $node;

        return $this;
    }

    /**
     * @return NodeTranslation|null
     */
    public function getNodeTranslation()
    {
        return $this->nodeTranslation;
    }

    /**
     * @param NodeTranslation $nodeTranslation
     */
    public function setNodeTranslation($nodeTranslation)
    {
        $this->nodeTranslation = $nodeTranslation;

        return $this;
    }

    /**
     * @return HasNodeInterface|null
     */
    public function getEntity()
    {
        return $this->entity;
    }

    /**
     * @param HasNodeInterface $entity
     */
    public function setEntity($entity)
    {
        $this->entity = $entity;

        return $this;
    }

    /**
     * @return Request|null
     */
    public function getRequest()
    {
        return $this->request;
    }

    /**
     * @param Request $request
     */
    public function setRequest($request)
    {
        $this->request = $request;

        return $this;
    }
}

[NodeBundle] Set correct typehints on methods and properties


<?php

namespace Project\AppBundle\Entity;

use Doctrine\ORM\EntityRepository;

/**
 * PromotionRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class PromotionRepository extends EntityRepository
{
}

<?php

namespace Project\AppBundle\Entity;

use Doctrine\ORM\EntityRepository;

/**
 * PromotionRepository
 *
 * This class was generated by the Doctrine ORM. Add your own custom
 * repository methods below.
 */
class PromotionRepository extends EntityRepository
{
    /**
     * Create a json of a promotion.
     *
     * @param int $promotion id of the promotion to convert to a json.
     * @return string JSON that contain the element of a promotion.
     */
    public function toJson($promotion)
    {
        $qb = $this->createQueryBuilder('p');

        $qb->where('p.id = :id')
            ->setParameter('id', $promotion)
            ->andWhere('p.archive IS NULL')
            ->setMaxResults(1);

        $promotion = $qb->getQuery()
            ->getSingleResult();

        $jsonData = array(
                          'promotion' => $promotion->__toString(),
                          'formation' => $promotion->getFormation()->__toString(),
                          'start'     => $promotion->getStartDate()->format('Y-m-d H:i:s'),
                          'end'       => $promotion->getEndDate()->format('Y-m-d H:i:s')
                          );

        return json_encode($jsonData);
    }
}

Add a toJson method to Promotion repository


<?php

/*
 * Global helper functions for Clearboard
 */

/**
 * Combines filesystem paths.
 * Accepts unlimited number of arguments in the form of strings.
 * @return string
 */
function joinPath() { // Credit - http://stackoverflow.com/a/1091219/3764348
    $args = func_get_args();
    $paths = array();
    foreach ($args as $arg) {
        $paths = array_merge($paths, (array)$arg);
    }

    $paths = array_map(create_function('$p', 'return trim($p, "/");'), $paths);
    $paths = array_filter($paths);
    return join('/', $paths);
}

/**
 * Returns the base path of the theme's personal asset directory.
 * Similar to Laravel's *_path() functions, a path argument can be supplied to produce a full path.
 * @param string $path Optional. Path to resource.
 * @param string|null $theme Name of theme. If left null, will use current theme.
 * @return string
 */
function theme_path($path = '', $theme = null) {
    if ($theme == null) { $theme = config('clearboard.theme'); }

    return app_path() . "/assets/$theme/" . ($path ? DIRECTORY_SEPARATOR.$path : $path);
}

<?php

/*
 * Global helper functions for Clearboard
 */

/**
 * Combines filesystem paths.
 * Accepts unlimited number of arguments in the form of strings.
 * @return string
 */
function joinPath() { // Credit - http://stackoverflow.com/a/1091219/3764348
    $args = func_get_args();
    $paths = array();
    foreach ($args as $arg) {
        $paths = array_merge($paths, (array)$arg);
    }

    $paths = array_map(create_function('$p', 'return trim($p, "/");'), $paths);
    $paths = array_filter($paths);
    return join('/', $paths);
}

/**
 * Returns the base path of the theme's personal asset directory.
 * Similar to Laravel's *_path() functions, a path argument can be supplied to produce a full path.
 * WARNING! Does not return URL!
 * @param string $path Optional. Path to resource.
 * @param string|null $theme Name of theme. If left null, will use current theme.
 * @return string
 */
function theme_path($path = '', $theme = null) {
    if ($theme == null) { $theme = config('clearboard.theme'); }

    return app_path() . "/assets/$theme/" . ($path ? DIRECTORY_SEPARATOR.$path : $path);
}

/**
 * Identical behaviour to Laravel's inbuilt asset() helper function, expect returns assets from a theme's personal
 * asset directory.
 * @param $path
 * @param null $secure
 * @param null $theme
 * @return string
 */
function theme_asset($path, $secure = null, $theme = null) {
    if ($theme == null) { $theme = config('clearboard.theme'); }

    return asset("assets/$theme/" . $path, $secure);
}

Add helper function to get theme assets

Add helper function to get theme assets


<?php
declare(strict_types=1);

namespace Nastoletni\Code\UserInterface\Web\Controller;

use Nastoletni\Code\Domain\Paste\Id;
use Nastoletni\Code\Domain\PasteRepository;
use Nastoletni\Code\UserInterface\Controller\AbstractController;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

class PasteController extends AbstractController
{
    /**
     * @var PasteRepository
     */
    private $pasteRepository;

    /**
     * PasteController constructor.
     *
     * @param PasteRepository $pasteRepository
     */
    public function __construct(PasteRepository $pasteRepository)
    {
        $this->pasteRepository = $pasteRepository;
    }

    /**
     * @param Request $request
     * @param Response $response
     * @return Response
     */
    public function home(Request $request, Response $response): Response
    {
        return $this->twig->render($response, 'home.twig');
    }

    /**
     * @param Request $request
     * @param Response $response
     * @param string $id
     * @return Response
     */
    public function paste(Request $request, Response $response, string $id): Response
    {
        $paste = $this->pasteRepository->getById(Id::createFromBase62($id));

        return $this->twig->render($response, 'paste.twig', [
            'paste' => $paste
        ]);
    }
}

<?php
declare(strict_types=1);

namespace Nastoletni\Code\UserInterface\Web\Controller;

use Nastoletni\Code\Domain\Paste\Id;
use Nastoletni\Code\Domain\Paste\NotExistsException;
use Nastoletni\Code\Domain\PasteRepository;
use Nastoletni\Code\UserInterface\Controller\AbstractController;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

class PasteController extends AbstractController
{
    /**
     * @var PasteRepository
     */
    private $pasteRepository;

    /**
     * PasteController constructor.
     *
     * @param PasteRepository $pasteRepository
     */
    public function __construct(PasteRepository $pasteRepository)
    {
        $this->pasteRepository = $pasteRepository;
    }

    /**
     * @param Request $request
     * @param Response $response
     * @return Response
     */
    public function home(Request $request, Response $response): Response
    {
        return $this->twig->render($response, 'home.twig');
    }

    /**
     * @param Request $request
     * @param Response $response
     * @param string $id
     * @return Response
     */
    public function paste(Request $request, Response $response, string $id): Response
    {
        try {
            $paste = $this->pasteRepository->getById(Id::createFromBase62($id));
        } catch (NotExistsException $e) {
            $response->getBody()->write('404');
            return $response->withStatus(404);
        }

        return $this->twig->render($response, 'paste.twig', [
            'paste' => $paste
        ]);
    }
}

Add basic controller support for 404

Add basic controller support for 404


<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;

abstract class Job
{
    /*
    |--------------------------------------------------------------------------
    | Queueable Jobs
    |--------------------------------------------------------------------------
    |
    | This job base class provides a central location to place any logic that
    | is shared across all of your jobs. The trait included with the class
    | provides access to the "queueOn" and "delay" queue helper methods.
    |
    */
    use Queueable;
}

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;

abstract class Job implements ShouldQueue
{
    /*
    |--------------------------------------------------------------------------
    | Queueable Jobs
    |--------------------------------------------------------------------------
    |
    | This job base class provides a central location to place any logic that
    | is shared across all of your jobs. The trait included with the class
    | provides access to the "queueOn" and "delay" queue helper methods.
    |
    */
    use Queueable;
}

Set jobs to be queued

Set jobs to be queued


<?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\ContentBundle\Slug;

use Darvin\Utils\Slug\SlugHandlerInterface;
use Doctrine\ORM\EntityManager;

/**
 * Unique slug handler
 */
class UniqueSlugHandler implements SlugHandlerInterface
{
    /**
     * {@inheritdoc}
     */
    public function handle(&$slug, &$suffix, EntityManager $em)
    {
        $similarSlugs = $this->getSlugMapItemRepository($em)->getSimilarSlugs($slug);

        if (empty($similarSlugs) || !in_array($slug, $similarSlugs)) {
            return;
        }

        $originalSlug = $slug;
        $index = 0;

        do {
            $index++;
            $slug = $originalSlug.'-'.$index;
        } while (in_array($slug, $similarSlugs));

        $suffix.='-'.$index;
    }

    /**
     * @param \Doctrine\ORM\EntityManager $em Entity manager
     *
     * @return \Darvin\ContentBundle\Repository\SlugMapItemRepository
     */
    private function getSlugMapItemRepository(EntityManager $em)
    {
        return $em->getRepository('DarvinContentBundle:SlugMapItem');
    }
}

<?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\ContentBundle\Slug;

use Darvin\Utils\Sluggable\SlugHandlerInterface;
use Doctrine\ORM\EntityManager;

/**
 * Unique slug handler
 */
class UniqueSlugHandler implements SlugHandlerInterface
{
    /**
     * {@inheritdoc}
     */
    public function handle(&$slug, &$suffix, EntityManager $em)
    {
        $similarSlugs = $this->getSlugMapItemRepository($em)->getSimilarSlugs($slug);

        if (empty($similarSlugs) || !in_array($slug, $similarSlugs)) {
            return;
        }

        $originalSlug = $slug;
        $index = 0;

        do {
            $index++;
            $slug = $originalSlug.'-'.$index;
        } while (in_array($slug, $similarSlugs));

        $suffix.='-'.$index;
    }

    /**
     * @param \Doctrine\ORM\EntityManager $em Entity manager
     *
     * @return \Darvin\ContentBundle\Repository\SlugMapItemRepository
     */
    private function getSlugMapItemRepository(EntityManager $em)
    {
        return $em->getRepository('DarvinContentBundle:SlugMapItem');
    }
}

Implement sluggable manager in utils bundle.


<?php

namespace Amp;

/**
 * Cancellation tokens are simple objects that allow registering handlers to subscribe to cancellation requests.
 */
interface CancellationToken
{
    /**
     * Subscribes a new handler to be invoked on a cancellation request.
     *
     * This handler might be invoked immediately in case the token has already been cancelled. Returned generators will
     * automatically be run as coroutines. Any unhandled exceptions will be throw into the event loop.
     *
     * @param callable $callback Callback to be invoked on a cancellation request. Will receive a `CancelledException`
     * as first argument that may be used to fail the operation's promise.
     *
     * @return string Identifier that can be used to cancel the subscription.
     */
    public function subscribe(callable $callback): string;

    /**
     * Unsubscribes a previously registered handler.
     *
     * The handler will no longer be called as long as this method isn't invoked from a subscribed callback.
     *
     * @param string $id
     *
     * @return void
     */
    public function unsubscribe(string $id);

    /**
     * Returns whether cancellation has been requested yet.
     *
     * @return bool
     */
    public function isRequested(): bool;

    /**
     * Throws the `CancelledException` if cancellation has been requested, otherwise does nothing.
     *
     * @return void
     */
    public function throwIfRequested();
}

<?php

namespace Amp;

/**
 * Cancellation tokens are simple objects that allow registering handlers to subscribe to cancellation requests.
 */
interface CancellationToken
{
    /**
     * Subscribes a new handler to be invoked on a cancellation request.
     *
     * This handler might be invoked immediately in case the token has already been cancelled. Returned generators will
     * automatically be run as coroutines. Any unhandled exceptions will be throw into the event loop.
     *
     * @param callable $callback Callback to be invoked on a cancellation request. Will receive a `CancelledException`
     * as first argument that may be used to fail the operation's promise.
     *
     * @return string Identifier that can be used to cancel the subscription.
     */
    public function subscribe(callable $callback): string;

    /**
     * Unsubscribes a previously registered handler.
     *
     * The handler will no longer be called as long as this method isn't invoked from a subscribed callback.
     *
     * @param string $id
     *
     * @return void
     */
    public function unsubscribe(string $id);

    /**
     * Returns whether cancellation has been requested yet.
     *
     * @return bool
     */
    public function isRequested(): bool;

    /**
     * Throws the `CancelledException` if cancellation has been requested, otherwise does nothing.
     *
     * @return void
     *
     * @throws CancelledException
     */
    public function throwIfRequested();
}

Annotate that throwIfRequested might throw CancelledException


<?php

/*
 * This file is part of the kompakt/audio-tools package.
 *
 * (c) Christian Hoegl <chrigu@sirprize.me>
 *
 */

namespace Kompakt\AudioTools\Runner;

use Kompakt\AudioTools\Runner\Exception\RuntimeException;

class Kid3Runner
{
    protected $bin = null;
    protected $returnCode = 0;
    protected $output = array();

    public function __construct($bin = 'kid3')
    {
        $this->bin = $bin;
    }

    public function execute($args)
    {
        $this->returnCode = 0;
        $this->output = array();
        $cmd = sprintf("%s %s", $this->bin, $args);
        $lastLine = exec($cmd, $this->output, $this->returnCode);

        /*if ($this->returnCode > 0)
        {
            throw new RuntimeException(sprintf('Kid3 execution error: "%s". Cmd: "%s"', $lastLine, $cmd));
        }*/

        return $lastLine;
    }

    public function getReturnCode()
    {
        return $this->returnCode;
    }

    public function getOutput()
    {
        return $this->output;
    }

    public function __clone()
    {}
}

<?php

/*
 * This file is part of the kompakt/audio-tools package.
 *
 * (c) Christian Hoegl <chrigu@sirprize.me>
 *
 */

namespace Kompakt\AudioTools\Runner;

use Kompakt\AudioTools\Runner\Exception\RuntimeException;

class Kid3Runner
{
    protected $bin = null;
    protected $tempWorkDir = null;
    protected $returnCode = 0;
    protected $output = [];

    public function __construct($bin = 'kid3', $tempWorkDir = '/')
    {
        $this->bin = $bin;
        $this->tempWorkDir = $tempWorkDir;
    }

    public function execute($args)
    {
        $this->returnCode = 0;
        $this->output = [];

        $cwd = getcwd(); // Save current working directory
        $cmd = sprintf("%s %s", $this->bin, $args);

        chdir($this->tempWorkDir); // Set working dir to guarantee that kid3 runs from a parent directory relative to the audio file - kid3 tagging doesn't seem to work when run from sibling or child directory relative to audio file

        $lastLine = exec($cmd, $this->output, $this->returnCode);

        chdir($cwd); // restore working dir

        /*if ($this->returnCode > 0)
        {
            throw new RuntimeException(sprintf('Kid3 execution error: "%s". Cmd: "%s"', $lastLine, $cmd));
        }*/

        return $lastLine;
    }

    public function getReturnCode()
    {
        return $this->returnCode;
    }

    public function getOutput()
    {
        return $this->output;
    }

    public function __clone()
    {}
}

Fix kid3-cli issue (AIFF tagging not working on the server)


<?php

namespace LastFmApi\Exception;
/**
 * MissingArgumentException
 *
 * @author Marcos Peña
 */
class InvalidArgumentException extends LastFmApiExeption
{
}

<?php

namespace LastFmApi\Exception;
/**
 * MissingArgumentException
 *
 * @author Marcos Peña
 */
class InvalidArgumentException extends LastFmApiException
{
}

Fix missing « c » char on LastFmApiException.php


<?php

namespace PHPMD;

class Fingerprint
{
    const OVERRIDE_RULES = [
      "CyclomaticComplexity",
      "Design/LongClass",
      "Design/LongMethod",
      "Design/LongParameterList",
      "Design/NpathComplexity",
      "Design/NumberOfChildren",
      "Design/TooManyFields",
      "Design/TooManyMethods",
      "Design/TooManyPublicMethods",
      "Design/WeightedMethodCount",
      "ExcessivePublicCount",
    ];
    private $name;
    private $path;
    private $rule;

    public function __construct($path, $rule, $name)
    {
        $this->path = $path;
        $this->rule = $rule;
        $this->name = $name;
    }

    public function compute()
    {
        $fingerprint = null;

        if (in_array($this->rule, self::OVERRIDE_RULES)) {
            $fingerprint = md5($this->path . $this->rule . $this->name);
        }

        return $fingerprint;
    }
}

<?php

namespace PHPMD;

class Fingerprint
{
    const OVERRIDE_RULES = [
      "Controversial/CamelCaseVariableName",
      "Controversial/CamelCasePropertyName",
      "CyclomaticComplexity",
      "Design/LongClass",
      "Design/LongMethod",
      "Design/LongParameterList",
      "Design/NpathComplexity",
      "Design/NumberOfChildren",
      "Design/TooManyFields",
      "Design/TooManyMethods",
      "Design/TooManyPublicMethods",
      "Design/WeightedMethodCount",
      "ExcessivePublicCount",
      "Naming/ShortMethodName",
    ];
    private $name;
    private $path;
    private $rule;

    public function __construct($path, $rule, $name)
    {
        $this->path = $path;
        $this->rule = $rule;
        $this->name = $name;
    }

    public function compute()
    {
        $fingerprint = null;

        if (in_array($this->rule, self::OVERRIDE_RULES)) {
            $fingerprint = md5($this->path . $this->rule . $this->name);
        }

        return $fingerprint;
    }
}

Use stricter fingerprints for some rules

We received a report that this engine produces a number of fixed/new
issues on pull request comparisons. I looked at an example PR:

https://codeclimate.com/github/yiisoft/yii2/pull/13113

And saw that the issues showing up as fixed/new are these three.

The location reported by the underlying tool, phpmd, is fairly broad.
So, for example, the `Naming/ShortMethodName` rule checks that your
method names aren't too short, and reports the location as being from
the beginning of the method to the end of the method. This means, with
our default fingerprinting algorithm, that if you change the method _at
all_, we'll generate a new fingerprint for the issue, and it will show
up as fixed/new.

Some phpmd rules don't include a "name", but I confirmed that these
three do.


<?php

namespace Tests\Functional\Configuration;

use Paraunit\Configuration\PHPDbgBinFile;
use Tests\BaseFunctionalTestCase;

/**
 * Class PHPDbgBinFileTest
 * @package Tests\Functional\Configuration
 */
class PHPDbgBinFileTest extends BaseFunctionalTestCase
{
    public function testGetPhpDbgBin()
    {
        $bin = new PHPDbgBinFile();

        $this->assertStringEndsWith('phpdbg', $bin->getPhpDbgBin());
        $this->assertNotContains(' ', $bin->getPhpDbgBin());
        $this->assertNotContains("\n", $bin->getPhpDbgBin());
    }
}

<?php

namespace Tests\Functional\Configuration;

use Paraunit\Configuration\PHPDbgBinFile;
use Tests\BaseFunctionalTestCase;

/**
 * Class PHPDbgBinFileTest
 * @package Tests\Functional\Configuration
 */
class PHPDbgBinFileTest extends BaseFunctionalTestCase
{
    public function testIsAvailable()
    {
        $bin = new PHPDbgBinFile();

        $this->assertSame($this->shouldPHPDbgDriverBeAvailable(), $bin->isAvailable());
    }

    public function testGetPhpDbgBin()
    {
        if (! $this->shouldPHPDbgDriverBeAvailable()) {
            $this->markTestSkipped('PHPDbg coverage driver not available for PHP < 7.0');
        }

        $bin = new PHPDbgBinFile();

        $this->assertStringEndsWith('phpdbg', $bin->getPhpDbgBin());
        $this->assertNotContains(' ', $bin->getPhpDbgBin());
        $this->assertNotContains("\n", $bin->getPhpDbgBin());
    }

    private function shouldPHPDbgDriverBeAvailable()
    {
        return version_compare('7', PHP_VERSION, '<');
    }
}

Test for PHPDbg only on PHP >= 7

Test for PHPDbg only on PHP >= 7


<?php

/*
 * This file is part of the Sylius package.
 *
 * (c) Paweł Jędrzejewski
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sylius\Component\Addressing\Model;

/**
 * @author Łukasz Chruściel <lukasz.chrusciel@lakion.com>
 */
final class Scope
{
    const SHIPPING = 'shipping';
    const TAX = 'tax';
    const ALL = 'all';

    private function __construct()
    {
    }
}

<?php

/*
 * This file is part of the Sylius package.
 *
 * (c) Paweł Jędrzejewski
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sylius\Component\Addressing\Model;

/**
 * @author Łukasz Chruściel <lukasz.chrusciel@lakion.com>
 */
final class Scope
{
    const ALL = 'all';

    private function __construct()
    {
    }
}

Split scope to core and addressing

[Addressing] Split scope to core and addressing


<?php
    include('head.php');
?>

<?php
    include('../stockstable.php');
?>

<link href="lsv.css" rel="stylesheet" type="text/css" />

<?php
    $scripts = array('../tableupdate.js', 'changestoupdatetable.js', '../stockupdate.js');
    include('foot.php');
?>

<?php
    include('head.php');
?>

<?php
    include('../stockstable.php');
?>

<link href="lsv.css" rel="stylesheet" type="text/css" />

<?php
    $scripts = array('../common.js', '../tableupdate.js', 'changestoupdatetable.js', '../stockupdate.js');
    include('foot.php');
?>

Fix cannot find updateTime function in JS error


<?php
// RadioPanel - Generic Functions
// (C) Matt Ribbins - matt@mattyribbo.co.uk

// API Calls
function api_call() {
	$task = mysql_real_escape_string($_GET['task']);
	switch($task) {
		case "html_live_stats":
			stream_getlivestats();
			break;
		default:

	}
}

?>

<?php
// RadioPanel - Generic Functions
// (C) Matt Ribbins - matt@mattyribbo.co.uk

// API Calls
function api_call() {
	$task = mysql_real_escape_string($_GET['task']);
	switch($task) {
		case "html_live_stats":
			stream_getlivestats();
			break;
		case "html_display_date":
			stats_search_display();
			break;
		default:

	}
}

?>

Add AJAX API for Week View

Add AJAX API for Week View


<?php namespace App\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 = [
        'App\Console\Commands\ConvertToSpeech',
		'App\Console\Commands\PocketSynchronise',
		'App\Console\Commands\UploadLocalFile',
	];

	/**
	 * Define the application's command schedule.
	 *
	 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
	 * @return void
	 */
	protected function schedule(Schedule $schedule)
	{
        $schedule->command('pocket:synchronise')->hourly();
		$schedule->command('articles:convert')->cron('15 * * * * *');
        $schedule->command('articles:upload')->cron('30 * * * * *');
	}

}

<?php namespace App\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 = [
        'App\Console\Commands\ConvertToSpeech',
		'App\Console\Commands\PocketSynchronise',
		'App\Console\Commands\UploadLocalFile',
	];

	/**
	 * Define the application's command schedule.
	 *
	 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
	 * @return void
	 */
	protected function schedule(Schedule $schedule)
	{
        $schedule->command('pocket:synchronise')->hourly();
		$schedule->command('articles:convert')->cron('*/15 * * * * *');
        $schedule->command('articles:upload')->cron('*/15 * * * * *');
	}

}

Check for articles to convert to speech and upload to amazon every 15 minutes.


<?php

namespace App\Models;

use App\Models\Base\BaseModel;

class Student extends BaseModel
{
    protected $table = 'students';

    /**
     * The accessors to append to the model's array form.
     *
     * @var array
     */
    protected $appends = ['program_satisfaction'];

    public function getProgramSatisfactionAttribute()
    {
        return $this->program_satisfaction_b1;
    }

    public function setProgramSatisfactionAttribute($value)
    {
        $this->attributes['program_satisfaction_b1'] = $value;
    }
}

<?php

namespace App\Models;

use App\Models\Base\BaseModel;

class Student extends BaseModel
{
    protected $table = 'students';

    /**
     * The accessors to append to the model's array form.
     *
     * @var array
     */
    protected $appends = ['program_satisfaction'];

    public function getProgramSatisfactionAttribute()
    {
        return $this->attributes['program_satisfaction_b' . Settings::first()->active_block];
    }

    public function setProgramSatisfactionAttribute($value)
    {
        $this->attributes['program_satisfaction_b' . Settings::first()->active_block] = $value;
    }
}

Update only active block satisfaction

Update only active block satisfaction


<?php
namespace RadDB;

use Illuminate\Database\Eloquent\Model;

class Recommendation extends Model
{
    /**
     * Attributes that are mass assignable
     *
     * @var array
     */
    protected $fillable = [
        'survey_id',
        'recommendation',
        'resolved',
        'rec_add_ts',
        'rec_resolve_ts',
        'resolved_by',
        'rec_status',
        'wo_number',
        'service_report_path'
    ];

    /**
     * Attributes that should be mutated to dates
     *
     * @var array
     */
    protected $dates = [
        'rec_add_ts',
        'rec_resolve_ts',
    ];

    /*
     * Relationships
     */
    public function survey()
    {
        return $this->belongsTo('RadDB\TestDate');
    }

    /*
     * Scopes
     */

    /**
     * Scope function to return unresolved recommendations (resolved=0)
     *
     * @param \Illuminate\Database\Eloquent\Builder $query
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeUnresolved($query)
    {
        return $query->where('resolved', 0);
    }
}

<?php
namespace RadDB;

use Illuminate\Database\Eloquent\Model;

class Recommendation extends Model
{
    /**
     * Attributes that are mass assignable
     *
     * @var array
     */
    protected $fillable = [
        'survey_id',
        'recommendation',
        'resolved',
        'rec_add_ts',
        'rec_resolve_ts',
        'resolved_by',
        'rec_status',
        'wo_number',
        'service_report_path'
    ];

    /**
     * Attributes that should be mutated to dates
     *
     * @var array
     */
    protected $dates = [
        'rec_add_ts',
        'rec_resolve_ts',
        'deleted_at',
        'created_at',
        'updated_at',
    ];

    /*
     * Relationships
     */
    public function survey()
    {
        return $this->belongsTo('RadDB\TestDate');
    }

    /*
     * Scopes
     */

    /**
     * Scope function to return unresolved recommendations (resolved=0)
     *
     * @param \Illuminate\Database\Eloquent\Builder $query
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeUnresolved($query)
    {
        return $query->where('resolved', 0);
    }

    /**
     * Scope function to return unresolved recommendations (resolved=1)
     *
     * @param \Illuminate\Database\Eloquent\Builder $query
     * @return \Illuminate\Database\Eloquent\Builder
     */
     public function scopeResolved($query)
     {
         return $query->where('resolved', 1);
     }

     /**
      * Scope function to return recommendations for a given $surveyID
      *
      * @param \Illuminate\Database\Eloquent\Builder $query
      * @param int $surveyID
      * @return \Illuminate\Database\Eloquent\Builder
      */
      public function scopeSurveyId($query, $surveyID)
      {
          return $query->where('survey_id', $surveyID)
      }

}

Add some more query scope functions

Add some more query scope functions


<?php
/**
 * Created by PhpStorm.
 * User: sonja
 * Date: 1/26/18
 * Time: 10:30 AM
 */

namespace AppBundle\API\Sharing;

class Projects
{

}

<?php
/**
 * Created by PhpStorm.
 * User: sonja
 * Date: 1/26/18
 * Time: 10:30 AM
 */

namespace AppBundle\API\Sharing;

use AppBundle\Service\DBVersion;

class Projects
{
    private $manager;

    /**
     * Projects constructor.
     * @param $dbversion
     */
    public function __construct(DBVersion $dbversion)
    {
        $this->manager = $dbversion->getEntityManager();
    }

}

Add first property and constructor

Add first property and constructor


<?php

// Routing configuration. You should have the `$app` variable set to be
// an instance of Silex Application.

use Silex\Application;

if (!isset($app)) {
    throw new \LogicException('The `$app` varialbe is not set.');
}

if (!$app instanceof Application) {
    throw new \LogicException(sprintf('Expected $app to be an instance of Silex\\Application, got %s instead.', is_object($app) ? get_class($app) : gettype($app)));
}

$app->get('/status', 'KnpU\\ActivityRunner\\Controller\\ActivityController::statusAction');
$app->post('/check', 'KnpU\\ActivityRunner\\Controller\\ActivityController::checkAction');

$app->get('/author', 'KnpU\\ActivityRunner\\Controller\\AuthorController::enterFilenameAction');
$app->get(
    '/author/activity',
    'KnpU\\ActivityRunner\\Controller\\AuthorController::renderActivityAction'
)->bind('render_activity');
$app->post(
    '/author/activity',
    'KnpU\\ActivityRunner\\Controller\\AuthorController::gradeAction'
)->bind('grade_activity');

<?php

// Routing configuration. You should have the `$app` variable set to be
// an instance of Silex Application.

use Silex\Application;

if (!isset($app)) {
    throw new \LogicException('The `$app` varialbe is not set.');
}

if (!$app instanceof Application) {
    throw new \LogicException(sprintf('Expected $app to be an instance of Silex\\Application, got %s instead.', is_object($app) ? get_class($app) : gettype($app)));
}

$app->get('/', function () use ($app) {
    $url = $app['url_generator']->generate('enter_filename');

    return $app->redirect($url);
})->bind('homepage');
$app->get('/status', 'KnpU\\ActivityRunner\\Controller\\ActivityController::statusAction');
$app->post('/check', 'KnpU\\ActivityRunner\\Controller\\ActivityController::checkAction');

$app->get(
    '/author',
    'KnpU\\ActivityRunner\\Controller\\AuthorController::enterFilenameAction'
)->bind('enter_filename');
$app->get(
    '/author/activity',
    'KnpU\\ActivityRunner\\Controller\\AuthorController::renderActivityAction'
)->bind('render_activity');
$app->post(
    '/author/activity',
    'KnpU\\ActivityRunner\\Controller\\AuthorController::gradeAction'
)->bind('grade_activity');

Add homepage route with redirecting to filename enter page