<?php declare(strict_types=1);

namespace ApiClients\Foundation\Middleware;

trait DefaultPriorityTrait
{
    /**
     * @return int
     */
    public function priority(): int
    {
        return 500;
    }
}

<?php declare(strict_types=1);

namespace ApiClients\Foundation\Middleware;

trait DefaultPriorityTrait
{
    /**
     * @return int
     */
    public function priority(): int
    {
        return Priority::DEFAULT;
    }
}

Use priority enum default for default trait


<?php
/**
 * @package   CherryTea.org
 * @category  themes
 * @author    Nazar Mokrynskyi <nazar@mokrynskyi.com>
 * @copyright Copyright (c) 2015, Nazar Mokrynskyi
 * @license   MIT License, see license.txt
 */
namespace cs;
$Page = Page::instance();
/**
 * @var _SERVER $_SERVER
 */
if (preg_match('/msie|trident/i', $_SERVER->user_agent)) {
	$Page->Head .= '<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">';
}
$Page->level['Content'] = home_page() ? 1 : 3;

<?php
/**
 * @package   CherryTea.org
 * @category  themes
 * @author    Nazar Mokrynskyi <nazar@mokrynskyi.com>
 * @copyright Copyright (c) 2015, Nazar Mokrynskyi
 * @license   MIT License, see license.txt
 */
namespace cs;
$Page = Page::instance();
/**
 * @var _SERVER $_SERVER
 */
if (preg_match('/msie|trident/i', $_SERVER->user_agent)) {
	$Page->Head .= '<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">';
}
$Page->Head .= '<meta name="viewport" content="width=1200">';
$Page->level['Content'] = home_page() ? 1 : 3;

Set viewport width for mobile devices

Set viewport width for mobile devices


<?php namespace Illuminate\Session;

use Illuminate\Cookie\CookieJar;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class ArrayStore extends CacheDrivenStore {

	/**
	 * Load the session for the request.
	 *
	 * @param  Illuminate\CookieJar  $cookies
	 * @param  string  $name
	 * @return void
	 */
	public function start(CookieJar $cookies, $name)
	{
		$this->session = $this->createFreshSession();
	}

	/**
	 * Finish the session handling for the request.
	 *
	 * @param  Symfony\Component\HttpFoundation\Response  $response
	 * @param  int  $lifetime
	 * @return void
	 */
	public function finish(Response $response, $lifetime)
	{
		// No storage on array sessions...
	}

	/**
	 * Write the session cookie to the response.
	 *
	 * @param  Illuminate\Cookie\CookieJar  $cookie
	 * @param  string  $name
	 * @param  int  $lifetime
	 * @return void
	 */
	public function getCookie(CookieJar $cookie, $name, $lifetime)
	{
		//
	}

}

<?php namespace Illuminate\Session;

use Illuminate\Cookie\CookieJar;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class ArrayStore extends CacheDrivenStore {

	/**
	 * Load the session for the request.
	 *
	 * @param  Illuminate\CookieJar  $cookies
	 * @param  string  $name
	 * @return void
	 */
	public function start(CookieJar $cookies, $name)
	{
		$this->session = $this->createFreshSession();
	}

	/**
	 * Finish the session handling for the request.
	 *
	 * @param  Symfony\Component\HttpFoundation\Response  $response
	 * @param  int  $lifetime
	 * @return void
	 */
	public function finish(Response $response, $lifetime)
	{
		// No storage on array sessions...
	}

	/**
	 * Write the session cookie to the response.
	 *
	 * @param  Illuminate\Cookie\CookieJar  $cookie
	 * @param  string  $name
	 * @param  int     $lifetime
	 * @param  string  $path
	 * @param  string  $domain
	 * @return void
	 */
	public function getCookie(CookieJar $cookie, $name, $lifetime, $path, $domain)
	{
		//
	}

}

Update array store to match.

Update array store to match.


<?php

namespace Stopka\OpenviduPhpClient\Recording;

use Stopka\OpenviduPhpClient\Enum;

class RecordingStatusEnum
{
    use Enum;

    const STARTING = "starting";
    const STARTED = "started";
    const STOPPED = "stopped";
    const AVAILABLE = "available";
    const FAILED = "failed";

    public function getValues(): array
    {
        return [
            self::STARTING,
            self::STARTED,
            self::STOPPED,
            self::AVAILABLE,
            self::FAILED
        ];
    }

}

<?php

namespace Stopka\OpenviduPhpClient\Recording;

use Stopka\OpenviduPhpClient\Enum;

class RecordingStatusEnum
{
    use Enum;

    const STARTING = "starting";
    const STARTED = "started";
    const STOPPED = "stopped";
    const READY = "ready";
    const FAILED = "failed";

    public function getValues(): array
    {
        return [
            self::STARTING,
            self::STARTED,
            self::STOPPED,
            self::READY,
            self::FAILED
        ];
    }

}

Fix Recording Status Possible Values

Fix Recording Status Possible Values

Updated "available" to "ready”.
See: https://github.com/OpenVidu/openvidu.io-docs/commit/b5be7c44f0161ca1569d5885c2fb0ded8d753fa9#diff-ffde0d3dc24a2bdec96cffaa3c0c261a


<?php
namespace Criterion\Helper;

class Notifications
{
    public static function failedEmail($test, $project)
    {
        $config = json_decode(file_get_contents(CONFIG_FILE), true);
        if (isset($project['email']) && $project['email'] && isset($config['email']))
        {
            $subject = '['.$project['repo'].'] Tests Failed (' . $test . ')';
            $message = "This is a short email to let you know that the following project's tests are failing: \n\n";
            $message .= $config['url'] . '/test/' . $test . "\n\n";
            $message .= 'Thanks';

            return self::email($project['email'], $config['email'], $subject, $message);
        }
        return false;
    }

    private static function email($to, $from, $subject, $message)
    {
        return mail($to, $subject, $message);
    }
}

<?php
namespace Criterion\Helper;

class Notifications
{
    public static function failedEmail($test, $project)
    {
        $config = json_decode(file_get_contents(CONFIG_FILE), true);
        if (isset($project['email']) && $project['email'] && isset($config['email']))
        {
            $subject = '['.$project['repo'].'] Tests Failed (' . $test . ')';
            $message = "This is a short email to let you know that the following project's tests are failing: \n\n";
            $message .= $config['url'] . '/test/' . $test . "\n\n";
            $message .= 'Thanks';

            return self::email($project['email'], $config['email'], $subject, $message);
        }
        return false;
    }

    private static function email($to, $from, $subject, $message)
    {
        $headers = "From:" . $from;
        return mail($to, $subject, $message, $headers);
    }
}

Add from headers in mail

Add from headers in mail


<?php

namespace Alchemy\WorkerBundle\Commands;

use Alchemy\Queue\MessageQueueRegistry;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class ShowQueueConfigurationCommand extends Command
{
    /**
     * @var MessageQueueRegistry
     */
    private $queueRegistry;

    /**
     * @param MessageQueueRegistry $queueRegistry
     */
    public function __construct(MessageQueueRegistry $queueRegistry)
    {
        parent::__construct();

        $this->queueRegistry = $queueRegistry;
    }

    protected function configure()
    {
        $this->setName('workers:show-configuration');
    }

    public function execute(InputInterface $input, OutputInterface $output)
    {
        foreach ($this->queueRegistry->getConfigurations() as $configuration) {
            var_dump($configuration);
        }

        var_dump($this->queueRegistry->getQueue('worker-queue'));
    }
}

<?php

namespace Alchemy\WorkerBundle\Commands;

use Alchemy\Queue\MessageQueueRegistry;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Yaml;

class ShowQueueConfigurationCommand extends Command
{
    /**
     * @var MessageQueueRegistry
     */
    private $queueRegistry;

    /**
     * @param MessageQueueRegistry $queueRegistry
     */
    public function __construct(MessageQueueRegistry $queueRegistry)
    {
        parent::__construct();

        $this->queueRegistry = $queueRegistry;
    }

    protected function configure()
    {
        $this->setName('workers:show-configuration');
    }

    public function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln([ '', 'Configured queues: ' ]);

        foreach ($this->queueRegistry->getConfigurations() as $name => $configuration) {
            $output->writeln([ '  ' . $name . ': ' . Yaml::dump($configuration, 0), '' ]);
        }
    }
}

Improve show configuration command output


<?php

namespace Northstar\Http\Transformers;

use Northstar\Models\User;
use League\Fractal\TransformerAbstract;

class UserInfoTransformer extends TransformerAbstract
{
    /**
     * @param User $user
     * @return array
     */
    public function transform(User $user)
    {
        $response = [
            'id' => $user->_id,
            'given_name' => $user->first_name,
            'family_name' => $user->last_name,
            'email' => $user->email,
            'phone_number' => $user->mobile,

            'address' => [
                'street_address' => implode(PHP_EOL, [$user->addr_street1, $user->addr_street2]),
                'locality' => $user->addr_city,
                'region' => $user->addr_state,
                'postal_code' => $user->addr_zip,
                'country' => $user->country,
            ],

            'updated_at' => $user->updated_at->timestamp,
            'created_at' => $user->created_at->timestamp,
        ];

        return $response;
    }
}

<?php

namespace Northstar\Http\Transformers;

use Northstar\Models\User;
use League\Fractal\TransformerAbstract;

class UserInfoTransformer extends TransformerAbstract
{
    /**
     * @param User $user
     * @return array
     */
    public function transform(User $user)
    {
        // User data, formatted according to OpenID Connect spec, section 5.3.
        // @see http://openid.net/specs/openid-connect-core-1_0.html#UserInfo
        $response = [
            'id' => $user->_id,
            'given_name' => $user->first_name,
            'family_name' => $user->last_name,
            'email' => $user->email,
            'phone_number' => $user->mobile,

            'address' => [
                'street_address' => implode(PHP_EOL, [$user->addr_street1, $user->addr_street2]),
                'locality' => $user->addr_city,
                'region' => $user->addr_state,
                'postal_code' => $user->addr_zip,
                'country' => $user->country,
            ],

            'updated_at' => $user->updated_at->timestamp,
            'created_at' => $user->created_at->timestamp,
        ];

        return $response;
    }
}

Add a comment explaining the fields here.


<?php
/**
 * This file is part of PHP Mess Detector.
 *
 * Copyright (c) Manuel Pichler <mapi@phpmd.org>.
 * All rights reserved.
 *
 * Licensed under BSD License
 * For full copyright and license information, please see the LICENSE file.
 * Redistributions of files must retain the above copyright notice.
 *
 * @author Manuel Pichler <mapi@phpmd.org>
 * @copyright Manuel Pichler. All rights reserved.
 * @license https://opensource.org/licenses/bsd-license.php BSD License
 * @link http://phpmd.org/
 */

function testRuleAppliesMultipleTimesToFunctionWithExitExpression()
{
    if (true) {
        exit(0);
    } else {
        if (time() % 42 === 0) {
            exit(1);
        }
    }
    exit(2);
}

