<?php
/**
 * Swiss Payment Slip TCPDF
 *
 * @license http://www.opensource.org/licenses/mit-license.php MIT License
 * @copyright 2012-2015 Some nice Swiss guys
 * @author Marc Würth ravage@bluewin.ch
 * @author Manuel Reinhard <manu@sprain.ch>
 * @author Peter Siska <pesche@gridonic.ch>
 * @link https://github.com/ravage84/SwissPaymentSlipTcpdf/
 */

namespace SwissPaymentSlip\SwissPaymentSlipTcpdf\Tests;

/**
 * Tests for the PaymentSlipTcpdf class
 *
 * @coversDefaultClass
 */
class PaymentSlipTcpdfTest extends \PHPUnit_Framework_TestCase {

}

<?php
/**
 * Swiss Payment Slip TCPDF
 *
 * @license http://www.opensource.org/licenses/mit-license.php MIT License
 * @copyright 2012-2015 Some nice Swiss guys
 * @author Marc Würth ravage@bluewin.ch
 * @author Manuel Reinhard <manu@sprain.ch>
 * @author Peter Siska <pesche@gridonic.ch>
 * @link https://github.com/ravage84/SwissPaymentSlipTcpdf/
 */

namespace SwissPaymentSlip\SwissPaymentSlipTcpdf\Tests;

/**
 * Tests for the PaymentSlipTcpdf class
 *
 * @coversDefaultClass
 */
class PaymentSlipTcpdfTest extends \PHPUnit_Framework_TestCase
{
    /**
     * Tests the displayImage method
     *
     * @return void
     * @covers ::displayImage
     */
    public function testDisplayImage()
    {
        $this->markTestIncomplete(
            'This test has not been implemented yet.'
        );
    }

    /**
     * Tests the setFont method
     *
     * @return void
     * @covers ::setFont
     */
    public function testSetFont()
    {
        $this->markTestIncomplete(
            'This test has not been implemented yet.'
        );
    }

    /**
     * Tests the setBackground method
     *
     * @return void
     * @covers ::setBackground
     */
    public function testSetBackground()
    {
        $this->markTestIncomplete(
            'This test has not been implemented yet.'
        );
    }

    /**
     * Tests the setPosition method
     *
     * @return void
     * @covers ::setPosition
     */
    public function testSetPosition()
    {
        $this->markTestIncomplete(
            'This test has not been implemented yet.'
        );
    }

    /**
     * Tests the createCell method
     *
     * @return void
     * @covers ::createCell
     */
    public function testCreateCell()
    {
        $this->markTestIncomplete(
            'This test has not been implemented yet.'
        );
    }

    /**
     * Tests the convertColor2Rgb method
     *
     * @return void
     * @covers ::convertColor2Rgb
     * @covers ::hex2RGB
     */
    public function testConvertColor2Rgb()
    {
        $this->markTestIncomplete(
            'This test has not been implemented yet.'
        );
    }
}

Add a bunch of incomplete test to shut up the CIs


<?php

namespace App\Console\Commands\Import;

use App\Models\Membership\TicketedEventType;

class ImportTicketedEventTypesFull extends AbstractImportCommand
{

    protected $signature = 'import:events-ticketed-types-full
                            {--y|yes : Answer "yes" to all prompts}';

    protected $description = "Import all ticketed event types data";

    public function handle()
    {

        $this->api = env('EVENTS_DATA_SERVICE_URL');

        if( !$this->reset() )
        {
            return false;
        }

        $this->importTicketedEventTypes();

    }

    protected function importTicketedEventTypes()
    {

        return $this->import( 'Membership', TicketedEventType::class, 'event-types' );

    }

    protected function reset()
    {

        return $this->resetData( TicketedEventType::class, 'ticketed_event_types' );

    }

    protected function save( $datum, $model, $transformer )
    {

        // TODO: Determine if this is still necessary
        $datum->source = 'galaxy';

        return parent::save( $datum, $model, $transformer );

    }

}

<?php

namespace App\Console\Commands\Import;

use App\Models\Membership\TicketedEventType;

class ImportTicketedEventTypesFull extends AbstractImportCommand
{

    protected $signature = 'import:events-ticketed-types-full
                            {--y|yes : Answer "yes" to all prompts}';

    protected $description = "Import all ticketed event types data";

    public function handle()
    {

        $this->api = env('EVENTS_DATA_SERVICE_URL');

        if( !$this->reset() )
        {
            return false;
        }

        $this->importTicketedEventTypes();

    }

    protected function importTicketedEventTypes()
    {

        return $this->import( 'Membership', TicketedEventType::class, 'event-types' );

    }

    protected function reset()
    {

        // We only need to clear a table, not flush a search index
        return $this->resetData( [], 'ticketed_event_types' );

    }

    protected function save( $datum, $model, $transformer )
    {

        // TODO: Determine if this is still necessary
        $datum->source = 'galaxy';

        return parent::save( $datum, $model, $transformer );

    }

}

Fix TicketedEventType import to not flush search


<?php
namespace Neos\Flow\Security\Authentication\Token;

/*
 * 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\Mvc\ActionRequest;

/**
 * Marker interface for authentication tokens which don't need a session.
 */
interface UsernamePasswordInterface
{
    public function getUsername(): string;

    public function getPassword(): string;
}

<?php
namespace Neos\Flow\Security\Authentication\Token;

/*
 * 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.
 */

/**
 * Marker interface for authentication tokens which hold a username and password
 */
interface UsernamePasswordInterface
{
    public function getUsername(): string;

    public function getPassword(): string;
}

Correct style and interface description

Correct style and interface description


<?php
declare(strict_types=1);

namespace SaschaEgerer\PhpstanTypo3\Reflection;

use PHPStan\Broker\Broker;
use PHPStan\Reflection\BrokerAwareClassReflectionExtension;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\MethodReflection;

class RepositoryMethodsClassReflectionExtension implements \PHPStan\Reflection\MethodsClassReflectionExtension, BrokerAwareClassReflectionExtension
{
    /**
     * @var Broker
     */
    private $broker;

    public function setBroker(Broker $broker)
    {
        $this->broker = $broker;
    }

    public function hasMethod(ClassReflection $classReflection, string $methodName): bool
    {
        if (
            !$classReflection->getNativeReflection()->hasMethod($methodName)
            && $classReflection->isSubclassOf(\TYPO3\CMS\Extbase\Persistence\Repository::class)
        ) {
            return 0 === strpos($methodName, 'findBy') || 0 === strpos($methodName, 'findOneBy');
        }
        return false;
    }

    public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection
    {
        if (0 === strpos($methodName, 'findOneBy')) {
            $methodReflection = new RepositoryFindOneByMethodReflection($classReflection, $methodName, $this->broker);
        } else {
            $methodReflection = new RepositoryFindByMethodReflection($classReflection, $methodName, $this->broker);
        }

        return $methodReflection;
    }
}

<?php
declare(strict_types=1);

namespace SaschaEgerer\PhpstanTypo3\Reflection;

use PHPStan\Broker\Broker;
use PHPStan\Reflection\BrokerAwareExtension;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\MethodsClassReflectionExtension;

class RepositoryMethodsClassReflectionExtension implements MethodsClassReflectionExtension, BrokerAwareExtension
{
    /**
     * @var Broker
     */
    private $broker;

    public function setBroker(Broker $broker)
    {
        $this->broker = $broker;
    }

    public function hasMethod(ClassReflection $classReflection, string $methodName): bool
    {
        if (
            !$classReflection->getNativeReflection()->hasMethod($methodName)
            && $classReflection->isSubclassOf(\TYPO3\CMS\Extbase\Persistence\Repository::class)
        ) {
            return 0 === strpos($methodName, 'findBy') || 0 === strpos($methodName, 'findOneBy');
        }
        return false;
    }

    public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection
    {
        if (0 === strpos($methodName, 'findOneBy')) {
            $methodReflection = new RepositoryFindOneByMethodReflection($classReflection, $methodName, $this->broker);
        } else {
            $methodReflection = new RepositoryFindByMethodReflection($classReflection, $methodName, $this->broker);
        }

        return $methodReflection;
    }
}

Use BrokerAwareExtension instead of deprecated BrokerAwareClassReflectionExtension


<?php namespace FOO; ?>

<div style="<?= $panel_style ?>; display: table; width: 100%">

  <div style="<?= $table_container_style ?>">

    <?php if($vertical): ?>
      <?php require(__DIR__ . '/alert_list.php'); ?>
    <?php else: ?>
      <?php require(__DIR__ . '/alert_table.php'); ?>
    <?php endif ?>

  <h2 style="<?= $panel_content_style ?>">
    <a style="<?= $link_style ?>" href="<?= $base_url ?>/search/<?= $search['id'] ?>"><?= Util::escape($search['name']) ?>
    <small style="<?= $sub_style ?>">[<?= count($alerts) ?> Alert<?= count($alerts) != 1 ? 's':'' ?>]

  <p style="<?= $panel_content_style ?>">
    <?= nl2br(Util::escape($search['description'])) ?>
    <?php if($search->isTimeBased()): ?>

      Time range: <?= $search['range'] ?> minute(s)
    <?php endif ?>

<?php namespace FOO; ?>

<div style="<?= $panel_style ?>; display: table; width: 100%">

    <h2 style="<?= $panel_content_style ?>">
      <a style="<?= $link_style ?>" href="<?= $base_url ?>/search/<?= $search['id'] ?>"><?= Util::escape($search['name']) ?>
      <small style="<?= $sub_style ?>">[<?= count($alerts) ?> Alert<?= count($alerts) != 1 ? 's':'' ?>]

    <p style="<?= $panel_content_style ?>">
      <?= nl2br(Util::escape($search['description'])) ?>
      <?php if($search->isTimeBased()): ?>

        Time range: <?= $search['range'] ?> minute(s)
      <?php endif ?>

  <div style="<?= $table_container_style ?>">

    <?php if($vertical): ?>
      <?php require(__DIR__ . '/alert_list.php'); ?>
    <?php else: ?>
      <?php require(__DIR__ . '/alert_table.php'); ?>
    <?php endif ?>

Revert table ordering tweaks to alert list

This causes weird behaviour in GMail because of how it hides duplicated
content. The header toggles between under/over the alert list on every
other email.


<?php

namespace App\Console\Commands;

use Carbon\Carbon;

class ImportWeb extends ImportWebFull
{

    protected $signature = 'import:web';

    protected $description = "Import web CMS data that has been updated since the last import";

    protected $isPartial = true;

    public function handle()
    {

        $this->importEndpoints();
    }

}

<?php

namespace App\Console\Commands;

use Carbon\Carbon;

class ImportWeb extends ImportWebFull
{

