<?php
use \Entity\Station;
use \Entity\Song;
use \Entity\Schedule;

class Api_NowplayingController extends \PVL\Controller\Action\Api
{
    public function indexAction()
    {
        $file_path_api = DF_INCLUDE_STATIC.'/api/nowplaying_api.json';
        $np_raw = file_get_contents($file_path_api);

        if ($this->hasParam('id') || $this->hasParam('station'))
        {
            $np_arr = @json_decode($np_raw, TRUE);
            $np = $np_arr['result'];

            if ($this->hasParam('id'))
            {
                $id = (int)$this->getParam('id');
                $station = Station::find($id);

                if (!($station instanceof Station))
                    return $this->returnError('Station not found!');
                else
                    $sc = $station->getShortName();
            }
            elseif ($this->hasParam('station'))
            {
                $sc = $this->getParam('station');
            }

            if (isset($np[$sc]))
                $this->returnSuccess($np[$sc]);
            else
                return $this->returnError('Station not found!');
        }
        else
        {
            $this->returnRaw($np_raw, 'json');
        }
    }
}

<?php
use \Entity\Station;
use \Entity\Song;
use \Entity\Schedule;

class Api_NowplayingController extends \PVL\Controller\Action\Api
{
    public function indexAction()
    {
        $file_path_api = DF_INCLUDE_STATIC.'/api/nowplaying_api.json';
        $np_raw = file_get_contents($file_path_api);

        if ($this->hasParam('id') || $this->hasParam('station'))
        {
            $np_arr = @json_decode($np_raw, TRUE);
            $np = $np_arr['result'];

            if ($this->hasParam('id'))
            {
                $id = (int)$this->getParam('id');
                foreach($np as $key => $station) {
                    if($station->id === $id) {
                        $sc = $key;
                        break;
                    }
                }
                return $this->returnError('Station not found!');
            }
            elseif ($this->hasParam('station'))
            {
                $sc = $this->getParam('station');
            }

            if (isset($np[$sc]))
                $this->returnSuccess($np[$sc]);
            else
                return $this->returnError('Station not found!');
        }
        else
        {
            $this->returnRaw($np_raw, 'json');
        }
    }
}

Reduce number of DB calls in NowPlayingController


<?php

namespace Backend\Modules\Analytics\Actions;

use Backend\Core\Engine\Base\ActionDelete;
use Backend\Core\Engine\Model;

/**
 * This is the reset-action. It will remove your coupling with analytics
 */
final class Reset extends ActionDelete
{
    public function execute(): void
    {
        $this->get('fork.settings')->delete($this->getModule(), 'certificate');
        $this->get('fork.settings')->delete($this->getModule(), 'email');
        $this->get('fork.settings')->delete($this->getModule(), 'account');
        $this->get('fork.settings')->delete($this->getModule(), 'web_property_id');
        $this->get('fork.settings')->delete($this->getModule(), 'profile');

        $this->redirect(Model::createUrlForAction('Settings'));
    }
}

<?php

namespace Backend\Modules\Analytics\Actions;

use Backend\Core\Engine\Base\Action;
use Backend\Core\Engine\Model;

/**
 * This is the reset-action. It will remove your coupling with analytics
 */
final class Reset extends Action
{
    public function execute(): void
    {
        $this->checkToken();

        $this->get('fork.settings')->delete($this->getModule(), 'certificate');
        $this->get('fork.settings')->delete($this->getModule(), 'email');
        $this->get('fork.settings')->delete($this->getModule(), 'account');
        $this->get('fork.settings')->delete($this->getModule(), 'web_property_id');
        $this->get('fork.settings')->delete($this->getModule(), 'profile');

        $this->redirect(Model::createUrlForAction('Settings'));
    }
}

Add csrf check to resetting the analytics


<?php

declare(strict_types=1);

/*
 * This file is part of SolidInvoice project.
 *
 * (c) 2013-2017 Pierre du Plessis <info@customscripts.co.za>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace SolidInvoice\CoreBundle\Twig\Extension;

use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class FileExtension extends AbstractExtension
{
    /**
     * @var string
     */
    private $projectDir;

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

    /**
     * {@inheritdoc}
     */
    public function getFunctions()
    {
        return [
            new TwigFunction('file', function ($file) {
                return file_get_contents($this->projectDir.'/web/'.ltrim($file, '\\'));
            }, ['is_safe' => ['css', 'html']]),
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'solidinvoice_core.twig.file';
    }
}

<?php

declare(strict_types=1);

/*
 * This file is part of SolidInvoice project.
 *
 * (c) 2013-2017 Pierre du Plessis <info@customscripts.co.za>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace SolidInvoice\CoreBundle\Twig\Extension;

use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class FileExtension extends AbstractExtension
{
    /**
     * @var string
     */
    private $projectDir;

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

    /**
     * {@inheritdoc}
     */
    public function getFunctions()
    {
        return [
            new TwigFunction('file', function ($file) {
                return file_get_contents($this->projectDir.'/public/'.ltrim($file, '\\'));
            }, ['is_safe' => ['css', 'html']]),
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'solidinvoice_core.twig.file';
    }
}

Update file extension to use public dir instead of web dir


<?php
/**
 * Jetpack Compatibility File.
 *
 * @link https://jetpack.me/
 *
 * @package _s
 */

/**
 * Add theme support for Infinite Scroll.
 * See: https://jetpack.me/support/infinite-scroll/
 */
function _s_jetpack_setup() {
	add_theme_support( 'infinite-scroll', array(
		'container' => 'main',
		'render'    => '_s_infinite_scroll_render',
		'footer'    => 'page',
	) );
} // end function _s_jetpack_setup
add_action( 'after_setup_theme', '_s_jetpack_setup' );

/**
 * Custom render function for Infinite Scroll.
 */
function _s_infinite_scroll_render() {
	while ( have_posts() ) {
		the_post();
		get_template_part( 'template-parts/content', get_post_format() );
	}
} // end function _s_infinite_scroll_render

<?php
/**
 * Jetpack Compatibility File.
 *
 * @link https://jetpack.me/
 *
 * @package _s
 */

function _s_jetpack_setup() {
	/**
	 * Add theme support for Infinite Scroll.
	 * See: https://jetpack.me/support/infinite-scroll/
	 */
	add_theme_support( 'infinite-scroll', array(
		'container' => 'main',
		'render'    => '_s_infinite_scroll_render',
		'footer'    => 'page',
	) );

	/**
	 * Add theme support for Responsive Videos.
	 * See: https://jetpack.me/support/responsive-videos/
	 */
	add_theme_support( 'jetpack-responsive-videos' );
} // end function _s_jetpack_setup
add_action( 'after_setup_theme', '_s_jetpack_setup' );

/**
 * Custom render function for Infinite Scroll.
 */
function _s_infinite_scroll_render() {
	while ( have_posts() ) {
		the_post();
		get_template_part( 'template-parts/content', get_post_format() );
	}
} // end function _s_infinite_scroll_render


Add username and password for Bitly accounts


<?php

namespace Phphilosophy\Security;

/**
 * Phphilosophy Input Validation
 *
 * @author      Lisa Saalfrank <lisa.saalfrank@web.de>
 * @copyright   2015-2016 Lisa Saalfrank
 * @license	http://opensource.org/licenses/MIT MIT License
 * @since       0.1.0
 * @version     0.1.0
 * @package     Phphilosophy
 */
class Validation {

    /**
     * @var array
     */
    private $rules = [];

    /**
     * @var array
     */
    private $input = [];

    /**
     * @var array
     */
    private $messages = [];

    /**
     * @param   array   $input
     * @param   array   $rules
     * @param   array   $messages
     */
    public function __construct(
        array $input,
        array $rules,
        array $messages = []
    ) {
        $this->input = $input;
        $this->rules = $rules;
        $this->messages = $messages;
    }
}

<?php

namespace Phphilosophy\Validation;

/**
 * Phphilosophy Input Validation
 *
 * @author      Lisa Saalfrank <lisa.saalfrank@web.de>
 * @copyright   2015-2016 Lisa Saalfrank
 * @license	http://opensource.org/licenses/MIT MIT License
 * @since       0.1.0
 * @version     0.1.0
 * @package     Phphilosophy
 */
class Validation {

    /**
     * @var array
     */
    private $rules = [];

    /**
     * @var array
     */
    private $input = [];

    /**
     * @var array
     */
    private $messages = [];

    /**
     * @var \Phphilosophy\Validation\Errors
     */
    private $errors;

    /**
     * @param   array   $input
     * @param   array   $rules
     * @param   array   $messages
     */
    public function __construct(
        array $input,
        array $rules,
        array $messages = []
    ) {
        $this->input = $input;
        $this->rules = $rules;
        $this->messages = $messages;
        $this->errors = new Errors();
    }

    /**
     * @return  \Phphilosophy\Validation\Errors
     */
    public function errors() {
        return $this->errors;
    }
}

Add errors property and method

Add errors property and method


<?php
/**
 * Get information about QGIS Server.
 *
 * @author    3liz
 * @copyright 2012 3liz
 *
 * @see      http://3liz.com
 *
 * @license Mozilla Public License : http://www.mozilla.org/MPL/
 */
class qgisServer
{
    // QGIS Server version
    public $qgisServerVersion;

    // List of activated server plugins
    public $plugins = array();

    // constructor
    public function __construct()
    {
        $services = lizmap::getServices();

        $this->qgisServerVersion = $services->qgisServerVersion;

        //$this->getPlugins();
    }

    public function getPlugins($project)
    {
        $plugins = array();

        // Check for atlasprint plugin
        $params = array(
            'service' => 'WMS',
            'request' => 'GetCapabilitiesAtlas',
            'map' => $project->getRelativeQgisPath()
        );
        $url = lizmapProxy::constructUrl($params);
        list($data, $mime, $code) = lizmapProxy::getRemoteData($url);
        if ($mime == 'text/json') {
            $json = json_decode($data);
            $metadata = $json->metadata;
            $plugins[$metadata->name] = array('version' => $metadata->version);
        }

        return $plugins;
    }
}

<?php
/**
 * Get information about QGIS Server.
 *
 * @author    3liz
 * @copyright 2012 3liz
 *
 * @see      http://3liz.com
 *
 * @license Mozilla Public License : http://www.mozilla.org/MPL/
 */
class qgisServer
{
    // QGIS Server version
    public $qgisServerVersion;

    // List of activated server plugins
    public $plugins = array();

    // constructor
    public function __construct()
    {
        $services = lizmap::getServices();

        $this->qgisServerVersion = $services->qgisServerVersion;
    }

    public function getPlugins($project)
    {
        $plugins = array();

        // Check for atlasprint plugin
        $params = array(
            'service' => 'WMS',
            'request' => 'GetCapabilitiesAtlas',
            'map' => $project->getRelativeQgisPath()
        );
        $url = lizmapProxy::constructUrl($params);
        list($data, $mime, $code) = lizmapProxy::getRemoteData($url);
        if (strpos($mime, 'text/json') === 0 || strpos($mime, 'application/json') === 0) {
            $json = json_decode($data);
            $metadata = $json->metadata;
            $plugins[$metadata->name] = array('version' => $metadata->version);
        }

        return $plugins;
    }
}

Test JSON mime type correctly

