<?php
session_start();
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
define("DOC_ROOT", str_replace("/core/inc", "", str_replace("\\", "/", __DIR__)));

require_once(DOC_ROOT."/core/inc/constants.php");
require_once(DOC_ROOT."/core/inc/functions.php");
require_once(DOC_ROOT."/core/inc/country_list.php");
require_once(DOC_ROOT."/core/entity/entity.php");
require_once(DOC_ROOT."/core/entity/l10n_entity.php");
require_once(DOC_ROOT."/core/controller/controller.php");
require_once(DOC_ROOT."/core/model/model.php");
require_once(DOC_ROOT."/core/class/mail_message.php");

if (file_exists(DOC_ROOT."/extend/inc/constants.php"))
	require_once(DOC_ROOT."/extend/inc/constants.php");
if (file_exists(DOC_ROOT."/extend/inc/functions.php"))
	require_once(DOC_ROOT."/extend/inc/functions.php");

$Config = newClass("Config");
$Db = newClass("Db");
$Db->debug = $Config->getDebug();
$dbc = $Config->getDatabase();
$Db->connect($dbc["user"], $dbc["pass"], $dbc["db"], $dbc["host"]);

$ControllerFactory = newClass("ControllerFactory", $Config, $Db);

<?php
session_start();
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
define("DOC_ROOT", str_replace("/core/inc", "", str_replace("\\", "/", __DIR__)));

require_once(DOC_ROOT."/core/inc/constants.php");
require_once(DOC_ROOT."/core/inc/functions.php");
require_once(filePath("inc/country_list.php"));
require_once(DOC_ROOT."/core/entity/entity.php");
require_once(DOC_ROOT."/core/entity/l10n_entity.php");
require_once(DOC_ROOT."/core/controller/controller.php");
require_once(DOC_ROOT."/core/model/model.php");
require_once(DOC_ROOT."/core/class/mail_message.php");

if (file_exists(DOC_ROOT."/extend/inc/constants.php"))
	require_once(DOC_ROOT."/extend/inc/constants.php");
if (file_exists(DOC_ROOT."/extend/inc/functions.php"))
	require_once(DOC_ROOT."/extend/inc/functions.php");

$Config = newClass("Config");
$Db = newClass("Db");
$Db->debug = $Config->getDebug();
$dbc = $Config->getDatabase();
$Db->connect($dbc["user"], $dbc["pass"], $dbc["db"], $dbc["host"]);

$ControllerFactory = newClass("ControllerFactory", $Config, $Db);

Add possibility of custom country list.

Add possibility of custom country list.


<?php
class Kwc_FulltextSearch_Box_Trl_Component extends Kwc_Chained_Trl_Component
{
    public function getTemplateVars()
    {
        $ret = parent::getTemplateVars();
        $ret['searchPage'] = Kwc_Chained_Trl_Component::getChainedByMaster($ret['searchPage'], $this->getData(), array('ignoreVisible'=>true));
        return $ret;
    }
}

<?php
class Kwc_FulltextSearch_Box_Trl_Component extends Kwc_Chained_Trl_Component
{
    public function processInput($postData)
    {
        Kwf_Component_Data_Root::getInstance()
            ->getComponentByClass('Kwc_FulltextSearch_Search_Trl_Component',
                                   array('subroot'=>$this->getData()))
            ->getChildComponent('-child')
            ->getChildComponent('-view')->getChildComponent('-searchForm')
            ->getComponent()->processInput($postData);
    }

    public function getTemplateVars()
    {
        $ret = parent::getTemplateVars();
        $searchPage = Kwf_Component_Data_Root::getInstance()
            ->getComponentByClass('Kwc_FulltextSearch_Search_Trl_Component',
                                   array('subroot'=>$this->getData()))
            ->getChildComponent('-child');
        $ret['searchForm'] = $searchPage->getChildComponent('-view')
            ->getChildComponent('-searchForm');
        $ret['config']['searchTitle'] = $searchPage->getTitle();
        $ret['config']['searchUrl'] = $searchPage->getAbsoluteUrl();
        return $ret;
    }
}

Fix searchBox-trl getting the correct form

The old searchBox-trl code was deprecated. Now it's searching for the search-trl component and getting it's form to display.


<?php
class MultimediaFileValidatorSchema extends sfValidatorSchema
{
  protected function configure($options = array(), $messages = array())
  {
    $this->addMessage('invalid_file_type', 'this type of extention is not allowed here');
    $this->addMessage('file_not_found', "Please don't try stupid things, don't touch the uri");
  }

  protected function doClean($value)
  {
    $errorSchema = new sfValidatorErrorSchema($this);
    $errorSchemaLocal = new sfValidatorErrorSchema($this);
    if (!$value['referenced_relation'])
    {
      return array();
    }
    if($value['record_id'] == 0)
    {
      //TODO replace the line below with a nice preg_replace function (instead of str_replace)
      if(!file_exists(sfConfig::get('sf_upload_dir').'/multimedia/temp/'.str_replace("/","",$value['uri'])))
      {
          $errorSchemaLocal->addError(new sfValidatorError($this, 'file_not_found'));
      }
    }
    return $value;
  }
}

<?php
class MultimediaFileValidatorSchema extends sfValidatorSchema
{
  protected function configure($options = array(), $messages = array())
  {
    $this->addMessage('invalid_file_type', 'this type of extention is not allowed here');
    $this->addMessage('file_not_found', "Please don't try stupid things, don't touch the uri");
  }

  protected function doClean($value)
  {
    $errorSchema = new sfValidatorErrorSchema($this);
    $errorSchemaLocal = new sfValidatorErrorSchema($this);
    if (!$value['referenced_relation'])
    {
      return array();
    }
    if($value['record_id'] == 0)
    {
      if( ! preg_match("/^[a-zA-Z0-9\.]+$/", $value['uri'])) {
        $errorSchemaLocal->addError(new sfValidatorError($this, 'file_not_found'));
      }
      if(! file_exists(sfConfig::get('sf_upload_dir').'/multimedia/temp/'.$value['uri'])) {
        $errorSchemaLocal->addError(new sfValidatorError($this, 'file_not_found'));
      }
    }
    return $value;
  }
}

Correct file name check for multimedia validator


<?php

use App\Models\Artist;
use Illuminate\Database\Migrations\Migration;

class CreateVariousArtists extends Migration
{
    /**
     * Create the "Various Artists".
     *
     * @return void
     */
    public function up()
    {
        Artist::unguard();

        $existingArtist = Artist::find(Artist::VARIOUS_ID);

        if ($existingArtist) {
            if ($existingArtist->name === Artist::VARIOUS_NAME) {
                goto ret;
            }

            // There's an existing artist with that special ID, but it's not our Various Artist
            // We move it to the end of the table.
            $latestArtist = Artist::orderBy('id', 'DESC')->first();
            $existingArtist->id = $latestArtist->id + 1;
            $existingArtist->save();
        }

        Artist::create([
            'id' => Artist::VARIOUS_ID,
            'name' => Artist::VARIOUS_NAME,
        ]);

        ret:
        Artist::reguard();
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
    }
}

<?php

use App\Models\Artist;
use Illuminate\Database\Migrations\Migration;

class CreateVariousArtists extends Migration
{
    /**
     * Create the "Various Artists".
     *
     * @return void
     */
    public function up()
    {
        // Make sure modified artists cascade the album's artist_id field.
        Schema::table('albums', function ($table) {
            $table->dropForeign('albums_artist_id_foreign');
            $table->foreign('artist_id')->references('id')->on('artists')->onUpdate('cascade')->onDelete('cascade');
        });

        Artist::unguard();

        $existingArtist = Artist::find(Artist::VARIOUS_ID);

        if ($existingArtist) {
            if ($existingArtist->name === Artist::VARIOUS_NAME) {
                goto ret;
            }

            // There's an existing artist with that special ID, but it's not our Various Artist
            // We move it to the end of the table.
            $latestArtist = Artist::orderBy('id', 'DESC')->first();
            $existingArtist->id = $latestArtist->id + 1;
            $existingArtist->save();
        }

        Artist::create([
            'id' => Artist::VARIOUS_ID,
            'name' => Artist::VARIOUS_NAME,
        ]);

        ret:
        Artist::reguard();
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
    }
}


<?php

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

$console = new Application('My Silex Application', 'n/a');

$console->register( 'shift' )
  ->setDefinition( array(/*Add all options*/) )
  ->setDescription('Shift the item in the playlist to pass to the next song')
  ->setHelp('Usage: <info>./console.php sync [--test]</info>')
  ->setCode(
    function(InputInterface $input, OutputInterface $output) use ($app)
    {
        //\RH\Playlist::shift();
    }
  );

return $console;

<?php

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

$console = new Application('My Silex Application', 'n/a');

$console->register( 'shift' )
  ->setDefinition( array(/*Add all options*/) )
  ->setDescription('Shift the item in the playlist to pass to the next song')
  ->setHelp('Usage: <info>./console.php sync [--test]</info>')
  ->setCode(
    function(InputInterface $input, OutputInterface $output) use ($app)
    {

//      This boucle is used to test if the script works
//      $test = true;
//        while ($test) {

      $contenu_array = null;
      $contenu_array = file('time');

        if (!$fp = fopen("time","w+")) {
            print('Probleme');
            exit;
        }

        if ($contenu_array != null)
        {
            $tab = explode('/', $contenu_array[0]);
            $times = explode(':', $tab[1]);
            $minutes = $times[0];
            $secondes = $times[1];
            $timstampToNotPass = $tab[0] + $secondes + 60*$minutes;

            if($timstampToNotPass> time())
            {
                fputs($fp, $tab[0] . '/' . $tab[1]);
            }
            else
            {
                print('On change');
                RH\Playlist::shift();
                $song = \RH\Playlist::getSong();
                if($song == null)
                {
                    print('fin');
                    exit;
                }
                fputs($fp, time() . '/' . $song->getTime());
            }
        }
        else
        {
            print('On met');
            $song = \RH\Playlist::getSong();
            fputs($fp, time() . '/' . $song->getTime());
        }
        fclose($fp);
//        }
    }
  );

return $console;

Add script to shift the music

Add script to shift the music


<?php

namespace Oro\Bundle\SearchBundle\Query\Criteria;

use Doctrine\Common\Collections\Expr\Value;
use Doctrine\Common\Collections\ExpressionBuilder as BaseExpressionBuilder;

class ExpressionBuilder extends BaseExpressionBuilder
{
    /**
     * @param string $field
     * @param string $value
     *
     * @return Comparison
     */
    public function notContains($field, $value)
    {
        return new Comparison($field, Comparison::NOT_CONTAINS, new Value($value));
    }

    public function exists($field)
    {
        return new Comparison($field, Comparison::EXISTS, new Value(null));
    }

    public function notExists($field)
    {
        return new Comparison($field, Comparison::NOT_EXISTS, new Value(null));
    }
}

<?php

namespace Oro\Bundle\SearchBundle\Query\Criteria;

use Doctrine\Common\Collections\Expr\Value;
use Doctrine\Common\Collections\ExpressionBuilder as BaseExpressionBuilder;