    protected $signature = 'import:web';

    protected $description = "Import web CMS data that has been updated since the last import";

    protected $isPartial = true;

    public function handle()
    {

        $this->api = env('WEB_CMS_DATA_SERVICE_URL');

        $this->importEndpoints();

    }

}

Add API URL to import:web

Add API URL to import:web


<?php

class Denkmal_Maintenance_Cli extends CM_Maintenance_Cli {

    /**
     * @synchronized
     */
    protected function _registerCallbacks() {
        parent::_registerCallbacks();
        $this->_registerClockworkCallbacks(new DateInterval('PT12H'), array(
            'Scraper'     => function () {
                    foreach (Denkmal_Scraper_Source_Abstract::getAll() as $scraper) {
                        $scraper->run();
                    }
                },
            'Check links' => function () {
                    $linkList = new Denkmal_Paging_Link_All();
                    foreach ($linkList as $link) {
                        /** @var Denkmal_Model_Link $link */
                        try {
                            CM_Util::getContents($link->getUrl());
                        } catch (CM_Exception_Invalid $ex) {
                            $link->setFailedCount($link->getFailedCount() + 1);
                        }
                    }
                },
        ));
    }

    public static function getPackageName() {
        return 'maintenance';
    }
}

<?php

class Denkmal_Maintenance_Cli extends CM_Maintenance_Cli {

    /**
     * @synchronized
     */
    protected function _registerCallbacks() {
        parent::_registerCallbacks();
        $this->_registerClockworkCallbacks(new DateInterval('PT12H'), array(
            'Scraper'     => function () {
                    foreach (Denkmal_Scraper_Source_Abstract::getAll() as $scraper) {
                        $scraper->run();
                    }
                },
            'Check links' => function () {
                    $linkList = new Denkmal_Paging_Link_All();
                    foreach ($linkList as $link) {
                        /** @var Denkmal_Model_Link $link */
                        try {
                            CM_Util::getContents($link->getUrl());
                            $link->setFailedCount(0);
                        } catch (CM_Exception_Invalid $ex) {
                            $link->setFailedCount($link->getFailedCount() + 1);
                        }
                    }
                },
        ));
    }

    public static function getPackageName() {
        return 'maintenance';
    }
}

Set link failedCount to zero on success

Set link failedCount to zero on success


<?php
namespace keeko\framework\utils;

use Tobscure\JsonApi\Parameters as BaseParameters;

class Parameters extends BaseParameters {

	public function getPage($key, $default = null) {
		$page = $this->getInput('page', []);

		return isset($page[$key]) ? $page[$key] : $default;
	}
}

<?php
namespace keeko\framework\utils;

use Tobscure\JsonApi\Parameters as BaseParameters;

class Parameters extends BaseParameters {

	public function getPage($key, $default = null) {
		$page = $this->getInput('page', []);

		return isset($page[$key]) ? $page[$key] : $default;
	}

	public function toQueryString(array $overwrites = []) {
		$parts = [];

		if ($include = $this->getInput('include')) {
			$parts['include'] = $include;
		}

		if ($sort = $this->getInput('sort')) {
			$parts['sort'] = $sort;
		}

		$parts['fields'] = $this->getFields();

		if ($filter = $this->getInput('filter')) {
			$parts['filter'] = $filter;
		}

		$parts['page'] = $this->getInput('page', []);

		// apply overwrites
		$parts = array_merge($parts, $overwrites);

		// to string
		$qs = [];
		foreach ($parts as $key => $value) {
			if (is_array($value)) {
				foreach ($value as $k => $val) {
					$qs[] = $key . '[' . $k . ']=' . $val;
				}
			} else {
				$qs[] = $key . '=' .$value;
			}
		}

		return implode('&', $qs);
	}
}

Make parameters use to create a query string from it


<?php
/**
 * @author         Pierre-Henry Soria <hello@ph7cms.com>
 * @copyright      (c) 2018-2019, Pierre-Henry Soria. All Rights Reserved.
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package        PH7 / App / System / Core / Class
 */

namespace PH7;

use PH7\Framework\Math\Measure\Year as YearMeasure;

class UserBirthDateCore
{
    const DEFAULT_AGE = 30;
    const BIRTHDATE_DELIMITER = '-';
    const NUMBER_ARRAY_ELEMENTS = 3;

    /**
     * @param string $sBirthDate YYYY-MM-DD format.
     *
     * @return int
     */
    public static function getAgeFromBirthDate($sBirthDate)
    {
        $aAge = explode(self::BIRTHDATE_DELIMITER, $sBirthDate);

        if (self::isInvalidBirthDate($aAge)) {
            return self::DEFAULT_AGE;
        }

        return (new YearMeasure($aAge[0], $aAge[1], $aAge[2]))->get();
    }

    /**
     * @param array $aAge
     * @return bool
     */
    private static function isInvalidBirthDate(array $aAge)
    {
        $iAgeElements = count($aAge);

        return $iAgeElements < self::NUMBER_ARRAY_ELEMENTS ||
            $iAgeElements > self::NUMBER_ARRAY_ELEMENTS;
    }
}

<?php
/**
 * @author         Pierre-Henry Soria <hello@ph7cms.com>
 * @copyright      (c) 2018-2019, Pierre-Henry Soria. All Rights Reserved.
 * @license        GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
 * @package        PH7 / App / System / Core / Class
 */

namespace PH7;

use PH7\Framework\Math\Measure\Year as YearMeasure;

class UserBirthDateCore
{
    const DEFAULT_AGE = 30;
    const BIRTHDATE_DELIMITER = '-';
    const NUMBER_ARRAY_ELEMENTS = 3;

    /**
     * @param string $sBirthDate YYYY-MM-DD format.
     *
     * @return int
     */
    public static function getAgeFromBirthDate($sBirthDate)
    {
        $aAge = explode(self::BIRTHDATE_DELIMITER, $sBirthDate);

        if (self::isInvalidBirthDate($aAge)) {
            return self::DEFAULT_AGE;
        }

        return (new YearMeasure($aAge[0], $aAge[1], $aAge[2]))->get();
    }

    /**
     * @param array $aAge
     *
     * @return bool
     */
    private static function isInvalidBirthDate(array $aAge)
    {
        $iAgeElements = count($aAge);

        return $iAgeElements < self::NUMBER_ARRAY_ELEMENTS ||
            $iAgeElements > self::NUMBER_ARRAY_ELEMENTS;
    }
}

[CONSISTENCY] Add newline between different phpdoc tag in docBlock


<?php

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

class CreateVotesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('votes', function (Blueprint $table) {
            $table->unsignedInteger('user_id');
            $table->unsignedInteger('votable_id');
            $table->string('votable_type')->index();

            $table->timestamps();
        });
    }

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

<?php

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

class CreateVotesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('votes', function (Blueprint $table) {
            $table->unsignedInteger('user_id');
            $table->unsignedInteger('votable_id');
            $table->string('votable_type')->index();
            $table->enum('type', ['up_vote', 'down_vote'])->default('up_vote');

            $table->timestamps();
        });
    }

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

Add the type column for votes table

Add the type column for votes table


<?php

namespace WyriHaximus\React\Tests\Inspector;

use Phake;
use React\EventLoop\Timer\Timer;
use WyriHaximus\React\Inspector\LoopDecorator;
use WyriHaximus\React\Inspector\TimerDecorator;

class TimerDecoratorTest extends \PHPUnit_Framework_TestCase
{
    public function testTimerDecorator()
    {
        $func = function () {};

        $loop = Phake::mock('React\EventLoop\LoopInterface');

        $decoratedLoop = new LoopDecorator($loop);
        $timer = new Timer($decoratedLoop, 123, $func, true);
        $decoratedTimer = new TimerDecorator($decoratedLoop, $timer);

        Phake::when($loop)->isTimerActive($timer)->thenReturn(true);

        $this->assertSame($decoratedLoop, $decoratedTimer->getLoop());
        $this->assertSame(123.0, $decoratedTimer->getInterval());
        $this->assertSame($func, $decoratedTimer->getCallback());
        $this->assertSame(null, $decoratedTimer->getData());

        $data = 'sdkgn ihrngihnrigihrw';
        $decoratedTimer->setData($data);
        $this->assertSame($data, $decoratedTimer->getData());

        $this->assertSame(true, $decoratedTimer->isPeriodic());
        $this->assertSame(true, $decoratedTimer->isActive());
    }
}

<?php

namespace WyriHaximus\React\Tests\Inspector;

use Phake;
use React\EventLoop\Timer\Timer;
use WyriHaximus\React\Inspector\LoopDecorator;
use WyriHaximus\React\Inspector\TimerDecorator;

class TimerDecoratorTest extends \PHPUnit_Framework_TestCase
{
    public function testTimerDecorator()
    {
        $func = function () {};

        $loop = Phake::mock('React\EventLoop\LoopInterface');

        $decoratedLoop = new LoopDecorator($loop);
        $timer = new Timer($decoratedLoop, 123, $func, true);
        $decoratedTimer = new TimerDecorator($decoratedLoop, $timer);

        Phake::when($loop)->isTimerActive($timer)->thenReturn(true);

        $this->assertSame($decoratedLoop, $decoratedTimer->getLoop());
        $this->assertSame(123.0, $decoratedTimer->getInterval());
        $this->assertSame($func, $decoratedTimer->getCallback());
        $this->assertSame(null, $decoratedTimer->getData());

        $data = 'sdkgn ihrngihnrigihrw';
        $decoratedTimer->setData($data);
        $this->assertSame($data, $decoratedTimer->getData());

        $this->assertSame(true, $decoratedTimer->isPeriodic());
        $this->assertSame(true, $decoratedTimer->isActive());

        $decoratedTimer->cancel();
        Phake::verify($loop)->cancelTimer($timer);
    }
}

Add extra assertion for cancel timer

Add extra assertion for cancel timer


<?php

/** @var \Codeception\Scenario $scenario $I */
$I = new FunctionalTester($scenario);
$I->wantTo('perform analysis and see svg results');

$configFolder = codecept_data_dir('svg' . DIRECTORY_SEPARATOR . 'config');
$expectationFolder = codecept_data_dir('svg' . DIRECTORY_SEPARATOR . 'expectation');
$outputFolder = codecept_output_dir('svg');

array_map('unlink', glob($outputFolder . DIRECTORY_SEPARATOR . '*.svg'));