Test JSON mime type correctly


<?php
/**
 * The template used for displaying page content in page.php
 *
 * @package Flacso
 */
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

		<?php the_title( '
', '
' ); ?>

		<?php the_content(); ?>
		<?php
			wp_link_pages( array(
				'before' => '
' . __( 'Pages:', 'flacso' ),
				'after'  => '
',
			) );
		?>

		<?php edit_post_link( __( 'Edit', 'flacso' ), '', '' ); ?>

Update entry footer structure for pages

Update entry footer structure for pages


<?php
    include 'checklogged.php';
    $code = $_GET['code'];

    //make code uppercase cause the user probably screwed up
    $code = strtoupper($code);

    //connect to the MySQL database
    $$db = null;
    if(isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false){
    //connect to the MySQL database on app engine
        $db = new pdo('mysql:unix_socket=/cloudsql/sodium-pathway-93914:users;dbname=lessons',
                  'root',  // username
                  'xGQEsWRd39G3UrGU' // password
                  );
    }
    else{
        $db = new pdo('mysql:host=127.0.0.1:3307;dbname=lessons',
                  'root',  // username
                  'xGQEsWRd39G3UrGU' // password
                  );
    }
    //prevent emulated prepared statements to prevent against SQL injection
    $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

    //attempt to query the database for the user
    $stmt = $db->prepare('SELECT JSON FROM Lessons WHERE Code=? LIMIT 1');
    $stmt->execute(array($code));
    if ($stmt->rowCount() > 0 ) {
        $queryResult = $stmt->fetch();
        echo $queryResult['JSON'];
    }
else{
    echo '{"status":"fail","message":"Code not found"}';
}

?>

<?php
    include 'checklogged.php';
    include 'GDS/GDS.php';
    $code = $_GET['code'];
    $obj_store = new GDS\Store('Lessons');

    //make code uppercase cause the user probably screwed up
    $code = strtoupper($code);

    $result = $obj_store->fetchOne('SELECT * From Lessons WHERE Code=@code',['code'=>$code]);

    if($result == null)
        echo json_encode(['status'=>'fail','message'=>'Code not found']);
    else
        echo $result->JSON;

?>

Migrate lesson getter to cloud datastore


<?php use Roots\Sage\Titles; ?>

<?= Titles\title(); ?>

Remove page title from header

Remove page title from header


<?php

/**
 * @file
 * Contains \Drupal\Console\EventSubscriber\ShowWelcomeMessageListener.
 */

namespace Drupal\Console\EventSubscriber;

use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\Console\Style\DrupalStyle;

class ShowWelcomeMessageListener implements EventSubscriberInterface
{
    /**
     * @param ConsoleCommandEvent $event
     */
    public function showMessage(ConsoleCommandEvent $event)
    {
        /**
         * @var \Drupal\Console\Command\Command $command
         */
        $command = $event->getCommand();
        $input = $event->getInput();
        $output = $event->getOutput();

        $output = new DrupalStyle($input, $output);

        $application = $command->getApplication();
        $translatorHelper = $application->getTranslator();

        $welcomeMessageKey = 'commands.'.str_replace(':', '.', $command->getName()).'.welcome';
        $welcomeMessage = $translatorHelper->trans($welcomeMessageKey);

        if ($welcomeMessage != $welcomeMessageKey) {
            $output->title($welcomeMessage);
        }
    }

    /**
     * @{@inheritdoc}
     */
    public static function getSubscribedEvents()
    {
        return [ConsoleEvents::COMMAND => 'showMessage'];
    }
}

<?php

/**
 * @file
 * Contains \Drupal\Console\EventSubscriber\ShowWelcomeMessageListener.
 */

namespace Drupal\Console\EventSubscriber;

use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\Console\Style\DrupalStyle;

class ShowWelcomeMessageListener implements EventSubscriberInterface
{
    /**
     * @param ConsoleCommandEvent $event
     */
    public function showMessage(ConsoleCommandEvent $event)
    {
        /**
         * @var \Drupal\Console\Command\Command $command
         */
        $command = $event->getCommand();
        $input = $event->getInput();
        $output = $event->getOutput();

        $output = new DrupalStyle($input, $output);

        $application = $command->getApplication();
        $translatorHelper = $application->getTranslator();

        $welcomeMessageKey = 'commands.'.str_replace(':', '.', $command->getName()).'.welcome';
        $welcomeMessage = $translatorHelper->trans($welcomeMessageKey);

        if ($welcomeMessage != $welcomeMessageKey) {
            $output->text($welcomeMessage);
        }
    }

    /**
     * @{@inheritdoc}
     */
    public static function getSubscribedEvents()
    {
        return [ConsoleEvents::COMMAND => 'showMessage'];
    }
}

Set text format to welcome message

[console] Set text format to welcome message


<?php

namespace App\Http\Controllers;

class FiguresController extends ApiController
{

    protected $model = \App\Models\Dsc\Figure::class;

    protected $transformer = \App\Http\Transformers\FigureTransformer::class;

}

<?php

namespace App\Http\Controllers;

class FiguresController extends ApiController
{

    protected $model = \App\Models\Dsc\Figure::class;

    protected $transformer = \App\Http\Transformers\FigureTransformer::class;

    /**
     * Validate `id` route or query string param format.
     * Figures follow OSCI `id` format, e.g. `fig-429-158`
     *
     * @param mixed $id
     * @return boolean
     */
    protected function validateId( $id )
    {

        return preg_match( '/^fig-[0-9]+-[0-9]+$/', $id );

    }

}

Fix id validation for Figures

Fix id validation for Figures


<?php
/**
 * Domain.php
 * Copyright (C) 2016 Sander Dorigo
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

namespace FireflyIII\Support;

/**
 * Class Domain
 *
 * @package FireflyIII\Support
 */
class Domain
{
    /**
     * @return array
     */
    public static function getBindables()
    {
        return [
            // models
            'account'         => 'FireflyIII\Models\Account',
            'attachment'      => 'FireflyIII\Models\Attachment',
            'bill'            => 'FireflyIII\Models\Bill',
            'budget'          => 'FireflyIII\Models\Budget',
            'category'        => 'FireflyIII\Models\Category',
            'currency'        => 'FireflyIII\Models\TransactionCurrency',
            'limitrepetition' => 'FireflyIII\Models\LimitRepetition',
            'piggyBank'       => 'FireflyIII\Models\PiggyBank',
            'tj'              => 'FireflyIII\Models\TransactionJournal',
            'tag'             => 'FireflyIII\Models\Tag',
            // lists
            'accountList'     => 'FireflyIII\Support\Binder\AccountList',
            'budgetList'      => 'FireflyIII\Support\Binder\BudgetList',
            'categoryList'    => 'FireflyIII\Support\Binder\CategoryList',

            // others
            'start_date'      => 'FireflyIII\Support\Binder\Date',
            'end_date'        => 'FireflyIII\Support\Binder\Date'
        ];

    }

}

<?php
/**
 * Domain.php
 * Copyright (C) 2016 Sander Dorigo
 *
 * This software may be modified and distributed under the terms
 * of the MIT license.  See the LICENSE file for details.
 */

namespace FireflyIII\Support;

use Config;

/**
 * Class Domain
 *
 * @package FireflyIII\Support
 */
class Domain
{
    /**
     * @return array
     */
    public static function getBindables()
    {
        return Config::get('firefly.bindables');

    }
}

Move domain stuff to configuration.

Move domain stuff to configuration.


<?php

namespace Ojs\ImportBundle\Helper;

class FileHelper {
    public static $mimeToExtMap = [
        'application/pdf'    => 'pdf',
        'image/jpeg'         => 'jpg',
        'image/png'          => 'png',
        'application/msword' => 'doc',
        'application/zip'    => 'zip',
        'application/xml'    => 'xml',
        'text/plain'         => 'txt',
        'application/rar '   => 'rar',
        'application/x-rar'  => 'rar',
        'application/octet-stream' => 'bin',
        'application/text-plain:formatted' => 'txt',
        'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx'
    ];
}

<?php

namespace Ojs\ImportBundle\Helper;

class FileHelper {
    public static $mimeToExtMap = [
        '' => 'unknown',
        'application/pdf'    => 'pdf',
        'image/jpeg'         => 'jpg',
        'image/png'          => 'png',
        'application/msword' => 'doc',
        'application/zip'    => 'zip',
        'application/xml'    => 'xml',
        'text/plain'         => 'txt',
        'application/rar '   => 'rar',
        'application/x-rar'  => 'rar',
        'application/octet-stream' => 'bin',
        'application/text-plain:formatted' => 'txt',
        'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx'
    ];
}

Return "unknown" for the empty string key


<?php
/**
 * Copyright (C) 2019 Xibo Signage Ltd
 *
 * Xibo - Digital Signage - http://www.xibo.org.uk
 *
 * This file is part of Xibo.
 *
 * Xibo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * Xibo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
 */

use Phinx\Migration\AbstractMigration;

class AddDoohUserTypeMigration extends AbstractMigration
{
    /** @inheritdoc */
    public function change()
    {
        $userTypeTable = $this->table('usertype');

        if (!$this->fetchRow('SELECT * FROM usertype WHERE `userType` = \'DOOH\'')) {
            $userTypeTable->insert([
                'userType' => 'DOOH'
            ])->save();
        }
    }
}

<?php
/**
 * Copyright (C) 2019 Xibo Signage Ltd
 *
 * Xibo - Digital Signage - http://www.xibo.org.uk
 *
 * This file is part of Xibo.
 *
 * Xibo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * Xibo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
 */

use Phinx\Migration\AbstractMigration;

class AddDoohUserTypeMigration extends AbstractMigration
{
    /** @inheritdoc */
    public function change()
    {
        $userTypeTable = $this->table('usertype');

        if (!$this->fetchRow('SELECT * FROM usertype WHERE `userType` = \'DOOH\'')) {
            $userTypeTable->insert([
                'userTypeId' => 4,
                'userType' => 'DOOH'
            ])->save();
        }
    }
}

Fix Dooh userType migration, ensure the userTypeId is correctly set


<?php

namespace Saft\Rdf\Test;

use Saft\Rdf\StatementIteratorFactory;
use Saft\Test\TestCase;

abstract class StatementIteratorFactoryAbstractTest extends TestCase
{
    /**
     * @return StatementIteratorFactory
     */
    abstract public function newInstance();

    /*
     * Tests createIteratorFromArray
     */

    public function testCreateIteratorFromArrayArrayGiven()
    {
        $this->fixture = $this->newInstance();
        $parameter = array();

        $this->assertClassOfInstanceImplements(
            $this->fixture->createIteratorFromArray($parameter),
            'Saft\Rdf\StatementIterator'
        );
    }

    public function testCreateIteratorFromArrayIteratorGiven()
    {
        $this->fixture = $this->newInstance();
        $parameter = new \ArrayIterator(array());

        // get a list of all interfaces that instance implements
        $implements = class_implements();

        $this->assertClassOfInstanceImplements(
            $this->fixture->createIteratorFromArray($parameter),
            'Saft\Rdf\StatementIterator'
        );
    }

    public function testCreateIteratorFromArrayInvalidParameterGiven()
    {
        $this->setExpectedException('\Exception');

        $parameter = array('invalid parameter');
        $this->newInstance()->createIteratorFromArray($parameter);
    }
}

<?php

namespace Saft\Rdf\Test;

use Saft\Rdf\StatementIteratorFactory;
use Saft\Test\TestCase;

abstract class StatementIteratorFactoryAbstractTest extends TestCase
{
    /**
     * @return StatementIteratorFactory
     */
    abstract public function newInstance();

    /*
     * Tests createIteratorFromArray
     */

    public function testCreateIteratorFromArrayArrayGiven()
    {
        $this->fixture = $this->newInstance();
        $parameter = array();

        $this->assertClassOfInstanceImplements(
            $this->fixture->createIteratorFromArray($parameter),
            'Saft\Rdf\StatementIterator'
        );
    }

    public function testCreateIteratorFromArrayInvalidParameterGiven()
    {
        $this->setExpectedException('\Exception');

        $parameter = array('invalid parameter');
        $this->newInstance()->createIteratorFromArray($parameter);
    }
}

Remove obsolete and failing test testCreateIteratorFromArrayIteratorGiven

Because of the change from @white_gecko, that
StatementIteratorFactory(Impl) only has the method
createIteratorFromArray which only accepts an array for
$statements.


<?php
/**
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @since         3.3.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
namespace TestApp;

use Cake\Http\BaseApplication;
use Cake\Routing\Middleware\RoutingMiddleware;

class Application extends BaseApplication
{
    /**
     * Bootstrap hook.
     *
     * Nerfed as this is for IntegrationTestCase testing.
     *
     * @return void
     */
    public function bootstrap()
    {
        // Do nothing.
    }

    public function middleware($middleware)
    {
        $middleware->push(new RoutingMiddleware());
        $middleware->push(function ($req, $res, $next) {
            $res = $next($req, $res);

            return $res->withHeader('X-Middleware', 'true');
        });

        return $middleware;
    }
}