<?php
/**
 * This file is part of PHP Mess Detector.
 *
 * Copyright (c) Manuel Pichler <mapi@phpmd.org>.
 * All rights reserved.
 *
 * Licensed under BSD License
 * For full copyright and license information, please see the LICENSE file.
 * Redistributions of files must retain the above copyright notice.
 *
 * @author Manuel Pichler <mapi@phpmd.org>
 * @copyright Manuel Pichler. All rights reserved.
 * @license https://opensource.org/licenses/bsd-license.php BSD License
 * @link http://phpmd.org/
 */

function testRuleAppliesMultipleTimesToFunctionWithExitExpression()
{
    if (true) {
        exit(0);
    } elseif (time() % 42 === 0) {
        exit(1);
    }
    exit(2);
}

Use elseif instead of else + nested if

Use elseif instead of else + nested if

Co-authored-by: Kyle <a691fe45072ea6917fdb7509f2e859c5439778af@users.noreply.github.com>


<?php

namespace OpenConext\EngineBlockBridge\EventListener;

use EngineBlock_ApplicationSingleton;
use OpenConext\EngineBlockBundle\Localization\LocaleProvider;
use Zend_Translate_Adapter;

final class SetCortoTranslationsLocaleListener
{
    /**
     * @var LocaleProvider
     */
    private $localeProvider;

    /**
     * @var Zend_Translate_Adapter
     */
    private $translator;

    public function __construct(LocaleProvider $localeProvider)
    {
        $this->localeProvider = $localeProvider;
        $this->translator = EngineBlock_ApplicationSingleton::getInstance()->getTranslator()->getAdapter();
    }

    public function onKernelRequest()
    {
        $locale = $this->localeProvider->getLocale();

        $this->translator->setLocale($locale);
    }
}

<?php

namespace OpenConext\EngineBlockBridge\EventListener;

use EngineBlock_ApplicationSingleton;
use OpenConext\EngineBlockBundle\Localization\LocaleProvider;
use Zend_Translate_Adapter;

/**
 * This listener depends on the LocaleListener in the EngineBlockBundle, so the priority should be set so that it is
 * called after the LocaleListener.
 */
final class SetCortoTranslationsLocaleListener
{
    /**
     * @var LocaleProvider
     */
    private $localeProvider;

    /**
     * @var Zend_Translate_Adapter
     */
    private $translator;

    public function __construct(LocaleProvider $localeProvider)
    {
        $this->localeProvider = $localeProvider;
        $this->translator = EngineBlock_ApplicationSingleton::getInstance()->getTranslator()->getAdapter();
    }

    public function onKernelRequest()
    {
        $locale = $this->localeProvider->getLocale();

        $this->translator->setLocale($locale);
    }
}

Add class docblock explaining the dependency on the LocaleListener


<?php

namespace Overblog\GraphBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;

class GraphController extends Controller
{
    public function endpointAction(Request $request)
    {
        $req = $this->get('overblog_graph.request_parser')->parse($request);
        $res = $this->get('overblog_graph.request_executor')->execute($req, []);

        $response = new JsonResponse($res->toArray(), 200);
        $response->headers->set('Content-Type', 'application/json');

        return $response;
    }
}

<?php

namespace Overblog\GraphBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;

class GraphController extends Controller
{
    public function endpointAction(Request $request)
    {
        $req = $this->get('overblog_graph.request_parser')->parse($request);
        $res = $this->get('overblog_graph.request_executor')->execute($req, []);

        return new JsonResponse($res->toArray(), 200);
    }
}

Add CORS preflight request support

Add CORS preflight request support


@extends('layouts.master')

@section('content')

Selecione um paciente para realizar o atendimento

		@foreach ($atendimentos as $atendimento)

codigo }}">{{ $atendimento->paciente->nome }}

		@endforeach

@stop

Add ID to patients list so we can easily get hold of it from specs