$dir = new \DirectoryIterator($configFolder);
foreach ($dir as $fileinfo) {
    if (!$fileinfo->isDot()) {
        exec('./bin/phpda analyze ' . $fileinfo->getRealPath(), $output);
        $result = sha1_file($outputFolder . DIRECTORY_SEPARATOR . $fileinfo->getBasename('yml') . 'svg');
        $expectation = sha1_file($expectationFolder . DIRECTORY_SEPARATOR . $fileinfo->getBasename('yml') . 'svg');
        if ($expectation !== $result) {
            //throw new \Exception($fileinfo->getBasename('yml') . ' not working');
        }
    }
}

<?php

/** @var \Codeception\Scenario $scenario $I */
$I = new FunctionalTester($scenario);
$I->wantTo('perform analysis and see svg results');

@mkdir(codecept_output_dir() . 'svg');

$configFolder = codecept_data_dir('svg' . DIRECTORY_SEPARATOR . 'config');
$expectationFolder = codecept_data_dir('svg' . DIRECTORY_SEPARATOR . 'expectation');
$outputFolder = codecept_output_dir('svg');

array_map('unlink', glob($outputFolder . DIRECTORY_SEPARATOR . '*.svg'));

$dir = new \DirectoryIterator($configFolder);
foreach ($dir as $fileinfo) {
    if (!$fileinfo->isDot()) {
        exec('./bin/phpda analyze ' . $fileinfo->getRealPath(), $output);
        $result = sha1_file($outputFolder . DIRECTORY_SEPARATOR . $fileinfo->getBasename('yml') . 'svg');
        $expectation = sha1_file($expectationFolder . DIRECTORY_SEPARATOR . $fileinfo->getBasename('yml') . 'svg');
        if ($expectation !== $result) {
            //throw new \Exception($fileinfo->getBasename('yml') . ' not working');
        }
    }
}

Add codeception framework for E2E tests

Add codeception framework for E2E tests [wip]


<?php
require_once 'core/slir.class.php';

abstract class SLIRTestCase extends PHPUnit_Framework_TestCase
{
  protected function setUp()
  {
    $slir = new SLIR();
    $slir->getConfig();
    SLIRConfig::$defaultImagePath = null;
    SLIRConfig::$forceQueryString = false;

    // Try to fix documentRoot for CLI
    SLIRConfig::$documentRoot = preg_replace('`/slir/?$`', '', SLIRConfig::$documentRoot);
  }
}

<?php
require_once 'core/slir.class.php';

abstract class SLIRTestCase extends PHPUnit_Framework_TestCase
{
  /**
   * @var SLIR
   */
  protected $slir;

  /**
   * @return void
   */
  protected function setUp()
  {
    $this->slir = new SLIR();
    $this->slir->getConfig();
    SLIRConfig::$defaultImagePath = null;
    SLIRConfig::$forceQueryString = false;

    // Try to fix documentRoot for CLI
    SLIRConfig::$documentRoot = preg_replace('`/slir/?$`', '', SLIRConfig::$documentRoot);
  }

  /**
   * @return void
   */
  protected function tearDown()
  {
    unset($this->slir);
  }
}

Set up the instance of SLIR as a property of the object so it can be used by test cases if we want to.


<?php

	$dbh = new PDO('mysql:host=xxx;port=xxx;dbname=xxx', 'xxx', 'xxx', array( PDO::ATTR_PERSISTENT => false));

?>

<?php
	require_once('config.php');

	$dbh = new PDO('mysql:host='.HOST, DB_USER, DB_PASS);

	//Create the database if it doesn't exist
	$dbh->query("CREATE DATABASE IF NOT EXISTS " . DB_NAME);
	$dbh->query("USE " . DB_NAME);

	//Create Tables if they don't exist
	$dbh->query("CREATE TABLE IF NOT EXISTS `types` (pkId INT(10) AUTO_INCREMENT PRIMARY KEY, description VARCHAR(20) );");
	$dbh->query("CREATE TABLE IF NOT EXISTS `pins` ( pkId INT(10) AUTO_INCREMENT PRIMARY KEY, lon VARCHAR(64), lat VARCHAR(64), fkType INT(10) REFERENCES types(pkId));");

?>

Create setup script for database creation


<?php
namespace Neos\Flow\Tests\Functional\Reflection\Fixtures\Model;

/*
 * 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;

/**
 * A model fixture which is used for testing the class schema building
 *
 * @Flow\Entity
 */
class SuperEntity extends AbstractSuperEntity
{
    /**
     * Just a normal string
     *
     * @var string|null
     */
    protected $someString;

    /**
     * Just an int that can be null
     *
     * @var null|int
     */
    protected $someNullableInt;
}

<?php
namespace Neos\Flow\Tests\Functional\Reflection\Fixtures\Model;

/*
 * 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;

/**
 * A model fixture which is used for testing the class schema building
 *
 * @Flow\Entity
 */
class SuperEntity extends AbstractSuperEntity
{
    /**
     * Just a normal string
     *
     * @var string
     */
    protected $someString;

    /**
     * Just a string that can be null
     *
     * @var string|null
     */
    protected $someNullableString;

    /**
     * Just an int that can be null
     *
     * @var null|int
     */
    protected $someNullableInt;

    /**
     * Just an array of strings that can be null
     *
     * @var array<string>|null
     */
    protected $someNullableArrayOfStrings;

}

TASK: Move nullable type to a separate property


<?php

namespace Tests\Unit;

use App\Models\Collections\Image;

class ImageTest extends AssetTestCase
{

    protected $model = Image::class;

    protected $route = 'images';

    // /** @test */
    // public function it_deletes_a_single_image()
    // {

    //     $this->make(Image::class);

    //     $response = $this->deleteJson('api/v1/images/' .$this->ids[0]);
    //     $response->assertSuccessful();

    // }

    // /** @test */
    // public function it_deletes_multiple_images()
    // {

    //     $this->times(5)->make(Image::class);

    //     $response = $this->deleteJson('api/v1/images?ids=' .implode(',',array_slice($this->ids, 0, 3)));
    //     $response->assertSuccessful();

    // }

    // /** @test */
    // public function it_overwrites_an_existing_image()
    // {

    //     $this->make(Image::class);

    //     $response = $this->putJson('api/v1/images/' .$this->ids[0]);
    //     $response->assertSuccessful();

    // }

    // /** @test */
    // public function it_adds_a_new_image()
    // {

    //     $this->make(Image::class);

    //     $response = $this->postJson('api/v1/images');
    //     $response->assertSuccessful();

    // }

}

<?php

namespace Tests\Unit;

use App\Models\Collections\Image;

class ImageTest extends AssetTestCase
{

    protected $model = Image::class;

    protected $route = 'images';

}

Delete commented-out tests for image handling

The data hub will not be used for image upload for the foreseeable
future. I wanted to make this a dedicated commit, so that its easier
to reference (and potentially reverse) later.


<?php
namespace Avatar;

class Hooks {

	public static function onGetPreferences($user, &$preferences) {
		global $wgDefaultAvatarRes;
		$link = \Linker::link(\SpecialPage::getTitleFor("AvatarUpload"), wfMsg('avatarupload'));

		$preferences['editavatar'] = array(
			'type' => 'info',
			'raw' => true,
			'label-message' => 'prefs-editavatar',
			'default' => 'getName()}/$wgDefaultAvatarRes")->getLinkURL() . '" width="32"> ' . $link,
			'section' => 'personal/info',
		);

		return true;
	}
}

<?php
namespace Avatar;

class Hooks {

	public static function onGetPreferences($user, &$preferences) {
		$link = \Linker::link(\SpecialPage::getTitleFor("AvatarUpload"), wfMsg('avatarupload'));

		$preferences['editavatar'] = array(
			'type' => 'info',
			'raw' => true,
			'label-message' => 'prefs-editavatar',
			'default' => 'getName()}")->getLinkURL() . '" width="32"> ' . $link,
			'section' => 'personal/info',
		);

		return true;
	}
}

Remove resolution specification to allow cache


<?php

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

namespace SymfonyCorp\Connect\DependencyInjection\Security\Factory;

use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;

class AuthenticatorConnectFactory extends ConnectFactory implements AuthenticatorFactoryInterface
{
}

<?php

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

namespace SymfonyCorp\Connect\DependencyInjection\Security\Factory;

use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;

if (interface_exists(EntryPointFactoryInterface::class)) {
    class AuthenticatorConnectFactory extends ConnectFactory implements AuthenticatorFactoryInterface, EntryPointFactoryInterface
    {
    }
} else {
    class AuthenticatorConnectFactory extends ConnectFactory implements AuthenticatorFactoryInterface
    {
    }
}

Fix compatibility with SecurityBundle 5.2


<?php

/*
 * This file is part of the pinepain/php-weak PHP extension.
 *
 * Copyright (c) 2016 Bogdan Padalko <zaq178miami@gmail.com>
 *
 * Licensed under the MIT license: http://opensource.org/licenses/MIT
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code or visit http://opensource.org/licenses/MIT
 */

namespace Weak;

/**
 * Check whether value is refcounted
 *
 * @param mixed $value
 *
 * @return bool
 */
function refcounted(mixed $value) : bool {}

/**
 * Get real value references count (not counting value reference passed as a function argument)
 *
 * @param mixed $value
 *
 * @return int
 */
function refcount(mixed $value) : int {}

/**
 * Check whether object has weak references or ever had them
 *
 * @param object $value
 *
 * @return bool
 */
function weakrefcounted(object $value) : bool {}

/**
 * Get object's weak references count

 * @param object $value
 *
 * @return int
 */
function weakrefcount(object $value) : int {}

/**
 * Get object's weak references
 *
 * @param object $value
 *
 * @return mixed
 */
function weakrefs(object $value) : array {}

/**
 * Get object's weak references
 *
 * @param object $value
 *
 * @return int
 */
function object_handle(object $value) : int {}

<?php

/*
 * This file is part of the pinepain/php-weak PHP extension.
 *
 * Copyright (c) 2016 Bogdan Padalko <zaq178miami@gmail.com>
 *
 * Licensed under the MIT license: http://opensource.org/licenses/MIT
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code or visit http://opensource.org/licenses/MIT
 */

namespace Weak;

/**
 * Check whether value is refcounted
 *
 * @param mixed $value
 *
 * @return bool
 */
function refcounted(mixed $value) : bool {}

/**
 * Get real value references count (not counting value reference passed as a function argument)
 *
 * @param mixed $value
 *
 * @return int
 */
function refcount(mixed $value) : int {}

/**
 * Check whether object has weak references
 *
 * @param object $value
 *
 * @return bool
 */
function weakrefcounted(object $value) : bool {}

/**
 * Get object's weak references count

 * @param object $value
 *
 * @return int
 */
function weakrefcount(object $value) : int {}

/**
 * Get object's weak references
 *
 * @param object $value
 *
 * @return mixed
 */
function weakrefs(object $value) : array {}