<?php
/**
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @since         3.3.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
namespace TestApp;

use Cake\Http\BaseApplication;
use Cake\Routing\Middleware\RoutingMiddleware;

class Application extends BaseApplication
{
    /**
     * Bootstrap hook.
     *
     * Nerfed as this is for IntegrationTestCase testing.
     *
     * @return void
     */
    public function bootstrap()
    {
        // Do nothing.
    }

    public function middleware($middleware)
    {
        $middleware->add(new RoutingMiddleware());
        $middleware->add(function ($req, $res, $next) {
            $res = $next($req, $res);

            return $res->withHeader('X-Middleware', 'true');
        });

        return $middleware;
    }
}

Update push() to addd() in test app.

Update push() to addd() in test app.


<?php namespace JamylBot\Http\Middleware;

use Closure;
use Illuminate\Contracts\Auth\Guard;

class MustBeAdmin {

    /**
     * The Guard implementation.
     *
     * @var Guard
     */
    protected $auth;

    /**
     * Create a new filter instance.
     *
     * @param  Guard  $auth
     */
    public function __construct(Guard $auth)
    {
        $this->auth = $auth;
    }

	/**
	 * Handle an incoming request.
	 *
	 * @param  \Illuminate\Http\Request  $request
	 * @param  \Closure  $next
	 * @return mixed
	 */
	public function handle($request, Closure $next)
	{
        if ($this->auth->guest() || !$this->auth->user()->admin)
        {
            if ($request->ajax())
            {
                return response('Unauthorized.', 401);
            }
            else
            {
                return redirect('/home')->with('auth_message', 'Access Denied');
            }
        }

		return $next($request);
	}

}

<?php namespace JamylBot\Http\Middleware;

use Closure;
use Illuminate\Contracts\Auth\Guard;
use JamylBot\Group;

class MustBeAdmin {

    /**
     * The Guard implementation.
     *
     * @var Guard
     */
    protected $auth;

    /**
     * Create a new filter instance.
     *
     * @param  Guard  $auth
     */
    public function __construct(Guard $auth)
    {
        $this->auth = $auth;
    }

	/**
	 * Handle an incoming request.
	 *
	 * @param  \Illuminate\Http\Request  $request
	 * @param  \Closure  $next
	 * @return mixed
	 */
	public function handle($request, Closure $next)
    {
        if ($this->auth->guest()) {
            if ($request->ajax()) {
                return response('Unauthorized.', 401);
            } else {
                return redirect('/home')->with('auth_message', 'Must be logged in.');
            }
        }
        /** @var \JamylBot\User $user */
        $user = $this->auth->user();
        if ($user->admin) {
            return $next($request);
        }
        $groupId = $request->groupId ? $request->groupId : $request->groups;
        if ($groupId) {
            /** @var Group $group */
            $group = Group::find($groupId);
            if ($group->isOwner($user->id)) {
                return $next($request);
            }
        }

        if ($request->ajax()) {
            return response('Unauthorized.', 401);
        } else {
            return redirect('/home')->with('auth_message', 'Access Denied');
        }

    }

}

Add owner support to admin middleware

Add owner support to admin middleware


<?php

class YiidisController extends CController {

  public $requireLogin = true;
  public $user;

  public function beforeAction() {
    if (isset($_GET['state']) && strstr(Yii::app()->request->getUrlReferrer(), 'facebook.com')) {
      $this->getUser(true);
      $this->redirect(array('yiidis/facebook/cleanupUrl'));
    }
    return $this->getUser();
  }

  public function getUser($login = null, $scope=array()) {
    if ($login === null) $login = $this->requireLogin;
    try {
      $this->user = Yii::app()->facebook->getUser($login);
    } catch (FacebookNeedsLogin $e) {
      Yii::app()->facebook->doLogin($scope);
      return false;
    }

    foreach ($scope as $perm) {
      if (!in_array($perm, $this->user->perms)) {
        Yii::app()->facebook->doLogin($scope);
        return false;
      }
    }

    return true;
  }

  public function getUserOrRedirect($to=array('site/index'), $scope=array()) {
    if ($this->getUser(true, $scope)) return true;
    $this->redirect($to);
    return false;
  }

  public function afterAction() {
    $count = Yii::app()->redis->conn->count;
    Yii::log("Queries: $count", "info");
  }

  public function getSession() {
    $sessionID = Yii::app()->session->sessionID;
    return RedisSession::ensure($sessionID);
  }

}

<?php

class YiidisController extends CController {

  public $requireLogin = true;
  public $user;

  public function beforeAction() {
    if (isset($_GET['state']) && strstr(Yii::app()->request->getUrlReferrer(), 'facebook.com')) {
      $this->getUser(true);
      $this->redirect(array('facebook/cleanupUrl'));
    }
    return $this->getUser();
  }

  public function getUser($login = null, $scope=array()) {
    if ($login === null) $login = $this->requireLogin;
    try {
      $this->user = Yii::app()->facebook->getUser($login);
    } catch (FacebookNeedsLogin $e) {
      Yii::app()->facebook->doLogin($scope);
      return false;
    }

    foreach ($scope as $perm) {
      if (!in_array($perm, $this->user->perms)) {
        Yii::app()->facebook->doLogin($scope);
        return false;
      }
    }

    return true;
  }

  public function getUserOrRedirect($to=array('site/index'), $scope=array()) {
    if ($this->getUser(true, $scope)) return true;
    $this->redirect($to);
    return false;
  }

  public function afterAction() {
    $count = Yii::app()->redis->conn->count;
    Yii::log("Queries: $count", "info");
  }

  public function getSession() {
    $sessionID = Yii::app()->session->sessionID;
    return RedisSession::ensure($sessionID);
  }

}

Fix redirect after logging in FB

Fix redirect after logging in FB


<?php
namespace Neos\Flow\Reflection;

/*
 * This file is part of the Neos.Flow package.
 *
 * (c) Contributors of the Neos Project - www.neos.io
 *
 * This package is Open Source Software. For the full copyright and license
 * information, please view the LICENSE file which was distributed with this
 * source code.
 */

use Neos\Flow\Annotations as Flow;

/**
 * Extended version of the ReflectionParameter
 *
 * @Flow\Proxy(false)
 */
class ParameterReflection extends \ReflectionParameter
{
    /**
     * @var string
     */
    protected $parameterClassName;

    /**
     * Returns the declaring class
     *
     * @return ClassReflection The declaring class
     */
    public function getDeclaringClass()
    {
        return new ClassReflection(parent::getDeclaringClass()->getName());
    }

    /**
     * Returns the parameter class
     *
     * @return ClassReflection The parameter class
     */
    public function getClass()
    {
        try {
            $class = parent::getClass();
        } catch (\Exception $exception) {
            return null;
        }

        return is_object($class) ? new ClassReflection($class->getName()) : null;
    }

    /**
     * @return string The name of a builtin type (e.g. string, int) if it was declared for the parameter (scalar type declaration), null otherwise
     */
    public function getBuiltinType()
    {
        $type = $this->getType();
        if (!$type instanceof \ReflectionNamedType) {
            return null;
        }
        return $type->isBuiltin() ? $type->getName() : null;
    }
}

<?php
namespace Neos\Flow\Reflection;

/*
 * This file is part of the Neos.Flow package.
 *
 * (c) Contributors of the Neos Project - www.neos.io
 *
 * This package is Open Source Software. For the full copyright and license
 * information, please view the LICENSE file which was distributed with this
 * source code.
 */

use Neos\Flow\Annotations as Flow;

/**
 * Extended version of the ReflectionParameter
 *
 * @Flow\Proxy(false)
 */
class ParameterReflection extends \ReflectionParameter
{
    /**
     * @var string
     */
    protected $parameterClassName;

    /**
     * Returns the declaring class
     *
     * @return ClassReflection The declaring class
     */
    public function getDeclaringClass()
    {
        return new ClassReflection(parent::getDeclaringClass()->getName());
    }

    /**
     * Returns the parameter class
     *
     * @return ClassReflection The parameter class
     */
    public function getClass()
    {
        try {
            $class = parent::getClass();
        } catch (\Exception $exception) {
            return null;
        }

        return is_object($class) ? new ClassReflection($class->getName()) : null;
    }

    /**
     * @return string|null The name of a builtin type (e.g. string, int) if it was declared for the parameter (scalar type declaration), null otherwise
     */
    public function getBuiltinType()
    {
        $type = $this->getType();
        if (!$type instanceof \ReflectionNamedType) {
            return null;
        }
        return $type->isBuiltin() ? $type->getName() : null;
    }
}

Fix return typehint for getBuiltinType

TASK: Fix return typehint for getBuiltinType


<?php

use yii\db\Migration;

class m160219_091156_createUser extends Migration
{
    public function up()
    {
        $userName = 'webmaster';

        $tableName = \dektrium\user\models\User::tableName();
        $query = 'SELECT COUNT(*) FROM '.$tableName.' WHERE `username`=:username';
        $count = \Yii::$app->db->createCommand($query, [':username'=>$userName])->queryScalar();
        if($count>0)
            return true;

        $user = \Yii::createObject([
            'class'    => \dektrium\user\models\User::className(),
            'scenario' => 'create',
            'username' => $userName,
            'password' => $userName,
            'email' => $userName.'@yii2enterprise.dev',
        ]);

        return $user->create();
    }