<!doctype html>

		@include("layouts.head")

		@include("admin.navbar")

		@yield("content", '
Some idiot forgot to render a view properly.
')

		@include("admin.footer")

		@include("layouts.postscript")

		@yield("script", "")

<!doctype html>

		@include("layouts.head")

		@include("admin.navbar")

		@yield("content", '
Some idiot forgot to render a view properly.
')

		@include("admin.footer")

		@yield("script", "")

Isolate postscript in the admin panel (and stop calling the API)


<?php
/**
 * @author        "Michael Collette" <metrol@metrol.net>
 * @package       Metrol/DBConnect
 * @version       1.0
 * @copyright (c) 2016, Michael Collette
 */

namespace Metrol\DBConnect;

/**
 * Network settings used to tell specify where the database server is.
 *
 */
trait Network
{
    /**
     *
     */
    private string $hostName = '';

    /**
     *
     */
    private int $port;

    /**
     *
     */
    public function setHost(string $hostName): static
    {
        $this->hostName = $hostName;

        return $this;
    }

    /**
     *
     */
    public function getHost(): string
    {
        return $this->hostName;
    }

    /**
     *
     */
    public function setPort(int $port): static
    {
        $this->port = $port;

        return $this;
    }

    /**
     *
     */
    public function getPort(): int
    {
        return $this->port;
    }
}

<?php
/**
 * @author        "Michael Collette" <metrol@metrol.net>
 * @package       Metrol/DBConnect
 * @version       1.0
 * @copyright (c) 2016, Michael Collette
 */

namespace Metrol\DBConnect;

/**
 * Network settings used to tell specify where the database server is.
 *
 */
trait Network
{
    /**
     *
     */
    private string $hostName = '';

    /**
     *
     */
    private int $port;

    private string $sslMode = '';
    private string $sslKey  = '';
    private string $sslCert = '';
    private string $sslRootCert = '';

    /**
     *
     */
    public function setHost(string $hostName): static
    {
        $this->hostName = $hostName;

        return $this;
    }

    /**
     *
     */
    public function getHost(): string
    {
        return $this->hostName;
    }

    /**
     *
     */
    public function setPort(int $port): static
    {
        $this->port = $port;

        return $this;
    }

    /**
     *
     */
    public function setSslMode(string $sslMode): static
    {
        $this->sslMode = $sslMode;

        return $this;
    }

    /**
     */
    public function setSslKey(string $sslKey): static
    {
        $this->sslKey = $sslKey;

        return $this;
    }

    /**
     */
    public function setSslCert(string $sslCert): static
    {
        $this->sslCert = $sslCert;

        return $this;
    }

    /**
     */
    public function setSslRootCert(string $sslRootCert): static
    {
        $this->sslRootCert = $sslRootCert;

        return $this;
    }
}

Add SSL information to the network connection


<?php

namespace Tests\Becklyn\AssetsBundle\Twig;

use Becklyn\AssetsBundle\Html\AssetHtmlGenerator;
use Becklyn\AssetsBundle\Twig\AssetsTwigExtension;
use PHPUnit\Framework\TestCase;

class AssetsTwigExtensionTest extends TestCase
{
    /**
     * Assert that the exposed twig functions don't change
     */
    public function testMethodNames ()
    {
        $htmlReferences = self::getMockBuilder(AssetHtmlGenerator::class)
            ->disableOriginalConstructor()
            ->getMock();

        $extension = new AssetsTwigExtension($htmlReferences);
        $functions = \array_map(
            function (\Twig_Function $f)
            {
                return $f->getName();
            },
            $extension->getFunctions()
        );

        self::assertContains("cssAssets", $functions);
        self::assertContains("jsAssets", $functions);
    }

}

<?php

namespace Tests\Becklyn\AssetsBundle\Twig;

use Becklyn\AssetsBundle\Html\AssetHtmlGenerator;
use Becklyn\AssetsBundle\Twig\AssetsTwigExtension;
use PHPUnit\Framework\TestCase;

class AssetsTwigExtensionTest extends TestCase
{
    /**
     * Assert that the exposed twig functions don't change
     */
    public function testMethodNames ()
    {
        $htmlReferences = self::getMockBuilder(AssetHtmlGenerator::class)
            ->disableOriginalConstructor()
            ->getMock();

        $extension = new AssetsTwigExtension($htmlReferences);
        $functions = \array_map(
            function (\Twig_Function $f)
            {
                return $f->getName();
            },
            $extension->getFunctions()
        );

        self::assertContains("cssAssets", $functions);
        self::assertContains("jsAssets", $functions);
        self::assertContains("assetPath", $functions);
    }

}

Add new function to twig extension tests


    <?php

    echo form_open();
    $aFieldSets = [];

    foreach ($CONFIG['FIELDS'] as $oField) {

        if (in_array($oField->key, $CONFIG['EDIT_IGNORE_FIELDS'])) {
            continue;
        }

        $sFieldSet = getFromArray('fieldset', (array) $oField, 'Basic Details');

        if (!array_key_exists($sFieldSet, $aFieldSets)) {
            $aFieldSets[$sFieldSet] = [];
        }

        $aFieldSets[$sFieldSet][] = $oField;
    }

    foreach ($aFieldSets as $sLegend => $aFields) {

        ?>
        <fieldset>
            <legend><?=$sLegend?></legend>
            <?php

            foreach ($aFields as $oField) {

                $aField            = (array) $oField;
                $aField['default'] = property_exists($item, $oField->key) ? $item->{$oField->key} : null;

                if (!array_key_exists('required', $aFieldSets)) {
                    $aField['required'] = in_array('required', $oField->validation);
                }

                if (is_callable('form_field_' . $aField['type'])) {
                    echo call_user_func('form_field_' . $aField['type'], $aField);
                } else {
                    echo form_field($aField);
                }
            }

            ?>
        </fieldset>
        <?php
    }

    ?>

        <button type="submit" class="btn btn-primary">
            Save Changes
        </button>

    <?=form_close()?>

    <?php

    echo form_open();
    $aFieldSets = [];

    foreach ($CONFIG['FIELDS'] as $oField) {

        if (in_array($oField->key, $CONFIG['EDIT_IGNORE_FIELDS'])) {
            continue;
        }

        $sFieldSet = getFromArray('fieldset', (array) $oField, 'Basic Details');

        if (!array_key_exists($sFieldSet, $aFieldSets)) {
            $aFieldSets[$sFieldSet] = [];
        }

        $aFieldSets[$sFieldSet][] = $oField;
    }

    foreach ($aFieldSets as $sLegend => $aFields) {

        ?>
        <fieldset>
            <legend><?=$sLegend?></legend>
            <?php

            foreach ($aFields as $oField) {

                $aField            = (array) $oField;
                $aField['default'] = !empty($item) && property_exists($item, $oField->key) ? $item->{$oField->key} : '';

                if (!array_key_exists('required', $aFieldSets)) {
                    $aField['required'] = in_array('required', $oField->validation);
                }

                if (is_callable('form_field_' . $aField['type'])) {
                    echo call_user_func('form_field_' . $aField['type'], $aField);
                } else {
                    echo form_field($aField);
                }
            }

            ?>
        </fieldset>
        <?php
    }

    ?>

        <button type="submit" class="btn btn-primary">
            Save Changes
        </button>

    <?=form_close()?>

Fix for defaultcontroller when creating new item


<?php

namespace React\Tests\Http;

use Evenement\EventEmitter;
use React\Socket\ServerInterface;

class SocketServerStub extends EventEmitter implements ServerInterface
{
     public function getAddress()
     {
         return '127.0.0.1:8080';
     }

     public function close()
     {
         // NO-OP
     }
}

<?php

namespace React\Tests\Http;

use Evenement\EventEmitter;
use React\Socket\ServerInterface;

class SocketServerStub extends EventEmitter implements ServerInterface
{
     public function getAddress()
     {
         return '127.0.0.1:8080';
     }

     public function close()
     {
         // NO-OP
     }

     public function pause()
     {
         // NO-OP
     }

     public function resume()
     {
         // NO-OP
     }
}

Fix tests to support new Socket v0.6 and up


<?php

namespace OzdemirBurak\Iris\Traits;

trait AlphaTrait
{
    /**
     * @var double
     */
    protected $alpha;

    /**
     * @param null $alpha
     *
     * @return $this|float
     */
    public function alpha($alpha = null)
    {
        if ($alpha !== null) {
            $this->alpha = $alpha <= 1 ? $alpha : 1;
            return $this;
        }
        return $this->alpha;
    }

    /**
     * @return string
     */
    protected function validationRules()
    {
        return '/^(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d\.\d{1,})$/';
    }

    /**
     * @param $color
     *
     * @return string
     */
    protected function fixPrecision($color)
    {
        if (strpos($color, ',') !== false) {
            $parts = explode(',', $color);
            $parts[3] = strpos($parts[3], '.') === false ? $parts[3] . '.0' : $parts[3];
            $color = implode(',', $parts);
        }
        return $color;
    }

    /**
     * @param string $alpha
     * @return float
     */
    protected function alphaHexToFloat(string $alpha): float
    {
        return sprintf('%0.2f', hexdec($alpha) / 255);
    }

    /**
     * @param float $alpha
     * @return string
     */
    protected function alphaFloatToHex(float $alpha): string
    {
        return dechex($alpha * 255);
    }
}

<?php

namespace OzdemirBurak\Iris\Traits;

trait AlphaTrait
{
    /**
     * @var double
     */
    protected $alpha;

    /**
     * @param null $alpha
     *
     * @return $this|float
     */
    public function alpha($alpha = null)
    {
        if ($alpha !== null) {
            $this->alpha = $alpha <= 1 ? $alpha : 1;
            return $this;
        }
        return $this->alpha;
    }

    /**
     * @return string
     */
    protected function validationRules()
    {
        return '/^(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d\.\d{1,})$/';
    }

    /**
     * @param $color
     *
     * @return string
     */
    protected function fixPrecision($color)
    {
        if (strpos($color, ',') !== false) {
            $parts = explode(',', $color);
            $parts[3] = strpos($parts[3], '.') === false ? $parts[3] . '.0' : $parts[3];
            $color = implode(',', $parts);
        }
        return $color;
    }

    /**
     * @param string $alpha
     * @return float
     */
    protected function alphaHexToFloat(string $alpha): float
    {
        return sprintf('%0.2F', hexdec($alpha) / 255);
    }

    /**
     * @param float $alpha
     * @return string
     */
    protected function alphaFloatToHex(float $alpha): string
    {
        return dechex($alpha * 255);
    }
}

Use a non-locale aware output

Use a non-locale aware output

Otherwise, the alpha value will not be handled correctly i.e. in a German locale (this locale uses a comma instead of a dot).


<?php

namespace Becklyn\AssetsBundle\File\Type;

use Becklyn\AssetsBundle\Asset\Asset;

class CssFile extends FileType
{
    use GenericFileHeaderTrait;

    /**
     * @inheritDoc
     */
    public function prependFileHeader (Asset $asset, string $filePath, string $fileContent) : string
    {
        $header = $this->generateGenericFileHeader($asset, $filePath, '/*', '*/');
        return $header . $fileContent;
    }

    /**
     * @inheritDoc
     */
    public function importDeferred () : bool
    {
        return true;
    }
}

<?php

namespace Becklyn\AssetsBundle\File\Type;

use Becklyn\AssetsBundle\Asset\Asset;

class CssFile extends FileType
{
    use GenericFileHeaderTrait;

    /**
     * @inheritDoc
     */
    public function prependFileHeader (Asset $asset, string $filePath, string $fileContent) : string
    {
        $header = $this->generateGenericFileHeader($asset, $filePath, '/*', '*/');
        return $header . $fileContent;
    }

    /**
     * @inheritDoc
     */
    public function importDeferred () : bool
    {
        // must be loaded deferred, as it might have dependencies on other files
        return true;
    }
}

Add comment explaining the deferred loading


<?php

declare(strict_types=1);

namespace Ruwork\RuworkBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;

final class RuworkExtension extends ConfigurableExtension
{
    /**
     * {@inheritdoc}
     */
    public function loadInternal(array $config, ContainerBuilder $container)
    {
        $locator = new FileLocator(__DIR__.'/../Resources/config');
        $loader = new PhpFileLoader($container, $locator);
        $loader->load('services.php');
    }
}

<?php

declare(strict_types=1);

namespace Ruwork\RuworkBundle\DependencyInjection;

use Ruwork\RuworkBundle\Serializer\Encoder\ExcelCsvEncoder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\ConfigurableExtension;
use Symfony\Component\Serializer\Encoder\EncoderInterface;

final class RuworkExtension extends ConfigurableExtension
{
    /**
     * {@inheritdoc}
     */
    public function loadInternal(array $config, ContainerBuilder $container)
    {
        $locator = new FileLocator(__DIR__.'/../Resources/config');
        $loader = new PhpFileLoader($container, $locator);
        $loader->load('services.php');

        if (!\interface_exists(EncoderInterface::class)) {
            $container->removeDefinition(ExcelCsvEncoder::class);
        }
    }
}

[RuworkBundle] Remove ExcelCsvEncoder when Serializer is not installed


<?php

namespace Qafoo\Analyzer\Handler;

use SebastianBergmann\FinderFacade\FinderFacade;

use Qafoo\Analyzer\Handler;
use Qafoo\Analyzer\Shell;

class Source extends Handler
{
    /**
     * Shell
     *
     * @var Shell
     */
    private $shell;

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

    /**
     * Handle provided directory
     *
     * Optionally an existing result file can be provided
     *
     * @param string $dir
     * @param array $excludes
     * @param string $file
     * @return void
     */
    public function handle($dir, array $excludes, $file = null)
    {
        $currentDir = getcwd();
        chdir($dir);

        if ($excludes) {
            $finder = new FinderFacade(array($dir), array(), $excludes);
            $excludes = array_map(
                function ($path) use ($dir) {
                    $path = substr($path, strlen($dir) + 1);
                    return is_file($path) ? $path : $path . '/*';
                },
                $finder->findFiles()
            );
            array_unshift($excludes, '-x');
        }

        $zipFile = __DIR__ . '/../../../../../data/source.zip';
        if (file_exists($zipFile)) {
            unlink($zipFile);
        }

        $this->shell->exec(
            'zip',
            array_merge(
                array('-r', $zipFile, './', '-i', '*.php'),
                $excludes
            )
        );

        chdir($currentDir);
    }
}

<?php

namespace Qafoo\Analyzer\Handler;

use SebastianBergmann\FinderFacade\FinderFacade;

use Qafoo\Analyzer\Handler;
use Qafoo\Analyzer\Shell;

class Source extends Handler
{
    /**
     * Shell
     *
     * @var Shell
     */
    private $shell;

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

    /**
     * Handle provided directory
     *
     * Optionally an existing result file can be provided
     *
     * @param string $dir
     * @param array $excludes
     * @param string $file
     * @return void
     */
    public function handle($dir, array $excludes, $file = null)
    {
        $zipFile = __DIR__ . '/../../../../../data/source.zip';
        $archive = new \ZipArchive();
        $archive->open($zipFile, \ZipArchive::OVERWRITE | \ZipArchive::CREATE);
        $finder = new FinderFacade(array($dir), $excludes, array('*.php'));
        foreach ($finder->findFiles() as $file) {
            $archive->addFile($file, ltrim(str_replace($dir, '', $file), '/'));
        }
        $archive->close();
    }
}

Use PHP zip extension to create zip archive

Fixes #8 & #6.


<?php

namespace Nord\ImageManipulationService\Exceptions;

use Exception;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpException;

class Handler extends ExceptionHandler
{
    /**
     * A list of the exception types that should not be reported.
     *
     * @var array
     */
    protected $dontReport = [
        AuthorizationException::class,
        HttpException::class,
        ModelNotFoundException::class,
        ValidationException::class,
    ];

    /**
     * Report or log an exception.
     *
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
     *
     * @param  \Exception  $e
     * @return void
     */
    public function report(Exception $e)
    {
        parent::report($e);
    }

    /**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $e
     * @return \Illuminate\Http\Response
     */
    public function render($request, Exception $e)
    {
        return parent::render($request, $e);
    }
}

<?php

namespace Nord\ImageManipulationService\Exceptions;

use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Validation\ValidationException;
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpException;

/**
 * Class Handler
 * @package Nord\ImageManipulationService\Exceptions
 */
class Handler extends ExceptionHandler
{

    /**
     * A list of the exception types that should not be reported.
     *
     * @var array
     */
    protected $dontReport = [
        AuthorizationException::class,
        HttpException::class,
        ModelNotFoundException::class,
        ValidationException::class,
    ];

}

Remove pointless overrides from the exception handler

We're not doing anything that the parent class doesn't do already


		<?php foreach ($_['navigationItems'] as $item) { ?>
		<li data-id="<?php p($item['id']) ?>" class="nav-<?php p($item['id']) ?>">
			<a href="<?php p(isset($item['href']) ? $item['href'] : '#') ?>"
				class="nav-icon-<?php p($item['id']) ?> svg">
				<?php p($item['name']);?>

		<?php } ?>

			<button class="settings-button" data-apps-slide-toggle="#app-settings-content">
				<?php p($l->t('Settings'));?>
			</button>

					<?php p($l->t('WebDAV'));?>

				<input id="webdavurl" type="text" readonly="readonly" value="<?php p(\OCP\Util::linkToRemote('webdav')); ?>" />
				<?php print_unescaped($l->t('Use this address to access your Files via WebDAV', array(link_to_docs('user-webdav'))));?>

		<?php foreach ($_['navigationItems'] as $item) { ?>
		<li data-id="<?php p($item['id']) ?>" class="nav-<?php p($item['id']) ?>">
			<a href="<?php p(isset($item['href']) ? $item['href'] : '#') ?>"
				class="nav-icon-<?php p($item['icon'] !== '' ? $item['icon'] : $item['id']) ?> svg">
				<?php p($item['name']);?>

		<?php } ?>

			<button class="settings-button" data-apps-slide-toggle="#app-settings-content">
				<?php p($l->t('Settings'));?>
			</button>

					<?php p($l->t('WebDAV'));?>

				<input id="webdavurl" type="text" readonly="readonly" value="<?php p(\OCP\Util::linkToRemote('webdav')); ?>" />
				<?php print_unescaped($l->t('Use this address to access your Files via WebDAV', array(link_to_docs('user-webdav'))));?>

Allow files app nav entries to have a different icon class


<?php

/*
 * This file is part of the Acme PHP project.
 *
 * (c) Titouan Galopin <galopintitouan@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace AcmePhp\Ssl;

use Webmozart\Assert\Assert;

/**
 * Represent a SSL key.
 *
 * @author Jérémy Derussé <jeremy@derusse.com>
 */
abstract class Key
{
    /** @var string */
    protected $keyPEM;

    public function __construct(string $keyPEM)
    {
        Assert::stringNotEmpty($keyPEM, __CLASS__.'::$keyPEM should not be an empty string. Got %s');

        $this->keyPEM = $keyPEM;
    }

    public function getPEM(): string
    {
        return $this->keyPEM;
    }

    public function getDER(): string
    {
        $lines = explode("\n", trim($this->keyPEM));
        unset($lines[\count($lines) - 1]);
        unset($lines[0]);
        $result = implode('', $lines);
        $result = base64_decode($result);

        return $result;
    }

    /**
     * @return resource
     */
    abstract public function getResource();
}

<?php

/*
 * This file is part of the Acme PHP project.
 *
 * (c) Titouan Galopin <galopintitouan@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace AcmePhp\Ssl;

use Webmozart\Assert\Assert;

/**
 * Represent a SSL key.
 *
 * @author Jérémy Derussé <jeremy@derusse.com>
 */
abstract class Key
{
    /** @var string */
    protected $keyPEM;

    public function __construct(string $keyPEM)
    {
        Assert::stringNotEmpty($keyPEM, __CLASS__.'::$keyPEM should not be an empty string. Got %s');

        $this->keyPEM = $keyPEM;
    }

    public function getPEM(): string
    {
        return $this->keyPEM;
    }

    public function getDER(): string
    {
        $lines = explode("\n", trim($this->keyPEM));
        unset($lines[\count($lines) - 1]);
        unset($lines[0]);
        $result = implode('', $lines);
        $result = base64_decode($result);

        return $result;
    }

    /**
     * @return resource|\OpenSSLAsymmetricKey
     */
    abstract public function getResource();
}

Fix tests on PHP 8.0/8.1

Fix tests on PHP 8.0/8.1


<?php

namespace Concise\Console;

use Concise\Console\TestRunner\DefaultTestRunner;
use Concise\Console\ResultPrinter\ResultPrinterProxy;
use Concise\Console\ResultPrinter\DefaultResultPrinter;
use Concise\Console\ResultPrinter\CIResultPrinter;

class Command extends \PHPUnit_TextUI_Command
{
    protected $ci = false;

    protected function createRunner()
    {
        $resultPrinter = $this->getResultPrinter();
        if (array_key_exists('verbose', $this->arguments) && $this->arguments['verbose']) {
            $resultPrinter->setVerbose(true);
        }
        $testRunner = new DefaultTestRunner();
        $testRunner->setPrinter(new ResultPrinterProxy($resultPrinter));

        return $testRunner;
    }

    public function getResultPrinter()
    {
        if ($this->ci) {
            return new CIResultPrinter();
        }

        return new DefaultResultPrinter();
    }

    /**
     * @codeCoverageIgnore
     */
    protected function handleArguments(array $argv)
    {
        $this->longOptions['test-colors'] = null;
        $this->longOptions['ci'] = null;
        parent::handleArguments($argv);

        foreach ($this->options[0] as $option) {
            switch ($option[0]) {
                case '--test-colors':
                    $testColors = new TestColors(new DefaultTheme());
                    echo $testColors->renderAll();
                    exit(0);
                    break;

                case '--ci':
                    $this->ci = true;
                    break;
            }
        }
    }
}

<?php

namespace Concise\Console;

use Concise\Console\TestRunner\DefaultTestRunner;
use Concise\Console\ResultPrinter\ResultPrinterProxy;
use Concise\Console\ResultPrinter\DefaultResultPrinter;
use Concise\Console\ResultPrinter\CIResultPrinter;

class Command extends \PHPUnit_TextUI_Command
{
    protected $ci = false;

    protected function createRunner()
    {
        $resultPrinter = $this->getResultPrinter();
        if (array_key_exists('verbose', $this->arguments) && $this->arguments['verbose']) {
            $resultPrinter->setVerbose(true);
        }
        $testRunner = new DefaultTestRunner();
        $testRunner->setPrinter(new ResultPrinterProxy($resultPrinter));

        return $testRunner;
    }

    public function getResultPrinter()
    {
        if ($this->ci || `tput colors` < 2) {
            return new CIResultPrinter();
        }

        return new DefaultResultPrinter();
    }

    /**
     * @codeCoverageIgnore
     */
    protected function handleArguments(array $argv)
    {
        $this->longOptions['test-colors'] = null;
        $this->longOptions['ci'] = null;
        parent::handleArguments($argv);

        foreach ($this->options[0] as $option) {
            switch ($option[0]) {
                case '--test-colors':
                    $testColors = new TestColors(new DefaultTheme());
                    echo $testColors->renderAll();
                    exit(0);
                    break;

                case '--ci':
                    $this->ci = true;
                    break;
            }
        }
    }
}

Use CI mode automatically if colours are not supported


<?php

namespace Brouzie\Sphinxy\Pagerfanta\Adapter;

use Brouzie\Sphinxy\Query\ResultSet;
use Brouzie\Sphinxy\QueryBuilder;
use Pagerfanta\Adapter\AdapterInterface;

/**
 * Sphinxy Pagerfanta Adapter
 *
 * @author Konstantin.Myakshin <koc-dp@yandex.ru>
 */
class SphinxyQbAdapter implements AdapterInterface
{
    /**
     * @var QueryBuilder
     */
    protected $qb;

    /**
     * @var ResultSet|null
     */
    protected $previousResultSet;

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

    /**
     * @inheritdoc
     */
    public function getNbResults()
    {
        if (null !== $this->previousResultSet) {
            return $this->previousResultSet->getAllowedCount();
        }

        $this->getSlice(0, 1);

        return $this->previousResultSet->getAllowedCount();
    }

    /**
     * @inheritdoc
     */
    public function getSlice($offset, $length)
    {
        $this->previousResultSet = $this
            ->qb
            ->setMaxResults($length)
            ->setFirstResult($offset)
            ->getResult();

        return $this->previousResultSet->getIterator();
    }

    /**
     * @return ResultSet|null
     */
    public function getPreviousResultSet()
    {
        return $this->previousResultSet;
    }
}

<?php

namespace Brouzie\Sphinxy\Pagerfanta\Adapter;

use Brouzie\Sphinxy\Query\ResultSet;
use Brouzie\Sphinxy\QueryBuilder;
use Pagerfanta\Adapter\AdapterInterface;

/**
 * Sphinxy Pagerfanta Adapter
 *
 * @author Konstantin.Myakshin <koc-dp@yandex.ru>
 */
class SphinxyQbAdapter implements AdapterInterface
{
    /**
     * @var QueryBuilder
     */
    protected $qb;

    /**
     * @var ResultSet|null
     */
    protected $previousResultSet;

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

    /**
     * @inheritdoc
     */
    public function getNbResults()
    {
        if (null !== $this->previousResultSet) {
            return $this->previousResultSet->getAllowedCount();
        }

        return $this->qb
            ->setMaxResults(1)
            ->setFirstResult(0)
            ->getResult()
            ->getAllowedCount();
    }

    /**
     * @inheritdoc
     */
    public function getSlice($offset, $length)
    {
        $this->previousResultSet = $this->qb
            ->setMaxResults($length)
            ->setFirstResult($offset)
            ->getResult();

        return $this->previousResultSet->getIterator();
    }

    /**
     * @return ResultSet|null
     */
    public function getPreviousResultSet()
    {
        return $this->previousResultSet;
    }
}

Fix Pagerfanta adapter result caching

Fix Pagerfanta adapter result caching


<?php
/**
 * Gets a list of cgGroup objects.
 */
class cgGoogleFontListGetListProcessor extends modObjectGetListProcessor {
    public $languageTopics = array('clientconfig:default');

    /**
     * {@inheritDoc}
     * @return mixed
     */
    public function process() {
        $apiKey = $this->modx->getOption('clientconfig.google_fonts_api_key', null, '');
        if (empty($apiKey)) {
            return $this->outputArray(array(), 0);
        }
        $apiEndpoint = "https://www.googleapis.com/webfonts/v1/webfonts?key={$apiKey}&sort=alpha";
        $fonts = array();
        $json = $this->modx->fromJson($this->curlGet($apiEndpoint));
        $fonts = $json['items'];
        $total = count($fonts);
        $list = array();

        foreach ($fonts as $font) {
            $item = array();
            $item['family'] = $font['family'];
            $item['name'] = str_replace(' ','+',$font['family']);
            $list[] = $item;
        }

        return $this->outputArray($list,$total);
    }

    protected function curlGet($url) {
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $results = curl_exec($curl);
        curl_close($curl);

        return $results;
    }
}
return 'cgGoogleFontListGetListProcessor';

<?php
/**
 * Gets a list of cgGroup objects.
 */
class cgGoogleFontListGetListProcessor extends modObjectGetListProcessor {
    public $languageTopics = array('clientconfig:default');

    /**
     * {@inheritDoc}
     * @return mixed
     */
    public function process() {
        $apiKey = $this->modx->getOption('clientconfig.google_fonts_api_key', null, '');
        if (empty($apiKey)) {
            return $this->outputArray(array(), 0);
        }
        $apiEndpoint = "https://www.googleapis.com/webfonts/v1/webfonts?key={$apiKey}&sort=alpha";
        $fonts = array();
        $json = $this->modx->fromJson($this->curlGet($apiEndpoint));
        $fonts = $json['items'];
        $total = count($fonts);
        $list = array();

        foreach ($fonts as $font) {
            $item = array();
            $item['family'] = str_replace(' ','+',$font['family']);
            $item['name'] = $font['family'];
            $list[] = $item;
        }

        return $this->outputArray($list,$total);
    }

    protected function curlGet($url) {
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $results = curl_exec($curl);
        curl_close($curl);

        return $results;
    }
}
return 'cgGoogleFontListGetListProcessor';

Fix name/value pairing for Google Font List


<?php

namespace Bolt\Nut;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Nut command to repair/update database schema
 */
class DatabaseRepair extends BaseCommand
{
    /**
     * @see \Symfony\Component\Console\Command\Command::configure()
     */
    protected function configure()
    {
        $this
            ->setName('database:update')
            ->setDescription('Repair and/or update the database.');
    }

    /**
     * @see \Symfony\Component\Console\Command\Command::execute()
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $result = $this->app['integritychecker']->repairTables();

        if (empty($result)) {
            $content = "<info>Your database is already up to date.</info>";
        } else {
            $content = "<info>Modifications made to the database:</info>\n";
            foreach ($result as $line) {
                $content .= ' - ' . str_replace('tt>', 'info>', $line) . "\n";
            }
            $content .= "<info>Your database is now up to date.</info>";

            $this->auditLog(__CLASS__, 'Database updated');
        }

        $output->writeln($content);
    }
}

<?php

namespace Bolt\Nut;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * Nut command to repair/update database schema
 */
class DatabaseRepair extends BaseCommand
{
    /**
     * @see \Symfony\Component\Console\Command\Command::configure()
     */
    protected function configure()
    {
        $this
            ->setName('database:update')
            ->setDescription('Repair and/or update the database.');
    }

    /**
     * @see \Symfony\Component\Console\Command\Command::execute()
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $messages = [];
        $responses = $this->app['integritychecker']->repairTables();

        foreach ($responses as $response) {
            if ($response->hasMessages()) {
                $messages[] = $response->getTitle() . ' ' . implode(', ', $response->getMessages());
            }
        }

        if (empty($messages)) {
            $content = "<info>Your database is already up to date.</info>";
        } else {
            $content = "<info>Modifications made to the database:</info>\n";
            foreach ($messages as $line) {
                $content .= ' - ' . str_replace('tt>', 'info>', $line) . "\n";
            }
            $content .= "<info>Your database is now up to date.</info>";

            $this->auditLog(__CLASS__, 'Database updated');
        }

        $output->writeln($content);
    }
}

Update the Nut call to checkTablesIntegrity()


<?php

class AddressTestCase extends TestCase
{
    public function testDataBaseAccess()
    {
        $address = new App\Models\Address();
        $results = $address->query()->where('zip', '001-0000')->get();

        self::assertTrue(count($results) === 1);
    }

}

<?php

class AddressTest extends TestCase
{
    public function testDataBaseAccess()
    {
        $address = new App\Models\Address();
        $results = $address->query()->where('zip', '001-0000')->get();

        self::assertTrue(count($results) === 1);
    }

}

Rename test class name to execute the test correctly.


<?php namespace App\Providers;

use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

class RouteServiceProvider extends ServiceProvider {

	/**
	 * All of the application's route middleware keys.
	 *
	 * @var array
	 */
	protected $middleware = [
		'auth' => 'App\Http\Middleware\Authenticate',
		'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
		'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
	];

	/**
	 * Called before routes are registered.
	 *
	 * Register any model bindings or pattern based filters.
	 *
	 * @param  \Illuminate\Routing\Router  $router
	 * @return void
	 */
	public function before(Router $router)
	{
		//
	}

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

}

<?php namespace App\Providers;

use Illuminate\Routing\Router;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

class RouteServiceProvider extends ServiceProvider {

	/**
	 * All of the application's route middleware keys.
	 *
	 * @var array
	 */
	protected $middleware = [
		'auth' => 'App\Http\Middleware\Authenticate',
		'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
		'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
	];

	/**
	 * Called before routes are registered.
	 *
	 * Register any model bindings or pattern based filters.
	 *
	 * @param  \Illuminate\Routing\Router  $router
	 * @param  \Illuminate\Contracts\Routing\UrlGenerator  $url
	 * @return void
	 */
	public function before(Router $router, UrlGenerator $url)
	{
		$url->setRootControllerNamespace('App\Http\Controllers');
	}

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

}

Set the root controller namespace.

Set the root controller namespace.


<?php

namespace TimetablePusher\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        //
    ];
}

<?php

namespace TimetablePusher\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        'api/*'
    ];
}