class ExpressionBuilder extends BaseExpressionBuilder
{
    /**
     * @param string $field
     * @param string $value
     *
     * @return Comparison
     */
    public function notContains($field, $value)
    {
        return new Comparison($field, Comparison::NOT_CONTAINS, new Value($value));
    }

    /**
     * @param string $field
     * @return Comparison
     */
    public function exists($field)
    {
        return new Comparison($field, Comparison::EXISTS, new Value(null));
    }

    /**
     * @param string $field
     * @return Comparison
     */
    public function notExists($field)
    {
        return new Comparison($field, Comparison::NOT_EXISTS, new Value(null));
    }
}

BB-4508: Add is null operator to search index
 - add missed phpdocs


<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylorotwell@gmail.com>
 */

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
|
*/

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

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once __DIR__.'/../bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

<?php

/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| First we need to get an application instance. This creates an instance
| of the application / container and bootstraps the application so it
| is ready to receive HTTP / Console requests from the environment.
|
*/

$app = require __DIR__.'/../bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$app->run();

Change the initial bootstrap file

Change the initial bootstrap file


<?php

class MatchValidator extends Validator
{
	public function validate()
	{
		$allok = true;
		foreach($this->keys as $key) {
			$result = preg_match($this->value, $this->model->$key);
			if($result === false) {
				throw new Exception('Wrong regex pattern for key ' . $key);
			} elseif($result === 0) {
				$allok = false;
				$this->error .= "$key does not match pattern.\n";
			}
		}
		return $allok;
	}
}

<?php

class MatchValidator extends Validator
{
	public function validate()
	{
		$allok = true;
		foreach($this->keys as $key) {
			$v = $this->model->$key;
			if(empty($v)) {
				continue;
			}
			$result = preg_match($this->value, $v);
			if($result === false) {
				throw new Exception('Wrong regex pattern for key ' . $key);
			} elseif($result === 0) {
				$allok = false;
				$this->error .= "$key does not match pattern.\n";
			}
		}
		return $allok;
	}
}

Allow empty strings in Match validator (set the "require" validator explicitly)


<?php
// src/Effi/QCMBundle/Admin/ChoiceAdmin.php

namespace Effi\QCMBundle\Admin;

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

class ChoiceAdmin extends Admin
{
    // FORMULAIRE EDITION AJOUT
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('user', 'entity', array('class' => 'Effi/UserBundle/Entity/User'))
            ->add('question', 'entity', array('class' => 'Effi/QCMBundle/Entity/Question'))
        ;
    }

    // FORMULAIRE FILTRE
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('user')
            ->add('question')
        ;
    }

    // FORMULAIRE LISTE
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->add('id')
            ->add('user')
            ->add('question')
        ;
    }
}

<?php
// src/Effi/QCMBundle/Admin/ChoiceAdmin.php

namespace Effi\QCMBundle\Admin;

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

class ChoiceAdmin extends Admin
{
    // FORMULAIRE EDITION AJOUT
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->add('user', 'entity', array('class' => 'Effi\UserBundle\Entity\User'))
            ->add('question', 'entity', array('class' => 'Effi\QCMBundle\Entity\Question', 'property' => 'label'))
        ;
    }

    // FORMULAIRE FILTRE
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('user')
        ;
    }

    // FORMULAIRE LISTE
    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->add('id')
            ->add('user')
            ->add('question', null, array('associated_tostring' => 'getLabel'))
        ;
    }
}

Fix Choice Admin listing and adding/editing


<?php namespace Orchestra\Extension\Console;

class MigrateCommand extends BaseCommand
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'extension:migrate';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Run migration for orchestra/extension package.';

    /**
     * {@inheritdoc}
     */
    public function fire()
    {
        $this->call('migrate', ['--package' => 'orchestra/memory']);
    }
}

<?php namespace Orchestra\Extension\Console;

class MigrateCommand extends BaseCommand
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'extension:migrate';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Run migration for orchestra/extension package.';

    /**
     * {@inheritdoc}
     */
    public function fire()
    {
        $path = $this->laravel['path.base'].'/vendor/orchestra/memory/src/migrations';

        $this->call('migrate', ['--path' => $path]);
    }
}

Use --path instead of deprecated --package.

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


<?php

namespace CultuurNet\UDB3\Media\Properties;

use InvalidArgumentException;
use ValueObjects\Exception\InvalidNativeArgumentException;
use ValueObjects\StringLiteral\StringLiteral;

final class CopyrightHolder extends StringLiteral
{
    public function __construct($value)
    {
        if (false === \is_string($value)) {
            throw new InvalidNativeArgumentException($value, array('string'));
        }

        if (strlen($value) < 2) {
            throw new InvalidArgumentException('The name of a copyright holder should be at least 2 characters');
        }

        return parent::__construct(substr($value, 0, 250));
    }
}

<?php

namespace CultuurNet\UDB3\Media\Properties;

use InvalidArgumentException;
use ValueObjects\Exception\InvalidNativeArgumentException;
use ValueObjects\StringLiteral\StringLiteral;

final class CopyrightHolder extends StringLiteral
{
    public function __construct($value)
    {
        if (false === \is_string($value)) {
            throw new InvalidNativeArgumentException($value, array('string'));
        }

        if (strlen($value) < 2) {
            throw new InvalidArgumentException('The name of a copyright holder should be at least 2 characters');
        }

        parent::__construct(substr($value, 0, 250));
    }
}

Fix phpstan error about return value of void being used


<?php

namespace League\Route\Strategy;

use RuntimeException;
use Symfony\Component\HttpFoundation\Response;

class RequestResponseStrategy extends AbstractStrategy implements StrategyInterface
{
    /**
     * {@inheritdoc}
     */
    public function dispatch($controller, array $vars)
    {
        $response = $this->invokeController($controller, [
            $this->getRequest(),
            $this->getContainer()->get('Symfony\Component\HttpFoundation\Response'),
            $vars
        ]);

        if ($response instanceof Response) {
            return $response;
        }

        throw new RuntimeException(
            'When using the Request -> Response Strategy your controller must ' .
            'return an instance of [Symfony\Component\HttpFoundation\Response]'
        );
    }

    /**
     * Get Request either from the container or else create it from globals
     * @return \Symfony\Component\HttpFoundation\Request
     */
    protected function getRequest()
    {
        if ($this->getContainer()->isRegistered('Symfony\Component\HttpFoundation\Request') ||
            $this->getContainer()->isInServiceProvider('Symfony\Component\HttpFoundation\Request') ) {
            return $this->getContainer()->get('Symfony\Component\HttpFoundation\Request');
        } else {
            return $this->getContainer()->get('Symfony\Component\HttpFoundation\Request')->createFromGlobals();
        }
    }
}

<?php

namespace League\Route\Strategy;

use RuntimeException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class RequestResponseStrategy extends AbstractStrategy implements StrategyInterface
{
    /**
     * {@inheritdoc}
     */
    public function dispatch($controller, array $vars)
    {
        $response = $this->invokeController($controller, [
            $this->getRequest(),
            $this->getContainer()->get('Symfony\Component\HttpFoundation\Response'),
            $vars
        ]);

        if ($response instanceof Response) {
            return $response;
        }

        throw new RuntimeException(
            'When using the Request -> Response Strategy your controller must ' .
            'return an instance of [Symfony\Component\HttpFoundation\Response]'
        );
    }

    /**
     * Get Request either from the container or else create it from globals
     * @return \Symfony\Component\HttpFoundation\Request
     */
    protected function getRequest()
    {
        if (
            $this->getContainer()->isRegistered('Symfony\Component\HttpFoundation\Request') ||
            $this->getContainer()->isInServiceProvider('Symfony\Component\HttpFoundation\Request')
        ) {
            return $this->getContainer()->get('Symfony\Component\HttpFoundation\Request');
        }

        return Request::createFromGlobals();
    }
}

Create new container when not pulled from container


<?php

use Galahad\LaravelAddressing\Entity\Country;
use Galahad\LaravelAddressing\LaravelAddressing;

/**
 * Class LaravelAddressingTest
 *
 * @author Junior Grossi <juniorgro@gmail.com>
 */
class LaravelAddressingTest extends PHPUnit_Framework_TestCase
{
    /**
     * @var LaravelAddressing
     */
    protected $addressing;

    /**
     * Setup the LaravelAddressing instance
     */
    protected function setUp()
    {
        $this->addressing = new LaravelAddressing();
    }

    public function testTheReturningTypeOfCountryMethod()
    {
        $country = $this->addressing->country('US');
        $this->assertTrue($country instanceof Country);
    }

    public function testIfTheCountryHasTheCorrectName()
    {
        $country = $this->addressing->country('US');
        $this->assertEquals($country->getName(), 'United States');
        $this->assertEquals($country->getCountryCode(), 'US');
    }

    public function testIfTheCountryByNameMethodIsReturningTheCorrectCountry()
    {
        $country = $this->addressing->countryByName('United States');
        $this->assertTrue($country instanceof Country);
        $this->assertEquals($country->getCountryCode(), 'US');
        $country = $this->addressing->countryByName('Brazil');
        $this->assertEquals($country->getCountryCode(), 'BR');
    }
}

<?php

use Galahad\LaravelAddressing\Entity\Country;
use Galahad\LaravelAddressing\LaravelAddressing;

/**
 * Class LaravelAddressingTest
 *
 * @author Junior Grossi <juniorgro@gmail.com>
 */
class LaravelAddressingTest extends PHPUnit_Framework_TestCase
{
    /**
     * @var LaravelAddressing
     */
    protected $addressing;

    /**
     * Setup the LaravelAddressing instance
     */
    protected function setUp()
    {
        $this->addressing = new LaravelAddressing();
    }

    public function testTheReturningTypeOfCountryMethod()
    {
        $country = $this->addressing->country('US');
        $this->assertTrue($country instanceof Country);
    }

    public function testIfTheCountryHasTheCorrectName()
    {
        $country = $this->addressing->country('US');
        $this->assertEquals($country->getName(), 'United States');
        $this->assertEquals($country->getCountryCode(), 'US');
    }

    public function testIfTheCountryByNameMethodIsReturningTheCorrectCountry()
    {
        $country = $this->addressing->countryByName('United States');
        $this->assertTrue($country instanceof Country);
        $this->assertEquals($country->getCountryCode(), 'US');
        $country = $this->addressing->countryByName('Brazil');
        $this->assertEquals($country->getCountryCode(), 'BR');
    }

    public function testIfFindCountryMethodIsWorking()
    {
        $country = $this->addressing->findCountry('US');
        $this->assertEquals($country->getName(), 'United States');
        $country = $this->addressing->findCountry('United States');
        $this->assertEquals($country->getCountryCode(), 'US');
        $country = $this->addressing->findCountry('ZZZZZZZZZ');
        $this->assertTrue(is_null($country));
    }
}

Add tests for finding a country using code or name


<?php

namespace Edujugon\Skeleton\Providers;

use Edujugon\Skeleton\Skeleton;
use Illuminate\Support\ServiceProvider;

class SkeletonServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        $config_path = function_exists('config_path') ? config_path('skeleton.php') : 'skeleton.php';

        $this->publishes([
            __DIR__.'/../Config/config.php' => $config_path,
        ], 'config');
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton('skeleton', function ($app) {
            return new Skeleton();
        });
    }
}

<?php

namespace Edujugon\Skeleton\Providers;

use Edujugon\Skeleton\Skeleton;
use Illuminate\Support\ServiceProvider;

class SkeletonServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        $config_path = function_exists('config_path') ? config_path('skeleton.php') : 'skeleton.php';

        $this->publishes([
            __DIR__.'/../Config/config.php' => $config_path,
        ], 'config');
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind(Skeleton::class, function ($app) {
            return new Skeleton();
        });
    }
}

Replace singleton to bind main class. Bind Class name instead hardcoding a string.


<?php

use Robo\Tasks;

require_once 'vendor/autoload.php';

class RoboFile extends Tasks
{
    function build()
    {
        $this->fixCodeStyle();
        $this->test();
    }

    function test()
    {
        $this->taskPhpUnit()->run();
    }

    function fixCodeStyle()
    {
        $this->_exec('./vendor/bin/php-cs-fixer fix src');
    }
}

<?php

use Robo\Tasks;

require_once 'vendor/autoload.php';

class RoboFile extends Tasks
{
    function build()
    {
        $this->fixCodeStyle();
        $this->test();
    }

    function test()
    {
        return $this->taskPhpUnit()->run();
    }

    function fixCodeStyle()
    {
        return $this->_exec('./vendor/bin/php-cs-fixer fix src');
    }
}

Return result sub-tasks to expose exit code for CI


<?php
/*
 * Go! AOP framework
 *
 * @copyright Copyright 2013, Lisachenko Alexander <lisachenko.it@gmail.com>
 *
 * This source file is subject to the license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Go\Aop\Framework;

use Go\Aop\IntroductionInfo;

/**
 * Advice for introduction that holds list of traits and interfaces for the concrete class
 */
class TraitIntroductionInfo implements IntroductionInfo
{

    /**
     * Introduced interface
     *
     * @var string
     */
    private $introducedInterface = '';

    /**
     * Trait to use
     *
     * @var string
     */
    private $introducedTrait = '';

    /**
     * Create a DefaultIntroductionAdvisor for the given advice.
     *
     * @param string $introducedTrait Introduced trait
     * @param string $introducedInterface Introduced interface
     */
    public function __construct($introducedTrait, $introducedInterface)
    {
        $this->introducedTrait     = $introducedTrait;
        $this->introducedInterface = $introducedInterface;
    }

    /**
     * Return the additional interface introduced by this Advisor or Advice.
     *
     * @return string The introduced interface or empty
     */
    public function getInterface()
    {
        return $this->introducedInterface;
    }

    /**
     * Return the additional trait with realization of introduced interface
     *
     * @return string The trait name to use or empty
     */
    public function getTrait()
    {
        return $this->introducedTrait;
    }
}

<?php
/*
 * Go! AOP framework
 *
 * @copyright Copyright 2013, Lisachenko Alexander <lisachenko.it@gmail.com>
 *
 * This source file is subject to the license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Go\Aop\Framework;

use Go\Aop\IntroductionInfo;

/**
 * Advice for introduction that holds list of traits and interfaces for the concrete class
 */
class TraitIntroductionInfo implements IntroductionInfo
{

    /**
     * Introduced interface
     *
     * @var string
     */
    private $introducedInterface;

    /**
     * Trait to use
     *
     * @var string
     */
    private $introducedTrait;

    /**
     * Create a DefaultIntroductionAdvisor for the given advice.
     *
     * @param string $introducedTrait Introduced trait
     * @param string $introducedInterface Introduced interface
     */
    public function __construct($introducedTrait, $introducedInterface)
    {
        $this->introducedTrait     = $introducedTrait;
        $this->introducedInterface = $introducedInterface;
    }

    /**
     * Return the additional interface introduced by this Advisor or Advice.
     *
     * @return string The introduced interface or empty
     */
    public function getInterface()
    {
        return $this->introducedInterface;
    }

    /**
     * Return the additional trait with realization of introduced interface
     *
     * @return string The trait name to use or empty
     */
    public function getTrait()
    {
        return $this->introducedTrait;
    }
}

Clean unused default values for properties


<?php

namespace MoFlashCards\DeckBundle\Controller;

use JMS\Serializer\SerializationContext;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class DeckController extends Controller
{
    /**
     * Lists all available decks.
     *
     * @return Response
     */
    public function listAction()
    {
        $decks = $this->get('doctrine_mongodb')
            ->getRepository('DeckBundle:Deck')
            ->findAll();

        $context = SerializationContext::create()->setGroups(['list']);
        $json = $this->get('jms_serializer')->serialize($decks, 'json', $context);

        $response = new Response();
        $response->setContent($json);
        $response->headers->set('Content-Type', 'application/json');

        return $response;
    }

    /**
     * Loads a certain deck by it's slug.
     *
     * @param string $slug
     * @return Response
     */
    public function getAction($slug)
    {
        $deck = $this->get('doctrine_mongodb')
            ->getRepository('DeckBundle:Deck')
            ->findOneBySlug($slug);

        if (!$deck) {
            throw new NotFoundHttpException();
        }

        $context = SerializationContext::create()->setGroups(['details']);
        $json = $this->get('jms_serializer')->serialize($deck, 'json', $context);

        $response = new Response();
        $response->setContent($json);
        $response->headers->set('Content-Type', 'application/json');

        return $response;
    }
}

<?php

namespace MoFlashCards\DeckBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class DeckController extends Controller
{
    /**
     * Lists all available decks.
     *
     * @return Response
     */
    public function listAction()
    {
        $decks = $this->get('doctrine_mongodb')
            ->getRepository('DeckBundle:Deck')
            ->findAll();

        return $this->get('utility.response.factory')
            ->createSerializedResponse($decks, ['list']);
    }

    /**
     * Loads a certain deck by it's slug.
     *
     * @param string $slug
     * @return Response
     */
    public function getAction($slug)
    {
        $deck = $this->get('doctrine_mongodb')
            ->getRepository('DeckBundle:Deck')
            ->findOneBySlug($slug);

        if (!$deck) {
            throw new NotFoundHttpException();
        }

        return $this->get('utility.response.factory')
            ->createSerializedResponse($deck, ['details']);
    }
}

Integrate response factory into the deck controller."


<?php

use PragmaRX\Support\Migration;
use Illuminate\Database\Schema\Blueprint;