    public function down()
    {
        echo "m160219_091156_createUser cannot be reverted.\n";

        return false;
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}

<?php

use yii\db\Migration;

class m160219_091156_createUser extends Migration
{
    public function up()
    {
        if(isset($_SERVER['TRAVIS']))
            return true;

        $userName = 'webmaster';

        $tableName = \dektrium\user\models\User::tableName();
        $query = 'SELECT COUNT(*) FROM '.$tableName.' WHERE `username`=:username';
        $count = \Yii::$app->db->createCommand($query, [':username'=>$userName])->queryScalar();
        if($count>0)
            return true;

        $user = \Yii::createObject([
            'class'    => \dektrium\user\models\User::className(),
            'scenario' => 'create',
            'username' => $userName,
            'password' => $userName,
            'email' => $userName.'@yii2enterprise.dev',
        ]);

        return $user->create();
    }

    public function down()
    {
        echo "m160219_091156_createUser cannot be reverted.\n";

        return false;
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}

Update and try fix bug with migration

Update and try fix bug with migration


<?php
use \Entity\Station;
use \Entity\Song;
use \Entity\Schedule;

class Api_NowplayingController extends \PVL\Controller\Action\Api
{
    public function indexAction()
    {
        $file_path_api = DF_INCLUDE_STATIC.'/api/nowplaying_api.json';
        $np_raw = file_get_contents($file_path_api);

        // Sanity check for now playing data.
        if (empty($np_raw))
        {
            $this->returnError('Now Playing data has not loaded into the cache. Wait for file reload.');
            return;
        }

        if ($this->hasParam('id') || $this->hasParam('station'))
        {
            $np_arr = @json_decode($np_raw, TRUE);
            $np = $np_arr['result'];

            if ($this->hasParam('id'))
            {
                $id = (int)$this->getParam('id');
                foreach($np as $key => $station) {
                    if($station->id === $id) {
                        $sc = $key;
                        break;
                    }
                }

                if (!$sc)
                    return $this->returnError('Station not found!');
            }
            elseif ($this->hasParam('station'))
            {
                $sc = $this->getParam('station');
            }

            if (isset($np[$sc]))
                $this->returnSuccess($np[$sc]);
            else
                return $this->returnError('Station not found!');
        }
        else
        {
            $this->returnRaw($np_raw, 'json');
        }
    }
}

<?php
use \Entity\Station;
use \Entity\Song;
use \Entity\Schedule;

class Api_NowplayingController extends \PVL\Controller\Action\Api
{
    public function indexAction()
    {
        $file_path_api = DF_INCLUDE_STATIC.'/api/nowplaying_api.json';
        $np_raw = file_get_contents($file_path_api);

        // Sanity check for now playing data.
        if (empty($np_raw))
        {
            $this->returnError('Now Playing data has not loaded into the cache. Wait for file reload.');
            return;
        }

        if ($this->hasParam('id') || $this->hasParam('station'))
        {
            $np_arr = @json_decode($np_raw, TRUE);
            $np = $np_arr['result'];

            if ($this->hasParam('id'))
            {
                $id = (int)$this->getParam('id');
                foreach($np as $key => $np_row)
                {
                    if ($np_row['station']['id'] == $id)
                    {
                        $sc = $key;
                        break;
                    }
                }

                if (empty($sc))
                    return $this->returnError('Station not found!');
            }
            elseif ($this->hasParam('station'))
            {
                $sc = $this->getParam('station');
            }

            if (isset($np[$sc]))
                $this->returnSuccess($np[$sc]);
            else
                return $this->returnError('Station not found!');
        }
        else
        {
            $this->returnRaw($np_raw, 'json');
        }
    }
}

Fix array addressing in nowplaying API again. :P


<?php

class UsersPosts extends Seeder
{
    public function init()
    {
        $faker = $this->faker;

        $this->define('users', function () use ($faker) {
            return [
                'name' => $faker->name,
            ];
        }, $truncate = true);

        $this->define('posts', function ($data) use ($faker) {
            return [
                'user_id' => $data->user_id,
                'title'   => $faker->sentence($nbWords = 6, $variableNbWords = true),
                'content' => $faker->realText(500),
            ];
        }, $truncate = true);
    }

    public function run()
    {
        $this->seed(function ($counter){

            $user_id = $this->factory('users')->create();
            $data    = ['user_id' => $user_id];
            $random  = rand(1,10);

            for ($i=0; $i < $random; $i++) {
                $this->factory('posts')->create($data);
            }
        });
    }
}

<?php

class UsersPosts extends Seeder
{
    public function init()
    {
        $faker = $this->faker;

        $this->define('users', function () use ($faker) {
            return [
                'name' => $faker->name,
            ];
        }, $truncate = true);

        $this->define('posts', function ($data) use ($faker) {
            return [
                'user_id' => $data->user_id,
                'title'   => $faker->sentence($nbWords = 6, $variableNbWords = true),
                'content' => $faker->realText(500),
            ];
        }, $truncate = true);
    }

    public function run()
    {
        $this->seed(function ($counter){

            $userId = $this->factory('users')->create();
            $data   = ['user_id' => $userId];
            $random = rand(1,10);

            for ($i=0; $i < $random; $i++) {
                $this->factory('posts')->create($data);
            }
        });
    }
}

Fix psr naming convention for variables.


<?php
/* Development */
define('DB_NAME', getenv('DB_NAME'));
define('DB_USER', getenv('DB_USER'));
define('DB_PASSWORD', getenv('DB_PASSWORD'));
define('DB_HOST', getenv('DB_HOST') ? getenv('DB_HOST') : 'localhost');

define('WP_HOME', getenv('WP_HOME'));
define('WP_SITEURL', getenv('WP_SITEURL'));

define('SAVEQUERIES', true);
define('WP_DEBUG', true);
define('SCRIPT_DEBUG', true);

ini_set('display_errors','1');
ini_set('display_startup_errors','1');
error_reporting (E_ALL);include('index.php');

Revert "extra dev error logging"

Revert "extra dev error logging"

This reverts commit 57072be8905a19a8f7ea486006380134585d88ff.


<?php

use Illuminate\Http\Response;
use Illuminate\Support\Facades\Session;

class LanguageSwitchTest extends TestCase
{
    /**
     * Test switch language to English
     * @covers App\Http\Controllers\LanguageController::switchLang
     */
    public function testSwitchLanguageToEnglish()
    {
        $applocale = 'en_US.utf8';
        $this->call('GET', "/lang/$applocale");

        $this->assertSessionHas('language', 'en');
        $this->assertSessionHas('applocale', $applocale);
        $this->assertResponseStatus(302);
    }

    /**
     * Test switch language to Spanish Spain
     * @covers App\Http\Controllers\LanguageController::switchLang
     */
    public function testSwitchLanguageToSpanishSpain()
    {
        $applocale = 'es_ES.utf8';
        $this->call('GET', "/lang/$applocale");

        $this->assertSessionHas('language', 'es');
        $this->assertSessionHas('applocale', $applocale);
        $this->assertResponseStatus(302);
    }

    /**
     * Test switch language to Spanish Argentina
     * @covers App\Http\Controllers\LanguageController::switchLang
     */
    public function testSwitchLanguageToSpanishArgentina()
    {
        $applocale = 'es_AR.utf8';
        $this->call('GET', "/lang/$applocale");

        $this->assertSessionHas('language', 'es');
        $this->assertSessionHas('applocale', $applocale);
        $this->assertResponseStatus(302);
    }
}

<?php

use Illuminate\Http\Response;
use Illuminate\Support\Facades\Session;

class LanguageSwitchTest extends TestCase
{
    /**
     * Test switch language to English
     * @covers \App\Http\Controllers\LanguageController::switchLang
     */
    public function testSwitchLanguageToEnglish()
    {
        $applocale = 'en_US.utf8';
        $this->call('GET', "/lang/$applocale");

        $this->assertSessionHas('language', 'en');
        $this->assertSessionHas('applocale', $applocale);
        $this->assertResponseStatus(302);
    }

    /**
     * Test switch language to Spanish Spain
     * @covers \App\Http\Controllers\LanguageController::switchLang
     */
    public function testSwitchLanguageToSpanishSpain()
    {
        $applocale = 'es_ES.utf8';
        $this->call('GET', "/lang/$applocale");

        $this->assertSessionHas('language', 'es');
        $this->assertSessionHas('applocale', $applocale);
        $this->assertResponseStatus(302);
    }

    /**
     * Test switch language to Spanish Argentina
     * @covers \App\Http\Controllers\LanguageController::switchLang
     */
    public function testSwitchLanguageToSpanishArgentina()
    {
        $applocale = 'es_AR.utf8';
        $this->call('GET', "/lang/$applocale");

        $this->assertSessionHas('language', 'es');
        $this->assertSessionHas('applocale', $applocale);
        $this->assertResponseStatus(302);
    }
}

Fix docblock @covers class path

Fix docblock @covers class path


<?php namespace Algorit\Synchronizer\Request;

use Str, Exception;

trait EntityTrait {

	protected $entity;

	public function setEntity($entity)
	{
		$this->entity = $entity;

		return $this;
	}

	public function getEntity()
	{
		return $this->entity;
	}

	/**
	 * Get the base name given an entity plural name.
	 *
	 * @param  $entityName
	 * @return string
	 */
	protected function getFromEntityName($name)
	{
		if( ! is_string($name))
		{
			throw new Exception('Wrong name format');
		}

		return ucfirst(strtolower(Str::singular($name)));
	}

}

<?php namespace Algorit\Synchronizer\Request;

use Exception;

trait EntityTrait {

	protected $entity;

	public function setEntity($entity)
	{
		$this->entity = $entity;

		return $this;
	}

	public function getEntity()
	{
		return $this->entity;
	}

	/**
	 * Get the base name given an entity plural name.
	 *
	 * @param  $entityName
	 * @return string
	 */
	protected function getFromEntityName($name)
	{
		if( ! is_string($name))
		{
			throw new Exception('Wrong name format');
		}

		return ucfirst(strtolower(str_singular($name)));
	}

}

Remove dependency of Str class

Remove dependency of Str class


<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link           http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright      Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
 * @license        http://framework.zend.com/license/new-bsd New BSD License
 */
namespace Zend\Stdlib\Hydrator\Filter;

use InvalidArgumentException;
use ReflectionException;
use ReflectionMethod;
use ReflectionParameter;

/**
 * Filter that includes methods which have no parameters or only optional parameters
 */
class OptionalParametersFilter implements FilterInterface
{
    /**
     * Map of methods already analyzed
     * by {@see \Zend\Stdlib\Hydrator\Filter\OptionalParametersFilter::filter()},
     * cached for performance reasons
     *
     * @var bool[]
     */
    private static $propertiesCache = array();