Exclude API routes from CSRF verification


<?php get_template_part('templates/head'); ?>
<body <?php body_class(); ?>>

  <?php
    do_action('get_header');
    // Use Bootstrap's navbar if enabled in config.php
    if (current_theme_supports('bootstrap-top-navbar')) {
      get_template_part('templates/header-top-navbar');
    } else {
      get_template_part('templates/header');
    }
  ?>

      <main class="main <?php echo roots_main_class(); ?>" role="main">
        <?php include roots_template_path(); ?>

      <?php if (roots_display_sidebar()) : ?>
        <aside class="sidebar <?php echo roots_sidebar_class(); ?>" role="complementary">
          <?php include roots_sidebar_path(); ?>

      <?php endif; ?>

  <?php get_template_part('templates/footer'); ?>

<?php get_template_part('templates/head'); ?>
<body <?php body_class(); ?>>

  <?php
    do_action('get_header');
    // Use Bootstrap's navbar if enabled in config.php
    if (current_theme_supports('bootstrap-top-navbar')) {
      get_template_part('templates/header-top-navbar');
    } else {
      get_template_part('templates/header');
    }
  ?>

      <?php if (roots_display_sidebar()) : ?>
        <aside class="sidebar <?php echo roots_sidebar_class(); ?>" role="complementary">
          <?php include roots_sidebar_path(); ?>

      <?php endif; ?>
      <main class="main <?php echo roots_main_class(); ?>" role="main">
        <?php include roots_template_path(); ?>

  <?php get_template_part('templates/footer'); ?>