class UpdateTrackerIds extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function migrateUp()
	{
		$this->dropColumn('tracker_sessions', 'user_id');

		Schema::table('tracker_sessions', function(Blueprint $table)
		{
			$table->string('user_id', 64)->nullable();
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function migrateDown()
	{
		// Ignore
	}

}

<?php

use PragmaRX\Support\Migration;
use Illuminate\Database\Schema\Blueprint;

class UpdateTrackerIds extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function migrateUp()
	{
		if ($this->tableExists('tracker_sessions'))
		{
			$this->dropColumn('tracker_sessions', 'user_id');

			Schema::table('tracker_sessions', function(Blueprint $table)
			{
				$table->string('user_id', 64)->nullable();
			});
		}
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function migrateDown()
	{
		// Ignore
	}

}

Fix migration when tracker is not being used


<?php
/**
 * SURFconext EngineBlock
 *
 * LICENSE
 *
 * Copyright 2011 SURFnet bv, The Netherlands
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations under the License.
 *
 * @category  SURFconext EngineBlock
 * @package
 * @copyright Copyright © 2010-2011 SURFnet SURFnet bv, The Netherlands (http://www.surfnet.nl)
 * @license   http://www.apache.org/licenses/LICENSE-2.0  Apache License 2.0
 */

require '../../library/EngineBlock/ApplicationSingleton.php';

$application = EngineBlock_ApplicationSingleton::getInstance();
$application->bootstrap();

$dispatcher = new EngineBlock_Dispatcher();
$dispatcher->setRouters(array(
    new EngineBlock_Router_Profile(),
    new EngineBlock_Router_CatchAll('profile', 'index', 'index'),
));
$dispatcher->dispatch();

$application->getHttpResponse()->send();

<?php
/**
 * SURFconext EngineBlock
 *
 * LICENSE
 *
 * Copyright 2011 SURFnet bv, The Netherlands
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations under the License.
 *
 * @category  SURFconext EngineBlock
 * @package
 * @copyright Copyright © 2010-2011 SURFnet SURFnet bv, The Netherlands (http://www.surfnet.nl)
 * @license   http://www.apache.org/licenses/LICENSE-2.0  Apache License 2.0
 */

require '../../library/EngineBlock/ApplicationSingleton.php';

$application = EngineBlock_ApplicationSingleton::getInstance();
$application->bootstrap();

$dispatcher = new EngineBlock_Dispatcher();

$profileRouter = new EngineBlock_Router_Default();
$profileRouter->requireModule('authentication');
$dispatcher->setRouters(array(
    $profileRouter,
    new EngineBlock_Router_CatchAll('profile', 'index', 'index'),
));
$dispatcher->dispatch();

$application->getHttpResponse()->send();

Use default module with a required instead of own subclass, this enables NOT routing /

git-svn-id: e77a8db410fc7e53f700994083f7980387c3a882@657 528793b8-127e-4309-9901-b74759c7208d


<?php

namespace Edge\QA\Tools\Analyzer;

use Edge\QA\OutputMode;

class SecurityChecker extends \Edge\QA\Tools\Tool
{
    public static $SETTINGS = array(
        'optionSeparator' => '=',
        'internalClass' => 'SensioLabs\Security\SecurityChecker',
        'outputMode' => OutputMode::RAW_CONSOLE_OUTPUT,
        'composer' => 'sensiolabs/security-checker',
    );

    public function __invoke()
    {
        $composerLock = getcwd() . "/composer.lock";
        foreach ($this->options->getAnalyzedDirs() as $escapedDir) {
            $dir = rtrim(trim($escapedDir, '"'), '/');
            $path = "{$dir}/composer.lock";
            if (file_exists($path)) {
                $composerLock = $path;
                break;
            }
        }
        $args = [
            'security:check',
            $composerLock,
        ];
        if (getenv('TRAVIS_COMMIT')) {
            $args['end-point'] = 'http://security.sensiolabs.org/check_lock';
        }
        return $args;
    }
}

<?php

namespace Edge\QA\Tools\Analyzer;

use Edge\QA\OutputMode;

class SecurityChecker extends \Edge\QA\Tools\Tool
{
    public static $SETTINGS = array(
        'optionSeparator' => '=',
        'internalClass' => 'SensioLabs\Security\SecurityChecker',
        'outputMode' => OutputMode::RAW_CONSOLE_OUTPUT,
        'composer' => 'sensiolabs/security-checker',
    );

    public function __invoke()
    {
        $composerLock = getcwd() . "/composer.lock";
        foreach ($this->options->getAnalyzedDirs() as $escapedDir) {
            $dir = rtrim(trim($escapedDir, '"'), '/');
            $path = "{$dir}/composer.lock";
            if (file_exists($path)) {
                $composerLock = $path;
                break;
            }
        }
        return [
            'security:check',
            $composerLock,
        ];
    }
}

Revert "Security-checker - fix tls issue at travis.ci"

This reverts commit 4c483c163b8e9c49eaca5cc34a9e74dc866b1a45.


<?php
/**
 * Plugin Name: Airstory
 * Plugin URI:  http://www.airstory.co/integrations/
 * Description: Publish content from Airstory to WordPress.
 * Version:     0.1.0
 * Author:      Liquid Web
 * Author URI:  https://www.liquidweb.com
 * Text Domain: airstory
 *
 * @package Airstory
 */

namespace Airstory;

define( 'AIRSTORY_INC', __DIR__ . '/includes' );

require_once AIRSTORY_INC . '/async-tasks.php';
require_once AIRSTORY_INC . '/class-api.php';
require_once AIRSTORY_INC . '/core.php';
require_once AIRSTORY_INC . '/formatting.php';
require_once AIRSTORY_INC . '/webhook.php';

/**
 * Load asynchronous tasks.
 *
 * To prevent locking the main thread and possibly hitting timeouts, the plugin leverages the
 * TechCrunch WP Asynchronous Tasks library. Actions that require some potentially expensive
 * processes (for instance, side-loading images) can instead be handled asynchronously, by using
 * the wp_async_{hook} pattern.
 *
 * @link https://github.com/techcrunch/wp-async-task
 */
require_once AIRSTORY_INC . '/lib/wp-async-task/wp-async-task.php';
require_once AIRSTORY_INC . '/async-tasks/import-post.php';

// Each task must be instantiated once.
new AsyncTasks\ImportPost();

<?php
/**
 * Plugin Name: Airstory
 * Plugin URI:  http://www.airstory.co/integrations/
 * Description: Publish content from Airstory to WordPress.
 * Version:     0.1.0
 * Author:      Liquid Web
 * Author URI:  https://www.liquidweb.com
 * Text Domain: airstory
 *
 * @package Airstory
 */

namespace Airstory;

define( 'AIRSTORY_INC', __DIR__ . '/includes' );

require_once AIRSTORY_INC . '/class-api.php';
require_once AIRSTORY_INC . '/core.php';
require_once AIRSTORY_INC . '/formatting.php';
require_once AIRSTORY_INC . '/webhook.php';

/**
 * Load asynchronous tasks.
 *
 * To prevent locking the main thread and possibly hitting timeouts, the plugin leverages the
 * TechCrunch WP Asynchronous Tasks library. Actions that require some potentially expensive
 * processes (for instance, side-loading images) can instead be handled asynchronously, by using
 * the wp_async_{hook} pattern.
 *
 * @link https://github.com/techcrunch/wp-async-task
 */
require_once AIRSTORY_INC . '/lib/wp-async-task/wp-async-task.php';
require_once AIRSTORY_INC . '/async-tasks/import-post.php';

// Each task must be instantiated once.
new AsyncTasks\ImportPost();

Remove a reference to an empty file

Remove a reference to an empty file


<?php

namespace Enzyme\Axiom\Models;

interface ModelInterface
{
    /**
     * Get the unique identity for this mode.
     *
     * @return int
     */
    public function identity();

    /**
     * Checks whether this model has the given attribute set.
     *
     * @param string $attribute
     *
     * @return boolean
     */
    public function has($attribute);

    /**
     * Get the value associated with the given attribute.
     *
     * @param string $attribute
     *
     * @return mixed
     */
    public function get($attribute);
}

<?php

namespace Enzyme\Axiom\Models;

interface ModelInterface
{
    /**
     * Get the unique identity for this mode.
     *
     * @return int
     */
    public function identity();

    /**
     * Checks whether this model has the given attribute set.
     *
     * @param string $attribute
     *
     * @return boolean
     */
    public function hasAttribute($attribute);

    /**
     * Get the value associated with the given attribute.
     *
     * @param string $attribute
     *
     * @return mixed
     */
    public function getAttribute($attribute);

    /**
     * Get all the attributes associated with this model.
     *
     * @return array
     */
    public function getAllAttributes();
}

Add more descriptive attribute methods.

Add more descriptive attribute methods.


<?php

namespace fieldwork\components;

class TextField extends Field
{

    const ON_ENTER_NEXT   = 'next';
    const ON_ENTER_SUBMIT = 'submit';

    private $onEnter = '',
        $mask = null;

    public function getAttributes ()
    {
        $att = array('placeholder' => $this->label);
        if (!empty($this->onEnter))
            $att['data-input-action-on-enter'] = $this->onEnter;
        if ($this->mask !== null)
            $att['data-input-mask'] = $this->mask;
        return array_merge(parent::getAttributes(), $att);
    }

    public function onEnter ($action = '')
    {
        $this->onEnter = $action;
        return $this;
    }

    /**
     * Sets input mask for this field
     *
     * @param string $mask
     *
     * @return static
     */
    public function setMask ($mask)
    {
        $this->mask = $mask;
        return $this;
    }

    public function getClasses ()
    {
        return array_merge(
            parent::getClasses(), array('textfield', 'fieldwork-inputfield')
        );
    }

    public function getHTML ($showLabel = true)
    {
        return "<input type='text'" . $this->getAttributesString() . ">";
    }

}

<?php

namespace fieldwork\components;

class TextField extends Field
{

    const ON_ENTER_NEXT   = 'next';
    const ON_ENTER_SUBMIT = 'submit';

    private $onEnter = '',
        $mask = null;

    public function getAttributes ()
    {
        //$att = array('placeholder' => $this->label);
        $att = array();
        if (!empty($this->onEnter))
            $att['data-input-action-on-enter'] = $this->onEnter;
        if ($this->mask !== null)
            $att['data-input-mask'] = $this->mask;
        return array_merge(parent::getAttributes(), $att);
    }

    public function onEnter ($action = '')
    {
        $this->onEnter = $action;
        return $this;
    }

    /**
     * Sets input mask for this field
     *
     * @param string $mask
     *
     * @return static
     */
    public function setMask ($mask)
    {
        $this->mask = $mask;
        return $this;
    }

    public function getClasses ()
    {
        return array_merge(
            parent::getClasses(), array('textfield', 'fieldwork-inputfield')
        );
    }

    public function getHTML ($showLabel = true)
    {
        return sprintf("
<input type='text' %s>%s
",
            $this->getAttributesString(),
            $this->getId(),
            $this->label);
    }

}

Use the materialize CSS markup

Use the materialize CSS markup


<?php
final class DVRUI_Vars
{
	const DVRUI_version	="0.4.3";
	const DVRUI_name	="HDHomeRun DVR UI";
	const DVRUI_git		="https://github.com/demonrik/HDHR-DVRUI.git";

	/* Set TZ to something valid from http://php.net/manual/en/timezones.php */
	const DVRUI_TZ		= '';
}
?>

<?php
final class DVRUI_Vars
{
	const DVRUI_version	="0.4.4";
	const DVRUI_name	="HDHomeRun DVR UI";
	const DVRUI_git		="https://github.com/demonrik/HDHR-DVRUI.git";

	/* Set TZ to something valid from http://php.net/manual/en/timezones.php */
	const DVRUI_TZ		= '';
}
?>

Fix advanced rule saving bug

Fix advanced rule saving bug


<?php

/**
 * FormSafe
 *
 * PHP version 5
 *
 * @category  Library
 * @package   PyritePHP
 * @author    Stéphane Lavergne <lis@imars.com>
 * @copyright 2016 Stéphane Lavergne
 * @license   https://opensource.org/licenses/MIT  MIT
 * @link      https://github.com/vphantom/pyrite-php
 */

namespace FormSafe;

/**
 * Produce an opaque form name unique to current session
 *
 * @param string $form_name Application-wide unique name for this form
 *
 * @return string
 */
function hashname($form_name)
{
    return 'form' . md5($form_name . session_id());
}

on(
    'form_begin',
    function ($form_name) {
        $name = hashname($form_name);
        $token = md5(mcrypt_create_iv(32));
        $_SESSION[$name] = $token;
        return '<input type="hidden" name="'.$name.'" value="'.$token.'" />';
    }
);

on(
    'form_validate',
    function ($form_name) {
        $name = hashname($form_name);
        $sess = (isset($_SESSION[$name]) ? $_SESSION[$name] : false);
        $_SESSION[$name] = ' ';
        unset($_SESSION[$name]);
        if ($sess && isset($_POST[$name]) && $_POST[$name] === $sess) {
            return true;
        } else {
            $_POST = array();
            return false;
        };
    }
);

<?php

/**
 * FormSafe
 *
 * PHP version 5
 *
 * @category  Library
 * @package   PyritePHP
 * @author    Stéphane Lavergne <lis@imars.com>
 * @copyright 2016 Stéphane Lavergne
 * @license   https://opensource.org/licenses/MIT  MIT
 * @link      https://github.com/vphantom/pyrite-php
 */

namespace FormSafe;

/**
 * Produce an opaque form name unique to current session
 *
 * @param string $form_name Application-wide unique name for this form
 *
 * @return string
 */
function hashname($form_name)
{
    return 'form' . md5($form_name . session_id());
}

on(
    'form_begin',
    function ($form_name) {
        $name = hashname($form_name);
        $token = md5(mcrypt_create_iv(32));
        $_SESSION[$name] = $token;
        return '<input type="hidden" name="'.$name.'" value="'.$token.'" />';
    }
);

on(
    'form_validate',
    function ($form_name) {
        $name = hashname($form_name);
        $sess = (isset($_SESSION[$name]) ? $_SESSION[$name] : false);
        $_SESSION[$name] = ' ';
        unset($_SESSION[$name]);
        if ($sess && isset($_POST[$name]) && $_POST[$name] === $sess) {
            unset $_POST[$name];
            return true;
        } else {
            $_POST = array();
            return false;
        };
    }
);

Clean POST data after validation

Clean POST data after validation


<?php

namespace At\Theme\Resolver;

/**
 * Class ConfigurationResolver
 * @package Theme\Resolver
 */
class ConfigurationResolver implements ResolverInterface
{
    /**
     * @var array
     */
    protected $config;

    /**
     * ConfigurationResolver constructor.
     * @param array $config
     */
    public function __construct(array $config)
    {
        $this->config = $config;
    }

    /**
     * @return string|null
     */
    public function resolve()
    {
        if (!isset($this->config['current_theme'])){
            return null;
        }
        return $this->config['current_theme'];
    }
}

<?php

namespace At\Theme\Resolver;

/**
 * Class ConfigurationResolver
 * @package Theme\Resolver
 */
class ConfigurationResolver implements ResolverInterface
{
    /**
     * @var array
     */
    protected $config;

    /**
     * ConfigurationResolver constructor.
     * @param array $config
     */
    public function __construct(array $config)
    {
        $this->config = $config;
    }

    /**
     * @return string|null
     */
    public function resolve()
    {
        if (!isset($this->config['default_theme'])){
            return null;
        }
        return $this->config['default_theme'];
    }
}

Rename theme param name for configuration resolver


<?php
//Connect to database
require('db.php');

$connection = getConnection();

function sqlToJson($sql) {
	$json = array();
	while ($row = mysqli_fetch_assoc($sql)) {
		$json[] = $row;
	}
	return json_encode($json, JSON_NUMERIC_CHECK);
}

function escapeArray($array){
	global $connection;
	$keys = array_keys($array);
	foreach ($keys as  $key) {
	 	$array[$key] = $connection->real_escape_string($array[$key]);
	}
	return $array;
}

function getQuery($query) {
	global $connection;
	$sql = mysqli_query($connection, $query) or die(mysqli_error($connection));
	return $sql;
}

function setQuery($query) {
	global $connection;
	mysqli_query($connection, $query) or die(mysqli_error($connection));
}

function printJson($json) {
	 header("Content-Type: application/json");
	 echo $json;
}

function loadLanguage($language) {
	$path ="lang/".$language.".json";
	$languageFile = file_get_contents($path);
	$languageFile = mb_convert_encoding($languageFile,'HTML-ENTITIES', "UTF-8");
	$languageArray = json_decode($languageFile, true);

	return $languageArray;
}
loadLanguage('norwegian');

?>

<?php
//Connect to database
require('db.php');

$connection = getConnection();

function sqlToJson($sql) {
	$json = array();
	while ($row = mysqli_fetch_assoc($sql)) {
		$json[] = $row;
	}
	return json_encode($json, JSON_NUMERIC_CHECK);
}

function escapeArray($array){
	global $connection;
	$keys = array_keys($array);
	foreach ($keys as  $key) {
	 	$array[$key] = $connection->real_escape_string($array[$key]);
	}
	return $array;
}

function getQuery($query) {
	global $connection;
	$sql = mysqli_query($connection, $query) or die(mysqli_error($connection));
	return $sql;
}

function setQuery($query) {
	global $connection;
	mysqli_query($connection, $query) or die(mysqli_error($connection));
}

function printJson($json) {
	 header("Content-Type: application/json");
	 echo $json;
}

function loadLanguage($language) {
	$path ="lang/".$language.".json";
	$languageFile = file_get_contents($path);
	$languageFile = mb_convert_encoding($languageFile,'HTML-ENTITIES', "UTF-8");
	$languageArray = json_decode($languageFile, true);

	return $languageArray;
}

function getString($id) {
	//Insert code here
}

?>

Add function skeletons for future work

Add function skeletons for future work


<?php
/**
 * @package Scheduler
 * @subpackage Conversion.engines
 */
class KConversionEngineFfmpegAux  extends KJobConversionEngine
{
	const FFMPEG_AUX = "ffmpeg_aux";

	public function getName()
	{
		return self::FFMPEG_AUX;
	}

	public function getType()
	{
		return KalturaConversionEngineType::FFMPEG_AUX;
	}

	public function getCmd ()
	{
		return KBatchBase::$taskConfig->params->ffmpegAuxCmd;
	}
}

<?php
/**
 * @package Scheduler
 * @subpackage Conversion.engines
 */
class KConversionEngineFfmpegAux  extends KJobConversionEngine
{
	const FFMPEG_AUX = "ffmpeg_aux";

	public function getName()
	{
		return self::FFMPEG_AUX;
	}

	public function getType()
	{
		return KalturaConversionEngineType::FFMPEG_AUX;
	}

	public function getCmd ()
	{
		return KBatchBase::$taskConfig->params->ffmpegAuxCmd;
	}

	protected function getCmdLine ($cmd_line , $add_log )
	{
		// I have commented out the audio parameters so we don't decrease the quality - it stays as-is
		$binName = $this->getCmd();
		$inputFilePath = kFile::buildDirectUrl($this->inFilePath);
		kBatchUtils::addReconnectParams("http", $inputFilePath,$binName);

		$exec_cmd = $binName . " " .
			str_replace (
				array(KDLCmdlinePlaceholders::InFileName, KDLCmdlinePlaceholders::OutFileName, KDLCmdlinePlaceholders::ConfigFileName, KDLCmdlinePlaceholders::BinaryName),
				array('"' . $inputFilePath . '"', $this->outFilePath, $this->configFilePath, $binName),
				$cmd_line);

		if ( $add_log )
		{
			// redirect both the STDOUT & STDERR to the log
			$exec_cmd .= " >> \"{$this->logFilePath}\" 2>&1";
		}

		return $exec_cmd;
	}
}

FOUN-79: Add reconnect parms when working with ffmpeg aux


<?php

namespace easybill\SDK\Model;

/**
 * Class CreateDocument
 *
 * @package easybill\SDK\Model
 */
class DocumentCreated
{
    /** @var  string */
    public $fileName;
    /** @var  string */
    public $file;
    /** @var  boolean */
    public $signDocument;
    /** @varstring */
    public $signexception;
    /** @var  boolean */
    public $sentasemail;
    /** @var  string */
    public $emailsendexception;
    /** @var  boolean */
    public $sentaspost;
    /** @var  string */
    public $postsendexception;
    /** @var  DocumentDescriber */
    public $document;
}

<?php

namespace easybill\SDK\Model;

/**
 * Class CreateDocument
 *
 * @package easybill\SDK\Model
 */
class DocumentCreated
{
    /** @var  string */
    public $fileName;
    /** @var  string */
    public $file;
    /** @var  boolean */
    public $signDocument;
    /** @varstring */
    public $signexception;
    /** @var  boolean */
    public $sentasemail;
    /** @var  string */
    public $emailsendexception;
    /** @var  boolean */
    public $sentaspost;
    /** @var  string */
    public $postsendexception;
    /** @var  DocumentDescriber */
    public $document;

    public function savePDF($destinationPath)
    {
        $handle = fopen($destinationPath, 'w');
        fwrite($handle, base64_decode($this->file));
        fclose($handle);
    }

}

Add function to save pdf file from Document


<?php

namespace SofaChamps\Bundle\BowlPickemBundle\Admin;

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

class SeasonAdmin extends Admin
{
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->with('General')
                ->add('season')
                ->add('locked', null, array('required' => false))
            ->end()
            ->with('Points')
                ->add('gamePoints')
                ->add('championshipPoints')
            ->end()
            ->with('Championship/Playoffs')
                ->add('hasChampionship', null, array('required' => false))
                ->add('championshipWinner')
            ->end()
        ;
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('season')
        ;
    }

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

<?php

namespace SofaChamps\Bundle\BowlPickemBundle\Admin;

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

class SeasonAdmin extends Admin
{
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->with('General')
                ->add('season')
                ->add('picksLockAt', null, array('required' => false))
                ->add('locked', null, array('required' => false))
            ->end()
            ->with('Points')
                ->add('gamePoints')
                ->add('championshipPoints')
            ->end()
            ->with('Championship/Playoffs')
                ->add('hasChampionship', null, array('required' => false))
                ->add('championshipWinner')
            ->end()
        ;
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('season')
        ;
    }

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

Allow updating of pick lock time

Allow updating of pick lock time


<?php

namespace Jalle19\CertificateParser\Provider;

/**
 * Interface ProviderInterface
 * @package Jalle19\CertificateParser\Provider
 */
interface ProviderInterface
{

    /**
     * @return array
     */
    public function getRawCertificate();

}

<?php

namespace Jalle19\CertificateParser\Provider;

/**
 * Interface ProviderInterface
 * @package Jalle19\CertificateParser\Provider
 */
interface ProviderInterface
{

    /**
     * @return resource the raw X.509 certificate
     */
    public function getRawCertificate();

}

Change the interface phpdoc (resource is returned, not array)


<?php
class Kwf_Assets_Dependency_Decorator_Abstract extends Kwf_Assets_Dependency_Abstract
{
    protected $_dep;
    public function __construct(Kwf_Assets_Dependency_Abstract $dep)
    {
        $this->_dep = $dep;
        parent::__construct();
    }

    public function usesLanguage()
    {
        return $this->_dep->usesLanguage();
    }

    public function getContentsSource()
    {
        return $this->_dep->getContentsSource();
    }

    public function getContentsSourceString()
    {
        return $this->_dep->getContentsSourceString();
    }

    public function getMimeType()
    {
        return $this->_dep->getMimeType();
    }

    public function getMTime()
    {
        return $this->_dep->getMTime();
    }

    public function warmupCaches()
    {
        return $this->_dep->warmupCaches();
    }

    public function getDeferLoad()
    {
        return $this->_dep->getDeferLoad();
    }

    public function isCommonJsEntry()
    {
        return $this->_dep->isCommonJsEntry();
    }

    public function __toString()
    {
        return str_replace('Kwf_Assets_Dependency_Decorator_', '', get_class($this)).'('.$this->_dep->__toString().')';
    }
}

<?php
class Kwf_Assets_Dependency_Decorator_Abstract extends Kwf_Assets_Dependency_Abstract
{
    protected $_dep;
    public function __construct(Kwf_Assets_Dependency_Abstract $dep)
    {
        $this->_dep = $dep;
        parent::__construct();
    }

    public function usesLanguage()
    {
        return $this->_dep->usesLanguage();
    }

    public function getContentsSource()
    {
        return $this->_dep->getContentsSource();
    }

    public function getContentsSourceString()
    {
        return $this->_dep->getContentsSourceString();
    }

    public function getMimeType()
    {
        return $this->_dep->getMimeType();
    }

    public function getMTime()
    {
        return $this->_dep->getMTime();
    }

    public function warmupCaches()
    {
        return $this->_dep->warmupCaches();
    }

    public function getDeferLoad()
    {
        return $this->_dep->getDeferLoad();
    }

    public function isCommonJsEntry()
    {
        return $this->_dep->isCommonJsEntry();
    }

    public function __toString()
    {
        return str_replace('Kwf_Assets_Dependency_Decorator_', '', get_class($this)).'('.$this->_dep->__toString().')';
    }

    public function setDependencies($type, $deps)
    {
        return $this->_dep->setDependencies($type, $deps);
    }

    public function addDependencies($type, $deps)
    {
        return $this->_dep->addDependencies($type, $deps);
    }

    public function addDependency($type, $dep, $index = null)
    {
        return $this->_dep->addDependency($type, $dep, $index);
    }

    public function getDependencies($type)
    {
        return $this->_dep->getDependencies($type);
    }
}

Add dependency methods for asset decorator


<?php

namespace Nectary\Services;

/**
 * Feed Services should implement a public
 * get_feed( $url ) to abstract away how a
 * particular feed is retreived.
 */
abstract class Feed_Service {
	abstract public function get_feed( $url );
}

<?php

namespace Nectary\Services;

/**
 * Feed Services should implement a public
 * get_feed( $url ) to abstract away how a
 * particular feed is retreived.
 */
abstract class Feed_Service {
	abstract public function get_feed( string $url );
}

Add type hint on feed service argument

Add type hint on feed service argument


<?php

declare(strict_types=1);

namespace unit\src\Hasher;

use Signature\Hasher\Md5Hasher;

/**
 * Tests for {@see Signature\Hasher\Md5Hasher}.
 *
 * @group   Unitary
 * @author  Jefersson Nathan <malukenho@phpse.net>
 * @license MIT
 *
 * @covers \Signature\Hasher\Md5Hasher
 */
final class Md5HasherTest extends \PHPUnit_Framework_TestCase
{
    public function testHash()
    {
        $hasher = new Md5Hasher();

        self::assertSame('40cd750bba9870f18aada2478b24840a', $hasher->hash([]));
        self::assertSame('38017a839aaeb8ff1a658fce9af6edd3', $hasher->hash([null]));
        self::assertSame('262bbc0aa0dc62a93e350f1f7df792b9', $hasher->hash([1, 2, 3]));
        self::assertSame('aa565c66cb423c77379a37dd2d17bb2b', $hasher->hash(['params' => ['one' => [], 'two' => 123]]));
    }
}

<?php

declare(strict_types=1);

namespace SignatureTest\Hasher;

use Signature\Hasher\Md5Hasher;

/**
 * Tests for {@see Signature\Hasher\Md5Hasher}.
 *
 * @group   Unitary
 * @author  Jefersson Nathan <malukenho@phpse.net>
 * @license MIT
 *
 * @covers \Signature\Hasher\Md5Hasher
 */
final class Md5HasherTest extends \PHPUnit_Framework_TestCase
{
    public function testHash()
    {
        $hasher = new Md5Hasher();

        self::assertSame('40cd750bba9870f18aada2478b24840a', $hasher->hash([]));
        self::assertSame('38017a839aaeb8ff1a658fce9af6edd3', $hasher->hash([null]));
        self::assertSame('262bbc0aa0dc62a93e350f1f7df792b9', $hasher->hash([1, 2, 3]));
        self::assertSame('aa565c66cb423c77379a37dd2d17bb2b', $hasher->hash(['params' => ['one' => [], 'two' => 123]]));
    }
}

Fix wrong namespace for unit test

Fix wrong namespace for unit test


<?php

namespace EventStore\Common\Annotation;

/**
 * @Annotation
 */
class EventSourcedAggregate
{

}

<?php

namespace EventStore\Common\Annotation;

use Doctrine\Common\Annotations\Annotation\Target;

/**
 * @Annotation
 * @Target({"CLASS"})
 */
class EventSourcedAggregate
{

}

Add missing target annotation definition.


<?php

namespace Code16\Sharp\Utils\Transformers\Attributes;

use Code16\Sharp\Utils\Transformers\SharpAttributeTransformer;

class MarkdownAttributeTransformer implements SharpAttributeTransformer
{
    /** @var bool */
    protected $handleImages = false;

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

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

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

    /**
     * @param int|null $width
     * @param int|null $height
     * @param array $filters
     * @return MarkdownAttributeTransformer
     */
    public function handleImages(int $width = null, int $height = null, array $filters = [])
    {
        $this->handleImages = true;
        $this->imageWidth = $width;
        $this->imageHeight = $height;
        $this->imageFilters = $filters;

        return $this;
    }

    /**
     * Transform a model attribute to array (json-able).
     *
     * @param mixed $value
     * @param object $instance
     * @param string $attribute
     * @return mixed
     */
    function apply($value, $instance = null, $attribute = null)
    {
        if(!$instance->$attribute) {
            return null;
        }

        $html = (new \Parsedown())->parse($instance->$attribute);

        if($this->handleImages) {
            return sharp_markdown_thumbnails(
                $html, "", $this->imageWidth, $this->imageHeight, $this->imageFilters
            );
        }

        return $html;
    }
}

<?php

namespace Code16\Sharp\Utils\Transformers\Attributes;

use Code16\Sharp\Utils\Transformers\SharpAttributeTransformer;

class MarkdownAttributeTransformer implements SharpAttributeTransformer
{
    /** @var bool */
    protected $handleImages = false;

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

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

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

    /**
     * @param int|null $width
     * @param int|null $height
     * @param array $filters
     * @return MarkdownAttributeTransformer
     */
    public function handleImages(int $width = null, int $height = null, array $filters = [])
    {
        $this->handleImages = true;
        $this->imageWidth = $width;
        $this->imageHeight = $height;
        $this->imageFilters = $filters;

        return $this;
    }

    /**
     * Transform a model attribute to array (json-able).
     *
     * @param mixed $value
     * @param object $instance
     * @param string $attribute
     * @return mixed
     */
    function apply($value, $instance = null, $attribute = null)
    {
        if(!$instance->$attribute) {
            return null;
        }

        $html = (new \Parsedown())
            ->setBreaksEnabled(true)
            ->parse($instance->$attribute);

        if($this->handleImages) {
            return sharp_markdown_thumbnails(
                $html, "", $this->imageWidth, $this->imageHeight, $this->imageFilters
            );
        }

        return $html;
    }
}

Handle GFM line break by default in MD transformer


@extends('theme/main')
@section('title')
Login - Researchew
@endsection
@section('content')

        @if(Session::has('message'))

{{ Session::get('message') }}

        @endif

Login

                {{ Form::open(array('url'=>'user/auth', 'class'=>'am-form')) }}

                      Email
                      {{ Form::text('email', null, array('class'=>'', 'placeholder'=>'Please type in your account email')) }}

                        Password
                        {{ Form::password('password', array('class'=>'', 'placeholder'=>'Please type in your password')) }}

<button type="submit" class="am-btn am-btn-primary am-btn-block">Submit</button>

                {{ Form::close() }}

@endsection
@section('script')

@endsection

Change alert color in login page

Change alert color in login page


<?php

namespace BitWasp\Bitcoin\Tests;

use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Crypto\EcAdapter\PhpEcc;
use BitWasp\Bitcoin\Crypto\EcAdapter\Secp256k1;

class AbstractTestCase extends \PHPUnit_Framework_TestCase
{
    /**
     * @return array
     */
    public function getEcAdapters()
    {
        $math = Bitcoin::getMath();
        $generator = Bitcoin::getGenerator();

        $adapters = [
            [new PhpEcc($math, $generator)]
        ];

        if (!defined('HHVM_VERSION') && extension_loaded('secp256k1')) {
            $adapters[] = [new Secp256k1($math, $generator)];
        }

        return $adapters;
    }
}

<?php

namespace BitWasp\Bitcoin\Tests;

use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Crypto\EcAdapter\PhpEcc;
use BitWasp\Bitcoin\Crypto\EcAdapter\Secp256k1;

class AbstractTestCase extends \PHPUnit_Framework_TestCase
{
    /**
     * @return array
     */
    public function getEcAdapters()
    {
        $math = Bitcoin::getMath();
        $generator = Bitcoin::getGenerator();

        $adapters = [
            [new PhpEcc($math, $generator)]
        ];

        if (getenv('TRAVIS_PHP_VERSION') !== 'hhvm' && extension_loaded('secp256k1')) {
            $adapters[] = [new Secp256k1($math, $generator)];
        }

        return $adapters;
    }
}

Make sure we're not blocking secp256k1 tests


<?php
/**
 * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

namespace Test\App\AppStore\Bundles;

use OC\App\AppStore\Bundles\SocialSharingBundle;

class SocialSharingBundleTest extends BundleBase {
	public function setUp() {
		parent::setUp();
		$this->bundle = new SocialSharingBundle($this->l10n);
		$this->bundleIdentifier = 'SocialSharingBundle';
		$this->bundleName = 'Social sharing bundle';
		$this->bundleAppIds = [
			'socialsharing_twitter',
			'socialsharing_googleplus',
			'socialsharing_facebook',
			'socialsharing_email',
			'socialsharing_diaspora',
		];
	}
}

<?php
/**
 * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

namespace Test\App\AppStore\Bundles;

use OC\App\AppStore\Bundles\SocialSharingBundle;

class SocialSharingBundleTest extends BundleBase {
	public function setUp() {
		parent::setUp();
		$this->bundle = new SocialSharingBundle($this->l10n);
		$this->bundleIdentifier = 'SocialSharingBundle';
		$this->bundleName = 'Social sharing bundle';
		$this->bundleAppIds = [
			'socialsharing_twitter',
			'socialsharing_facebook',
			'socialsharing_email',
			'socialsharing_diaspora',
		];
	}
}

Remove "socialsharing_googleplus" from Social Sharing Bundle

Signed-off-by: Marius Blüm <38edb439dbcce85f0f597d90d338db16e5438073@lineone.io>


<?php namespace Tait\ModelLogging;

use Tait\ModelLogging\ModelLog;
use Auth;

trait LoggableTrait
{
    /**
     * Get all logs for this object
     *
     * @return collection
     */
    protected function getAllLogs()
    {
        return ModelLog::
            with('user')
            ->where('content_id', '=', $this->id)
            ->where('content_type', '=', class_basename($this))
            ->get();
    }

    /**
     * Get paginated logs for this object
     *
     * @return collection
     */
    protected function getPaginatedLogs($per_page = 10)
    {
        return ModelLog::
            with('user')
            ->where('content_id', '=', $this->id)
            ->where('content_type', '=', class_basename($this))
            ->paginate($per_page);
    }

    /**
     * Save a new log
     *
     * @param  array $settings An array of settings to override the defaults
     *
     * @return void
     */
    public function saveLog(array $settings)
    {
        $log = new ModelLog;

        $log->fill(array_merge($this->getDefaults(), $settings));
        $log->save();
    }

    /**
     * Get some sensible defaults for this class
     *
     * @return array
     */
    protected function getDefaults()
    {
        return [
            'user_id' => Auth::id(),
            'content_id' => $this->id,
            'content_type' => class_basename($this),
            'action' => '',
            'description' => null,
        ];
    }
}

<?php namespace Tait\ModelLogging;

use Tait\ModelLogging\ModelLog;
use Auth;

trait LoggableTrait
{
    /**
     * Get all logs for this object
     *
     * @return collection
     */
    public function getAllLogs()
    {
        return ModelLog::
            with('user')
            ->where('content_id', '=', $this->id)
            ->where('content_type', '=', class_basename($this))
            ->get();
    }

    /**
     * Get paginated logs for this object
     *
     * @return collection
     */
    public function getPaginatedLogs($per_page = 10)
    {
        return ModelLog::
            with('user')
            ->where('content_id', '=', $this->id)
            ->where('content_type', '=', class_basename($this))
            ->paginate($per_page);
    }

    /**
     * Save a new log
     *
     * @param  array $settings An array of settings to override the defaults
     *
     * @return void
     */
    public function saveLog(array $settings)
    {
        $log = new ModelLog;

        $log->fill(array_merge($this->getDefaults(), $settings));
        $log->save();
    }

    /**
     * Get some sensible defaults for this class
     *
     * @return array
     */
    protected function getDefaults()
    {
        return [
            'user_id' => Auth::id(),
            'content_id' => $this->id,
            'content_type' => class_basename($this),
            'action' => '',
            'description' => null,
        ];
    }
}

Revert setting methods as protected

Revert setting methods as protected


<?php

/**
 * @file
 * Init all the data and environment.
 */

require_once(__DIR__ .  "/php/lang/ClassLoader.php");

$default = array();

$default['classloader'] = new \php\lang\ClassLoader();

$_ENV = $_ENV + $default;

unset($default);

require_once(__DIR__ . "/static.php");

import("php.lang");

spl_autoload_register(function ($class) {
	$_ENV['classloader']->loadClass($class);
});

?>

<?php

/**
 * @file
 * Init all the data and environment.
 */
use \php\lang;

require_once(__DIR__ .  "/php/lang/ClassLoader.php");

$default = array();

$default['classloader'] = new ClassLoader();

$_ENV = $_ENV + $default;

unset($default);

require_once(__DIR__ . "/static.php");

import("php.lang");

spl_autoload_register(function ($class) {
	$_ENV['classloader']->loadClass($class);
});

?>

Add use namespace insteade of use absolute path


<?php

declare(strict_types=1);

/*
 * This file is part of the Sonata Project package.
 *
 * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sonata\ClassificationBundle\Tests\Resources;

use Sonata\CoreBundle\Test\XliffValidatorTestCase;

class XliffTest extends XliffValidatorTestCase
{
    /**
     * @return array List all path to validate xliff
     */
    public function getXliffPaths()
    {
        return [[__DIR__.'/../../Resources/translations']];
    }
}