/**
 * Get object's weak references
 *
 * @param object $value
 *
 * @return int
 */
function object_handle(object $value) : int {}

Check whether object has weakrefs, not whether he was ever refcounted


<?php

namespace Backend\Modules\Pages\Tests\Actions;

use Backend\Core\Tests\BackendWebTestCase;
use Symfony\Bundle\FrameworkBundle\Client;

final class IndexTest extends BackendWebTestCase
{
    public function testAuthenticationIsNeeded(Client $client): void
    {
        $this->assertAuthenticationIsNeeded($client, '/private/en/pages/index');
    }

    public function testIndexContainsPages(): void
    {
        $client = static::createClient();
        $this->login($client);

        $client->request('GET', '/private/en/pages/index');

        self::assertContains(
            'Home',
            $client->getResponse()->getContent()
        );

        // some stuff we also want to see on the blog index
        self::assertContains(
            'Add page',
            $client->getResponse()->getContent()
        );
        self::assertContains(
            'Recently edited',
            $client->getResponse()->getContent()
        );
    }
}

<?php

namespace Backend\Modules\Pages\Tests\Actions;

use Backend\Core\Tests\BackendWebTestCase;
use Symfony\Bundle\FrameworkBundle\Client;

final class IndexTest extends BackendWebTestCase
{
    public function testAuthenticationIsNeeded(Client $client): void
    {
        $this->assertAuthenticationIsNeeded($client, '/private/en/pages/index');
    }

    public function testIndexContainsPages(Client $client): void
    {
        $this->login($client);

        $this->assertPageLoadedCorrectly(
            $client,
            '/private/en/pages/index',
            [
                'Home',
                'Add page',
                'Recently edited',
            ]
        );
    }
}

Clean up page index test

Clean up page index test


<?php

declare(strict_types=1);

namespace LAG\AdminBundle\Event\Listener\Menu;

use LAG\AdminBundle\Admin\Helper\AdminHelperInterface;
use LAG\AdminBundle\Event\Events\Configuration\MenuConfigurationEvent;

class MenuConfigurationListener
{
    private array $menusConfiguration;
    private AdminHelperInterface $helper;

    public function __construct(array $menusConfiguration, AdminHelperInterface $helper)
    {
        $this->helper = $helper;
        $this->menusConfiguration = $menusConfiguration;
    }

    public function __invoke(MenuConfigurationEvent $event): void
    {
        if (!$this->helper->hasAdmin()) {
            return;
        }
        $admin = $this->helper->getAdmin();
        $menuConfiguration = $event->getMenuConfiguration();
        $menuConfigurationFromAction = $admin->getAction()->getConfiguration()->getMenus();
        $inherits = $menuConfiguration['inherits'] ?? false;
        $menuConfiguration = $menuConfigurationFromAction[$event->getMenuName()] ?? [];

        if ($inherits) {
            $menuConfiguration = array_merge($this->menusConfiguration[$event->getMenuName()] ?? [], $menuConfiguration);
            $menuConfiguration = array_merge($menuConfiguration, $menuConfigurationFromAction[$event->getMenuName()]);
        }
        $event->setMenuConfiguration($menuConfiguration);
    }
}

<?php

declare(strict_types=1);

namespace LAG\AdminBundle\Event\Listener\Menu;

use LAG\AdminBundle\Admin\Helper\AdminHelperInterface;
use LAG\AdminBundle\Event\Events\Configuration\MenuConfigurationEvent;

class MenuConfigurationListener
{
    private array $menusConfiguration;
    private AdminHelperInterface $helper;

    public function __construct(array $menusConfiguration, AdminHelperInterface $helper)
    {
        $this->helper = $helper;
        $this->menusConfiguration = $menusConfiguration;
    }

    public function __invoke(MenuConfigurationEvent $event): void
    {
        $menuConfiguration = $event->getMenuConfiguration();
        $inherits = $menuConfiguration['inherits'] ?? false;
        $menuConfiguration = $menuConfigurationFromAction[$event->getMenuName()] ?? [];
        $menuConfiguration = array_merge($this->menusConfiguration[$event->getMenuName()] ?? [], $menuConfiguration);

        if ($this->helper->hasAdmin()) {
            $admin = $this->helper->getAdmin();
            $menuConfigurationFromAction = $admin->getAction()->getConfiguration()->getMenus();

            if ($inherits) {
                $menuConfiguration = array_merge($menuConfiguration, $menuConfigurationFromAction[$event->getMenuName()]);
            }
        }
        $event->setMenuConfiguration($menuConfiguration);
    }
}

Fix a bug with menu inheritance

Fix a bug with menu inheritance


<?php

namespace Spark\Core;

class Cli
{
    protected $console;
    protected $application;

    function __construct()
    {
        if ($bootstrap = $this->findApplicationBootstrap()) {
            if (!isset($_SERVER['SPARK_ENV'])) $_SERVER['SPARK_ENV'] = 'development';

            $this->application = require($bootstrap);
        } else {
            $this->application = new \Spark\Application;
        }

        $this->console = $this->application['console'];
    }

    function run()
    {
        $this->console->run();
    }

    protected function findApplicationBootstrap()
    {
        $path = "config/bootstrap.php";
        $cwd = getcwd();

        while (!$rp = realpath("$cwd/$path")) {
            $cwd .= '/..';

            if (realpath($cwd) === false) {
                break;
            }
        }

        return $rp;
    }
}

<?php

namespace Spark\Core;

class Cli
{
    function run()
    {
        if (!isset($_SERVER['SPARK_ENV'])) $_SERVER['SPARK_ENV'] = 'development';

        if ($bootstrap = $this->findApplicationBootstrap()) {
            $app = require($bootstrap);
        } else {
            $app = new \Spark\Application;
        }

        return $app['console']->run();
    }

    protected function findApplicationBootstrap()
    {
        $path = "config/bootstrap.php";
        $cwd = getcwd();

        while (!$rp = realpath("$cwd/$path")) {
            $cwd .= '/..';

            if (realpath($cwd) === false) {
                break;
            }
        }

        return $rp;
    }
}

Simplify some of the console boot code

Simplify some of the console boot code


<?php

namespace adLDAP\Tests;

use Mockery;

// Set constants for testing without LDAP support
if( ! defined('LDAP_OPT_PROTOCOL_VERSION')) define('LDAP_OPT_PROTOCOL_VERSION', 3);

if( ! defined('LDAP_OPT_REFERRALS')) define('LDAP_OPT_REFERRALS', 0);

if( ! array_key_exists('REMOTE_USER', $_SERVER)) $_SERVER['REMOTE_USER'] = 'true';

if( ! array_key_exists('KRB5CCNAME', $_SERVER)) $_SERVER['KRB5CCNAME'] = 'true';

abstract class FunctionalTestCase extends \PHPUnit_Framework_TestCase
{
    protected function mock($class)
    {
        return Mockery::mock($class);
    }
}

<?php

namespace adLDAP\Tests;

use Mockery;

abstract class FunctionalTestCase extends \PHPUnit_Framework_TestCase
{
    protected function mock($class)
    {
        return Mockery::mock($class);
    }

    public function setUp()
    {
        // Set constants for testing without LDAP support
        if( ! defined('LDAP_OPT_PROTOCOL_VERSION')) define('LDAP_OPT_PROTOCOL_VERSION', 3);

        if( ! defined('LDAP_OPT_REFERRALS')) define('LDAP_OPT_REFERRALS', 0);

        if( ! array_key_exists('REMOTE_USER', $_SERVER)) $_SERVER['REMOTE_USER'] = 'true';

        if( ! array_key_exists('KRB5CCNAME', $_SERVER)) $_SERVER['KRB5CCNAME'] = 'true';

        parent::setUp();
    }
}

Move test definitions into PHPUnit setUp method


<?php

namespace Misantron\Silex\Provider\Adapter;

use Misantron\Silex\Provider\ConfigAdapter;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Parser;

/**
 * Class YamlConfigAdapter
 * @package Misantron\Silex\Provider\Adapter
 */
class YamlConfigAdapter extends ConfigAdapter
{
    /**
     * @param \SplFileInfo $file
     * @return array
     */
    protected function parse(\SplFileInfo $file): array
    {
        $this->assertLibraryInstalled();

        try {
            $config = (new Parser())->parse(file_get_contents($file->getRealPath()));
        } catch (ParseException $e) {
            throw new \RuntimeException('Unable to parse config file: ' . $e->getMessage());
        }

        return $config;
    }

    /**
     * @return array
     */
    protected function configFileExtensions(): array
    {
        return ['yml', 'yaml'];
    }

    /**
     * @throws \RuntimeException
     */
    private function assertLibraryInstalled()
    {
        // @codeCoverageIgnoreStart
        if (!class_exists('Symfony\\Component\\Yaml\\Yaml')) {
            throw new \RuntimeException('Yaml parser component is not installed');
        }
        // @codeCoverageIgnoreEnd
    }
}

<?php

namespace Misantron\Silex\Provider\Adapter;

use Misantron\Silex\Provider\ConfigAdapter;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Parser;

/**
 * Class YamlConfigAdapter
 * @package Misantron\Silex\Provider\Adapter
 */
class YamlConfigAdapter extends ConfigAdapter
{
    /**
     * @param \SplFileInfo $file
     * @return array
     */
    protected function parse(\SplFileInfo $file): array
    {
        $this->assertLibraryInstalled();

        try {
            $config = (new Parser())->parseFile($file->getRealPath());
        } catch (ParseException $e) {
            throw new \RuntimeException('Unable to parse config file: ' . $e->getMessage());
        }

        return $config;
    }

    /**
     * @return array
     */
    protected function configFileExtensions(): array
    {
        return ['yml', 'yaml'];
    }

    /**
     * @throws \RuntimeException
     */
    private function assertLibraryInstalled()
    {
        // @codeCoverageIgnoreStart
        if (!class_exists('Symfony\\Component\\Yaml\\Yaml')) {
            throw new \RuntimeException('Yaml parser component is not installed');
        }
        // @codeCoverageIgnoreEnd
    }
}

Replace YAML parse function to parseFile


<?php

/* Find the authentication state. */
if (!array_key_exists('AuthState', $_REQUEST) || empty($_REQUEST['AuthState'])) {
	throw new SimpleSAML_Error_BadRequest('Missing mandatory parameter: AuthState');
}

$authState = $_REQUEST['AuthState'];
$state = SimpleSAML_Auth_State::loadState($authState, 'openid:init');
$sourceId = $state['openid:AuthId'];
$authSource = SimpleSAML_Auth_Source::getById($sourceId);
if ($authSource === NULL) {
	throw new SimpleSAML_Error_BadRequest('Invalid AuthId \'' . $sourceId . '\' - not found.');
}