Move sidebar to the left side

Move sidebar to the left side


<?php
/**
 * A driver interface
 */
interface Payment_Process2_Driver {

    /**
     * Class constructor
     *
     * Initializes the driver's default state
     */
    public function __construct($options = array(), HTTP_Request2 $request = null);

    /**
     * Translates an action into a localised string
     *
     * @param string $action One of the PAYMENT_PROCESS2_ACTION_* constants
     *
     * @return string|false Returns false when it cannot translate
     */
    public function translateAction($action);

    public function process();
    public function processCallback();
    public function getStatus();
}

<?php
/**
 * A driver interface
 */
interface Payment_Process2_Driver {

    /**
     * Class constructor
     *
     * Initializes the driver's default state
     */
    public function __construct($options = array(), HTTP_Request2 $request = null);

    /**
     * Translates an action into a localised string
     *
     * @param string $action One of the PAYMENT_PROCESS2_ACTION_* constants
     *
     * @return string|false Returns false when it cannot translate
     */
    public function translateAction($action);

    public function process();
    public function processCallback();
    public function getStatus();

    /**
     * Create a hash suitable for use with HTTP_Request2::addPostParameter();
     *
     * array('key' => 'value')
     *
     * @return mixed[]
     */
    public function prepareRequestData();
}

Add new common method for all drivers

Add new common method for all drivers

git-svn-id: 36b7be5e7fa0b144356cf0adbb4d8bae05b5299b@276407 c90b9560-bf6c-de11-be94-00142212c4b1


<?php
?>

Time

        <?= $element->time ?>

Result

        <?= $element->result ?>

Comment

        <?= $element->comment ?>

Change view to be horizontal for easier scanning.


<?php
namespace Neos\Flow\Http;

use Neos\Flow\Annotations as Flow;
use Neos\Flow\Core\Bootstrap;
use Psr\Http\Message\ServerRequestInterface;

/**
 * Central authority to get hold of the active HTTP request.
 * When no active HTTP request can be determined (for example in CLI context) an exception will be thrown
 *
 * Note: Naturally this class is not being used directly. But it is configured as factory for Psr\Http\Message\ServerRequestInterface instances
 *
 * @Flow\Scope("singleton")
 */
final class ActiveHttpRequestProvider
{
    /**
     * @Flow\Inject
     * @var Bootstrap
     */
    protected $bootstrap;

    /**
     * Returns the currently active HTTP request, if available.
     * If the HTTP request can't be determined (for example in CLI context) a \Neos\Flow\Http\Exception is thrown
     *
     * @return ServerRequestInterface
     * @throws Exception
     */
    public function getActiveHttpRequest(): ServerRequestInterface
    {
        $requestHandler = $this->bootstrap->getActiveRequestHandler();
        if (!$requestHandler instanceof HttpRequestHandlerInterface) {
            throw new Exception(sprintf('The active HTTP request can\'t be determined because the request handler is not an instance of %s but a %s. Use a ServerRequestFactory to create a HTTP requests in CLI context', HttpRequestHandlerInterface::class, get_class($requestHandler)), 1600869131);
        }
        return $requestHandler->getHttpRequest();
    }
}

<?php
namespace Neos\Flow\Http;

use Neos\Flow\Annotations as Flow;
use Neos\Flow\Core\Bootstrap;
use Psr\Http\Message\ServerRequestInterface;

/**
 * Central authority to get hold of the active HTTP request.
 * When no active HTTP request can be determined (for example in CLI context) an exception will be thrown
 *
 * Note: Usually this class is not being used directly. But it is configured as factory for Psr\Http\Message\ServerRequestInterface instances
 *
 * @Flow\Scope("singleton")
 */
final class ActiveHttpRequestProvider
{
    /**
     * @Flow\Inject
     * @var Bootstrap
     */
    protected $bootstrap;

    /**
     * Returns the currently active HTTP request, if available.
     * If the HTTP request can't be determined (for example in CLI context) a \Neos\Flow\Http\Exception is thrown
     *
     * @return ServerRequestInterface
     * @throws Exception
     */
    public function getActiveHttpRequest(): ServerRequestInterface
    {
        $requestHandler = $this->bootstrap->getActiveRequestHandler();
        if (!$requestHandler instanceof HttpRequestHandlerInterface) {
            throw new Exception(sprintf('The active HTTP request can\'t be determined because the request handler is not an instance of %s but a %s. Use a ServerRequestFactory to create a HTTP requests in CLI context', HttpRequestHandlerInterface::class, get_class($requestHandler)), 1600869131);
        }
        return $requestHandler->getHttpRequest();
    }
}

Tweak wording in doc comments

Tweak wording in doc comments


<?php

namespace Twilio;

class InstanceResource {
    protected $version;
    protected $context = null;

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

    public function __toString() {
        return '[InstanceResource]';
    }
}

<?php

namespace Twilio;

class InstanceResource {
    protected $version;
    protected $context = null;
    protected $properties = array();
    protected $solution = array();

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

    public function __toString() {
        return '[InstanceResource]';
    }
}

Declare the properties and solutions fields


<?php

namespace HostBox\Components\PayPal\PaymentButtons;

use Nette\Application as Nette;

abstract class BasicButton extends PaypalPaymentButton {

    /** @var int */
    public $quantity;

    /** @var float */
    public $shipping;

    /** @var float */
    public $tax;

}

<?php

namespace HostBox\Components\PayPal\PaymentButtons;

use Nette\Application as Nette;

abstract class BasicButton extends PaypalPaymentButton {

    /** @var int */
    public $quantity = 1;

    /** @var float */
    public $shipping;

    /** @var float */
    public $tax;

    /**
     * @var string
     * @name cpp_logo_image
     */
    public $logoUrl;

    /** @var mixed */
    public $custom;

}

Add logoUrl and custom button field

Add logoUrl and custom button field


@extends('template.skeleton')

@section('title')
{{ Auth::user()->username.' | '._('Online phones') }}
@stop

@section('content')

{{ _('Online Phones') }}

Last update: {{ $online_phones[0]->created_at }}

		@include('template.messages')

                    {{ _('Phone Number (E.164)') }}
                    {{ _('Local Phone Number') }}
                    {{ _('Domain') }}
                    {{ _('Description') }}

                @foreach ($online_phones as $online_phone)

                    +{{ Config::get('settings.global_prefix') }}-{{ $online_phone->domain->prefix }}-{{ $online_phone->username }}
                    {{ $online_phone->username }}
                    {{ $online_phone->sip_server }}
                    {{ $online_phone->phonenumber->description }}

                @endforeach

@stop

@extends('template.skeleton')

@section('title')
{{ Auth::user()->username.' | '._('Online phones') }}
@stop

@section('content')

{{ _('Online Phones') }}