<?php

declare(strict_types=1);

/*
 * This file is part of the Sonata Project package.
 *
 * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sonata\ClassificationBundle\Tests\Resources;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Translation\Exception\InvalidResourceException;
use Symfony\Component\Translation\Loader\XliffFileLoader;

class XliffTest extends TestCase
{
    /**
     * @var XliffFileLoader
     */
    protected $loader;

    /**
     * @var string[]
     */
    protected $errors = [];

    public function setUp(): void
    {
        $this->loader = new XliffFileLoader();
    }

    /**
     * @dataProvider getXliffPaths
     */
    public function testXliff($path)
    {
        $this->validatePath($path);

        if (\count($this->errors) > 0) {
            $this->fail(sprintf('Unable to parse xliff files: %s', implode(', ', $this->errors)));
        }
    }

    /**
     * @return array List all path to validate xliff
     */
    public function getXliffPaths()
    {
        return [[__DIR__.'/../../Resources/translations']];
    }

    /**
     * @param string $file The path to the xliff file
     */
    protected function validateXliff($file)
    {
        try {
            $this->loader->load($file, 'en');
            $this->assertTrue(true, sprintf('Successful loading file: %s', $file));
        } catch (InvalidResourceException $e) {
            $this->errors[] = sprintf('%s => %s', $file, $e->getMessage());
        }
    }

    /**
     * @param string $path The path to lookup for Xliff file
     */
    protected function validatePath($path)
    {
        $files = glob(sprintf('%s/*.xliff', $path));

        foreach ($files as $file) {
            $this->validateXliff($file);
        }
    }
}