    /**
     * {@inheritDoc}
     */
    public function filter($property)
    {
        if (isset(static::$propertiesCache[$property])) {
            return static::$propertiesCache[$property];
        }

        try {
            $reflectionMethod = new ReflectionMethod($property);
        } catch (ReflectionException $exception) {
            throw new InvalidArgumentException(sprintf('Method %s doesn\'t exist', $property));
        }

        $mandatoryParameters = array_filter(
            $reflectionMethod->getParameters(),
            function (ReflectionParameter $parameter) {
                return ! $parameter->isOptional();
            }
        );

        return static::$propertiesCache[$property] = empty($mandatoryParameters);
    }
}

<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link           http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright      Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
 * @license        http://framework.zend.com/license/new-bsd New BSD License
 */
namespace Zend\Stdlib\Hydrator\Filter;

use InvalidArgumentException;
use ReflectionException;
use ReflectionMethod;
use ReflectionParameter;

/**
 * Filter that includes methods which have no parameters or only optional parameters
 */
class OptionalParametersFilter implements FilterInterface
{
    /**
     * Map of methods already analyzed
     * by {@see \Zend\Stdlib\Hydrator\Filter\OptionalParametersFilter::filter()},
     * cached for performance reasons
     *
     * @var bool[]
     */
    protected static $propertiesCache = array();

    /**
     * {@inheritDoc}
     */
    public function filter($property)
    {
        if (isset(static::$propertiesCache[$property])) {
            return static::$propertiesCache[$property];
        }

        try {
            $reflectionMethod = new ReflectionMethod($property);
        } catch (ReflectionException $exception) {
            throw new InvalidArgumentException(sprintf('Method %s doesn\'t exist', $property));
        }

        $mandatoryParameters = array_filter(
            $reflectionMethod->getParameters(),
            function (ReflectionParameter $parameter) {
                return ! $parameter->isOptional();
            }
        );

        return static::$propertiesCache[$property] = empty($mandatoryParameters);
    }
}

Fix possible undefined methods in inherited classes


<?php namespace Octommerce\Octommerce\Models;

use Model;

/**
 * City Model
 */
class City extends Model
{

    /**
     * @var string The database table used by the model.
     */
    public $table = 'octommerce_octommerce_cities';

    public $timestamps = false;
    /**
     * @var array Guarded fields
     */
    protected $guarded = ['*'];

    /**
     * @var array Fillable fields
     */
    protected $fillable = [];

    /**
     * @var array Relations
     */
    public $hasOne = [];
    public $hasMany = [];
    public $belongsTo = [
        'state' => 'RainLab\Location\Models\State',
    ];
    public $belongsToMany = [];
    public $morphTo = [];
    public $morphOne = [];
    public $morphMany = [];
    public $attachOne = [];
    public $attachMany = [];

}

<?php namespace Octommerce\Octommerce\Models;

use Model;

/**
 * City Model
 */
class City extends Model
{

    /**
     * @var string The database table used by the model.
     */
    public $table = 'octommerce_octommerce_cities';

    /**
     * Implement the CityModel behavior.
     */
    public $implement = ['Octommerce.Octommerce.Behaviors.CityModel'];

    public $timestamps = false;
    /**
     * @var array Guarded fields
     */
    protected $guarded = ['*'];

    /**
     * @var array Fillable fields
     */
    protected $fillable = [];

    /**
     * @var array Relations
     */
    public $hasOne = [];
    public $hasMany = [];
    public $belongsTo = [
        'state' => 'RainLab\Location\Models\State',
    ];
    public $belongsToMany = [];
    public $morphTo = [];
    public $morphOne = [];
    public $morphMany = [];
    public $attachOne = [];
    public $attachMany = [];

}

Implement city model behavior in existing city model


<?php
/*
 * WellCommerce Open-Source E-Commerce Platform
 *
 * This file is part of the WellCommerce package.
 *
 * (c) Adam Piotrowski <adam@wellcommerce.org>
 *
 * For the full copyright and license information,
 * please view the LICENSE file that was distributed with this source code.
 */

namespace WellCommerce\Bundle\DictionaryBundle\Tests\Manager;

use WellCommerce\Bundle\CoreBundle\Test\Manager\AbstractManagerTestCase;

/**
 * Class DictionaryManagerTest
 *
 * @author  Adam Piotrowski <adam@wellcommerce.org>
 */
class DictionaryManagerTest extends AbstractManagerTestCase
{
    protected function get()
    {
        return $this->container->get('dictionary.manager');
    }
}

<?php
/*
 * WellCommerce Open-Source E-Commerce Platform
 *
 * This file is part of the WellCommerce package.
 *
 * (c) Adam Piotrowski <adam@wellcommerce.org>
 *
 * For the full copyright and license information,
 * please view the LICENSE file that was distributed with this source code.
 */

namespace WellCommerce\Bundle\DictionaryBundle\Tests\Manager;

use WellCommerce\Bundle\CoreBundle\Test\Manager\AbstractManagerTestCase;
use WellCommerce\Bundle\DoctrineBundle\Manager\ManagerInterface;

/**
 * Class DictionaryManagerTest
 *
 * @author  Adam Piotrowski <adam@wellcommerce.org>
 */
class DictionaryManagerTest extends AbstractManagerTestCase
{
    protected function get() : ManagerInterface
    {
        return $this->container->get('dictionary.manager');
    }
}

Return types in manager tests

Return types in manager tests


<?php

namespace Brick\Form\Element\Input;

use Brick\Form\Element\Input;
use Brick\Form\Attribute\AutocompleteAttribute;
use Brick\Form\Attribute\ListAttribute;
use Brick\Form\Attribute\MaxLengthAttribute;
use Brick\Form\Attribute\PatternAttribute;
use Brick\Form\Attribute\PlaceholderAttribute;
use Brick\Form\Attribute\ReadOnlyAttribute;
use Brick\Form\Attribute\RequiredAttribute;
use Brick\Form\Attribute\SizeAttribute;
use Brick\Form\Attribute\ValueAttribute;

/**
 * Represents a url input element.
 */
class Url extends Input
{
    use AutocompleteAttribute;
    use ListAttribute;
    use MaxLengthAttribute;
    use PatternAttribute;
    use PlaceholderAttribute;
    use ReadOnlyAttribute;
    use RequiredAttribute;
    use SizeAttribute;
    use ValueAttribute;

    /**
     * {@inheritdoc}
     */
    protected function getType()
    {
        return 'url';
    }

    /**
     * {@inheritdoc}
     */
    protected function doPopulate($value)
    {
        $this->setValue($value);
    }
}

<?php

namespace Brick\Form\Element\Input;

use Brick\Form\Element\Input;
use Brick\Form\Attribute\AutocompleteAttribute;
use Brick\Form\Attribute\ListAttribute;
use Brick\Form\Attribute\MaxLengthAttribute;
use Brick\Form\Attribute\PatternAttribute;
use Brick\Form\Attribute\PlaceholderAttribute;
use Brick\Form\Attribute\ReadOnlyAttribute;
use Brick\Form\Attribute\RequiredAttribute;
use Brick\Form\Attribute\SizeAttribute;
use Brick\Form\Attribute\ValueAttribute;
use Brick\Validation\Validator\UrlValidator;

/**
 * Represents a url input element.
 */
class Url extends Input
{
    use AutocompleteAttribute;
    use ListAttribute;
    use MaxLengthAttribute;
    use PatternAttribute;
    use PlaceholderAttribute;
    use ReadOnlyAttribute;
    use RequiredAttribute;
    use SizeAttribute;
    use ValueAttribute;

    /**
     * {@inheritdoc}
     */
    protected function init()
    {
        $this->addValidator(new UrlValidator());
    }

    /**
     * {@inheritdoc}
     */
    protected function getType()
    {
        return 'url';
    }

    /**
     * {@inheritdoc}
     */
    protected function doPopulate($value)
    {
        $this->setValue($value);
    }
}

Add validator to URL input

Add validator to URL input


<?php

/*
 * This file is part of Laravel Translator.
 *
 * (c) Vincent Klaiber <hello@vinkla.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

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

/**
 * This is the locales table seeder class.
 *
 * @author Vincent Klaiber <hello@vinkla.com>
 */
class CreateLocalesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('locales', function (Blueprint $table) {
            $table->increments('id');
            $table->string('language', 2);
            $table->timestamps();
        });
    }

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

<?php

/*
 * This file is part of Laravel Translator.
 *
 * (c) Vincent Klaiber <hello@vinkla.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

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

/**
 * This is the locales table seeder class.
 *
 * @author Vincent Klaiber <hello@vinkla.com>
 */
class CreateLocalesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('locales', function (Blueprint $table) {
            $table->string('id', 2)->index()->primary();
            $table->timestamps();
        });
    }

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

Make locale id a string

Make locale id a string


<?php

namespace Accompli\Chrono\Adapter;

/**
 * AdapterInterface.
 *
 * @author Niels Nijens <nijens.niels@gmail.com>
 */
interface AdapterInterface
{
    /**
     * Returns true when the adapter supports the repository URL.
     *
     * @param string $repositoryUrl
     *
     * @return bool
     */
    public function supportsRepository();

    /**
     * Returns the list of branches from the repository.
     *
     * @return array
     */
    public function getBranches();

    /**
     * Returns the list of tags from the repository.
     *
     * @return array
     */
    public function getTags();

    /**
     * Checks out a branch or tag from the repository.
     *
     * @param string $version
     *
     * @return bool
     */
    public function checkout($version);
}

<?php

namespace Accompli\Chrono\Adapter;

/**
 * AdapterInterface.
 *
 * @author Niels Nijens <nijens.niels@gmail.com>
 */
interface AdapterInterface
{
    /**
     * Returns true when the adapter supports the repository URL.
     *
     * @return bool
     */
    public function supportsRepository();

    /**
     * Returns the list of branches from the repository.
     *
     * @return array
     */
    public function getBranches();

    /**
     * Returns the list of tags from the repository.
     *
     * @return array
     */
    public function getTags();

    /**
     * Checks out a branch or tag from the repository.
     *
     * @param string $version
     *
     * @return bool
     */
    public function checkout($version);
}

Remove repositoryUrl as a parameter in comment


<?php

namespace Spark\Controller;

class ControllerCollection extends \Silex\ControllerCollection
{
    function draw(callable $callback)
    {
        $callback($this);
        return $this;
    }

    function resources($resourceName)
    {
        $this->get("/$resourceName", "$resourceName#index")
             ->bind("{$resourceName}_index");

        $this->get("/$resourceName/new", "$resourceName#new")
             ->bind("{$resourceName}_new");

        $this->get("/$resourceName/{id}", "$resourceName#show")
             ->bind("{$resourceName}_show");

        $this->get("/$resourceName/{id}/edit", "$resourceName#edit")
             ->bind("{$resourceName}_edit");

        $this->post("/$resourceName", "$resourceName#create")
             ->bind("{$resourceName}_create");

        $this->put("/$resourceName/{id}", "$resourceName#update")
             ->bind("{$resourceName}_update");

        $this->delete("/$resourceName/{id}", "$resourceName#destroy")
             ->bind("{$resourceName}_destroy");
    }

    function resource($resourceName)
    {
        $this->get("/$resourceName", "$resourceName#show");
        $this->get("/$resourceName/new", "$resourceName#new");
        $this->get("/$resourceName/edit", "$resourceName#edit");
        $this->post("/$resourceName", "$resourceName#create");
        $this->put("/$resourceName", "$resourceName#update");
        $this->delete("/$resourceName", "$resourceName#destroy");
    }
}

<?php

namespace Spark\Controller;

class ControllerCollection extends \Silex\ControllerCollection
{
    function draw(callable $callback)
    {
        if ($callback instanceof \Closure) {
            $callback = $callback->bindTo($this);
        }

        $callback($this);
        return $this;
    }