Last update: {{ count($online_phones) > 0 ? $online_phones[0]->created_at : ''}}

		@include('template.messages')

                    {{ _('Phone Number (E.164)') }}
                    {{ _('Local Phone Number') }}
                    {{ _('Domain') }}
                    {{ _('Description') }}

                @foreach ($online_phones as $online_phone)

                    +{{ Config::get('settings.global_prefix') }}-{{ $online_phone->domain->prefix }}-{{ $online_phone->username }}
                    {{ $online_phone->username }}
                    {{ $online_phone->sip_server }}
                    {{ $online_phone->phonenumber->description }}

                @endforeach

@stop

Fix online phone number if empty

Fix online phone number if empty


<?php

namespace SofaChamps\Bundle\BowlPickemBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;

class LeagueAdmin extends Admin
{
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('id')
            ->add('name')
            ->add('motto')
            ->add('password')
            ->add('locked')
        ;
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('id')
            ->add('name')
            ->add('motto')
            ->add('password')
            ->add('locked')
        ;
    }

    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('id')
            ->add('name')
        ;
    }
}

<?php

namespace SofaChamps\Bundle\BowlPickemBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;

class LeagueAdmin extends Admin
{
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('id')
            ->add('season')
            ->add('name')
            ->add('motto')
            ->add('password')
            ->add('locked')
        ;
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('id')
            ->add('season')
            ->add('name')
            ->add('motto')
            ->add('password')
            ->add('locked')
        ;
    }

    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('id')
            ->add('season')
            ->add('name')
        ;
    }
}

Add season to league admin

Add season to league admin


<?php
/**
 * Taxonomy App Controller
 *
 * @category Taxonomy.Controller
 * @package  Croogo
 * @version  1.4
 * @author   Fahad Ibnay Heylaal <contact@fahad19.com>
 * @license  http://www.opensource.org/licenses/mit-license.php The MIT License
 * @link     http://www.croogo.org
 */
class TaxonomyAppController extends AppController {

}

<?php
App::uses('CroogoAppController', 'Croogo.Controller');
/**
 * Taxonomy App Controller
 *
 * @category Taxonomy.Controller
 * @package  Croogo
 * @version  1.4
 * @author   Fahad Ibnay Heylaal <contact@fahad19.com>
 * @license  http://www.opensource.org/licenses/mit-license.php The MIT License
 * @link     http://www.croogo.org
 */
class TaxonomyAppController extends CroogoAppController {

}

Fix bad namespace and replace use of cake app controller for croogo one.


<?php

namespace Websanova\EasyCache\Models;

class Domain extends BaseModel
{
    protected $table = 'websanova_easycache_domains';

    protected $cacheKey = 'domains';

    protected $cacheBy = 'slug';

    public $timestamps = false;

    public function slug()
    {
        return $this->select('*');
    }

    public function items()
    {
    	return $this->hasMany('\Websanova\EasyCache\Models\Item');
    }

    public function comments()
    {
        return $this->hasMany('\Websanova\EasyCache\Models\Comment');
    }

    public function recountItems()
    {
        return $this->items()->active();
    }

    public function recountComments()
    {
        return $this->comments()->active();
    }
}

<?php

namespace Websanova\EasyCache\Models;

class Domain extends BaseModel
{
    protected $table = 'websanova_easycache_domains';

    protected $cacheKey = 'domains';

    public $cacheBy = 'slug';

    public $timestamps = false;

    public function slug()
    {
        return $this->select('*');
    }

    public function items()
    {
    	return $this->hasMany('\Websanova\EasyCache\Models\Item');
    }

    public function comments()
    {
        return $this->hasMany('\Websanova\EasyCache\Models\Comment');
    }

    public function recountItems()
    {
        return $this->items()->active();
    }

    public function recountComments()
    {
        return $this->comments()->active();
    }
}

Fix public cacheBy for domain model.

Fix public cacheBy for domain model.


<?php
define('IN_SCRIPT',1);
define('HESK_PATH','../');
require(HESK_PATH . 'install/install_functions.inc.php');
require(HESK_PATH . 'hesk_settings.inc.php');
hesk_dbConnect();
hesk_dbQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` ADD COLUMN `active` ENUM('0', '1') NOT NULL DEFAULT 1 AFTER `autorefresh`");
hesk_dbQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` ADD COLUMN `can_manage_settings` INT NOT NULL DEFAULT 1");
?>

Update complete!

Please delete the install folder for security reasons, and then proceed back to the Help Desk