try {
	if (!empty($_GET['openid_url'])) {
		$authSource->doAuth($state, (string)$_GET['openid_url']);
	}
} catch (Exception $e) {
	$error = $e->getMessage();
}

$config = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($config, 'openid:consumer.php', 'openid');
$t->data['error'] = $error;
$t->data['AuthState'] = $authState;
$t->show();

<?php

/* Find the authentication state. */
if (!array_key_exists('AuthState', $_REQUEST) || empty($_REQUEST['AuthState'])) {
	throw new SimpleSAML_Error_BadRequest('Missing mandatory parameter: AuthState');
}

$authState = $_REQUEST['AuthState'];
$state = SimpleSAML_Auth_State::loadState($authState, 'openid:init');
$sourceId = $state['openid:AuthId'];
$authSource = SimpleSAML_Auth_Source::getById($sourceId);
if ($authSource === NULL) {
	throw new SimpleSAML_Error_BadRequest('Invalid AuthId \'' . $sourceId . '\' - not found.');
}

$error = NULL;
try {
	if (!empty($_GET['openid_url'])) {
		$authSource->doAuth($state, (string)$_GET['openid_url']);
	}
} catch (Exception $e) {
	$error = $e->getMessage();
}

$config = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($config, 'openid:consumer.php', 'openid');
$t->data['error'] = $error;
$t->data['AuthState'] = $authState;
$t->show();

openid: Fix notice about unititialized variable.


<?php
	// FIXME: this should start a secure session if forcessl is enabled
	// see lib/base.php for an example
	//session_start();
	$_SESSION['timezone'] = $_GET['time'];

<?php
$_SESSION['timezone'] = $_GET['time'];

Remove fixme, problem is solved already

Remove fixme, problem is solved already


<?php

namespace Shaygan\AffiliateBundle\Entity;

use Doctrine\ORM\EntityRepository;

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

    public function getRegistrationByUser($user)
    {
        return $this->_em
                        ->createQuery('SELECT rr,r FROM ShayganAffiliateBundle:ReferralRegistration rr '
                                . 'JOIN rr.referrer r '
                                . 'WHERE r.id=:id '
                                . 'ORDER BY rr.id DESC ')
                        ->setParameter("id", $user->getId())
        ;
    }

    public function getRegistrationCountByUser($user)
    {
        return $this->_em
                        ->createQuery('SELECT COUNT(*) FROM ShayganAffiliateBundle:ReferralRegistration rr '
                                . 'WHERE r.id=:id ')
                        ->setParameter("id", $user->getId())
                        ->getSingleScalarResult()
        ;
    }

}

<?php

namespace Shaygan\AffiliateBundle\Entity;

use Doctrine\ORM\EntityRepository;

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

    public function getRegistrationByUser($user)
    {
        return $this->_em
                        ->createQuery('SELECT rr,r FROM ShayganAffiliateBundle:ReferralRegistration rr '
                                . 'JOIN rr.referrer r '
                                . 'WHERE r.id=:id '
                                . 'ORDER BY rr.id DESC ')
                        ->setParameter("id", $user->getId())
        ;
    }

    public function getRegistrationCountByUser($user)
    {
        return $this->_em
                        ->createQuery('SELECT COUNT(*) FROM ShayganAffiliateBundle:ReferralRegistration rr '
                                . 'JOIN rr.referrer r '
                                . 'WHERE r.id=:id ')
                        ->setParameter("id", $user->getId())
                        ->getSingleScalarResult()
        ;
    }

}

Add get registration count to service

Add get registration count to service


<?php
namespace Neos\Flow\Tests\Unit\Http\Helper;

use GuzzleHttp\Psr7\ServerRequest;
use Neos\Flow\Http\Helper\RequestInformationHelper;
use Neos\Flow\Tests\UnitTestCase;

/**
 * Tests for the RequestInformationHelper
 */
class RequestInformationHelperTest extends UnitTestCase
{
    /**
     * @test
     */
    public function renderRequestHeadersWillNotDiscloseAuthorizationCredentials()
    {
        $request = ServerRequest::fromGlobals()
            ->withAddedHeader('Authorization', 'Basic SomeUser:SomePassword')
            ->withAddedHeader('Authorization', 'Bearer SomeToken');

        $renderedHeaders = RequestInformationHelper::renderRequestHeaders($request);
        self::assertNotContains('SomePassword', $renderedHeaders);
        self::assertNotContains('SomeToken', $renderedHeaders);
    }
}

<?php
namespace Neos\Flow\Tests\Unit\Http\Helper;

use GuzzleHttp\Psr7\ServerRequest;
use Neos\Flow\Http\Helper\RequestInformationHelper;
use Neos\Flow\Tests\UnitTestCase;

/**
 * Tests for the RequestInformationHelper
 */
class RequestInformationHelperTest extends UnitTestCase
{
    /**
     * @test
     */
    public function renderRequestHeadersWillNotDiscloseAuthorizationCredentials()
    {
        $request = ServerRequest::fromGlobals()
            ->withAddedHeader('Authorization', 'Basic SomeUser:SomePassword')
            ->withAddedHeader('Authorization', 'Bearer SomeToken');

        $renderedHeaders = RequestInformationHelper::renderRequestHeaders($request);
        self::assertStringContainsString('SomePassword', $renderedHeaders);
        self::assertStringContainsString('SomeToken', $renderedHeaders);
    }
}

Adjust test assertions to PHPUnit 8

TASK: Adjust test assertions to PHPUnit 8


                close

                    @each('notes::partials.images', $images, 'img')

<button class="btn btn-primary" data-dismiss="modal">Close</button>

               <button class="btn btn-default"> Browse Photos</button>

                    @each('notes::partials.images', $images, 'img')

<button class="btn btn-primary" data-dismiss="modal">Close</button>

Add a browse photo button to the modal-header


<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
    $name = $request->getAttribute('name');
    $response->getBody()->write("Hello, $name");

    return $response;
});

$app->get('/macon[/]', function (Request $req, Response $res) {
    return $res->withStatus(302)->withHeader('Location', '/united-states/macon-ga');
});

$app->get('/canada/oshawa[/]', function (Request $req, Response $res) {
    return $res->withStatus(302)->withHeader('Location', '/canada/durham-region');
});

$app->get('/canada/whitby[/]', function (Request $req, Response $res) {
    return $res->withStatus(302)->withHeader('Location', '/canada/durham-region');
});

$app->any('/[{path:.*}]', function(Request $req, Response $res) {
    // Loads the c5 Environment and Template
    require_once __DIR__ . '/concrete5/web/router.php';
} );

$app->run();

<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
    $name = $request->getAttribute('name');
    $response->getBody()->write("Hello, $name");

    return $response;
});

$app->get('/macon[/]', function (Request $req, Response $res) {
    return $res->withStatus(302)->withHeader('Location', '/united-states/macon-ga');
});

$app->get('/canada/oshawa[/]', function (Request $req, Response $res) {
    return $res->withStatus(302)->withHeader('Location', '/canada/durham-region');
});

$app->get('/canada/whitby[/]', function (Request $req, Response $res) {
    return $res->withStatus(302)->withHeader('Location', '/canada/durham-region');
});

$app->any('/[{path:.*}]', function(Request $req, Response $res) {
    ob_start();
    // Loads the c5 Environment and Template
    require_once __DIR__ . '/concrete5/web/router.php';
    return $res->getBody()->write(ob_get_clean());
} );

$app->run();

Build slim response from captured output buffer


<?php

/*
 * This file is part of the Doctrine Bundle
 *
 * The code was originally distributed inside the Symfony framework.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 * (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;

use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand;

/**
 * Ensure the Doctrine ORM is configured properly for a production environment.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 * @author Jonathan H. Wage <jonwage@gmail.com>
 */
class EnsureProductionSettingsDoctrineCommand extends EnsureProductionSettingsCommand
{
    /**
     * {@inheritDoc}
     */
    protected function configure()
    {
        parent::configure();

        $this
            ->setName('doctrine:ensure-production-settings')
            ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
    }

    /**
     * {@inheritDoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));

        parent::execute($input, $output);
    }
}

<?php

/*
 * This file is part of the Doctrine Bundle
 *
 * The code was originally distributed inside the Symfony framework.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 * (c) Doctrine Project, Benjamin Eberlei <kontakt@beberlei.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Doctrine\Bundle\DoctrineBundle\Command\Proxy;

use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand;

/**
 * Ensure the Doctrine ORM is configured properly for a production environment.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 * @author Jonathan H. Wage <jonwage@gmail.com>
 */
class EnsureProductionSettingsDoctrineCommand extends EnsureProductionSettingsCommand
{
    /**
     * {@inheritDoc}
     */
    protected function configure()
    {
        parent::configure();

        $this
            ->setName('doctrine:ensure-production-settings')
            ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
    }

    /**
     * {@inheritDoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));

        return parent::execute($input, $output);
    }
}

Add return to ensure prodution settings command to get exit status of command


<?php

namespace Consolidare;

use Consolidare\Mergeable\Mergeable;
use Consolidare\Mergeable\MergeableFactory;
use Consolidare\MergeStrategy\MergeStrategy;
use Consolidare\Record\RecordFactory;

class Merge
{
    private $mergeable = [];

    public function data($input)
    {
        return $this->mergeable(MergeableFactory::create($input));
    }

    public function mergeable(Mergeable $data)
    {
        $this->mergeable[] = $data;

        return $this;
    }

    public function merge(MergeStrategy $strategy = NULL)
    {
        if (!$strategy) {
            $strategy = new MergeStrategy();
        }

        $record = NULL;

        foreach ($this->mergeable as $data) {
            $record = RecordFactory::create(
                $strategy,
                $record,
                $data
            );
        }

        return $record;
    }
}

<?php

namespace Consolidare;

use Consolidare\Mergeable\Mergeable;
use Consolidare\Mergeable\MergeableFactory;
use Consolidare\MergeStrategy\MergeStrategy;
use Consolidare\Record\RecordFactory;

class Merge
{
    private $mergeable = [];

    public function data($input)
    {
        return $this->mergeable(MergeableFactory::create($input));
    }

    public function mergeable(Mergeable $data)
    {
        $this->mergeable[] = $data;

        return $this;
    }

    public function merge(MergeStrategy $strategy = NULL)
    {
        if (!$strategy) {
            $strategy = new MergeStrategy();
        }

        return array_reduce($this->mergeable, function ($record, $data) use ($strategy) {
            return RecordFactory::create(
                $strategy,
                $record,
                $data
            );
        });
    }
}

Refactor Foreach Into Array Reduce

Refactor Foreach Into Array Reduce

This was a foreach doing exactly what array_reduce did before. So just
tidying this up.


<?php

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

namespace Symfony\Component\Filesystem\Tests\Fixtures\MockStream;

/**
 * Mock stream class to be used with stream_wrapper_register.
 * stream_wrapper_register('mock', 'Symfony\Component\Filesystem\Tests\Fixtures\MockStream\MockStream').
 */
class MockStream
{
    /**
     * Opens file or URL.
     *
     * @param string $path        Specifies the URL that was passed to the original function
     * @param string $mode        The mode used to open the file, as detailed for fopen()
     * @param int    $options     Holds additional flags set by the streams API
     * @param string $opened_path If the path is opened successfully, and STREAM_USE_PATH is set in options,
     *                            opened_path should be set to the full path of the file/resource that was actually opened
     *
     * @return bool
     */
    public function stream_open($path, $mode, $options, &$opened_path)
    {
        return true;
    }