    function resources($resourceName, $options = [])
    {
        $controller = @$options['controller'] ?: $resourceName;

        $this->get("/$resourceName", "$controller#index")
             ->bind("{$resourceName}_index");

        $this->get("/$resourceName/new", "$controller#new")
             ->bind("{$resourceName}_new");

        $this->get("/$resourceName/{id}", "$controller#show")
             ->bind("{$resourceName}_show");

        $this->get("/$resourceName/{id}/edit", "$controller#edit")
             ->bind("{$resourceName}_edit");

        $this->post("/$resourceName", "$controller#create")
             ->bind("{$resourceName}_create");

        $this->put("/$resourceName/{id}", "$controller#update")
             ->bind("{$resourceName}_update");

        $this->delete("/$resourceName/{id}", "$controller#destroy")
             ->bind("{$resourceName}_destroy");
    }

    function resource($resourceName, $options = [])
    {
        $controller = @$options['controller'] ?: $resourceName;

        $this->get("/$resourceName", "$controller#show");
        $this->get("/$resourceName/new", "$controller#new");
        $this->get("/$resourceName/edit", "$controller#edit");
        $this->post("/$resourceName", "$controller#create");
        $this->put("/$resourceName", "$controller#update");
        $this->delete("/$resourceName", "$controller#destroy");
    }
}

Make controller name configurable for resource routes


<?php

namespace Banklink\Request;

/**
 * Generic request representation
 *
 * @author Roman Marintsenko <inoryy@gmail.com>
 * @since  31.10.2012
 */
abstract class Request
{
    protected $requestUrl;
    protected $requestData = array();

    /**
     * @param string $requestUrl
     * @param array  $requestData
     */
    public function __construct($requestUrl, array $requestData)
    {
        $this->requestUrl  = $requestUrl;
        $this->requestData = $requestData;
    }

    /**
     * Get request data which should be sent to desired bank
     *
     * @return array
     */
    public function getRequestData()
    {
        return $this->requestData;
    }

    /**
     * Generates HTML view for request <input> fields
     * NB! This does not generate actual <form> element, it must be rendered manually
     *
     * @return string
     */
    public function buildRequestHtml()
    {
        $output = '';

        foreach ($this->requestData as $key => $value) {
            $output .= sprintf('<input name="%s" value="%s" type="hidden" />', strtolower($key), $key, $value);
        }

        return $output;
    }

    /**
     * Get URL to where request data should be sent (most likely via POST method)
     *
     * @return string
     */
    public function getRequestUrl()
    {
        return $this->requestUrl;
    }
}

<?php

namespace Banklink\Request;

/**
 * Generic request representation
 *
 * @author Roman Marintsenko <inoryy@gmail.com>
 * @since  31.10.2012
 */
abstract class Request
{
    protected $requestUrl;
    protected $requestData = array();

    /**
     * @param string $requestUrl
     * @param array  $requestData
     */
    public function __construct($requestUrl, array $requestData)
    {
        $this->requestUrl  = $requestUrl;
        $this->requestData = $requestData;
    }

    /**
     * Get request data which should be sent to desired bank
     *
     * @return array
     */
    public function getRequestData()
    {
        return $this->requestData;
    }

    /**
     * Generates HTML view for request <input> fields
     * NB! This does not generate actual <form> element, it must be rendered manually
     *
     * @return string
     */
    public function buildRequestHtml()
    {
        $output = '';

        foreach ($this->requestData as $key => $value) {
            $output .= sprintf('<input name="%s" value="%s" type="hidden" />', $key, $value);
        }

        return $output;
    }

    /**
     * Get URL to where request data should be sent (most likely via POST method)
     *
     * @return string
     */
    public function getRequestUrl()
    {
        return $this->requestUrl;
    }
}

Remove id attribute from input fix

Remove id attribute from input fix


<?php

class PureBilling
{

    /**
     * Private key
     *
     * @var string
     */
    private static $privateKey;

    /**
     * End point
     *
     * @var string
     */
    private static $endPoint;

    /**
     * Sets privatekey
     *
     * @param string $privateKey
     */
    public static function setPrivateKey($privateKey)
    {
        self::$privateKey = $privateKey;
    }

    /**
     * Sets endPoint
     *
     * @param string $endPoint
     */
    public static function setEndPoint($endPoint)
    {
        self::$endPoint = $endPoint;
    }

    /**
     * Return privateKey
     *
     * @return string
     */
    public static function getPrivateKey()
    {
        return self::$privateKey;
    }

    /**
     * Return Endpoint
     *
     * @return string
     */
    public static function getEndPoint()
    {
        return self::$endPoint;
    }

}

<?php

class PureBilling
{

    /**
     * Private key
     *
     * @var string
     */
    private static $privateKey;

    /**
     * End point
     *
     * @var string
     */
    private static $endPoint;

    /**
     * Version
     *
     * @var string
     */
    private static $version = 'V1';

    /**
     * Sets privatekey
     *
     * @param string $privateKey
     */
    public static function setPrivateKey($privateKey)
    {
        self::$privateKey = $privateKey;
    }

    /**
     * Sets endPoint
     *
     * @param string $endPoint
     */
    public static function setEndPoint($endPoint)
    {
        self::$endPoint = $endPoint;
    }

    /**
     * Sets endPoint
     *
     * @param string $endPoint
     */
    public static function setVersion($version)
    {
        self::$version = $version;
    }

    /**
     * Return privateKey
     *
     * @return string
     */
    public static function getPrivateKey()
    {
        return self::$privateKey;
    }

    /**
     * Return Endpoint
     *
     * @return string
     */
    public static function getEndPoint()
    {
        return self::$endPoint;
    }

    /**
     * Return Version
     *
     * @return string
     */
    public static function getVersion()
    {
        return self::$version;
    }

}

Allow to define static WebService version


  <?php

  $position_label = get_option( 'staff_position_label', 'Position' );

  echo sprintf( '

%s	%s	%s	%s	%s	%s

',
    __( 'Name', 'proud-teaser' ),
    __( $position_label, 'proud-teaser' ),
    empty($this->hide['agency']) ? _x( 'Agency', 'post type singular name', 'wp-agency' ): '',
    __( 'Phone', 'proud-teaser' ),
    __( 'Contact', 'proud-teaser' ),
    empty($this->hide['social']) ? __( 'Social', 'proud-teaser' ) : ''
  );

  ?>

  <?php

  $position_label = get_option( 'staff_position_label', 'Position' );

  echo sprintf( '

%s	%s	%s	%s	%s	%s

',
    __( 'Name', 'proud-teaser' ),
    __( $position_label, 'proud-teaser' ),
    empty($this->hide['agency']) ? _x( 'Agency', 'post type singular name', 'wp-agency' ) : '',
    empty($this->hide['phone']) ? __( 'Phone', 'proud-teaser' ) : '',
    __( 'Contact', 'proud-teaser' ),
    empty($this->hide['social']) ? __( 'Social', 'proud-teaser' ) : ''
  );

  ?>

Allow Contacts: Phone column to be hidden


<?php

/*
 * This file is part of the Yodler package.
 *
 * (c) aes3xs <aes3xs@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Aes3xs\Yodler\Commander;

use Aes3xs\Yodler\Common\ProcessFactory;
use Symfony\Component\Filesystem\Filesystem;

class LocalCommander implements CommanderInterface
{
    const TIMEOUT = 300;

    protected $filesystem;
    protected $processFactory;

    public function __construct(Filesystem $filesystem, ProcessFactory $processFactory)
    {
        $this->filesystem = $filesystem;
        $this->processFactory = $processFactory;
    }

    /**
     * {@inheritdoc}
     */
    public function exec($command)
    {
        $process = $this->processFactory->create($command);
        $process->setTimeout(self::TIMEOUT);
        $process->setIdleTimeout(self::TIMEOUT);
        $process->mustRun();

        return $process->getOutput();
    }

    /**
     * {@inheritdoc}
     */
    public function send($local, $remote)
    {
        $this->filesystem->copy($local, $remote);
    }

    /**
     * {@inheritdoc}
     */
    public function recv($remote, $local)
    {
        $this->filesystem->copy($remote, $local);
    }
}

<?php

/*
 * This file is part of the Yodler package.
 *
 * (c) aes3xs <aes3xs@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Aes3xs\Yodler\Commander;

use Aes3xs\Yodler\Common\ProcessFactory;
use Symfony\Component\Filesystem\Filesystem;

class LocalCommander implements CommanderInterface
{
    const TIMEOUT = 300;

    protected $filesystem;
    protected $processFactory;

    public function __construct(Filesystem $filesystem, ProcessFactory $processFactory)
    {
        $this->filesystem = $filesystem;
        $this->processFactory = $processFactory;
    }

    /**
     * {@inheritdoc}
     */
    public function exec($command)
    {
        $process = $this->processFactory->create($command);
        $process->setTimeout(self::TIMEOUT);
        $process->setIdleTimeout(self::TIMEOUT);
        $process->mustRun();

        return $process->getOutput();
    }

    /**
     * {@inheritdoc}
     */
    public function send($local, $remote)
    {
        $this->filesystem->copy($local, $remote, true);
    }

    /**
     * {@inheritdoc}
     */
    public function recv($remote, $local)
    {
        $this->filesystem->copy($remote, $local, true);
    }
}

Fix download and upload on local commander


<?php

namespace Jstewmc\Rtf\Element\Control\Word;

/**
 * The "\cxs" control word indicates an "ignored" steno group. Steno is written as a
 * series of strokes using pure steno notation with forward-slashes between them but
 * no leading- or trailing-slashes.
 *
 * The valid steno characters, in order, are STKPWHRAO*EUFRPBLGTSDZ. When the number
 * bar is used, the digits 0-9 are valid. Finally, the hyphen (-) and number sign (#)
 * are allowed.
 *
 * A hyphen is used in cases where there may be confusion between initial and final
 * consonants. For instance, to differentiate between the strokes /RBGS and /-RBGS.
 *
 * If the number bar was used in a stroke, the stroke contains a number sign to
 * indicate that. The number sign may be anywhere within the stroke, but it should
 * probably be at one end or the other. Keep in mind, most steno programs will output
 * the digit when the number bar is used to create a number, but the number sign when
 * the number bar is used to create a stroke (e.g., "/K#").
 */
class Cxs extends Word
{
    /**
     * The "\cxs" is an ignored control word
     */
    protected $isIgnored = true;

    public function __construct(?int $parameter = null)
    {
        parent::__construct('cxs', $parameter);
    }
}

<?php

namespace Jstewmc\Rtf\Element\Control\Word;

/**
 * The "\cxs" control word indicates an "ignored" steno group. Steno is written as a
 * series of strokes using pure steno notation with forward-slashes between them but
 * no leading- or trailing-slashes.
 *
 * The valid steno characters, in order, are STKPWHRAO*EUFRPBLGTSDZ. When the number
 * bar is used, the digits 0-9 are valid. Finally, the hyphen (-) and number sign (#)
 * are allowed.
 *
 * A hyphen is used in cases where there may be confusion between initial and final
 * consonants. For instance, to differentiate between the strokes /RBGS and /-RBGS.
 *
 * If the number bar was used in a stroke, the stroke contains a number sign to
 * indicate that. The number sign may be anywhere within the stroke, but it should
 * probably be at one end or the other. Keep in mind, most steno programs will output
 * the digit when the number bar is used to create a number, but the number sign when
 * the number bar is used to create a stroke (e.g., "/K#").
 */