<?php
define('IN_SCRIPT',1);
define('HESK_PATH','../');
require(HESK_PATH . 'install/install_functions.inc.php');
require(HESK_PATH . 'hesk_settings.inc.php');
hesk_dbConnect();
hesk_dbQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` ADD COLUMN `active` ENUM('0', '1') NOT NULL DEFAULT 1 AFTER `autorefresh`");
hesk_dbQuery("ALTER TABLE `".hesk_dbEscape($hesk_settings['db_pfix'])."users` ADD COLUMN `can_manage_settings` ENUM('0', '1') NOT NULL DEFAULT 1");
?>

Update complete!

Please delete the install folder for security reasons, and then proceed back to the Help Desk

Use an enum instead of an int

Use an enum instead of an int


<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Bundle\DoctrineMigrationsBundle\Command;

use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\DoctrineBundle\Command\DoctrineCommand as BaseCommand;
use Doctrine\DBAL\Migrations\Configuration\Configuration;
use Doctrine\Common\Util\Inflector;

/**
 * Base class for Doctrine console commands to extend from.
 *
 * @author Fabien Potencier <fabien.potencier@symfony-project.com>
 */
abstract class DoctrineCommand extends BaseCommand
{
    public static function configureMigrationsForBundle(Application $application, $bundle, Configuration $configuration)
    {
        $configuration->setMigrationsNamespace($bundle.'\DoctrineMigrations');

        $bundle = $application->getKernel()->getBundle($bundle);
        $dir = $bundle->getPath().'/DoctrineMigrations';

        $configuration->setMigrationsDirectory($dir);
        $configuration->registerMigrationsFromDirectory($dir);
        $configuration->setName($bundle->getName().' Migrations');
        $configuration->setMigrationsTableName(Inflector::tableize($bundle->getName()).'_migration_versions');
    }
}

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Bundle\DoctrineMigrationsBundle\Command;

use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\DoctrineBundle\Command\DoctrineCommand as BaseCommand;
use Doctrine\DBAL\Migrations\Configuration\Configuration;
use Doctrine\Common\Util\Inflector;

/**
 * Base class for Doctrine console commands to extend from.
 *
 * @author Fabien Potencier <fabien.potencier@symfony-project.com>
 */
abstract class DoctrineCommand extends BaseCommand
{
    public static function configureMigrationsForBundle(Application $application, $bundle, Configuration $configuration)
    {
        $bundle = $application->getKernel()->getBundle($bundle);
        $dir = $bundle->getPath().'/DoctrineMigrations';

        $configuration->setMigrationsNamespace($bundle->getNamespace().'\DoctrineMigrations');
        $configuration->setMigrationsDirectory($dir);
        $configuration->registerMigrationsFromDirectory($dir);
        $configuration->setName($bundle->getName().' Migrations');
        $configuration->setMigrationsTableName(Inflector::tableize($bundle->getName()).'_migration_versions');
    }
}

Fix Doctrine Migrations commands to work with new bundles.


<?php

class UploadFile {

    public function fire($job, $data)
    {
        $object = Object::where('name', $data['name'])->first();

        // Take file
        $path = base_path().DIRECTORY_SEPARATOR.'storage'.DIRECTORY_SEPARATOR.$object->name;

        // Upload to S3
        $s3 = App::make('aws')->get('s3');
        $s3->putObject(array(
            'Bucket' => 'storag',
            'Key' => $object->name,
            'SourceFile' => $path,
        ));

        $object->s3 = true;
        $object->save();

        $job->delete();
    }

}

<?php

class UploadFile {

    public function fire($job, $data)
    {
        $object = Object::where('name', $data['name'])->first();

        // Take file
        $path = base_path().DIRECTORY_SEPARATOR.'storage'.DIRECTORY_SEPARATOR.$object->name;

        // Upload to S3
        $s3 = App::make('aws')->get('s3');
        $s3->putObject(array(
            'Bucket' => 'storag',
            'Key' => $object->name,
            'SourceFile' => $path,
            'ContentType' => $object->mime,
        ));

        $object->s3 = true;
        $object->save();

        $job->delete();
    }

}

Allow S3 to properly serve to the cache servers


<?php
    namespace Page;

    class SignUp
    {
        public function index()
        {
            if ($this->input->hasPost('username'))
            {
                $this->addUser();
            }

            $this->load->storeView('SignUp');

            $this->load->layout('Fresh');
        }

        public function addUser()
        {
            $username = $this->input->post('username');
            $password = $this->input->post('password');
            $rpassword = $this->input->post('rpassword');

            $this->load->library('Validation');

            if ($password !== $rpassword)
            {
                $this->message->error('Your retype password is not match with the password you entered.');
            }

            if (!$this->validation->username($username))
            {
                $this->message->error('Your username is not valid, only use alphabet (a-z), number (0-9),'.
                    ' and symbol (_.-). The character length must between 5-16 characters');
            }

            if (!$this->validation->password($password))
            {
                $this->message->error('Your password is not valid, only use alphabet (a-z), number (0-9),'.
                    ' and symbol (@#!$*&~;:,?_.-). The character length must between 5-16 characters');
            }

            if ($this->message->count('error') > 0)
            {
                return;
            }

            $this->message->success('Your account has been created successfully.'.
                ' Enter with your username and password', true);
            $this->router->redirect('user/signin');
        }
    }

?>

<?php
    namespace Page;

    class SignUp
    {
        public function index()
        {
            if ($this->input->hasPost('username'))
            {
                $this->addUser();
            }

            $this->load->storeView('SignUp');

            $this->load->layout('Fresh');
        }

        public function addUser()
        {
            $username = $this->input->post('username');
            $password = $this->input->post('password');
            $rpassword = $this->input->post('rpassword');

            $this->load->library('Validation');

            if ($password !== $rpassword)
            {
                $this->message->error('Your retype password is not match with the password you entered.');
            }

            if (!$this->validation->username($username))
            {
                $this->message->error('Your username is not valid, only use alphabet (a-z), number (0-9),'.
                    ' and symbol (_.-). The character length must between 5-16 characters');
            }

            if (!$this->validation->password($password))
            {
                $this->message->error('Your password is not valid, only use alphabet (a-z), number (0-9),'.
                    ' and symbol (@#!$*&~;:,?_.-). The character length must between 5-16 characters');
            }

            if ($this->message->count('error') > 0)
            {
                return;
            }

            $create = $this->auth->addUser($username, $password);

            if ($create === true)
            {
                $this->message->success('Your account has been created successfully.'.
                ' Enter with your username and password', true);
                $this->router->redirect('user/signin');
            }
            else
            {
                $this->message->error($create);
            }

        }
    }

?>

Implement addUser library at signup page


Put profile stuff in storage

Put profile stuff in storage


<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;

class ProfileController extends Controller
{
    public function __construct()
    {
        //$this->middleware('jwt.auth', ['except' => ['authenticate']]);
    }

    /*
        returns profile data for GET request
        @return json
    **/
    public function profile(Request $request)
    {
        $email = $request->email;
        $userdetails = User::where('email', $email)->get();

        return response()->json(['user' => $userdetails]);
    }

    /*
        returns visitor profile data for GET request
        @return json
    **/
    public function visitor(Request $request)
    {
        $username = $request->username;
        if ($userdetails = User::where('firstname', $username)->get()) {
            return response()->json(['user' => $userdetails, 'status' => 200], 200);
        } else {
            return response()->json(['user' => $userdetails, 'status' => 505], 505);
        }
    }
}

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;

class ProfileController extends Controller
{
    public function __construct()
    {
        //$this->middleware('jwt.auth', ['except' => ['authenticate']]);
    }

    /*
        returns profile data for GET request
        @return json
    **/
    public function profile(Request $request)
    {
        $email = $request->email;
        $userdetails = User::where('email', $email)->get();

        return response()->json(['user' => $userdetails]);
    }

    /*
        returns visitor profile data for GET request
        @return json
    **/
    public function visitor(Request $request)
    {
        $username = $request->username;
        if ($userdetails = User::where('firstname', $username)->get()) {
            return response()->json(['user' => $userdetails, 'status' => 200], 200);
        } else {
            return response()->json(['user' => $userdetails, 'status' => 505], 505);
        }
    }
    /*
        handles POST request from client
        adds a like to profile
        @return json ... status of action
    **/
    public function like(Request $request)
    {
        $likedUsername = $request->likedUsername;
        $gotLikedUsername = $request->gotLikedUsername;

    }
}

Add method for liking profiles

Add method for liking profiles


<?php

namespace React\Socket;

use Evenement\EventEmitter;
use React\EventLoop\LoopInterface;
use React\Stream\WritableStreamInterface;
use React\Stream\Buffer;
use React\Stream\Stream;
use React\Stream\Util;

class Connection extends Stream implements ConnectionInterface
{
    public function handleData($stream)
    {
        $data = stream_socket_recvfrom($stream, $this->bufferSize);
        if ('' === $data || false === $data || feof($stream)) {
            $this->end();
        } else {
            $this->emit('data', array($data, $this));
        }
    }

    public function handleClose()
    {
        if (is_resource($this->stream)) {
            stream_socket_shutdown($this->stream, STREAM_SHUT_RDWR);
            fclose($this->stream);
        }
    }

    public function getRemoteAddress()
    {
        return $this->parseAddress(stream_socket_get_name($this->stream, true));
    }

    private function parseAddress($address)
    {
        return trim(substr($address, 0, strrpos($address, ':')), '[]');
    }
}

<?php

namespace React\Socket;

use Evenement\EventEmitter;
use React\EventLoop\LoopInterface;
use React\Stream\WritableStreamInterface;
use React\Stream\Buffer;
use React\Stream\Stream;
use React\Stream\Util;

class Connection extends Stream implements ConnectionInterface
{
    public function handleData($stream)
    {
        $data = stream_socket_recvfrom($stream, $this->bufferSize);
        if ('' === $data || false === $data || feof($stream)) {
            $this->end();
        } else {
            $this->emit('data', array($data, $this));
        }
    }

    public function handleClose()
    {
        if (is_resource($this->stream)) {
            // http://chat.stackoverflow.com/transcript/message/7727858#7727858
            stream_socket_shutdown($this->stream, STREAM_SHUT_RDWR);
            stream_set_blocking($this->stream, false);
            fclose($this->stream);
        }
    }

    public function getRemoteAddress()
    {
        return $this->parseAddress(stream_socket_get_name($this->stream, true));
    }

    private function parseAddress($address)
    {
        return trim(substr($address, 0, strrpos($address, ':')), '[]');
    }
}

Reset non-blocking to be safe

[Streams] Reset non-blocking to be safe


<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Sauna</title>
<script src="http://code.jquery.com/jquery-1.10.1.js"></script>
<script>
	$(document).ready(function(e) {
       $.ajax({
			url:"Sauna.php",
			dataType:"html",
			success: function(html) {
				$('body').html(html);
			}
		});
    });
</script>
</head>

<body>
</body>
</html>

<?php

header('Location: Sauna.php');
?>

Revert "Revert "Revert "Index aangepast zodat deze via ajax Sauna.php ophaalt"""

This reverts commit c5d3a9fdd2d9df477213acc0b0bbf8c88c6d50d3.


<?php

header('Location: Sauna.php');
?>

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Sauna</title>
<script src="http://code.jquery.com/jquery-1.10.1.js"></script>
<script>
	$(document).ready(function(e) {
       $.ajax({
			url:"Sauna.php",
			dataType:"html",
			success: function(html) {
				$('body').html(html);
			}
		});
    });
</script>
</head>

<body>
</body>
</html>

Index aangepast zodat deze via ajax Sauna.php ophaalt


<?php

header('Content-Type: application/json');

//Variables
$user_agent = "lmgtfy/0.1 (https://github.com/shokinn/lmgtfy-slack-slash-command)";
$command = $_POST['command'];
$search = $_POST['text'];
$token = $_POST['token'];
$tokenMatch = "";

if($token != $tokenMatch){
    $msg = "{ \"error_msg\": \"The token for the slash command doesn't match. Check your script.\" }";
    die($msg);
    echo $msg;
}

$longUrl = "http://lmgtfy.com/?q=".$search;

$reply_json = json_encode(array('response_type'=>'in_channel','text'=>"You'll find your answer here:\n*<".$longUrl.">.*"));
echo $reply_json;
?>

<?php

header('Content-Type: application/json');

//Variables
$user_agent = "lmgtfy/0.1 (https://github.com/shokinn/lmgtfy-slack-slash-command)";
$command = $_POST['command'];
$search = $_POST['text'];
$token = $_POST['token'];
$tokenMatch = "";

if($token != $tokenMatch or $token == "" or $tokenMatch == ""){
    $msg = "{ \"error_msg\": \"The token for the slash command doesn't match. Check your script.\" }";
    die($msg);
    echo $msg;
}

$longUrl = "http://lmgtfy.com/?q=".$search;

$reply_json = json_encode(array('response_type'=>'in_channel','text'=>"You'll find your answer here:\n*<".$longUrl.">.*"));
echo $reply_json;
?>

Change line endings from DOS to unix; Improve token match.


<?php
namespace Epfl\Contact;

require_once 'shortcake-config.php';

function epfl_contact_process_shortcode($atts) {
    // sanitize parameters
    foreach($atts as $key => $value) {
        if (strpos($key, 'information') !== false) {
            $atts[$key] = wp_kses_post($value);
        }
        elseif ($key == 'introduction')
        {
            $atts[$key] = sanitize_textarea_field($value);
        } else {
            $atts[$key] = sanitize_text_field($value);
        }
    }

    if (has_action("epfl_contact_action")) {
        ob_start();

        try {
           do_action("epfl_contact_action", $atts);
           return ob_get_contents();
        } finally {
          ob_end_clean();
        }
    // otherwise the plugin does the rendering
    } else {
        return 'You must activate the epfl theme';
    }
}

add_action( 'register_shortcode_ui', __NAMESPACE__ . '\ShortCake\config');

add_action( 'init', function() {
    // define the shortcode
   add_shortcode('epfl_contact', __NAMESPACE__ . '\epfl_contact_process_shortcode');
});

<?php
namespace Epfl\Contact;

require_once 'shortcake-config.php';

function epfl_contact_process_shortcode($atts) {
    // sanitize parameters
    foreach($atts as $key => $value) {
        if (strpos($key, 'information') !== false ||
        strpos($key, 'timetable') !== false) {
            $atts[$key] = wp_kses_post($value);
        }
        elseif ($key == 'introduction')
        {
            $atts[$key] = sanitize_textarea_field($value);
        } else {
            $atts[$key] = sanitize_text_field($value);
        }
    }

    if (has_action("epfl_contact_action")) {
        ob_start();

        try {
           do_action("epfl_contact_action", $atts);
           return ob_get_contents();
        } finally {
          ob_end_clean();
        }
    // otherwise the plugin does the rendering
    } else {
        return 'You must activate the epfl theme';
    }
}

add_action( 'register_shortcode_ui', __NAMESPACE__ . '\ShortCake\config');

add_action( 'init', function() {
    // define the shortcode
   add_shortcode('epfl_contact', __NAMESPACE__ . '\epfl_contact_process_shortcode');
});

Fix timetable being wrongly escaped

Fix timetable being wrongly escaped


<?php

namespace JoeStewart\RoboDrupalVM\Task;

use Robo\Result;
use Robo\Task\BaseTask;
use Robo\Common\ExecOneCommand;
use Robo\Contract\CommandInterface;
use Robo\Contract\TaskInterface;
use Robo\Contract\PrintedInterface;
use Robo\Exception\TaskException;

class Vm extends \JoeStewart\RoboDrupalVM\Task\Base
{

    /**
     * @return Result
     */
    public function run()
    {
        return new Result(
            $this,
            0,
            'Vm'
        );
    }
}

<?php

namespace JoeStewart\RoboDrupalVM\Task;

use Robo\Result;

class Vm extends \JoeStewart\RoboDrupalVM\Task\Base
{

    /**
     * @return Result
     */
    public function run()
    {
        return new Result(
            $this,
            0,
            'Vm'
        );
    }
}

Remove unused use statements since extending Base Task


<?php
if (!function_exists('backend_router')) {
    /**
     * Retrieve router
     *
     * @author Casper Rasmussen <cr@nodes.dk>
     *
     * @return \Nodes\Backend\Routing\Router
     */
    function backend_router()
    {
        return \NodesBackend::router();
    }
}

if (!function_exists('backend_router_pattern')) {
    /**
     * Match route by pattern
     *
     * @author Casper Rasmussen <cr@nodes.dk>
     *
     * @param  string|array $patterns
     * @return string
     */

    function backend_router_pattern($patterns)
    {
        return \NodesBackend::router()->pattern($patterns);
    }
}

if (!function_exists('backend_router_alias')) {
    /**
     * Match route by pattern
     *
     * @author Casper Rasmussen <cr@nodes.dk>
     *
     * @param  string|array $aliases
     * @return string
     */

    function backend_router_alias($aliases)
    {
        return \NodesBackend::router()->alias($aliases);
    }
}

<?php
if (!function_exists('backend_router')) {
    /**
     * Retrieve router
     *
     * @author Casper Rasmussen <cr@nodes.dk>
     *
     * @return \Nodes\Backend\Routing\Router
     */
    function backend_router()
    {
        return app('nodes.backend.router');
    }
}

if (!function_exists('backend_router_pattern')) {
    /**
     * Match route by pattern
     *
     * @author Casper Rasmussen <cr@nodes.dk>
     *
     * @param  string|array $patterns
     * @return string
     */

    function backend_router_pattern($patterns)
    {
        return app('nodes.backend.router')->pattern($patterns);
    }
}

if (!function_exists('backend_router_alias')) {
    /**
     * Match route by pattern
     *
     * @author Casper Rasmussen <cr@nodes.dk>
     *
     * @param  string|array $aliases
     * @return string
     */

    function backend_router_alias($aliases)
    {
        return app('nodes.backend.router')->alias($aliases);
    }
}

Update to not use Facade alias

Update to not use Facade alias


<?php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, Notifiable;

    public function votes()
    {
        return $this->hasMany(Vote::class);
    }
}

<?php

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Passport\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens, Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    public function votes()
    {
        return $this->hasMany(Vote::class);
    }
}

Add fillable fields to user

Add fillable fields to user


<?php

require_once(__DIR__ . '/../GitHubObject.php');

class GitHubTeam extends GitHubObject
{
	/* (non-PHPdoc)
	 * @see GitHubObject::getAttributes()
	 */
	protected function getAttributes()
	{
		return array_merge(parent::getAttributes(), array(
			'url' => 'string',
			'name' => 'string',
		));
	}

	/**
	 * @var string
	 */
	protected $url;

	/**
	 * @var string
	 */
	protected $name;

	/**
	 * @return string
	 */
	public function getUrl()
	{
		return $this->url;
	}

	/**
	 * @return string
	 */
	public function getName()
	{
		return $this->name;
	}

}

<?php

require_once(__DIR__ . '/../GitHubObject.php');

class GitHubTeam extends GitHubObject
{
	/* (non-PHPdoc)
	 * @see GitHubObject::getAttributes()
	 */
	protected function getAttributes()
	{
		return array_merge(parent::getAttributes(), array(
			'id' => 'int',
			'url' => 'string',
			'name' => 'string'
		));
	}

	/**
	 * @var int
	 */
	protected $id;

	/**
	 * @var string
	 */
	protected $url;

	/**
	 * @var string
	 */
	protected $name;

	/**
	 * @return int
	 */
	public function getId()
	{
		return $this->id;
	}

	/**
	 * @return string
	 */
	public function getUrl()
	{
		return $this->url;
	}

	/**
	 * @return string
	 */
	public function getName()
	{
		return $this->name;
	}

}

Add Id in github team

Add Id in github team


<?php

class ApiFastTest extends TestCase
{
    protected $baseUrl = '';

    /**
     * ApiFastTest constructor.
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * A basic functional test example.
     *
     * @return void
     */
    public function testEmotes()
    {
        // WoTlk
        $this->json('GET', '/api/v1/dbc/emotes/')->seeJson(
            ["id" => 0, "emote" => "ONESHOT_NONE"]
        );

        $this->json('GET', '/api/v1/dbc/emotes/3')->seeJsonEquals(
            ["id" => 3, "emote" => "ONESHOT_WAVE(DNR)"]
        );

        // Wod
        $this->json('GET', '/api/v1/dbc/emotes/?version=wod')->seeJson(
            ["id" => 577, "emote" => "ONESHOT_ATTACK1H"]
        );

        $this->json('GET', '/api/v1/dbc/emotes/619/?version=wod')->seeJsonEquals(
            ["id" => 619, "emote" => "STATE_PARRY_UNARMED"]
        );
    }
}

<?php

class ApiFastTest extends TestCase
{
    protected $baseUrl = '';

    /**
     * A basic functional test example.
     *
     * @return void
     */
    public function testEmotes()
    {
        // WoTlk
        $this->json('GET', '/api/v1/dbc/emotes/')->seeJson(
            ["id" => 0, "emote" => "ONESHOT_NONE"]
        );

        $this->json('GET', '/api/v1/dbc/emotes/3')->seeJsonEquals(
            ["id" => 3, "emote" => "ONESHOT_WAVE(DNR)"]
        );

        // Wod
        $this->json('GET', '/api/v1/dbc/emotes/?version=wod')->seeJson(
            ["id" => 577, "emote" => "ONESHOT_ATTACK1H"]
        );

        $this->json('GET', '/api/v1/dbc/emotes/619/?version=wod')->seeJsonEquals(
            ["id" => 619, "emote" => "STATE_PARRY_UNARMED"]
        );
    }
}

Remove useless constructor. (That is last for this pull.)


<?php

declare(strict_types=1);

namespace Psalm\Plugin\EventHandler\Event;

use Psalm\Issue\CodeIssue;

class BeforeAddIssueEvent
{
    /**
     * @var CodeIssue
     */
    private CodeIssue $issue;

    /**
     * @var bool
     */
    private bool $fixable;

    public function __construct(CodeIssue $issue, bool $fixable)
    {
        $this->issue = $issue;
        $this->fixable = $fixable;
    }

    public function getIssue(): CodeIssue
    {
        return $this->issue;
    }

    public function isFixable(): bool
    {
        return $this->fixable;
    }
}

<?php

declare(strict_types=1);

namespace Psalm\Plugin\EventHandler\Event;

use Psalm\Issue\CodeIssue;

final class BeforeAddIssueEvent
{
    /**
     * @var CodeIssue
     */
    private CodeIssue $issue;

    /**
     * @var bool
     */
    private bool $fixable;

    public function __construct(CodeIssue $issue, bool $fixable)
    {
        $this->issue = $issue;
        $this->fixable = $fixable;
    }

    public function getIssue(): CodeIssue
    {
        return $this->issue;
    }

    public function isFixable(): bool
    {
        return $this->fixable;
    }
}

Use final event class declarations

[TASK] Use final event class declarations


<?php

define('SLASHCOMMAND_TOKEN', '');
define('WEBHOOK_URL', '');

<?php

/**
 * Slash Command Token
 * You will get a token when you add a new Slash Command integration in your Slack settings.
 */
define('SLASHCOMMAND_TOKEN', '');

/**
 * Webhook URL
 * You will find your Webhook URL when you add a new Incoming WebHook integration in your Slack settings.
 */
define('WEBHOOK_URL', '');

Add comments for better orientation

Add comments for better orientation


<?php
require 'main.php';
# Here should do whatever authentication / verification needed

# Create model using the data received
$photo = \PhotoAlbum\create_photo_model($_POST["public_id"], $_POST["format"]);
?>

<?php
require 'main.php';
# Here should do whatever authentication / verification needed

# Check for authentic cloudinary response
$api_secret = Cloudinary::config_get("api_secret");
if (!$api_secret) throw new \InvalidArgumentException("Must supply api_secret");
$existing_signature = \Cloudinary::option_consume($_POST, "signature");
$to_sign = array(
    'public_id' => $_POST['public_id'],
    'version' => $_POST['version'],
);
$calculated_signature = \Cloudinary::api_sign_request($to_sign, $api_secret);

if ($existing_signature == $calculated_signature) {
    $photo = \PhotoAlbum\create_photo_model($_POST["public_id"], $_POST["format"]);
} else {
    error_log("Given data's signature can't be verified (" .
        $existing_signature . " != " . $calculated_signature . "). data: " .
        \PhotoAlbum\ret_var_dump(_POST));
}
?>

Check signature of direct upload

Check signature of direct upload


<?php

use Icmp\Message;
use Icmp\Icmp;
use React\EventLoop\Factory;

class MessageTest extends TestCase
{
    public function testGetters()
    {
        $message = new Message(1, 2, null, 3, 'payload');

        $this->assertEquals(1, $message->getType());
        $this->assertEquals(2, $message->getCode());

        $this->assertEquals(3, $message->getHeader());
        $this->assertEquals('payload', $message->getPayload());
    }

    /**
     * asdasd
     *
     * @expectedException Exception
     * @asd asd asd
     * @datus-coverage ok
     */
    public function testPongInvalid()
    {
        $message = new Message(1, 2, 3, 4);

        $loop = React\EventLoop\Factory::create();

        $icmp = new Icmp($loop);

        $message->promisePong($icmp);
    }
}

<?php

use Icmp\Message;
use Icmp\Icmp;
use React\EventLoop\Factory;

class MessageTest extends TestCase
{
    public function testGetters()
    {
        $message = new Message(1, 2, 3, 4, 'payload');

        $this->assertEquals(1, $message->getType());
        $this->assertEquals(2, $message->getCode());
        $this->assertEquals(3, $message->getChecksum());
        $this->assertEquals(4, $message->getHeader());
        $this->assertEquals('payload', $message->getPayload());

        $this->assertFalse($message->isChecksumValid());
    }

    /**
     * passing NULL as the checksum should automatically update the checksum to the valid, calculated value
     */
    public function testAutomaticMessageChecksum()
    {
        $message = new Message(1, 2, null, 3);

        $this->assertNotNull($message->getChecksum());
        $this->assertTrue($message->isChecksumValid());
    }

    /**
     * asdasd
     *
     * @expectedException Exception
     */
    public function testPongInvalid()
    {
        $message = new Message(1, 2, 3, 4);

        $loop = React\EventLoop\Factory::create();

        $icmp = new Icmp($loop);

        $message->promisePong($icmp);
    }
}

Test automatic generation of checksums

Test automatic generation of checksums


<?php
require_once '../../src/ParseXML.php';
require_once 'Book.php';

$parseXML = new ParseXML('book', 'Book', 'display');
try {
  $parseXML->parseFile("catalog.xml");
} catch (Exception $e) {
  print $e->getMessage();
}

function display($book)
{
  print '<pre>' . print_r($book, true) . '</pre>';
}

<?php
require_once '../../src/ParseXML.php';
require_once 'Book.php';

use ParseXML\ParseXML\ParseXML;

$parseXML = new ParseXML('book', 'Book', 'display');
try {
  $parseXML->parseFile("catalog.xml");
} catch (Exception $e) {
  print $e->getMessage();
}

function display($book)
{
  print '<pre>' . print_r($book, true) . '</pre>';
}

Fix namespace usage in example

Fix namespace usage in example


<?php
/**
 * Lock
 *
 * Class for create and handle locks.
 *
 * @author Ángel Guzmán Maeso <shakaran@gmail.com>
 * @since 0.1
 */
class Lock
{
	/**
	 * Create a lock.
	 *
	 * Additionally fetch the options in plugin hooks.
	 *
	 * @author Ángel Guzmán Maeso <shakaran@gmail.com>
	 * @param string $lock_filename The name of lock file.
	 * @return resource A file pointer resource on success, or FALSE on error
	 */
	public static function create($lock_filename = NULL)
	{
		$fp = fopen(LOCK_DIRECTORY . '/' . $lock_filename, 'w');

		if ($fp && flock($fp, LOCK_EX | LOCK_NB))
		{
			if (function_exists('posix_getpid'))
			{
				fwrite($fp, posix_getpid() . PHP_EOL);
			}

			return $fp;
		}
		else
		{
			return FALSE;
		}
	}
}

<?php
/**
 * Lock
 *
 * Class for create and handle locks.
 *
 * @author Ángel Guzmán Maeso <shakaran@gmail.com>
 * @since 0.1
 */
class Lock
{
	/**
	 * Create a lock.
	 *
	 * @author Ángel Guzmán Maeso <shakaran@gmail.com>
	 * @param string $lock_filename The name of lock file.
	 * @return resource A file pointer resource on success, or FALSE on error
	 */
	public static function create($lock_filename = NULL)
	{
		$fp = fopen(LOCK_DIRECTORY . '/' . $lock_filename, 'w');

		if ($fp && flock($fp, LOCK_EX | LOCK_NB))
		{
			if (function_exists('posix_getpid'))
			{
				fwrite($fp, posix_getpid() . PHP_EOL);
			}

			return $fp;
		}
		else
		{
			return FALSE;
		}
	}
}

Remove wrong copy/paste doc description typo