    /**
     * @param string $path  The file path or URL to stat
     * @param array  $flags Holds additional flags set by the streams API
     *
     * @return array File stats
     */
    public function url_stat($path, $flags)
    {
        return [];
    }
}

<?php

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

namespace Symfony\Component\Filesystem\Tests\Fixtures\MockStream;

/**
 * Mock stream class to be used with stream_wrapper_register.
 * stream_wrapper_register('mock', 'Symfony\Component\Filesystem\Tests\Fixtures\MockStream\MockStream').
 */
class MockStream
{
    /**
     * Opens file or URL.
     *
     * @param string $path        Specifies the URL that was passed to the original function
     * @param string $mode        The mode used to open the file, as detailed for fopen()
     * @param int    $options     Holds additional flags set by the streams API
     * @param string $opened_path If the path is opened successfully, and STREAM_USE_PATH is set in options,
     *                            opened_path should be set to the full path of the file/resource that was actually opened
     */
    public function stream_open($path, $mode, $options, &$opened_path): bool
    {
        return true;
    }

    /**
     * @param string $path  The file path or URL to stat
     * @param array  $flags Holds additional flags set by the streams API
     *
     * @return array File stats
     */
    public function url_stat($path, $flags): array
    {
        return [];
    }
}

Add return types to tests and final|internal|private methods


<?php

namespace Linfo\Laravel;

use Illuminate\Support\ServiceProvider;

class LinfoServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->publishes([
            __DIR__.'/config/linfo.php' => config_path('linfo.php'),
        ], 'config');

        $this->mergeConfigFrom(__DIR__.'/../config/linfo.php', 'linfo');
    }

    public function boot()
    {
        //
    }
}

<?php

namespace Linfo\Laravel;

use Illuminate\Support\ServiceProvider;

class LinfoServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->publishes([
            __DIR__.'/../config/linfo.php' => config_path('linfo.php'),
        ], 'config');

        $this->mergeConfigFrom(__DIR__.'/../config/linfo.php', 'linfo');
    }

    public function boot()
    {
        //
    }
}

Fix wrong path when publishing config

Fix wrong path when publishing config

It was pointed to `src/Linfo/config`, not `src/config`.


<?php
/**
 * Created by PhpStorm.
 * User: Nabeel
 * Date: 2015-09-28
 * Time: 11:01 AM
 */

namespace ShortCirquit\WordPressApi;

use yii\base\Object;

class ApiRequest extends Object
{
    public $method = 'GET';
    public $url = null;
    public $headers = [];
    public $params = [];
    public $curlOptions = [];
    public $body = null;
}

<?php
/**
 * Created by PhpStorm.
 * User: Nabeel
 * Date: 2015-09-28
 * Time: 11:01 AM
 */

namespace ShortCirquit\WordPressApi;

class ApiRequest
{
    public $method = 'GET';
    public $url = null;
    public $headers = [];
    public $params = [];
    public $curlOptions = [];
    public $body = null;

    public function __construct(array $cfg = [])
    {
        $params = ['method', 'url', 'header', 'params', 'curlOptions', 'body'];
        foreach ($params as $p){
            if (isset($cfg[$p]))
                $this->$p = $cfg[$p];
        }
    }
}

Remove dependency on Yii's Object class

Remove dependency on Yii's Object class

Initialization of members via array in constructor was the only feature
used.


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

define('CRONUS_BASE', 'http://hess.ess.washington.edu/');
define('CRONUS_URI', CRONUS_BASE . 'cgi-bin/matweb');

class Calculator {

    function send($submitText, $calcType) {
        // prepare for a curl call
        $fields = array(
            'requesting_ip' => getRealIp(),
            'mlmfile' => 'al_be_' . $calcType . '_many_v22',
            'text_block' => $submitText,
        );

        $options = array(
            CURLOPT_POST => count($fields),
            CURLOPT_RETURNTRANSFER => TRUE,
            CURLOPT_POSTFIELDS => http_build_query($fields),
            CURLOPT_CONNECTTIMEOUT => 90,
            CURLOPT_TIMEOUT => 200,
        );

        // send the request with curl
        $ch = curl_init(CRONUS_URI);
        curl_setopt_array($ch, $options);
        $result = curl_exec($ch);
        if (!$result) {
            die('Error retrieving calculator result:<br>' . curl_error($ch));
        }

        curl_close($ch);
        $rep = '<head><base href="' . CRONUS_BASE . '" />';
        $html = str_replace('<head>', $rep, $result);
        return $html;
    }

}

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

define('CRONUS_BASE', 'http://hess.ess.washington.edu/');
define('CRONUS_URI', CRONUS_BASE . 'cgi-bin/matweb');

class Calculator
{

    public static function send($submitText, $calcType)
    {
        // prepare for a curl call
        if ($calcType == 'erosion') {
            $mlmfile = 'al_be_erosion_many_v23';
        } else {
            // Assume age
            $mlmfile = 'age_input_v3';
        }

        $fields = array(
            'mlmfile' => $mlmfile,
            'reportType' => 'HTML',
            'resultType' => 'long',
            'plotFlag' => 'yes',
            'requesting_ip' => getRealIp(),
            'summary' => 'yes', // Assume data from 1 landform, currently true.
            'text_block' => $submitText,
        );

        $options = array(
            CURLOPT_POST => count($fields),
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POSTFIELDS => http_build_query($fields),
            CURLOPT_CONNECTTIMEOUT => 90,
            CURLOPT_TIMEOUT => 200,
        );

        // send the request with curl
        $ch = curl_init(CRONUS_URI);
        curl_setopt_array($ch, $options);
        $result = curl_exec($ch);

        if (!$result) {
            die('Error retrieving calculator result:<br>' . curl_error($ch));
        }

        curl_close($ch);

        return $result;
    }

}

Update calculator request for new CRONUS versions


<?php
namespace phpSmug\Tests;

use phpSmug\Client;

class ClientTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @test
     */
    public function shouldNotHaveToPassHttpClientToConstructor()
    {
        $client = new Client();

        $this->assertInstanceOf('phpSmug\HttpClient\HttpClient', $client->getHttpClient());
    }
}

?>

Add initial client instantiation test

Add initial client instantiation test


<?php
namespace Test;

// \HttpMessage
use Kambo\HttpMessage\Uri;
use Kambo\HttpMessage\Factories\String\UriFactory;

/**
 * Unit test for the UriFactory object.
 *
 * @package Test
 * @author  Bohuslav Simek <bohuslav@simek.si>
 * @license MIT
 */
class UriFactoryTest extends \PHPUnit_Framework_TestCase
{
    /**
     * Test creating url from string.
     *
     * @return void
     */
    public function testCreate()
    {
        $uri = UriFactory::create(
            'http://user:password@test.com:1111/path/123?q=abc#test'
        );

        $this->assertInstanceOf(Uri::class, $uri);
        $this->assertEquals('http', $uri->getScheme());
        $this->assertEquals('user:password', $uri->getUserInfo());
        $this->assertEquals('test.com', $uri->getHost());
        $this->assertEquals(1111, $uri->getPort());
        $this->assertEquals('/path/123', $uri->getPath());
        $this->assertEquals('q=abc', $uri->getQuery());
        $this->assertEquals('test', $uri->getFragment());
    }
}

<?php
namespace Test;

// \HttpMessage
use Kambo\HttpMessage\Uri;
use Kambo\HttpMessage\Factories\String\UriFactory;

/**
 * Unit test for the UriFactory object.
 *
 * @package Test
 * @author  Bohuslav Simek <bohuslav@simek.si>
 * @license MIT
 */
class UriFactoryTest extends \PHPUnit_Framework_TestCase
{
    /**
     * Test creating url from string.
     *
     * @return void
     */
    public function testCreate()
    {
        $uri = UriFactory::create(
            'http://user:password@test.com:1111/path/123?q=abc#test'
        );

        $this->assertInstanceOf('Kambo\HttpMessage\Uri', $uri);
        $this->assertEquals('http', $uri->getScheme());
        $this->assertEquals('user:password', $uri->getUserInfo());
        $this->assertEquals('test.com', $uri->getHost());
        $this->assertEquals(1111, $uri->getPort());
        $this->assertEquals('/path/123', $uri->getPath());
        $this->assertEquals('q=abc', $uri->getQuery());
        $this->assertEquals('test', $uri->getFragment());
    }
}

Fix broken test in PHP 5.4

Fix broken test in PHP 5.4


<?php namespace Pingpong\Modules\Commands;

use Illuminate\Console\Command;

class ListCommand extends Command {

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

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Show list of all modules.';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function fire()
    {
        $this->table(['Name', 'Status', 'Priority', 'Path'], $this->getRows());
    }

    /**
     * Get table rows.
     *
     * @return array
     */
    public function getRows()
    {
        $rows = [];

        foreach ($this->laravel['modules']->getOrdered() as $module)
        {
            $rows[] = [
                $module->getStudlyName(),
                $module->enabled() ? 'Enabled' : 'Disabled',
                $module->get('priority'),
                $module->getPath(),
            ];
        }

        return $rows;
    }

}

<?php namespace Pingpong\Modules\Commands;

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

class ListCommand extends Command {

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

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Show list of all modules.';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function fire()
    {
        $this->table(['Name', 'Status', 'Order', 'Path'], $this->getRows());
    }

    /**
     * Get table rows.
     *
     * @return array
     */
    public function getRows()
    {
        $rows = [];

        foreach ($this->getModules() as $module)
        {
            $rows[] = [
                $module->getStudlyName(),
                $module->enabled() ? 'Enabled' : 'Disabled',
                $module->get('order'),
                $module->getPath(),
            ];
        }

        return $rows;
    }