Reduce dependency on core bundle

Reduce dependency on core bundle


<?php
/**
 * This file is part of the Emperor Norton Commands.
 *
 * Public domain. All rites reversed.
 */

namespace EmperorNortonCommands\lib;

use DateTime;

/**
 * Class Holydays
 * @package EmperorNortonCommands\lib
 */
abstract class Holydays
{
    /**
     * Array of Holydays.
     *
     * Keys are composed of the Gregorian day and month (2 digits). Values are the
     * Holyday's name in the given language.
     *
     * @var mixed
     */
    protected $holydays = array();

    /**
     * Get Holyday.
     *
     * Returns the English name of the Holyday if there is a Holyday for given
     * the key, else returns empty string.
     *
     * @param string $key
     * @return string
     */
    public function getHolyday($key)
    {
        if (isset($key, $this->holydays)) {
            return $this->holydays[$key];
        }

        return '';
    }
}

<?php
/**
 * This file is part of the Emperor Norton Commands.
 *
 * Public domain. All rites reversed.
 */

namespace EmperorNortonCommands\lib;

use DateTime;

/**
 * Class Holydays
 * @package EmperorNortonCommands\lib
 */
abstract class Holydays
{
    /**
     * Array of Holydays.
     *
     * Keys are composed of the Gregorian day and month (2 digits). Values are the
     * Holyday's name in the given language.
     *
     * @var mixed
     */
    protected $holydays = array();