class Cxs extends Word
{
    /**
     * The "\cxs" is an ignored control word
     */
    protected bool $isIgnored = true;

    public function __construct(?int $parameter = null)
    {
        parent::__construct('cxs', $parameter);
    }
}

Add missing property type declaration

Add missing property type declaration


<?php

namespace Concrete\Package\CommunityStoreStripe;

use Package;
use Whoops\Exception\ErrorException;
use \Concrete\Package\CommunityStore\Src\CommunityStore\Payment\Method as PaymentMethod;

defined('C5_EXECUTE') or die(_("Access Denied."));

class Controller extends Package
{
    protected $pkgHandle = 'community_store_stripe';
    protected $appVersionRequired = '5.7.2';
    protected $pkgVersion = '1.0.4';

    public function on_start()
    {
        require __DIR__ . '/vendor/autoload.php';
    }

    public function getPackageDescription()
    {
        return t("Stripe Payment Method for Community Store");
    }

    public function getPackageName()
    {
        return t("Stripe Payment Method");
    }

    public function install()
    {
        $installed = Package::getInstalledHandles();
        if(!(is_array($installed) && in_array('community_store',$installed)) ) {
            throw new ErrorException(t('This package requires that Community Store be installed'));
        } else {
            $pkg = parent::install();
            $pm = new PaymentMethod();
            $pm->add('community_store_stripe','Stripe',$pkg);
        }

    }
    public function uninstall()
    {
        $pm = PaymentMethod::getByHandle('community_store_stripe');
        if ($pm) {
            $pm->delete();
        }
        $pkg = parent::uninstall();
    }

}
?>

<?php

namespace Concrete\Package\CommunityStoreStripe;

use Package;
use Whoops\Exception\ErrorException;
use \Concrete\Package\CommunityStore\Src\CommunityStore\Payment\Method as PaymentMethod;

defined('C5_EXECUTE') or die(_("Access Denied."));

class Controller extends Package
{
    protected $pkgHandle = 'community_store_stripe';
    protected $appVersionRequired = '5.7.2';
    protected $pkgVersion = '1.0.5';

    public function on_start()
    {
        require __DIR__ . '/vendor/autoload.php';
    }

    public function getPackageDescription()
    {
        return t("Stripe Payment Method for Community Store");
    }

    public function getPackageName()
    {
        return t("Stripe Payment Method");
    }

    public function install()
    {
        $installed = Package::getInstalledHandles();
        if(!(is_array($installed) && in_array('community_store',$installed)) ) {
            throw new ErrorException(t('This package requires that Community Store be installed'));
        } else {
            $pkg = parent::install();
            $pm = new PaymentMethod();
            $pm->add('community_store_stripe','Stripe',$pkg);
        }

    }
    public function uninstall()
    {
        $pm = PaymentMethod::getByHandle('community_store_stripe');
        if ($pm) {
            $pm->delete();
        }
        $pkg = parent::uninstall();
    }

}
?>

Increment version number for release

Increment version number for release


<?php

namespace PhpInPractice\Matters\Aggregate\Transaction;

use EventStore\EventStoreInterface;
use EventStore\WritableEvent;
use EventStore\WritableEventCollection;
use PhpInPractice\Matters\Aggregate\Transaction as TransactionInterface;

class SingleStream implements TransactionInterface
{
    /**
     * @var EventStoreInterface
     */
    private $eventstore;

    /** @var string */
    private $streamUri = '';

    /** @var WritableEvent[] */
    private $events = [];

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

    public function push($streamUri, array $writeableEvents)
    {
        if ($this->streamUri && $streamUri !== $this->streamUri) {
            throw new TransactionLimitedToASingleStreamException();
        }

        $this->streamUri = $streamUri;
        $this->events = array_merge($this->events, $writeableEvents);
    }

    public function commit()
    {
        $collection = new WritableEventCollection($this->events);
        $this->eventstore->writeToStream($this->streamUri, $collection);
    }
}

<?php

namespace PhpInPractice\Matters\Aggregate\Transaction;

use EventStore\EventStoreInterface;
use EventStore\WritableEvent;
use EventStore\WritableEventCollection;
use PhpInPractice\Matters\Aggregate\Transaction as TransactionInterface;

class SingleStream implements TransactionInterface
{
    /** @var EventStoreInterface */
    private $eventstore;

    /** @var string */
    private $streamUri = '';

    /** @var WritableEvent[] */
    private $events = [];

    public function __construct(EventStoreInterface $eventstore)
    {
        $this->eventstore = $eventstore;
        $this->resetTransaction();
    }

    public function push($streamUri, array $writeableEvents)
    {
        if ($this->streamUri && $streamUri !== $this->streamUri) {
            throw new TransactionLimitedToASingleStreamException();
        }

        $this->streamUri = $streamUri;
        $this->events = array_merge($this->events, $writeableEvents);
    }

    public function commit()
    {
        $collection = new WritableEventCollection($this->events);
        $this->eventstore->writeToStream($this->streamUri, $collection);

        $this->resetTransaction();
    }

    private function resetTransaction()
    {
        $this->streamUri = '';
        $this->events    = [];
    }
}

Clear the transaction after committing it


<?php
include '../resources/includes/PageCreator.php';

$page = new PageCreator;
$page->path_to_root = '../';
$page->title = "CheckJeStress - Admin";
$page->body = <<<EOF

Welkom bij het Admin paneel van de CheckJeStress website.

Kies een optie...

  <button type="button" class="button">Inhoud van de website aanpassen</button>
  <button type="button" class="button">Resultaten van de tests inzien</button>
EOF;
$page->create();

Fix broken link caused by base tag

Fix broken link caused by base tag


<?php

namespace Shadowhand\Test\Destrukt;

use Shadowhand\Destrukt\Dictionary;

class HashTest extends StructTest
{
    public function setUp()
    {
        $this->struct = new Dictionary([
            'one'   => 1,
            'two'   => 2,
            'three' => 3,
            'four'  => 4,
        ]);
    }

    public function testReplace()
    {
        $hash = $this->struct;
        $copy = $hash->withData([
            'one'   => 'uno',
            'two'   => 'dos',
            'three' => 'tres',
            'four'  => 'quatro',
        ]);

        $this->assertEquals(1, $hash->getValue('one'));
        $this->assertEquals('uno', $copy->getValue('one'));
    }