    public function getModules()
    {
        switch ($this->option('only')) {
            case 'enabled':
                return $this->laravel['modules']->getByStatus(1);
                break;

            case 'disabled':
                return $this->laravel['modules']->getByStatus(0);
                break;

            case 'ordered':
                return $this->laravel['modules']->getOrdered($this->option('direction'));
                break;

            default:
                return $this->laravel['modules']->all();
                break;
        }
    }

    /**
     * Get the console command options.
     *
     * @return array
     */
    protected function getOptions()
    {
        return array(
            array('only', null, InputOption::VALUE_OPTIONAL, 'Types of modules will be displayed.', null),
            array('direction', 'd', InputOption::VALUE_OPTIONAL, 'The direction of ordering.', 'asc'),
        );
    }

}

Add new option --only & --direction flags


<?php

namespace Redtrine\Tests\Structure;

use Redtrine\Tests\RedtrineTestCase;
use Redtrine\Structure\BitField;

class BitFieldTest extends RedtrineTestCase
{
    /**
     * @var bitField
     */
    protected $bit;

    public function setUp()
    {
        parent::setUp();

        $this->bit = new BitField('TestBitField');
        $this->bit->setClient($this->getRedisClient());
    }

    /**
     * @dataProvider bitValues
     */
    public function testToSetAndGetBitField($value)
    {
        $this->bit->set(100, $value);

        $this->assertEquals($this->bit->get(100), $value);
    }

    public function bitValues()
    {
        return array(
            array(0),
            array(1)
        );
    }
}

<?php

namespace Redtrine\Tests\Structure;

use Redtrine\Tests\RedtrineTestCase;
use Redtrine\Structure\BitField;

class BitFieldTest extends RedtrineTestCase
{
    /**
     * @var bitField
     */
    protected $bit;

    public function setUp()
    {
        parent::setUp();

        $this->bit = new BitField('TestBitField');
        $this->bit->setClient($this->getRedisClient());
    }

    /**
     * @dataProvider bitValues
     */
    public function testToSetAndGetBitField($key, $value)
    {
        $this->bit->set($key, $value);

        $this->assertEquals($this->bit->get($key), $value);
    }

    public function bitValues()
    {
        return array(
            array(100,0),
            array(101,0),
            array(100,1),
            array(101,1),
        );
    }
}

Update dataProvider on BitField structure


<?php
session_start();
require_once('config.php');
if ($_COOKIE['surveyok'] and $_SESSION['surveyok']){
  echo "The survey will be completed. Please wait the redirecting.. ";
  setcookie('surveyok',null);
  if (unset($_SESSION['surveyok']) && !$_COOKIE['surveyok']){
    header('refresh: 5; URL='.$survey_continue);
  } else {
    echo "UNSETTING ERROR (400x) - Please retry again";
  }
}
?>

Verify if the surveys will be completed

Verify if the surveys will be completed


<?php
/**
 * We made many changes in this code.
 * By pH7 (Pierre-Henry SORIA).
 */
namespace PFBC\Element;
use PH7\Framework\Mvc\Model\DbConfig;

class Password extends Textbox
{

    public function render()
    {
        // Adding the password pattern
        $this->attributes['pattern'] = '.{'.DbConfig::getSetting('minPasswordLength').','.DbConfig::getSetting('maxPasswordLength').'}';
        // Adding the password type attribute
        $this->attributes['type'] = 'password';

        parent::render();
    }

}

<?php
/**
 * We made many changes in this code.
 * By pH7 (Pierre-Henry SORIA).
 */
namespace PFBC\Element;

class Password extends Textbox
{

    public function render()
    {
        // Adding the password type attribute
        $this->attributes['type'] = 'password';

        parent::render();
    }

}

Remove the HTML5 pattenr as that PFBC field is present also on login forms and if the value if changed later (in admin panel) the users/admins wont be able to login anymore


<?php

/**
 * This file is part of the <name> project.
 *
 * (c) <yourname> <youremail>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Application\Sonata\CommentBundle\Entity;

use FOS\CommentBundle\Model\SignedCommentInterface;
use Sonata\CommentBundle\Entity\BaseComment as BaseComment;
use Symfony\Component\Security\Core\User\UserInterface;

/**
 * This file has been generated by the Sonata EasyExtends bundle ( http://sonata-project.org/bundles/easy-extends )
 *
 * References :
 *   working with object : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/working-with-objects/en
 *
 * @author <yourname> <youremail>
 */
class Comment extends BaseComment implements SignedCommentInterface
{
    /**
     * @var integer $id
     */
    protected $id;

    /**
     * @var UserInterface
     */
    protected $author;

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

    /**
     * {@inheritdoc}
     */
    public function setAuthor(UserInterface $author)
    {
        $this->author = $author;
    }

    /**
     * {@inheritdoc}
     */
    public function getAuthor()
    {
        return $this->author;
    }

    /**
     * {@inheritdoc}
     */
    public function getAuthorName()
    {
        return $this->getAuthor() ? $this->getAuthor()->getUsername() : 'Anonymous';
    }
}

<?php

/**
 * This file is part of the <name> project.
 *
 * (c) <yourname> <youremail>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Application\Sonata\CommentBundle\Entity;

use Sonata\CommentBundle\Entity\BaseComment as BaseComment;
use Symfony\Component\Security\Core\User\UserInterface;

/**
 * This file has been generated by the Sonata EasyExtends bundle ( http://sonata-project.org/bundles/easy-extends )
 *
 * References :
 *   working with object : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/working-with-objects/en
 *
 * @author <yourname> <youremail>
 */
class Comment extends BaseComment
{
    /**
     * @var integer $id
     */
    protected $id;

    /**
     * @var UserInterface
     */
    protected $author;

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

Update comments to do not use signed interface


<?php
/**
 * @version     $Id$
 * @package     Nooku_Components
 * @subpackage  Files
 * @copyright   Copyright (C) 2011 - 2012 Timble CVBA and Contributors. (http://www.timble.net).
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.nooku.org
 */

/**
 * File Name Filter Class
 *
 * @author      Ercan Ozkaya <http://nooku.assembla.com/profile/ercanozkaya>
 * @package     Nooku_Components
 * @subpackage  Files
 */

class ComFilesFilterFileName extends KFilterAbstract
{
	protected $_walk = false;

	protected function _validate($context)
	{
		$value = $this->_sanitize($context->caller->name);

		if ($value == '') {
			$context->setError(JText::_('Invalid file name'));
			return false;
		}
	}

	protected function _sanitize($value)
	{
		return $this->getService('com://admin/files.filter.path')->sanitize($value);
	}
}

<?php
/**
 * @version     $Id$
 * @package     Nooku_Components
 * @subpackage  Files
 * @copyright   Copyright (C) 2011 - 2012 Timble CVBA and Contributors. (http://www.timble.net).
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.nooku.org
 */

/**
 * File Name Filter Class
 *
 * @author      Ercan Ozkaya <http://nooku.assembla.com/profile/ercanozkaya>
 * @package     Nooku_Components
 * @subpackage  Files
 */

class ComFilesFilterFileName extends KFilterAbstract
{
	protected $_walk = false;

	protected function _validate($context)
	{
		$value = $this->_sanitize($context->getSubject()->name);

		if ($value == '') {
			$context->setError(JText::_('Invalid file name'));
			return false;
		}
	}

	protected function _sanitize($value)
	{
		return $this->getService('com://admin/files.filter.path')->sanitize($value);
	}
}

Use KCommandContext::getSubject() instead of $command->caller


<?php

/*
 * Data Object
 * https://github.com/ivopetkov/data-object
 * Copyright (c) Ivo Petkov
 * Free to use under the MIT license.
 */

namespace IvoPetkov;

/**
 *
 */
trait DataListContextTrait
{

    /**
     * An array containing all the actions.
     *
     * @var array
     */
    public $actions = [];

    /**
     * Apply the actions to the data list specified.
     *
     * @return void
     */
    public function apply($list)
    {
        foreach ($this->actions as $action) {
            switch ($action->name) {
                case 'filter':
                    $list->filter($action->callback);
                    break;
                case 'filterBy':
                    $list->filterBy($action->property, $action->value, $action->operator);
                    break;
                case 'sort':
                    $list->sort($action->callback);
                    break;
                case 'sortBy':
                    $list->sortBy($action->property, $action->order);
                    break;
                case 'sliceProperties':
                    $list->sliceProperties($action->properties);
                    break;
                case 'reverse':
                    $list->reverse();
                    break;
                case 'shuffle':
                    $list->shuffle();
                    break;
                case 'slice':
                    $list->slice($action->offset, $action->limit);
                    break;
                case 'map':
                    $list->map($action->callback);
                    break;
                default:
                    throw new \Exception('Should not get here for "' . $action->name . '"!');
                    break;
            }
        }
    }
}

<?php

/*
 * Data Object
 * https://github.com/ivopetkov/data-object
 * Copyright (c) Ivo Petkov
 * Free to use under the MIT license.
 */

namespace IvoPetkov;

/**
 *
 */
trait DataListContextTrait
{

    /**
     * An array containing all the actions.
     *
     * @var array
     */
    public $actions = [];

    /**
     * Apply the actions to the data list specified.
     *
     * @return void
     */
    public function apply(&$list)
    {
        foreach ($this->actions as $action) {
            switch ($action->name) {
                case 'filter':
                    $list->filter($action->callback);
                    break;
                case 'filterBy':
                    $list->filterBy($action->property, $action->value, $action->operator);
                    break;
                case 'sort':
                    $list->sort($action->callback);
                    break;
                case 'sortBy':
                    $list->sortBy($action->property, $action->order);
                    break;
                case 'sliceProperties':
                    $list = $list->sliceProperties($action->properties);
                    break;
                case 'reverse':
                    $list->reverse();
                    break;
                case 'shuffle':
                    $list->shuffle();
                    break;
                case 'slice':
                    $list = $list->slice($action->offset, $action->limit);
                    break;
                case 'map':
                    $list->map($action->callback);
                    break;
                default:
                    throw new \Exception('Should not get here for "' . $action->name . '"!');
                    break;
            }
        }
    }
}

Fix in the apply() method in list context (did not returned the correct list when slice and sliceProperties)


      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">

      </button>
      Husky Helpers

Home

Event List

Event Entry

      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">

      </button>
      Husky Helpers

        <li <? if($_SERVER['PHP_SELF'] == "/index.php") { ?>class="active"<? } ?>>Home

        <li <? if($_SERVER['PHP_SELF'] == "/eventlist.php") { ?>class="active"<? } ?>>Event List