    /**
     * Get Holyday.
     *
     * Returns the name of the Holyday if there is a Holyday for given the key,
     * else returns empty string.
     *
     * @param string $key
     * @return string
     */
    public function getHolyday($key)
    {
        if (isset($this->holydays[$key])) {
            return $this->holydays[$key];
        }

        return '';
    }
}

Fix wrong usage of isset().

Fix wrong usage of isset().


<?php
declare(strict_types=1);

namespace Onion\REST;

use \Onion\Framework\Http\Header\Accept;
use \Onion\REST\Transformers\Interfaces\TransformerInterface;

class TransformerContainer
{
    /**
     * @var TransformerInterface
     */
    private $strategies = [];

    /**
     * @param TransformerInterface[] $strategies
     */
    public function __construct(array $transformers)
    {
        $this->strategies = $stransformers;
    }

    public function getDefaultTransformer(): TransformerInterface
    {
        return array_pop($this->strategies);
    }

    public function negotiateTransformer(Accept $accept): TransformerInterface
    {
        $list = [];
        foreach ($this->strategies as $type => $strategy) {
            if ($header->supports($type)) {
                $list[$header->getPriority($type)] = $strategy;
            }
        }

        if ($list === []) {
            return $this->getDefaultTransformer();
        }

        return array_pop($list);
    }
}

<?php
declare(strict_types=1);

namespace Onion\REST;

use \Onion\Framework\Http\Header\Accept;
use \Onion\REST\Transformers\Interfaces\TransformerInterface;

class TransformerContainer
{
    /**
     * @var TransformerInterface
     */
    private $strategies = [];

    /**
     * @param TransformerInterface[] $strategies
     */
    public function __construct(array $transformers)
    {
        $this->strategies = $stransformers;
    }

    public function getDefaultTransformer(): TransformerInterface
    {
        return array_shift$this->strategies);
    }

    public function negotiateTransformer(Accept $accept): TransformerInterface
    {
        $list = [];
        foreach ($this->strategies as $type => $strategy) {
            if ($header->supports($type)) {
                $list[$header->getPriority($type)] = $strategy;
            }
        }

        if ($list === []) {
            return $this->getDefaultTransformer();
        }

        return array_pop($list);
    }
}

Change from array_pop to array_shift for returning the 'default' transformer


<?php

namespace RedBeanPHP\Plugins\RedSql\Filters;

use R;
use RedBean_QueryWriter_Oracle;
use RedBean_QueryWriter_MySQL;

class FilterOFFSET implements FilterInterface
{

    public function validate(array $parameters)
    {
        if (!array_key_exists('value', $parameters)) {
            throw new \InvalidArgumentException("OFFSET expects an [offset] value.");
        }
    }

    /**
     * @todo limit for oracle
     */
    public function apply(&$sql_reference, array &$values_reference, array $parameters)
    {
        $writer = R::$toolbox->getWriter();
        $values_reference[] = $parameters['value'];
        if ($writer instanceof RedBean_QueryWriter_Oracle) {
            return;
        }
        if ($writer instanceof RedBean_QueryWriter_MySQL) {
            $sql_reference .= ", ? ";
            return;
        }
        $sql_reference .= " OFFSET ? ";
    }
}

<?php

namespace RedBeanPHP\Plugins\RedSql\Filters;

use R;
use RedBean_QueryWriter_Oracle;

class FilterOFFSET implements FilterInterface
{

    public function validate(array $parameters)
    {
        if (!array_key_exists('value', $parameters)) {
            throw new \InvalidArgumentException("OFFSET expects an [offset] value.");
        }
    }

    /**
     * @todo limit for oracle
     */
    public function apply(&$sql_reference, array &$values_reference, array $parameters)
    {
        $writer = R::$toolbox->getWriter();
        $values_reference[] = $parameters['value'];
        if ($writer instanceof RedBean_QueryWriter_Oracle) {
            return;
        }
        $sql_reference .= " OFFSET ? ";
    }
}

Revert "OFFSSET filter uses shorthand syntax when in MySQL"

This reverts commit cdd6cb52d2f8646f3da10876f7a9caef56c7cd51.


<?php

/**
 * Hackwork v2.0.0-beta (http://git.io/hackwork)
 * Licensed under the MIT License.
 */

/*
 * Paths
 *
 * Omit trailing slashes here.
 */

// Root
define('ROOT', $_SERVER['DOCUMENT_ROOT']);
define('PATH', ROOT);

// Core
define('CORE', PATH . '/core');
define('HELPERS', CORE . '/helpers');

// Layouts
define('LAYOUTS', PATH . '/layouts');

// Data
define('DATA', PATH . '/data');

// Assets
define('ASSETS', '/assets');
define('CSS', ASSETS . '/css');
define('JS', ASSETS . '/js');
define('FONTS', ASSETS . '/fonts');
define('IMG', ASSETS . '/img');

/*
 * Helpers
 */

$helpers = array(
  'http',
  'errors',
  'layout',
  'config'
);

foreach ($helpers as $helper) {
  require_once HELPERS . "/$helper.php";
}

<?php

/**
 * Hackwork v2.0.0-beta (http://git.io/hackwork)
 * Licensed under the MIT License.
 */

/*
 * Paths
 *
 * Omit trailing slashes here.
 */

// Root
define('ROOT', $_SERVER['DOCUMENT_ROOT']);
define('PATH', ROOT);

// Core
define('CORE', PATH . '/core');
define('HELPERS', CORE . '/helpers');

// Layouts
define('LAYOUTS', PATH . '/layouts');

// Data
define('DATA', PATH . '/data');

// Assets
define('ASSETS', '/assets');
define('CSS', ASSETS . '/css');
define('JS', ASSETS . '/js');
define('FONTS', ASSETS . '/fonts');
define('IMG', ASSETS . '/img');

/*
 * Helpers
 */

$helpers = array(
  'http',
  'errors',
  'layout',
  'config'
);

foreach ($helpers as $helper) {
  $helper = HELPERS . "/$helper.php";

  if (file_exists($helper)) {
    require_once $helper;
  }
}

Fix errors if helper doesn't exist

Fix errors if helper doesn't exist


<?php
/**
 * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */

namespace OC\DB;

class AdapterOCI8 extends Adapter {
	public function lastInsertId($table) {
		if($table !== null) {
			$suffix = '_SEQ';
			$table = '"'.$table.$suffix.'"';
			$table = $this->conn->replaceTablePrefix( $table );
		}
		return $this->conn->lastInsertId($table);
	}

	public function fixupStatement($statement) {
		$statement = str_replace( '`', '"', $statement );
		$statement = str_ireplace( 'NOW()', 'CURRENT_TIMESTAMP', $statement );
		$statement = str_ireplace( 'UNIX_TIMESTAMP()', "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400", $statement );
		return $statement;
	}
}

<?php
/**
 * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */

namespace OC\DB;

class AdapterOCI8 extends Adapter {
	public function lastInsertId($table) {
		if($table !== null) {
			$suffix = '_SEQ';
			$table = '"'.$table.$suffix.'"';
		}
		return $this->conn->realLastInsertId($table);
	}