    public function testAppend()
    {
        $hash = $this->struct;
        $copy = $hash->withValue('five', 5);

        $this->assertEquals(4, count($hash));
        $this->assertEquals(5, count($copy));

        $this->assertEquals(null, $hash->getValue('five'));

        $this->assertEquals(5, $copy->getValue('five'));
        $this->assertEquals(null, $copy->getValue('six'));
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testAppendKeyFailure()
    {
        $this->struct->withValue(6, 'six');
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testValidateFailure()
    {
        $this->struct->validate([3, 2, 1]);
    }
}

<?php

namespace Shadowhand\Test\Destrukt;

use Shadowhand\Destrukt\Dictionary;

class DictionaryTest extends StructTest
{
    public function setUp()
    {
        $this->struct = new Dictionary([
            'one'   => 1,
            'two'   => 2,
            'three' => 3,
            'four'  => 4,
        ]);
    }

    public function testReplace()
    {
        $dict = $this->struct;
        $copy = $dict->withData([
            'one'   => 'uno',
            'two'   => 'dos',
            'three' => 'tres',
            'four'  => 'quatro',
        ]);

        $this->assertEquals(1, $dict->getValue('one'));
        $this->assertEquals('uno', $copy->getValue('one'));
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testReplaceFailure()
    {
        $this->struct->withData([3, 2, 1]);
    }

    public function testAppend()
    {
        $dict = $this->struct;
        $copy = $dict->withValue('five', 5);

        $this->assertEquals(4, count($dict));
        $this->assertEquals(5, count($copy));

        $this->assertEquals(null, $dict->getValue('five'));

        $this->assertEquals(5, $copy->getValue('five'));
        $this->assertEquals(null, $copy->getValue('six'));
    }

    /**
     * @expectedException \InvalidArgumentException
     */
    public function testAppendKeyFailure()
    {
        $this->struct->withValue(6, 'six');
    }
}

Fix naming issues in dictionary test

Fix naming issues in dictionary test


<?php

namespace App\Transformers\Outbound\Collections;

use App\Transformers\Outbound\CollectionsTransformer as BaseTransformer;

class Place extends BaseTransformer
{

    protected function getFields()
    {
        return [
            'type' => [
                'doc' => 'Type always takes one of the following values: AIC Gallery, AIC Storage, No location',
                'type' => 'string',
                'elasticsearch' => 'keyword',
            ],
        ];
    }

    public function getLicenseText()
    {
        return 'The data in this response is licensed under a Creative Commons Attribution 4.0 Generic License (CC-By) and the Terms and Conditions of artic.edu. Contains information from the J. Paul Getty Trust, Getty Research Institute, the Getty Thesaurus of Geographic Names, which is made available under the ODC Attribution License.';
    }

    public function getLicenseLinks()
    {
        return [
            'https://www.artic.edu/terms',
            'https://creativecommons.org/licenses/by/4.0/',
        ];
    }

    public function getLicensePriority()
    {
        return 50;
    }
}

<?php

namespace App\Transformers\Outbound\Collections;

use App\Transformers\Outbound\CollectionsTransformer as BaseTransformer;

class Place extends BaseTransformer
{

    protected function getFields()
    {
        return [
            'latitude' => [
                'doc' => 'Latitude coordinate of the center of the room',
                'type' => 'number',
                'elasticsearch' => 'float',
                'is_restricted' => true,
            ],
            'longitude' => [
                'doc' => 'Longitude coordinate of the center of the room',
                'type' => 'number',
                'elasticsearch' => 'float',
                'is_restricted' => true,
            ],
            'type' => [
                'doc' => 'Type always takes one of the following values: AIC Gallery, AIC Storage, No location',
                'type' => 'string',
                'elasticsearch' => 'keyword',
            ],
        ];
    }

    public function getLicenseText()
    {
        return 'The data in this response is licensed under a Creative Commons Attribution 4.0 Generic License (CC-By) and the Terms and Conditions of artic.edu. Contains information from the J. Paul Getty Trust, Getty Research Institute, the Getty Thesaurus of Geographic Names, which is made available under the ODC Attribution License.';
    }

    public function getLicenseLinks()
    {
        return [
            'https://www.artic.edu/terms',
            'https://creativecommons.org/licenses/by/4.0/',
        ];
    }

    public function getLicensePriority()
    {
        return 50;
    }
}

Add restricted `latitude` and `longitude` fields to `places` [API-12]


<?php

return [
    // Proxy settings
    'proxy' => [
        'default_url' => 'home',
        'prefixes' => [],
        'prefix_options' => [],
        'auto_trim' => true,
        'auto_null' => true
    ],

    // Auth settings
    'auth' => [
        'cookie_lifetime' => 86400,
        'session_lifetime' => 3600,
        'update_gap' => 1800,
        'pull_user' => false
    ],

    // LDAP settings
    'ldap' => [
        'hostname' => 'ldap.example.com',
        'port' => 389,
        'domain' => 'example.com'
    ],

    // Translator settings
    'translator' => [
        'default_locale' => 'en'
    ],
];

<?php

return [
    // Proxy settings
    'proxy' => [
        'default_url' => 'home',
        'prefixes' => [],
        'prefix_options' => [],
        'data_type' => 'query_string',
        'auto_trim' => true,
        'auto_null' => true
    ],

    // Auth settings
    'auth' => [
        'cookie_lifetime' => 86400,
        'session_lifetime' => 3600,
        'update_gap' => 1800,
        'pull_user' => false
    ],

    // LDAP settings
    'ldap' => [
        'hostname' => 'ldap.example.com',
        'port' => 389,
        'domain' => 'example.com'
    ],

    // Translator settings
    'translator' => [
        'default_locale' => 'en'
    ],
];

Revert "Suppress data_type option for proxy"

This reverts commit 366dd5d28c012a12f37aba4639d847a24456b271.


<?php

namespace Bethel\EntityBundle\Form\Handler;

use Bethel\EntityBundle\Entity\TutorSession;
use Bethel\WsapiBundle\Wsapi\WsRestApi;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\RequestStack;

class UserSearchFormHandler {
    protected $em;
    protected $requestStack;
    protected $wsapi;

    public function __construct(EntityManager $em, RequestStack $requestStack, WsRestApi $wsapi) {
        $this->em = $em;
        $this->request = $requestStack->getCurrentRequest();
        $this->wsapi = $wsapi;
    }

    public function process(Form $form) {
        if('POST' !== $this->request->getMethod()) {
            return false;
        }

        $form->submit($this->request);

        if($form->isValid()) {
            return $this->processValidForm($form);
        }

        return false;
    }

    /**
     * Processes the valid form
     *
     * @param Form $form
     * @return \Bethel\EntityBundle\Entity\Session
     */
    public function processValidForm(Form $form) {
        /** @var $session \Bethel\EntityBundle\Entity\Session */
        $searchTerms = $form->getData();

        $usernameResults = $this->wsapi->getUsername(urlencode("%" . $searchTerms['firstName'] . "%"), urlencode("%" . $searchTerms['lastName'] . "%"));

        return $usernameResults;
    }
}

<?php

namespace Bethel\EntityBundle\Form\Handler;

use Bethel\EntityBundle\Entity\TutorSession;
use Bethel\WsapiBundle\Wsapi\WsRestApi;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Form\Form;
use Symfony\Component\HttpFoundation\RequestStack;

class UserSearchFormHandler {
    protected $em;
    protected $requestStack;
    protected $wsapi;

    public function __construct(EntityManager $em, RequestStack $requestStack, WsRestApi $wsapi) {
        $this->em = $em;
        $this->request = $requestStack->getCurrentRequest();
        $this->wsapi = $wsapi;
    }

    public function process(Form $form) {
        if('POST' !== $this->request->getMethod()) {
            return false;
        }

        $form->submit($this->request);

        if($form->isValid()) {
            return $this->processValidForm($form);
        }

        return false;
    }

    /**
     * Processes the valid form
     *
     * @param Form $form
     * @return \Bethel\EntityBundle\Entity\Session
     */
    public function processValidForm(Form $form) {
        /** @var $session \Bethel\EntityBundle\Entity\Session */
        $searchTerms = $form->getData();

        $encode_percent = urlencode('%');
        $usernameResults = $this->wsapi->getUsername($encode_percent . $searchTerms['firstName'], $encode_percent . $searchTerms['lastName'] . $encode_percent);
        return $usernameResults;
    }
}

Allow username search to work with apostrophes


<?php

    include("/home/c0smic/secure/data_db_settings.php");

    $body = file_get_contents('php://input');

    $stime = "";
    $etime = "";
    $moves = "";

    function parseData($body) {
        $splitter = '|';
        global $stime, $etime, $moves;
        $inc = 1;
        while(strcmp(substr($body, $inc, 1), $splitter) > 0) {
            $stime = $stime . substr($body, $inc, 1);
            $inc++;
        }

        $inc++;
        while(strcmp(substr($body, $inc, 1), $splitter) > 0) {
            $etime = $etime . substr($body, $inc, 1);
            $inc++;
        }

        $inc++;
        while(strcmp(substr($body, $inc, 1), $splitter) > 0) {
            $moves = $moves . substr($body, $inc, 1);
        }
    }
    parseData($body);

    $conn = mysql_connect('localhost:3036', $dbuser, $dbpass);
    if(! $conn )
    {
        die('Could not connect: ' . mysql_error());
    }
    unset($dbuser, $dbpass);

    mysql_select_db('c0smic_maze-game');

    $sql= "INSERT INTO data (stime, etime, moves)
    VALUES
    ('$stime','$etime','$moves')";

    $retval = mysql_query( $sql, $conn );
    if(! $retval )
    {
        die('Could not enter data: ' . mysql_error());
    }

    mysql_close($conn);
    echo $str;

?>

<?php

    include("/home/c0smic/secure/data_db_settings.php");

    $body = file_get_contents('php://input');

    $stime = "";
    $etime = "";
    $moves = "";

    function parseData($body) {
        $splitter = substr($body, 0, 1);
        global $stime, $etime, $moves;

        $mark1 = strpos($body, $splitter, 1);
        $mark2 = strpos($body, $splitter, $mark1+1);
        $mark3 = strpos($body, $splitter, $mark2+1);

        $stime = substr($body, 1, $mark1-1);
        $etime = substr($body, $mark1+1, $mark2-$mark1-1);
        $moves = substr($body, $mark2+1, $mark3-$mark2-1);
    }
    parseData($body);

    $conn = mysql_connect('localhost:3036', $dbuser, $dbpass);
    if(! $conn )
    {
        die('Could not connect: ' . mysql_error());
    }
    unset($dbuser, $dbpass);

    mysql_select_db('c0smic_maze-game');

    $sql= "INSERT INTO data (stime, etime, moves)
    VALUES
    ('$stime','$etime','$moves')";

    $retval = mysql_query( $sql, $conn );
    if(! $retval )
    {
        die('Could not enter data: ' . mysql_error());
    }

    mysql_close($conn);
    echo $str;

?>

Complete parsing system, fully functional


<?php namespace Studious\Autologin;

use Illuminate\Support\ServiceProvider;
use Studious\Autologin\Autologin;

class AutologinServiceProvider extends ServiceProvider {

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

	/**
	 * Register the service provider.
	 *
	 * @return void
	 */
	public function register()
	{
		$this->registerAutologinProvider();
		$this->registerAutologin();
	}

	protected function registerAutologinProvider()
	{
		$this->app['autologin.provider'] = $this->app->share(function($app)
		{
			$provider = $app['config']['studious/autologin::provider'];

			$provider = 'Studious\Autologin\Providers\EloquentAutologinProvider';

			return new $provider;
		});
	}

	protected function registerAutologin()
	{
		$this->app['autologin'] = $this->app->share(function($app)
		{
			return new Autologin($app['config'], $app['url'], $app['autologin.provider']);
		});
	}

	/**
	 * Boot the service provider.
	 *
	 * @return void
	 */
	public function boot()
	{
		$this->package('studious/autologin');

		include __DIR__.'/../../routes.php';
	}

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

}

<?php namespace Studious\Autologin;

use Illuminate\Support\ServiceProvider;
use Studious\Autologin\Autologin;

class AutologinServiceProvider extends ServiceProvider {

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

	/**
	 * Register the service provider.
	 *
	 * @return void
	 */
	public function register()
	{
		$this->registerAutologinProvider();
		$this->registerAutologin();
	}

	protected function registerAutologinProvider()
	{
		$this->app['autologin.provider'] = $this->app->share(function($app)
		{
			$provider = $app['config']['autologin::provider'];

			return new $provider;
		});
	}

	protected function registerAutologin()
	{
		$this->app['autologin'] = $this->app->share(function($app)
		{
			return new Autologin($app['config'], $app['url'], $app['autologin.provider']);
		});
	}

	/**
	 * Boot the service provider.
	 *
	 * @return void
	 */
	public function boot()
	{
		$this->package('studious/autologin');

		include __DIR__.'/../../routes.php';
	}

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

}

Load correct provider from config file

Load correct provider from config file


<?php

use Sami\RemoteRepository\GitHubRemoteRepository;
use Sami\Sami;
use Symfony\Component\Finder\Finder;

// Download sami via
//      curl -O http://get.sensiolabs.org/sami.phar
// and run
//      php sami.phar update sami-config.php

$iterator = Finder::create()
    ->files()
    ->name('*.php')
    ->exclude('Commands')
    ->exclude('Providers')
    ->in('./src');

return new Sami($iterator, [
    'title'             => 'Hive API',
    'remote_repository' => new GitHubRemoteRepository('r3oath/hive', './'),
]);

<?php

use Sami\RemoteRepository\GitHubRemoteRepository;
use Sami\Sami;
use Symfony\Component\Finder\Finder;

// Download sami via
//      curl -O http://get.sensiolabs.org/sami.phar
// and run
//      php sami.phar update sami-config.php

$iterator = Finder::create()
    ->files()
    ->name('*.php')
    ->exclude('Commands')
    ->exclude('Providers')
    ->in('./src');

return new Sami($iterator, [
    'title'             => 'Hive API',
]);

Update config, remove repo url.

Update config, remove repo url.


<?php

/*
 * This file is apart of the DiscordPHP project.
 *
 * Copyright (c) 2016-2020 David Cole <david.cole1340@gmail.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the LICENSE.md file.
 */

namespace Discord\Repository\Channel;

use Discord\Parts\Channel\Message;
use Discord\Repository\AbstractRepository;

/**
 * Contains messages sent to channels.
 *
 * @see Discord\Parts\Channel\Message
 * @see Discord\Parts\Channel\Channel
 */
class MessageRepository extends AbstractRepository
{
    /**
     * {@inheritdoc}
     */
    protected $endpoints = [
        'get' => 'channels/:channel_id/messages/:id',
        'create' => 'channels/:channel_id/messages',
        'update' => 'channels/:channel_id/messages/:id',
        'delete' => 'channels/:channel_id/messages/:id',
    ];

    /**
     * {@inheritdoc}
     */
    protected $part = Message::class;
}

<?php

/*
 * This file is apart of the DiscordPHP project.
 *
 * Copyright (c) 2016-2020 David Cole <david.cole1340@gmail.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the LICENSE.md file.
 */

namespace Discord\Repository\Channel;

use Discord\Parts\Channel\Message;
use Discord\Repository\AbstractRepository;

/**
 * Contains messages sent to channels.
 *
 * @see Discord\Parts\Channel\Message
 * @see Discord\Parts\Channel\Channel
 */
class MessageRepository extends AbstractRepository
{
    /**
     * {@inheritdoc}
     */
    protected $endpoints = [
        'get' => 'channels/:channel_id/messages/:id',
        'update' => 'channels/:channel_id/messages/:id',
        'delete' => 'channels/:channel_id/messages/:id',
    ];

    /**
     * {@inheritdoc}
     */
    protected $part = Message::class;
}

Remove the ability to create messages through repository