        <li <? if($_SERVER['PHP_SELF'] == "/evententry.php") { ?>class="active"<? } ?>>Event Entry

Make pages' links in the header active when we visit them


<?php

/*
 * This file is part of the GifExceptionBundle project.
 *
 * (c) JoliCode <coucou@jolicode.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Joli\GifExceptionBundle;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class GifExceptionBundle extends Bundle
{
    public function build(ContainerBuilder $container)
    {
        parent::build($container);

        $container->addCompilerPass($this->getContainerExtension());
    }

    public function getParent()
    {
        return 'TwigBundle';
    }
}

<?php

/*
 * This file is part of the GifExceptionBundle project.
 *
 * (c) JoliCode <coucou@jolicode.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Joli\GifExceptionBundle;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class GifExceptionBundle extends Bundle
{
    public function build(ContainerBuilder $container)
    {
        parent::build($container);

        $container->addCompilerPass($this->getContainerExtension());
    }
}

Remove getParent call to TwigBundle

Remove getParent call to TwigBundle


<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Maxim
 * Date: 07/07/13
 * Time: 11:43
 * To change this template use File | Settings | File Templates.
 */

namespace Maxim\Module\ApplicationBundle\Menu;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Maxim\CMSBundle\Event\MenuEvent;

class MenuBuilder {
    private $dispatcher;
    private $logger;
    private $doctrine;

    public function __construct(EventDispatcherInterface $dispatcher, $logger, $container, $doctrine)
    {
        $this->dispatcher = $dispatcher;
        $this->logger = $logger;
        $this->container = $container;
        $this->doctrine = $doctrine;
    }

    /**
     * Main function for building menus and dispatching related events.
     */
    public function buildMenu()
    {
        $em = $this->doctrine->getManager();
        $website = $em->getRepository('MaximCMSBundle:Website')->findOneBy(array("id" => $this->container->getParameter('website')));
        $applications = $em->getRepository('MaximModuleApplicationBundle:Application')->findBy(array("website" => $website));
        $data['applications'] = $applications;

        $event = new MenuEvent($this->container->get('templating')->render('MaximModuleApplicationBundle:Navigation:applications.html.twig', $data));
        $this->dispatcher->dispatch('maxim_cms.event_menu', $event);

    }
}

<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Maxim
 * Date: 07/07/13
 * Time: 11:43
 * To change this template use File | Settings | File Templates.
 */

namespace Maxim\Module\ApplicationBundle\Menu;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Maxim\CMSBundle\Event\MenuEvent;

class MenuBuilder {
    private $dispatcher;
    private $logger;
    private $doctrine;

    public function __construct(EventDispatcherInterface $dispatcher, $logger, $container, $doctrine)
    {
        $this->dispatcher = $dispatcher;
        $this->logger = $logger;
        $this->container = $container;
        $this->doctrine = $doctrine;
    }

    /**
     * Main function for building menus and dispatching related events.
     */
    public function buildMenu()
    {
        $em = $this->doctrine->getManager();
        $website = $em->getRepository('MaximCMSBundle:Website')->findOneBy(array("id" => $this->container->getParameter('website')));
        $applications = $em->getRepository('MaximModuleApplicationBundle:Application')->findBy(array("website" => $website));
        $data['applications'] = $applications;

        $event = new MenuEvent($this->container->get('templating')->render('MaximModuleApplicationBundle:Module:Navigation\applications.html.twig', $data));
        $this->dispatcher->dispatch('maxim_cms.event_menu', $event);

    }
}

Fix menu rendering that prevents website from loading


<?php
/*
 * Dit is een standaardpagina voor op de website. Voor het includen van deze
 * pagina moet een aantal variabelen geïnitialiseerd worden:
 * $title: bevat de paginatitel.
 * $head: bevat extra inhoud voor binnen de head tag. Optioneel.
 * $body: bevat de inhoud van de pagina, binnen de body tag.
 */
 if (!isset($title)) {
   trigger_error('Paginatitel niet geïnitialiseerd!', E_USER_WARNING);
 }
 if (!isset($body)) {
   trigger_error('Deze pagina is leeg!', E_USER_NOTICE);
 }
?>
<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $title; ?></title>
    <?php echo $head; ?>

<?php echo $title; ?>

    <?php echo $body; ?>

<?php
/*
 * Dit is een standaardpagina voor op de website. Voor het includen van deze
 * pagina moet een aantal variabelen geïnitialiseerd worden:
 * $title: bevat de paginatitel.
 * $head: bevat extra inhoud voor binnen de head tag. Optioneel.
 * $body: bevat de inhoud van de pagina, binnen de body tag.
 */
 if (!isset($title)) {
   trigger_error('Paginatitel niet geïnitialiseerd!', E_USER_WARNING);
 }
 if (!isset($body)) {
   trigger_error('Deze pagina is leeg!', E_USER_NOTICE);
 }
?>
<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="resources/css/foundation.min.css" type="text/css">
    <title><?php echo $title; ?></title>
    <?php echo $head; ?>

<?php echo $title; ?>

    <?php echo $body; ?>

Use foundation stylesheet and js on every page


<?php
use CLIFramework\Component\Table\DateFormatCell;

class DateFormatCellTest extends PHPUnit_Framework_TestCase
{
    public function testDateFormat()
    {
        $dateFormatCell = new DateFormatCell('en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles');
        $str = $dateFormatCell->format(0);

        // older icu does not output "at"
        $this->assertRegExp('/Wednesday, December \d+, \d+ (at)? \d:00:00 PM Pacific Standard Time/', $str);
    }
}

<?php
use CLIFramework\Component\Table\DateFormatCell;

class DateFormatCellTest extends PHPUnit_Framework_TestCase
{
    public function testDateFormat()
    {
        $dateFormatCell = new DateFormatCell('en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'America/Los_Angeles');
        $str = $dateFormatCell->format(0);

        // older icu does not output "at"
        $this->assertRegExp('/Wednesday, December \d+, \d+( at)? \d:00:00 PM Pacific Standard Time/', $str);
    }
}

Fix the optional ( at) expression

Fix the optional ( at) expression


<?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


{{Lang::get('client.language')}} | 'iRail' © 2015, Open Knowledge Belgium. {{Lang::get('client.isPartOf')}} Open Knowledge Belgium. | {{Lang::get('contributors.title')}} |

Modify "iRail is a member of (...)"

Modify "iRail is a member of (...)"

Linking only "iRail" to hello.irail.be and leaving the "is a member of" string out of the link seems more logical


<?php
/**
 * Created by PhpStorm.
 * User: Bram
 * Date: 29-4-2017
 * Time: 06:21
 */

namespace Stormyy\B3\Helper;

use GeoIP;

abstract class PermissionHelper
{
    public static function ip($ip){
        if(\Auth::user() == null) {
            return preg_replace('/\.\d+\.\d+$/', '.***.***', $ip);
        } else {
            return $ip;
        }
    }

    public static function ipToFlag($ip){
        $countryinfo = GeoIp::getLocation($ip);
        return "";
    }

}

<?php
/**
 * Created by PhpStorm.
 * User: Bram
 * Date: 29-4-2017
 * Time: 06:21
 */

namespace Stormyy\B3\Helper;

use GeoIP;

abstract class PermissionHelper
{
    public static function ip($ip){
        if(\Auth::user() == null) {
            return preg_replace('/\.\d+\.\d+$/', '.***.***', $ip);
        } else {
            return $ip;
        }
    }

    public static function ipToFlag($ip){
        $countryinfo = geoip()->getLocation($ip);
        return "";
    }

}

Use geoip helper instead of facade

Use geoip helper instead of facade


<?php namespace MyBB\Core\Http\Middleware;

use Closure;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;

abstract class AbstractBootstrapMiddleware implements Middleware
{
	/**
	 * Handle an incoming request.
	 *
	 * @param  Request  $request
	 * @param  \Closure $next
	 *
	 * @return mixed
	 */
	abstract public function handle($request, Closure $next);

	/**
	 * @param Router  $router
	 * @param Request $request
	 *
	 * @return array
	 */
	protected function getOptions(Router $router, Request $request)
	{
		$collection = $router->getRoutes();
		$route = $collection->match($request->create($request->path()));

		return $route->getAction();
	}
}

<?php namespace MyBB\Core\Http\Middleware;

use Closure;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;

abstract class AbstractBootstrapMiddleware implements Middleware
{
	/**
	 * Handle an incoming request.
	 *
	 * @param  Request  $request
	 * @param  \Closure $next
	 *
	 * @return mixed
	 */
	abstract public function handle($request, Closure $next);

	/**
	 * @param Router  $router
	 * @param Request $request
	 *
	 * @return array
	 */
	protected function getOptions(Router $router, Request $request)
	{
		$collection = $router->getRoutes();
		$route = $collection->match($request->create($request->path(), $request->method()));

		return $route->getAction();
	}
}

Fix issues with bootstraping post methods


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

class Migration_change_filesize_type extends CI_Migration {

	public function up()
	{
		$prefix = $this->db->dbprefix;

		if ($this->db->dbdriver == 'postgre') {
			$this->db->query('
				ALTER TABLE "'.$prefix.'file_storage"
					ALTER "filesize" TYPE bigint;
				');
		} else {
			$this->db->query('
				ALTER TABLE `'.$prefix.'file_storage`
					MODIFY `filesize` bigint;
				');
		}
	}

	public function down()
	{
		throw new \exceptions\ApiException("migration/downgrade-not-supported", "downgrade not supported");
	}
}

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

class Migration_change_filesize_type extends CI_Migration {

	public function up()
	{
		$prefix = $this->db->dbprefix;

		if ($this->db->dbdriver == 'postgre') {
			$this->db->query('
				ALTER TABLE "'.$prefix.'file_storage"
					ALTER "filesize" TYPE bigint;
				');
		} else {
			$this->db->query('
				ALTER TABLE `'.$prefix.'file_storage`
					MODIFY `filesize` bigint;
				');
		}

		$chunk = 500;

		$total = $this->db->count_all("file_storage");

		for ($limit = 0; $limit < $total; $limit += $chunk) {
			$query = $this->db->select('hash, id')
				->from('file_storage')
				->where('filesize', 2147483647)
				->limit($chunk, $limit)
				->get()->result_array();

			foreach ($query as $key => $item) {
				$data_id = $item["hash"].'-'.$item['id'];
				$filesize = filesize($this->mfile->file($data_id));

				$this->db->where('id', $item['id'])
					->set(array(
						'filesize' => $filesize,
					))
					->update('file_storage');
			}
		}
	}

	public function down()
	{
		throw new \exceptions\ApiException("migration/downgrade-not-supported", "downgrade not supported");
	}
}

Update filesizes after changing filesize db type

This updates all wrong filesizes after db migration 19 (`filesize` type
change to `bigint`). It will only update files with a filesize of
2147483647 byte since the database set the max integer value as the
filesize if the file was > 2147483647 byte.