	public function fixupStatement($statement) {
		$statement = str_replace( '`', '"', $statement );
		$statement = str_ireplace( 'NOW()', 'CURRENT_TIMESTAMP', $statement );
		$statement = str_ireplace( 'UNIX_TIMESTAMP()', "(cast(sys_extract_utc(systimestamp) as date) - date'1970-01-01') * 86400", $statement );
		return $statement;
	}
}

Fix lastInsertId for OCI8 adapter

Fix lastInsertId for OCI8 adapter


{!! Form::hidden($name, $value ? $value : null, ['placeholder' => (isset($placeholder)) ? $placeholder : null, 'class' => (isset($class)) ? $class : null]) !!}

{!! Form::hidden($name, isset($value) ? $value : null, ['placeholder' => (isset($placeholder)) ? $placeholder : null, 'class' => (isset($class)) ? $class : null]) !!}

Fix hidden form partial value

Fix hidden form partial value


<?php
namespace res\infrastructure\String;

use vsc\infrastructure\String;

/**
 * Class encodeEntitiesTest
 * @package res\infrastructure\String
 * @covers \vsc\infrastructure\String::encodeEntites()
 */
class encodeEntitiesTest extends \PHPUnit_Framework_TestCase {

	public function testUseless() {
		$sString = 'ana are mere gigel <a /> ';
		$this->assertEquals(htmlentities($sString, ENT_QUOTES, 'UTF-8'), String::encodeEntities($sString));
	}
}

<?php
namespace res\infrastructure\String;

use vsc\infrastructure\String;

/**
 * Class encodeEntitiesTest
 * @package res\infrastructure\String
 * @covers \vsc\infrastructure\String::encodeEntities()
 */
class encodeEntitiesTest extends \PHPUnit_Framework_TestCase {

	public function testUseless() {
		$sString = 'ana are mere gigel <a /> ';
		$this->assertEquals(htmlentities($sString, ENT_QUOTES, 'UTF-8'), String::encodeEntities($sString));
	}
}

Fix a misspell in coverage

Fix a misspell in coverage


<?php
    // Use in the "Post-Receive URLs" section of your GitHub repo.
    if ( $_POST['payload'] ) {
        file_put_contents('log/payload.txt', print_r($_POST['payload'], FILE_APPEND);

        $exec_string = 'cd /var/customers/webs/jmm/weltengeschichte.de.repo/ && git reset --hard HEAD && git pull';
        exec ( $exec_string, $output);
        file_put_contents('log/output.txt', $output, FILE_APPEND);
    }

    file_put_contents('log/post.txt', print_r($_POST), FILE_APPEND);
?>

<?php
    // Use in the "Post-Receive URLs" section of your GitHub repo.
    if ( $_POST['payload'] && false ) {
        file_put_contents('log/payload.txt', print_r($_POST['payload'], FILE_APPEND);

        $exec_string = 'cd /var/customers/webs/jmm/weltengeschichte.de.repo/ && git reset --hard HEAD && git pull';
        exec ( $exec_string, $output);
        file_put_contents('log/output.txt', $output, FILE_APPEND);
    }

    file_put_contents('log/post.txt', print_r($_POST));
?>

Deploy on push, test 2

Deploy on push, test 2


<?php
App::uses('Purifier', 'HtmlPurifier.Lib');
/**
 * HtmlPurifierBehavior
 *
 * @author Florian Krämer
 * @copyright 2012 Florian Krämer
 * @license MIT
 */
class HtmlPurifierBehavior extends ModelBehavior {

	public function setup(Model $Model, $settings = array()) {
		$this->settings = $settings;
	}
/**
 * beforeSave
 *
 * @param Model $model
 * @return boolean
 */
	public function beforeSave(Model $Model, $options = array()) {
		extract($this->settings);

		foreach($fields as $field) {
			if (isset($Model->data[$Model->alias][$field])) {
				$Model->data[$Model->alias][$field] = $this->purifyHtml($Model, $Model->data[$Model->alias][$field], $config);
			}
		}

		return true;
	}

/**
 * Cleans markup
 *
 * @param Model $Model
 * @param string $markup
 * @param string $config
 */
	public function purifyHtml(Model $Model, $markup, $config) {
		return Purifier::clean($markup, $config);
	}

}

<?php
App::uses('Purifier', 'HtmlPurifier.Lib');
/**
 * HtmlPurifierBehavior
 *
 * @author Florian Krämer
 * @copyright 2012 Florian Krämer
 * @license MIT
 */
class HtmlPurifierBehavior extends ModelBehavior {

	public function setup(Model $Model, $settings = array()) {
		$this->settings[$Model->alias] = (array)$settings;
	}
/**
 * beforeSave
 *
 * @param Model $model
 * @return boolean
 */
	public function beforeSave(Model $Model, $options = array()) {
		extract($this->settings[$Model->alias]);

		foreach($fields as $field) {
			if (isset($Model->data[$Model->alias][$field])) {
				$Model->data[$Model->alias][$field] = $this->purifyHtml($Model, $Model->data[$Model->alias][$field], $config);
			}
		}

		return true;
	}

/**
 * Cleans markup
 *
 * @param Model $Model
 * @param string $markup
 * @param string $config
 */
	public function purifyHtml(Model $Model, $markup, $config) {
		return Purifier::clean($markup, $config);
	}

}

Store behavior settings by model

Store behavior settings by model


<?php

namespace Oro\Bundle\EmailBundle\Model;

/**
 * Represents an email message template
 */
interface EmailTemplateInterface
{
    /**
     * Gets email template type
     *
     * @return string
     */
    public function getType();

    /**
     * Gets email subject
     *
     * @return string
     */
    public function getSubject();

    /**
     * Gets email template content
     *
     * @return string
     */
    public function getContent();

    /**
     * Sets email template content
     *
     * @param string $content
     * @return EmailTemplateInterface
     */
    public function setContent($content);

    /**
     * Sets email subject
     *
     * @param string $subject
     * @return EmailTemplateInterface
     */
    public function setSubject($subject);
}

<?php

namespace Oro\Bundle\EmailBundle\Model;

/**
 * Represents an email message template
 */
interface EmailTemplateInterface
{
    /**
     * Gets email template type
     *
     * @return string
     */
    public function getType();

    /**
     * Gets email subject
     *
     * @return string
     */
    public function getSubject();

    /**
     * Gets email template content
     *
     * @return string
     */
    public function getContent();

    /**
     * Sets email template content
     *
     * @param string $content
     *
     * @return EmailTemplateInterface
     */
    public function setContent($content);

    /**
     * Sets email subject
     *
     * @param string $subject
     *
     * @return EmailTemplateInterface
     */
    public function setSubject($subject);
}

BAP-4676: Fix Major issues mentioned in Scrutinizer builds
 - Edit


<?php

namespace Admingenerator\GeneratorBundle\Menu;

use Knp\Menu\FactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Router;

class DefaultMenuBuilder
{
    private $factory;

    /**
     * @param \Knp\Menu\FactoryInterface $factory
     */
    public function __construct(FactoryInterface $factory)
    {
        $this->factory = $factory;
    }

    /**
     * @param Request $request
     * @param Router $router
     */
    public function createAdminMenu(Request $request)
    {
        $menu = $this->factory->createItem('root');

        $menu->setCurrentUri($request->getRequestUri());

        $menu->setAttributes(array('id' => 'main_navigation', 'class'=>'menu'));

        $help = $menu->addChild('Overwrite this menu', array('uri' => '#'));
        $help->setLinkAttributes(array('class'=>'sub main'));

        $help->addChild('Configure menu class', array('uri' => 'https://github.com/knplabs/KnpMenuBundle/blob/master/Resources/doc/index.md'));
        $help->addChild('Configure php class to use', array('uri' => 'https://github.com/cedriclombardot/AdmingeneratorGeneratorBundle/blob/master/Resources/doc/change-the-menu-class.markdown'));

        return $menu;
    }
}

<?php

namespace Admingenerator\GeneratorBundle\Menu;

use Knp\Menu\FactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Router;

class DefaultMenuBuilder
{
    private $factory;

    /**
     * @param \Knp\Menu\FactoryInterface $factory
     */
    public function __construct(FactoryInterface $factory)
    {
        $this->factory = $factory;
    }

    /**
     * @param Request $request
     * @param Router $router
     */
    public function createAdminMenu(Request $request)
    {
        $menu = $this->factory->createItem('root', array('childrenAttributes' => array('id' => 'main_navigation', 'class'=>'menu') ) );

        $menu->setCurrentUri($request->getRequestUri());

        $help = $menu->addChild('Overwrite this menu', array('uri' => '#'));
        $help->setLinkAttributes(array('class'=>'sub main'));

        $help->addChild('Configure menu class', array('uri' => 'https://github.com/knplabs/KnpMenuBundle/blob/master/Resources/doc/index.md'));
        $help->addChild('Configure php class to use', array('uri' => 'https://github.com/cedriclombardot/AdmingeneratorGeneratorBundle/blob/master/Resources/doc/change-the-menu-class.markdown'));

        return $menu;
    }
}

Update due to KnpMenuBundle changes

Update due to KnpMenuBundle changes


<?php

/**
 * Created by Cristian.
 * Date: 11/09/16 09:26 PM.
 */

namespace Reliese\Coders\Model\Relations;

use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Collection;

class HasMany extends HasOneOrMany
{
    /**
     * @return string
     */
    public function hint()
    {
        return '\\'.Collection::class;
    }

    /**
     * @return string
     */
    public function name()
    {
        if ($this->parent->usesSnakeAttributes()) {
            return Str::snake(Str::plural(Str::singular($this->related->getTable(true))));
        }

        return Str::camel(Str::plural(Str::singular($this->related->getTable(true))));
    }

    /**
     * @return string
     */
    public function method()
    {
        return 'hasMany';
    }
}

<?php

/**
 * Created by Cristian.
 * Date: 11/09/16 09:26 PM.
 */

namespace Reliese\Coders\Model\Relations;

use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Collection;

class HasMany extends HasOneOrMany
{
    /**
     * @return string
     */
    public function hint()
    {
        return '\\'.Collection::class;
    }

    /**
     * @return string
     */
    public function name()
    {
        $relationBaseName = Str::plural(Str::singular($this->related->getTable(true)));

        switch ($this->parent->getRelationNameStrategy()) {
            case 'foreign_key':
                $suffix = preg_replace("/[^a-zA-Z0-9]?{$this->localKey()}$/", '', $this->foreignKey());

                $relationName = $relationBaseName;

                // Don't make relations such as users_user, just leave it as 'users'.
                if ($this->parent->getTable(true) !== $suffix) {
                    $relationName .= "_{$suffix}";
                }

                break;
            case 'related':
            default:
                $relationName = $relationBaseName;
                break;
        }

        if ($this->parent->usesSnakeAttributes()) {
            return Str::snake($relationName);
        }

        return Str::camel($relationName);
    }

    /**
     * @return string
     */
    public function method()
    {
        return 'hasMany';
    }
}

Implement foreign key based naming for has many relations