<?php
namespace Tests\Unit;
/**
 * Dotenv Test
 *
 * @author Leonid Mamchenkov <l.mamchenkov@qobo.biz>
 */
class DotenvTest extends \PHPUnit_Framework_TestCase {

	/**
	 * Check that .env.example file exists
	 */
	public function testDotenvExampleFileExists() {
		$file = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '.env.example';
		$this->assertTrue(file_exists($file), ".env.example file does not exist [$file]");
	}

}

<?php
namespace Tests\Unit;

use \Dotenv;
/**
 * Dotenv Test
 *
 * @author Leonid Mamchenkov <l.mamchenkov@qobo.biz>
 */
class DotenvTest extends \PHPUnit_Framework_TestCase {

	protected $folder;
	protected $file;

	protected function setUp() {
		$this->folder = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
		$this->file = '.env.example';
	}

	/**
	 * Check that .env.example file exists
	 */
	public function testDotenvExampleFileExists() {
		$this->assertTrue(file_exists($this->folder . $this->file), ".env.example file does not exist [" . $this->folder . $this->file . "]");
	}

	/**
	* Check that we can parse .env.example file
	*
	* @depends testDotenvExampleFileExists
	*/
	public function testDotenvExampleFileIsParseable() {
		Dotenv::load($this->folder, $this->file);
	}
}

Test parsing of .env.example file

Test parsing of .env.example file


<?php
/**
 * @author    Igor Nikolaev <igor.sv.n@gmail.com>
 * @copyright Copyright (c) 2015, Darvin Studio
 * @link      https://www.darvin-studio.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Darvin\Utils\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Blank;

/**
 * Anti-spam form type
 */
class AntiSpamType extends AbstractType
{
    const ANTI_SPAM_TYPE_CLASS = __CLASS__;

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'label'       => false,
            'attr'        => array(
                'class' => 'title_field',
            ),
            'constraints' => new Blank(),
            'mapped'      => false,
            'required'    => false,
        ));
    }

    /**
     * {@inheritdoc}
     */
    public function getParent()
    {
        return 'text';
    }

    /**
     * {@inheritdoc}
     */
    public function getBlockPrefix()
    {
        return 'darvin_utils_anti_spam';
    }
}

<?php
/**
 * @author    Igor Nikolaev <igor.sv.n@gmail.com>
 * @copyright Copyright (c) 2015, Darvin Studio
 * @link      https://www.darvin-studio.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Darvin\Utils\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Blank;

/**
 * Anti-spam form type
 */
class AntiSpamType extends AbstractType
{
    const ANTI_SPAM_TYPE_CLASS = __CLASS__;

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'label'       => false,
            'attr'        => array(
                'class' => 'title_field',
            ),
            'constraints' => new Blank(),
            'mapped'      => false,
            'required'    => false,
        ));
    }

    /**
     * {@inheritdoc}
     */
    public function getParent()
    {
        return 'Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType';
    }

    /**
     * {@inheritdoc}
     */
    public function getBlockPrefix()
    {
        return 'darvin_utils_anti_spam';
    }
}

Replace form type name with FQCN in getParent() methods.


<?php

/*
 * This file is part of PhpSpec, A php toolset to drive emergent
 * design by specification.
 *
 * (c) Marcello Duarte <marcello.duarte@gmail.com>
 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PhpSpec\Process\Prerequisites;

use PhpSpec\Process\Context\ExecutionContextInterface;

final class SuitePrerequisites implements SuitePrerequisitesInterface
{
    /**
     * @var ExecutionContextInterface
     */
    private $executionContext;

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

    /**
     * @throws PrerequisiteFailedException
     */
    public function guardPrerequisites()
    {
        $undefinedTypes = array();

        foreach ($this->executionContext->getGeneratedTypes() as $type) {
            if (!class_exists($type) && !interface_exists($type)) {
                $undefinedTypes[] = $type;
            }
        }

        if ($undefinedTypes) {
            throw new PrerequisiteFailedException(sprintf(
                "The type%s %s was generated but could not be loaded. Do you need to configure an autoloader?\n",
                count($undefinedTypes) > 1 ? 's' : '',
                join(', ', $undefinedTypes)
            ));
        }
    }
}

<?php

/*
 * This file is part of PhpSpec, A php toolset to drive emergent
 * design by specification.
 *
 * (c) Marcello Duarte <marcello.duarte@gmail.com>
 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace PhpSpec\Process\Prerequisites;

use PhpSpec\Process\Context\ExecutionContextInterface;

final class SuitePrerequisites implements SuitePrerequisitesInterface
{
    /**
     * @var ExecutionContextInterface
     */
    private $executionContext;

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

    /**
     * @throws PrerequisiteFailedException
     */
    public function guardPrerequisites()
    {
        $undefinedTypes = array();

        foreach ($this->executionContext->getGeneratedTypes() as $type) {
            if (!class_exists($type) && !interface_exists($type)) {
                $undefinedTypes[] = $type;
            }
        }

        if ($undefinedTypes) {
            throw new PrerequisiteFailedException(sprintf(
                "The type%s %s %s generated but could not be loaded. Do you need to configure an autoloader?\n",
                count($undefinedTypes) > 1 ? 's' : '',
                join(', ', $undefinedTypes),
                count($undefinedTypes) > 1 ? 'were' : 'was'
            ));
        }
    }
}

Correct was->were in plural version of error message


<?php

class SimplePie_First_Item_Content_Test_RSS_090_Description extends SimplePie_First_Item_Content_Test
{
	function data()
	{
		$this->data =
'<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://my.netscape.com/rdf/simple/0.9/">
	<item>
		<description>Item Description</description>
	</item>
</rdf:RDF>';
	}

	function expected()
	{
		$this->expected = NULL;
	}
}

?>

<?php

class SimplePie_First_Item_Content_Test_RSS_090_Description extends SimplePie_First_Item_Content_Test
{
	function data()
	{
		$this->data =
'<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://my.netscape.com/rdf/simple/0.9/">
	<item>
		<description>Item Description</description>
	</item>
</rdf:RDF>';
	}

	function expected()
	{
		// <description> isn't technically in 0.90, but we support it for compatibility
		$this->expected = 'Item Description';
	}
}

?>

Change test to note compatibility

Change test to note compatibility


<?php

namespace SebastiaanLuca\Router;

use Illuminate\Contracts\Http\Kernel as AppKernel;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider;
use Illuminate\Routing\Router;
use SebastiaanLuca\Router\Routers\BootstrapRouter;

class RouterServiceProvider extends RouteServiceProvider
{

    /**
     * Map user-defined routers.
     */
    protected function registerUserRouters()
    {
        // We can safely assume the Kernel contract is the application's
        // HTTP kernel as it is bound in bootstrap/app.php to the actual
        // implementation.
        $routers = app(AppKernel::class)->getRouters();

        // Just instantiate each router, they handle the mapping itself
        foreach ($routers as $router) {
            app($router);
        }
    }

    /**
     * Register the service provider.
     */
    public function register()
    {
        // Define our router extension
        $this->app->singleton(ExtendedRouter::class, function ($app) {
            return new ExtendedRouter($app['events'], $app);
        });

        // Swap the default router with our extended router
        $this->app->alias(ExtendedRouter::class, 'router');
    }

    /**
     * Define your route model bindings, pattern filters, etc using the Bootstrap router.
     *
     * @param \Illuminate\Routing\Router $router
     */
    public function boot(Router $router)
    {
        // Create a router that defines route patterns and whatnot
        $this->app->make(BootstrapRouter::class);

        // Map user-defined routers
        $this->registerUserRouters();
    }

}

<?php

namespace SebastiaanLuca\Router;

use Illuminate\Contracts\Http\Kernel as AppKernel;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider;
use Illuminate\Routing\Router;
use SebastiaanLuca\Router\Routers\BootstrapRouter;

class RouterServiceProvider extends RouteServiceProvider
{

    /**
     * Map user-defined routers.
     */
    protected function registerUserRouters()
    {
        // We can safely assume the Kernel contract is the application's
        // HTTP kernel as it is bound in bootstrap/app.php to the actual
        // implementation. Still need to check if it's the package's
        // custom kernel though as that is an optional setup choice.

        $kernel = app(AppKernel::class);

        if (! $kernel instanceof Kernel) {
            return;
        }

        $routers = $kernel->getRouters();

        // Just instantiate each router as they handle the mapping itself
        foreach ($routers as $router) {
            app($router);
        }
    }

    /**
     * Register the service provider.
     */
    public function register()
    {
        // Define our router extension
        $this->app->singleton(ExtendedRouter::class, function ($app) {
            return new ExtendedRouter($app['events'], $app);
        });

        // Swap the default router with our extended router
        $this->app->alias(ExtendedRouter::class, 'router');
    }

    /**
     * Define your route model bindings, pattern filters, etc using the Bootstrap router.
     *
     * @param \Illuminate\Routing\Router $router
     */
    public function boot(Router $router)
    {
        // Create a router that defines route patterns and whatnot
        $this->app->make(BootstrapRouter::class);

        // Map user-defined routers
        $this->registerUserRouters();
    }

}

Fix service provider kernel detection

Fix service provider kernel detection


<?php

namespace Telegram\Bot\Objects;

/**
 * Class Update
 *
 * @package Telegram\Bot\Objects
 */
class Update extends BaseObject
{
    /**
     * @inheritdoc
     */
    public function relations()
    {
        return [
            'message' => Message::class,
        ];
    }

    /**
     * Get recent message.
     *
     * @return Update
     */
    public function recentMessage()
    {
        return new static($this->last());
    }
}

<?php

namespace Telegram\Bot\Objects;

/**
 * Class Update
 *
 * @package Telegram\Bot\Objects
 *
 * @method int      getUpdateId()  The update's unique identifier. Update identifiers start from a certain positive number and increase sequentially.
 * @method Message  getMessage()    (Optional). New incoming message of any kind - text, photo, sticker, etc.
 *
 */
class Update extends BaseObject
{
    /**
     * @inheritdoc
     */
    public function relations()
    {
        return [
            'message' => Message::class,
        ];
    }

    /**
     * Get recent message.
     *
     * @return Update
     */
    public function recentMessage()
    {
        return new static($this->last());
    }
}

Add @methods to object doc bloc

Add @methods to object doc bloc


<?php

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

namespace Sylius\Bundle\CoreBundle\OrderProcessing;

use Sylius\Bundle\CoreBundle\Model\OrderInterface;
use Sylius\Bundle\ResourceBundle\Model\RepositoryInterface;

/**
 * Payment processor.
 *
 * @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
 */
class PaymentProcessor implements PaymentProcessorInterface
{
    /**
     * Payment repository.
     *
     * @var RepositoryInterface
     */
    protected $paymentRepository;

    /**
     * Constructor.
     *
     * @param RepositoryInterface $paymentRepository
     */
    public function __construct(RepositoryInterface $paymentRepository)
    {
        $this->paymentRepository = $paymentRepository;
    }

    /**
     * {@inheritdoc}
     */
    public function createPayment(OrderInterface $order)
    {
        $payment = $this->paymentRepository->createNew();

        $payment->setCurrency($order->getCurrency());
        $order->setPayment($payment);

        return $payment;
    }
}

<?php

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

namespace Sylius\Bundle\CoreBundle\OrderProcessing;

use Sylius\Bundle\CoreBundle\Model\OrderInterface;
use Sylius\Bundle\ResourceBundle\Model\RepositoryInterface;

/**
 * Payment processor.
 *
 * @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
 */
class PaymentProcessor implements PaymentProcessorInterface
{
    /**
     * Payment repository.
     *
     * @var RepositoryInterface
     */
    protected $paymentRepository;

    /**
     * Constructor.
     *
     * @param RepositoryInterface $paymentRepository
     */
    public function __construct(RepositoryInterface $paymentRepository)
    {
        $this->paymentRepository = $paymentRepository;
    }

    /**
     * {@inheritdoc}
     */
    public function createPayment(OrderInterface $order)
    {
        $payment = $this->paymentRepository->createNew();

        $payment->setCurrency($order->getCurrency());
        $payment->setAmount($order->getTotal());
        $order->setPayment($payment);

        return $payment;
    }
}

Add amount to payment at creation

Add amount to payment at creation


<?php

namespace FullyBaked\Pslackr\Messages;

class CustomMessage implements Message
{
    protected $text;

    public function asJson()
    {
        $message = [
            'text' => $this->text
        ];
        return json_encode($message);
    }

    public function text($text)
    {
        $this->text = $text;
    }

}

<?php

namespace FullyBaked\Pslackr\Messages;

class CustomMessage implements Message
{
    protected $text;

    protected $optionalFields = [];

    public function __construct($messageText)
    {
        $this->text = $messageText;
    }
    public function asJson()
    {
        $message = ['text' => 'This is a test message'];

        $message = array_merge($message, $this->optionalFields);

        return json_encode($message);
    }

    public function channel($channelName)
    {
        $this->optionalFields['channel'] = $channelName;
    }

    public function username($username)
    {
        $this->optionalFields['username'] = $username;
    }

    public function iconEmoji($token)
    {
        $this->optionalFields['icon_emoji'] = $token;
    }

    public function iconUrl($url)
    {
        $this->optionalFields['icon_url'] = $url;
    }
}

Implement setter methods for optional params


<?php

/**
 * Returns the absolute URL of a theme asset.
 *
 * @param string  $relative_url If the URL starts with `@bower/`, the prefix will be the value of
 *                              $GLOBALS['bower_components_root_url'] if it exists
 * @param boolean $escape
 *
 * @return string
 */
function _fswpt_get_asset($relative_url, $escape = true)
{
    if (isset($GLOBALS['bower_components_root_url']) && substr($relative_url, 0, 7) === '@bower/') {
        $url = $GLOBALS['bower_components_root_url'].'/'.substr($relative_url, 7);
    } else {
        $url = get_stylesheet_directory_uri()."/{$relative_url}";
    }
    if ($escape) {
        $url = esc_url($url);
    }

    return $url;
}

/**
 * Returns the absolute URL of an image attachment, according to format.
 *
 * @param integer $attachment_id
 * @param string  $format
 * @param boolean $escape
 *
 * @return string
 */
function _fswpt_get_image_src($attachment_id, $format = 'thumbnail', $escape = true)
{
    $img_src = wp_get_attachment_image_src($attachment_id, $format);
    $src     = (isset($img_src[0]) ? $img_src[0] : '');
    if ($escape) {
        $src = esc_url($src);
    }

    return $src;
}

<?php

/**
 * Returns the absolute URL of a theme asset.
 *
 * @param string  $relative_url If the URL starts with `@bower/`, the prefix will be the value of
 *                              $GLOBALS['bower_components_root_url'] if it exists
 * @param boolean $escape
 *
 * @return string
 */
function _fswpt_get_asset($relative_url, $escape = true)
{
    global $bower_components_root_url;

    if ($bower_components_root_url && substr($relative_url, 0, 7) === '@bower/') {
        $url = "{$bower_components_root_url}/".substr($relative_url, 7);
    } else {
        $url = get_stylesheet_directory_uri()."/{$relative_url}";
    }
    if ($escape) {
        $url = esc_url($url);
    }

    return $url;
}

/**
 * Returns the absolute URL of an image attachment, according to format.
 *
 * @param integer $attachment_id
 * @param string  $format
 * @param boolean $escape
 *
 * @return string
 */
function _fswpt_get_image_src($attachment_id, $format = 'thumbnail', $escape = true)
{
    $img_src = wp_get_attachment_image_src($attachment_id, $format);
    $src     = (isset($img_src[0]) ? $img_src[0] : '');
    if ($escape) {
        $src = esc_url($src);
    }

    return $src;
}

Refactor the code a bit

Refactor the code a bit


<?php

/*
 * This file is part of CarcelUserBundle.
 *
 * Copyright (c) 2016 Damien Carcel <damien.carcel@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Carcel\Bundle\UserBundle\Factory;

/**
 * Creates a new instance of \Swift_Message.
 *
 * @author Damien Carcel <damien.carcel@gmail.com>
 */
class SwiftMessageFactory
{
    /**
     * @return \Swift_Message
     */
    public function create()
    {
        return \Swift_Message::newInstance();
    }
}

<?php

/*
 * This file is part of CarcelUserBundle.
 *
 * Copyright (c) 2016 Damien Carcel <damien.carcel@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Carcel\Bundle\UserBundle\Factory;

/**
 * Creates a new instance of \Swift_Message.
 *
 * @author Damien Carcel <damien.carcel@gmail.com>
 */
class SwiftMessageFactory
{
    /**
     * @return \Swift_Message
     */
    public function create()
    {
        return new \Swift_Message();
    }
}

Update Swiftmailer to 3.0 as 2.x has security risks


<?php

namespace Omnipay\SecureTrading\Message;

use DOMDocument;

/**
 * ThreeDSecure Request
 *
 * @method ThreeDSecureResponse send()
 */
class ThreeDSecureRequest extends AbstractPurchaseRequest
{
    /**
     * @return string
     */
    public function getAction()
    {
        return 'THREEDQUERY';
    }

    /**
     * @return DOMDocument
     */
    public function getData()
    {
        $data = parent::getData();

        $this->validate('returnUrl');

        /** @var DOMDocument $request */
        $request = $data->getElementsByTagName('request');
        /** @var DOMDocument $merchant */
        $merchant = $data->getElementsByTagName('merchant')->item(0);
        $merchant->appendChild($data->createElement('termurl', $this->getReturnUrl()));

        /** @var DOMDocument $customer */
        $customer = $request->getElementsByTagName('customer')->item(0) ?: $request->appendChild($data->createElement('customer'));
        $customer->appendChild($data->createElement('accept', $this->getAccept()));
        $customer->appendChild($data->createElement('useragent', $this->getUserAgent()));

        return $data;
    }

    /**
     * @param string $data
     * @return Response
     */
    protected function createResponse($data)
    {
        return $this->response = new ThreeDSecureResponse($this, $data);
    }
}

<?php

namespace Omnipay\SecureTrading\Message;

use DOMDocument;

/**
 * ThreeDSecure Request
 *
 * @method ThreeDSecureResponse send()
 */
class ThreeDSecureRequest extends AbstractPurchaseRequest
{
    /**
     * @return string
     */
    public function getAction()
    {
        return 'THREEDQUERY';
    }

    /**
     * @return DOMDocument
     */
    public function getData()
    {
        $data = parent::getData();

        $this->validate('returnUrl');

        /** @var DOMDocument $request */
        $request = $data->getElementsByTagName('request')->item(0);
        /** @var DOMDocument $merchant */
        $merchant = $data->getElementsByTagName('merchant')->item(0);
        $merchant->appendChild($data->createElement('termurl', $this->getReturnUrl()));

        /** @var DOMDocument $customer */
        $customer = $request->getElementsByTagName('customer')->item(0) ?: $request->appendChild($data->createElement('customer'));
        $customer->appendChild($data->createElement('accept', $this->getAccept()));
        $customer->appendChild($data->createElement('useragent', $this->getUserAgent()));

        return $data;
    }

    /**
     * @param string $data
     * @return Response
     */
    protected function createResponse($data)
    {
        return $this->response = new ThreeDSecureResponse($this, $data);
    }
}

Fix Call to undefined method DOMNodeList::getElementsByTagName()


<?php declare(strict_types=1);

namespace Symplify\Statie\Templating;

use Symplify\Statie\Configuration\Configuration;
use Symplify\Statie\Renderable\File\AbstractFile;

abstract class AbstractTemplatingFileDecorator
{
    /**
     * @var Configuration
     */
    protected $configuration;

    /**
     * @required
     */
    public function addConfiguration(Configuration $configuration): void
    {
        $this->configuration = $configuration;
    }

    /**
     * @return mixed[]
     */
    protected function createParameters(AbstractFile $file, string $fileKey): array
    {
        $parameters = $file->getConfiguration();
        $parameters += $this->configuration->getOptions();
        $parameters[$fileKey] = $file;

        return $parameters;
    }
}

<?php declare(strict_types=1);

namespace Symplify\Statie\Templating;

use Symplify\Statie\Configuration\Configuration;
use Symplify\Statie\Renderable\File\AbstractFile;

abstract class AbstractTemplatingFileDecorator
{
    /**
     * @var Configuration
     */
    protected $configuration;

    /**
     * @required
     */
    public function addConfiguration(Configuration $configuration): void
    {
        $this->configuration = $configuration;
    }

    /**
     * @return mixed[]
     */
    protected function createParameters(AbstractFile $file, string $fileKey): array
    {
        $parameters = $file->getConfiguration();
        $parameters += $this->configuration->getOptions();
        $parameters[$fileKey] = $file;
        $parameters['layout'] = $file->getLayout();

        return $parameters;
    }
}

Return missing layout to file params

[Statie] Return missing layout to file params


<?php
/*
 * PixLab PHP Client which is just a single class PHP file without any dependency that you can get from Github
 * https://github.com/symisc/pixlab-php
 */
require_once "pixlab.php";

# Tag an image based on detected visual content which mean running a CNN on top of it.
# https://pixlab.io/#/cmd?id=tagimg for more info.

# Target Image: Change to any link or switch to POST if you want to upload your image directly, refer to the sample set for more info.
$img = 'https://s-media-cache-ak0.pinimg.com/originals/35/d0/f6/35d0f6ee0e40306c41cfd714c625f78e.jpg';
# Your PixLab key
$key = 'My_Pixlab_Key';
/* Process */
$pix = new Pixlab($key);
if( !$pix->get('tagimg',array(
	'img' => $img,
	'key' => $key
	)) ){
	echo $pix->get_error_message();
	die;
}
/* Grab the total number of tags */
$tags = $pix->json->tags;
echo "Total number of detected tags: ".count($tags)."\n";
foreach($tags as $tag){
	echo "Tag = ".$tag->name.", Confidence: ".$tag->confidence."\n";
}

<?php
/*
 * PixLab PHP Client which is just a single class PHP file without any dependency that you can get from Github
 * https://github.com/symisc/pixlab-php
 */
require_once "pixlab.php";

# Tag an image based on detected visual content which mean running a CNN on top of it.
# https://pixlab.io/#/cmd?id=tagimg for more info.

# Target Image: Change to any link or switch to POST if you want to upload your image directly, refer to the sample set for more info.
$img = 'https://s-media-cache-ak0.pinimg.com/originals/35/d0/f6/35d0f6ee0e40306c41cfd714c625f78e.jpg';
# Your PixLab key
$key = 'My_Pixlab_Key';
/* Process */
$pix = new Pixlab($key);
if( !$pix->get('tagimg',array(
	'img' => $img,
	'key' => $key
	)) ){
	echo $pix->get_error_message();
	die;
}
/* Grab the total number of tags */
$tags = $pix->json->tags;
echo "Total number of tags: ".count($tags)."\n";
foreach($tags as $tag){
	echo "Tag = ".$tag->name.", Confidence: ".$tag->confidence."\n";
}


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

			<?php

			get_template_part( SNIPPETS_DIR . '/header/entry', 'header' );
			get_template_part( SNIPPETS_DIR . '/entry', 'content' );

			comments_template();

			?>

			<?php

			if ( '' !== get_the_post_thumbnail() && ! is_single() ) :
				get_template_part( SNIPPETS_DIR . '/post', 'thumbnail' );
			endif;

			keitaro_child_pages_list( get_the_ID() );

			dynamic_sidebar( 'keitaro_page_icon_blocks' );

			?>

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

        get_template_part(SNIPPETS_DIR . '/header/entry-header');
        get_template_part(SNIPPETS_DIR . '/entry-content');

        ?>
    </article>
    <?php
endif;

Load snippet only when page content not empty and clean code


<?php

namespace Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ORM\Query;

use Doctrine\ORM\Query;

/**
 * ORM Query helper for cloning
 * and hint processing
 */
class Helper
{
    /**
     * Clones the given $query and copies all used
     * parameters and hints
     *
     * @param Query $query
     * @return Query
     */
    public static function cloneQuery(Query $query)
    {
        $clonedQuery = clone $query;
        $clonedQuery->setParameters($query->getParameters());
        // attach hints
        foreach ($query->getHints() as $name => $hint) {
            $clonedQuery->setHint($name, $hint);
        }

        return $clonedQuery;
    }

    /**
     * Add a custom TreeWalker $walker class name to
     * be included in the CustomTreeWalker hint list
     * of the given $query
     *
     * @param Query $query
     * @param string $walker
     * @return void
     */
    public static function addCustomTreeWalker(Query $query, $walker)
    {
        $customTreeWalkers = $query->getHint(Query::HINT_CUSTOM_TREE_WALKERS);
        if ($customTreeWalkers !== false && is_array($customTreeWalkers)) {
            $customTreeWalkers = array_merge($customTreeWalkers, array($walker));
        } else {
            $customTreeWalkers = array($walker);
        }
        $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $customTreeWalkers);
    }
}

<?php

namespace Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ORM\Query;

use Doctrine\ORM\Query;

/**
 * ORM Query helper for cloning
 * and hint processing
 */
class Helper
{
    /**
     * Clones the given $query and copies all used
     * parameters and hints
     *
     * @param Query $query
     * @return Query
     */
    public static function cloneQuery(Query $query)
    {
        $clonedQuery = clone $query;
        $clonedQuery->setParameters(clone $query->getParameters());
        // attach hints
        foreach ($query->getHints() as $name => $hint) {
            $clonedQuery->setHint($name, $hint);
        }

        return $clonedQuery;
    }

    /**
     * Add a custom TreeWalker $walker class name to
     * be included in the CustomTreeWalker hint list
     * of the given $query
     *
     * @param Query $query
     * @param string $walker
     * @return void
     */
    public static function addCustomTreeWalker(Query $query, $walker)
    {
        $customTreeWalkers = $query->getHint(Query::HINT_CUSTOM_TREE_WALKERS);
        if ($customTreeWalkers !== false && is_array($customTreeWalkers)) {
            $customTreeWalkers = array_merge($customTreeWalkers, array($walker));
        } else {
            $customTreeWalkers = array($walker);
        }
        $query->setHint(Query::HINT_CUSTOM_TREE_WALKERS, $customTreeWalkers);
    }
}

Clone the parameters too since they are an object

We need to clone the parameters for this query or the parameters could change if the original query's parameters are changed.
This is how doctrine does it.
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/Pagination/Paginator.php#L212
To bad that method isn't static.


<?php declare(strict_types = 1);

namespace Churn\Tests;

use PHPUnit\Framework\TestCase;

abstract class BaseTestCase extends TestCase
{

}

<?php declare(strict_types = 1);

namespace Churn\Tests;

use Mockery as m;
use PHPUnit\Framework\TestCase;

abstract class BaseTestCase extends TestCase
{
    /**
     * @see https://github.com/phpspec/prophecy/issues/366#issuecomment-359587114
     */
    protected function tearDown()
    {
        $this->addToAssertionCount(m::getContainer()->mockery_getExpectationCount());
    }
}

Add to assertion count from Mockery

Fix: Add to assertion count from Mockery


		id) }}">

				content_page]->logo) ? $pages[$challenge->content_page]->logo : $pages[$challenge->content_page]->coverimage }}" class="img-responsive">

		id) }}">

					{{ $pages[$challenge->content_page]->heading }}

{{ $challenge->points_max }} Points

		@if( $challenge->remaining_attempts == 0 )
		@else   @endif

		id) }}">

				content_page]->logo) ? $pages[$challenge->content_page]->logo : $pages[$challenge->content_page]->coverimage }}" class="img-responsive">

		id) }}">

					{{ $pages[$challenge->content_page]->heading }}

{{ $challenge->points_max }} Points @if($challenge->type == ChallengeType::FEATURED)  FEATURED  @endif

		@if( $challenge->remaining_attempts == 0 )
		@else   @endif

Add featured tag to featured challenges

Add featured tag to featured challenges


<?php
namespace Aws\Test\Integ;

trait IntegUtils
{
    private static function getSdk(array $args = [])
    {
        return new \Aws\Sdk($args + [
            'region'  => 'us-east-1',
            'profile' => 'integ',
            'version' => 'latest',
            'user-agent' => 'PHPUnit/Integration'
        ]);
    }

    public static function log($message)
    {
        fwrite(STDERR, date('c') . ': ' . $message . "\n");
    }

    /**
     * Get the resource prefix to add to created resources
     *
     * @return string
     */
    public static function getResourcePrefix()
    {
        if (!isset($_SERVER['PREFIX']) || $_SERVER['PREFIX'] == 'hostname') {
            $_SERVER['PREFIX'] = crc32(gethostname()) . rand(0, 10000);
        }

        return $_SERVER['PREFIX'];
    }
}

<?php
namespace Aws\Test\Integ;

trait IntegUtils
{
    private static function getSdk(array $args = [])
    {
        return new \Aws\Sdk($args + [
            'region'  => 'us-east-1',
            'profile' => 'integ',
            'version' => 'latest',
            'ua_append' => 'PHPUnit/Integration'
        ]);
    }

    public static function log($message)
    {
        fwrite(STDERR, date('c') . ': ' . $message . "\n");
    }

    /**
     * Get the resource prefix to add to created resources
     *
     * @return string
     */
    public static function getResourcePrefix()
    {
        if (!isset($_SERVER['PREFIX']) || $_SERVER['PREFIX'] == 'hostname') {
            $_SERVER['PREFIX'] = crc32(gethostname()) . rand(0, 10000);
        }

        return $_SERVER['PREFIX'];
    }
}

Add a user agent identifier to the integration test client


<?php
use Afrihost\SwarmProcess\SwarmProcess;

/**
 * User: sarel
 * Date: 2015/12/29
 * Time: 17:51
 */
class SwarmProcessTest extends PHPUnit\Framework\TestCase
{
    /** @var SwarmProcess */
    private $swarm;

    protected function setUp()
    {
        $this->swarm = new SwarmProcess();
    }

    public function testSetMaxRunStack()
    {
        $this->assertEquals($this->swarm->getMaxRunStackSize(), 10); // default is 10

        $fluent = $this->swarm->setMaxRunStackSize(20);
        $this->assertEquals($this->swarm->getMaxRunStackSize(), 20);

        $this->assertInstanceOf('\Afrihost\SwarmProcess\SwarmProcess', $fluent);
    }

    public function testClassCreation()
    {
        $this->assertTrue(is_object($this->swarm), 'Cannot instantiate SwarmProcess class into an object.');
    }

    /**
     * @expectedException \OutOfBoundsException
     */
    public function testSetMaxRunStackSizeThrowsOutOfBounds()
    {
        $this->swarm->setMaxRunStackSize(-1);
    }

}

<?php

use Afrihost\SwarmProcess\Configuration;
use Afrihost\SwarmProcess\SwarmProcess;

/**
 * User: sarel
 * Date: 2015/12/29
 * Time: 17:51
 */
class SwarmProcessTest extends PHPUnit\Framework\TestCase
{
    /** @var SwarmProcess */
    private $swarm;

    protected function setUp()
    {
        $this->swarm = new SwarmProcess();
    }

    public function testSetMaxRunStack()
    {
        $this->assertEquals($this->swarm->getMaxRunStackSize(), 10); // default is 10

        $fluent = $this->swarm->setMaxRunStackSize(20);
        $this->assertEquals($this->swarm->getMaxRunStackSize(), 20);

        $this->assertInstanceOf('\Afrihost\SwarmProcess\SwarmProcess', $fluent);
    }

    public function testClassCreation()
    {
        $this->assertTrue(is_object($this->swarm), 'Cannot instantiate SwarmProcess class into an object.');
    }

    /**
     * @expectedException \OutOfBoundsException
     */
    public function testSetMaxRunStackSizeThrowsOutOfBounds()
    {
        $this->swarm->setMaxRunStackSize(-1);
    }

    public function testConfigurationSetting()
    {
        $config = new Configuration();
        // cannot set the callable, because clojure's are not serializable (and the assertion needs this)
        $config->setEnforceProcessTimeouts(true);
        $config->setTickLoopDelayMicroseconds(1234);

        $this->swarm->setConfiguration($config);

        $this->assertEquals($config, $this->swarm->getConfiguration());
    }

}

Test setting of the configuration class in the SwarmProcess


<?php
App::uses('AppModel', 'Model');

/**
 * Person model
 */
class Person extends AppModel
{
	public $primaryKey = 'facebook_id';

	public $hasMany = array(
		'ProductListing' => array(
			'className' => 'ProductListing',
			'foreignKey' => 'creator'
		)
	);

	public $hasAndBelongsToMany = array(
		'Buys' => array(
			'className' => 'ProductListing',
			'joinTable' => 'product_listing_buyers',
			'associationForeignKey' => 'product_listing_id',
			'unique' => true
		)
	);

	/**
	 * Gets the listings by the given person.
	 *
	 * @param string $id
	 */
	public function listings($id)
	{
		return $this->ProductListing->findByCreatorId($id);
	}
}

<?php
App::uses('AppModel', 'Model');

/**
 * Person model
 */
class Person extends AppModel
{
	public $primaryKey = 'facebook_id';

	public $hasMany = array(
		'ProductListing' => array(
			'className' => 'ProductListing',
			'foreignKey' => 'creator'
		)
	);

	public $hasAndBelongsToMany = array(
		'Buys' => array(
			'className' => 'ProductListing',
			'joinTable' => 'product_listing_buyers',
			'associationForeignKey' => 'product_listing_id',
			'unique' => true
		)
	);

	/**
	 * Gets the listings by the given person.
	 *
	 * @param string $id
	 */
	public function listings($id)
	{
		return $this->ProductListing->findByCreatorId($id);
	}

	/**
	 * Gets the listings from the friends of the given person.
	 *
	 * @param string $id
	 */
	public function friendListings($id)
	{
		$friends = FB::api('/' . $id . '/friends');
		$friend_ids = array_map(function($friend) {
				return $friend['id'];
			}, $friends['data']);

		return $this->ProductListing->findByCreatorId($friend_ids);
	}
}

Allow retrieval of the listings by the friends of the current user.


<?php
/***************************************************************************
 * @author           Pierre-Henry Soria <ph7software@gmail.com>
 * @category         PH7 Template Engine
 * @package          PH7 / Framework / Layout / Tpl / Engine / PH7Tpl / Syntax
 * @copyright        (c) 2018, Pierre-Henry Soria. All Rights Reserved.
 * @license          CC-BY License - http://creativecommons.org/licenses/by/3.0/
 ***************************************************************************/

namespace PH7\Framework\Layout\Tpl\Engine\PH7Tpl\Syntax;

use PH7\Framework\Error\CException\PH7RuntimeException;

defined('PH7') or exit('Restricted access');

class EmptyCodeException extends PH7RuntimeException
{
    const CURLY_SYNTAX = 1;
    const TAL_SYNTAX = 2;
}

<?php
/***************************************************************************
 * @author           Pierre-Henry Soria <ph7software@gmail.com>
 * @category         PH7 Template Engine
 * @package          PH7 / Framework / Layout / Tpl / Engine / PH7Tpl / Syntax
 * @copyright        (c) 2018, Pierre-Henry Soria. All Rights Reserved.
 * @license          CC-BY License - http://creativecommons.org/licenses/by/3.0/
 ***************************************************************************/

namespace PH7\Framework\Layout\Tpl\Engine\PH7Tpl\Syntax;

use PH7\Framework\Error\CException\PH7RuntimeException;

class EmptyCodeException extends PH7RuntimeException
{
    const CURLY_SYNTAX = 1;
    const TAL_SYNTAX = 2;
}

Remove redundant "defined or exit()" code


<?php
namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class SecurityController extends Controller
{
    /**
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\Response
     *
     * @Route("/login",
     *     name="app_security_login",
     *     methods={"GET"})
     */
    public function loginAction(Request $request)
    {
        $authenticationUtils = $this->get('security.authentication_utils');

        // Login error if there is one
        $error = $authenticationUtils->getLastAuthenticationError();

        // Last username entered by the user
        $lastUsername = $authenticationUtils->getLastUsername();

        return $this->render('security/login.html.twig', array('error' => $error, 'lastUserName' => $lastUsername));
    }

    /**
     * @Route("/login/check",
     *     name="app_security_login_check",
     *     methods={"GET"})
     */
    public function loginCheckAction()
    {
        // Never be executed
    }

    /**
     * @Route("/logout",
     *     name="app_security_logout",
     *     methods={"GET"})
     */
    public function logoutAction()
    {
        // Never be executed
    }
}

<?php
namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;

class SecurityController extends Controller
{
    /**
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\Response
     *
     * @Route("/login",
     *     name="app_security_login",
     *     methods={"GET"})
     */
    public function loginAction(Request $request)
    {
        $authenticationUtils = $this->get('security.authentication_utils');

        // Login error if there is one
        $error = $authenticationUtils->getLastAuthenticationError();

        // Last username entered by the user
        $lastUsername = $authenticationUtils->getLastUsername();

        return $this->render('security/login.html.twig', array('error' => $error, 'lastUserName' => $lastUsername));
    }

    /**
     * @Route("/login/check",
     *     name="app_security_login_check",
     *     methods={"POST"})
     */
    public function loginCheckAction()
    {
        // Never be executed
    }

    /**
     * @Route("/logout",
     *     name="app_security_logout",
     *     methods={"GET"})
     */
    public function logoutAction()
    {
        // Never be executed
    }
}

FIX method POST on login_check

FIX method POST on login_check


<?php

namespace Illuminate\Http\Client;

use GuzzleHttp\Psr7\Message;

class RequestException extends HttpClientException
{
    /**
     * The response instance.
     *
     * @var \Illuminate\Http\Client\Response
     */
    public $response;

    /**
     * Create a new exception instance.
     *
     * @param  \Illuminate\Http\Client\Response  $response
     * @return void
     */
    public function __construct(Response $response)
    {
        parent::__construct($this->prepareMessage($response), $response->status());

        $this->response = $response;
    }

    /**
     * Prepare the exception message.
     *
     * @param  \Illuminate\Http\Client\Response  $response
     * @return string
     */
    protected function prepareMessage(Response $response)
    {
        $message = "HTTP request returned status code {$response->status()}";

        $summary = Message::bodySummary($response->toPsrResponse());

        return is_null($summary) ? $message : $message .= ":\n{$summary}\n";
    }
}

<?php

namespace Illuminate\Http\Client;

class RequestException extends HttpClientException
{
    /**
     * The response instance.
     *
     * @var \Illuminate\Http\Client\Response
     */
    public $response;

    /**
     * Create a new exception instance.
     *
     * @param  \Illuminate\Http\Client\Response  $response
     * @return void
     */
    public function __construct(Response $response)
    {
        parent::__construct($this->prepareMessage($response), $response->status());

        $this->response = $response;
    }

    /**
     * Prepare the exception message.
     *
     * @param  \Illuminate\Http\Client\Response  $response
     * @return string
     */
    protected function prepareMessage(Response $response)
    {
        $message = "HTTP request returned status code {$response->status()}";

        $summary = \GuzzleHttp\Psr7\get_message_body_summary($response->toPsrResponse());

        return is_null($summary) ? $message : $message .= ":\n{$summary}\n";
    }
}

Revert deprecated function to support PHP 7.3


Related Grants and Projects

        @foreach($related['grants_projects']['docs'] as $col)

                {{ $col['display_relationship'] }}

                    {{$col['to_title']}}
                {{ isset($col['to_funder']) ? "(funded by ". $col['to_funder'] .")" : '' }}

        @endforeach
        @if($related['grants_projects']['count'] > 5)

View all {{ $related['grants_projects']['count'] }} related grants and projects

        @endif

Related Grants and Projects

        @foreach($related['grants_projects']['docs'] as $col)

                {{ $col['display_relationship'] }}
                <a href="{{ base_url() }}{{$col['to_slug']}}/{{$col['to_id']}}"
                   title="{{ $col['to_title'] }}"
                   class="ro_preview"
                   tip="{{ $col['display_description'] }}"
                    @if(isset($col['to_id']) && $col['to_id']!='false')
                        ro_id="{{ $col['to_id'] }}"
                    @elseif(isset($col["relation_identifier_id"]))
                        identifier_relation_id="{{ $col['relation_identifier_id'] }}"
                    @endif
                    >
                    {{$col['to_title']}}
                {{ isset($col['to_funder']) ? "(funded by ". $col['to_funder'] .")" : '' }}

        @endforeach
        @if($related['grants_projects']['count'] > 5)

View all {{ $related['grants_projects']['count'] }} related grants and projects

        @endif

Add identifier relation popout to grants and projects


<?php

/**
 *    Copyright 2015 ppy Pty. Ltd.
 *
 *    This file is part of osu!web. osu!web is distributed with the hope of
 *    attracting more community contributions to the core ecosystem of osu!.
 *
 *    osu!web is free software: you can redistribute it and/or modify
 *    it under the terms of the Affero GNU General Public License version 3
 *    as published by the Free Software Foundation.
 *
 *    osu!web is distributed 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 osu!web.  If not, see <http://www.gnu.org/licenses/>.
 */
namespace App\Models;

class DeletedUser extends User
{
    public $user_avatar = null;
    public $username = trans('users.deleted');
}

<?php

/**
 *    Copyright 2015 ppy Pty. Ltd.
 *
 *    This file is part of osu!web. osu!web is distributed with the hope of
 *    attracting more community contributions to the core ecosystem of osu!.
 *
 *    osu!web is free software: you can redistribute it and/or modify
 *    it under the terms of the Affero GNU General Public License version 3
 *    as published by the Free Software Foundation.
 *
 *    osu!web is distributed 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 osu!web.  If not, see <http://www.gnu.org/licenses/>.
 */
namespace App\Models;

class DeletedUser extends User
{
    public $user_avatar = null;
    public $username = '[deleted user]';
}

Fix showing deleted user in forum

Fix showing deleted user in forum

Apparently assigning default instance variable using function requires using constructor and stuff. Reverting it for now.


<?php

/**
 * Copyright 2014 SURFnet bv
 *
 * 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.
 */

namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Repository;

use Doctrine\ORM\EntityRepository;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;

class IdentityRepository extends EntityRepository
{
    /**
     * @param string $nameId
     * @return Identity|null
     */
    public function find($nameId)
    {
        return parent::find($nameId);
    }

    /**
     * @param Identity $identity
     */
    public function save(Identity $identity)
    {
        $entityManager = $this->getEntityManager();
        $entityManager->persist($identity);
        $entityManager->flush();
    }
}

<?php

/**
 * Copyright 2014 SURFnet bv
 *
 * 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.
 */

namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Repository;

use Doctrine\ORM\EntityRepository;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;

class IdentityRepository extends EntityRepository
{
    /**
     * @param string $nameId
     * @return Identity|null
     */
    public function find($nameId)
    {
        /** @var Identity|null $identity */
        $identity = parent::find($nameId);

        return $identity;
    }

    /**
     * @param Identity $identity
     */
    public function save(Identity $identity)
    {
        $entityManager = $this->getEntityManager();
        $entityManager->persist($identity);
        $entityManager->flush();
    }
}

Improve static analysis opportunities of Identity find().


<?php
	return [
		"info" => true,
		"warning" => true,
		"error" => true,
		"infoDisplay" => false,
		"warningDisplay" => true,
		"errorDisplay" => true
	];
?>

<?php
	return [
		"info" => true,
		"warning" => true,
		"error" => true,
		"infoDisplay" => false,
		"warningDisplay" => true,
		"errorDisplay" => true,
		"infoTrace" => true,
		"warningTrace" => true,
		"errorTrace" => true
	];
?>

Add default config for tracing

Add default config for tracing


<?php

namespace Orbitale\Bundle\EasyImpressBundle\DependencyInjection\Compiler;

use Orbitale\Bundle\EasyImpressBundle\Configuration\ConfigProcessor;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Finder\Finder;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

class PresentationsPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        $finder = (new Finder())
            ->files()
            ->name('*.yml')
            ->in($container->getParameter('easy_impress.presentations_dir'))
        ;

        $configProcessor = new ConfigProcessor();

        $presentations = [];

        foreach ($finder as $file) {
            /** @var \SplFileInfo $file */
            $container->addResource(new FileResource($file->getRealPath()));
            $presentations[$file->getBasename('.yml')] = $configProcessor->processConfigurationFile($file);
        }

        $container->setParameter('easy_impress.presentations', $presentations);
    }
}

<?php

namespace Orbitale\Bundle\EasyImpressBundle\DependencyInjection\Compiler;

use Orbitale\Bundle\EasyImpressBundle\Configuration\ConfigProcessor;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Finder\Finder;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

class PresentationsPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        $finder = (new Finder())
            ->files()
            ->name('*.{yaml,yml}')
            ->in($container->getParameter('easy_impress.presentations_dir'))
        ;

        $configProcessor = new ConfigProcessor();

        $presentations = [];

        foreach ($finder as $file) {
            /** @var \SplFileInfo $file */
            $container->addResource(new FileResource($file->getRealPath()));
            $presentations[$file->getBasename('.yml')] = $configProcessor->processConfigurationFile($file);
        }

        $container->setParameter('easy_impress.presentations', $presentations);
    }
}

Make sure "yaml" files are compatible too


<?php

namespace Stof\DoctrineExtensionsBundle;

use Stof\DoctrineExtensionsBundle\DependencyInjection\Compiler\SecurityContextPass;
use Stof\DoctrineExtensionsBundle\DependencyInjection\Compiler\ValidateExtensionConfigurationPass;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Gedmo\Uploadable\Mapping\Validator;

class StofDoctrineExtensionsBundle extends Bundle
{
    /**
     * {@inheritdoc}
     */
    public function build(ContainerBuilder $container)
    {
        $container->addCompilerPass(new ValidateExtensionConfigurationPass());
        $container->addCompilerPass(new SecurityContextPass());
    }

    public function boot()
    {
        Validator::$validateWritableDirectory = $this->container->getParameter('stof_doctrine_extensions.uploadable.validate_writable_directory');
    }
}

<?php

namespace Stof\DoctrineExtensionsBundle;

use Stof\DoctrineExtensionsBundle\DependencyInjection\Compiler\SecurityContextPass;
use Stof\DoctrineExtensionsBundle\DependencyInjection\Compiler\ValidateExtensionConfigurationPass;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Gedmo\Uploadable\Mapping\Validator;

class StofDoctrineExtensionsBundle extends Bundle
{
    /**
     * {@inheritdoc}
     */
    public function build(ContainerBuilder $container)
    {
        $container->addCompilerPass(new ValidateExtensionConfigurationPass());
        $container->addCompilerPass(new SecurityContextPass());
    }

    public function boot()
    {
        if ($this->container->hasParameter('stof_doctrine_extensions.uploadable.validate_writable_directory')) {
            Validator::$validateWritableDirectory = $this->container->getParameter('stof_doctrine_extensions.uploadable.validate_writable_directory');
        }
    }
}

Add a param check to be able to boot with an old cache

The parameter is always defined in the bundle. However, in non-debug
mode, the kernel needs to be able to boot with the old cache to clear
the cache, so we need the parameter check.
closes #260


<?php
namespace Bolt\Storage\Entity;

/**
 * Entity for User.
 */
class Users extends Entity
{
    protected $id;
    protected $username;
    protected $password;
    protected $email;
    protected $lastseen;
    protected $lastip;
    protected $displayname;
    protected $stack = [];
    protected $enabled = 1;
    protected $shadowpassword = '';
    protected $shadowtoken = '';
    protected $shadowvalidity;
    protected $failedlogins = 0;
    protected $throttleduntil;
    protected $roles = [];

    /**
     * Setter for roles to ensure the array is always unique.
     *
     * @param array $roles
     */
    public function setRoles(array $roles)
    {
        $this->roles = array_unique($roles);
    }
}

<?php
namespace Bolt\Storage\Entity;

use Bolt\AccessControl\Permissions;

/**
 * Entity for User.
 */
class Users extends Entity
{
    protected $id;
    protected $username;
    protected $password;
    protected $email;
    protected $lastseen;
    protected $lastip;
    protected $displayname;
    protected $stack = [];
    protected $enabled = 1;
    protected $shadowpassword = '';
    protected $shadowtoken = '';
    protected $shadowvalidity;
    protected $failedlogins = 0;
    protected $throttleduntil;
    protected $roles = [];

    /**
     * Getter for roles to ensure Permissions::ROLE_EVERYONE always exists.
     *
     * @param array $roles
     */
    public function getRoles()
    {
        if (!in_array(Permissions::ROLE_EVERYONE, $this->roles)) {
            $this->roles[] = Permissions::ROLE_EVERYONE;
        }

        return $this->roles;
    }

    /**
     * Setter for roles to ensure the array is always unique.
     *
     * @param array $roles
     */
    public function setRoles(array $roles)
    {
        $this->roles = array_unique($roles);
    }
}

Add getter for roles to ensure Permissions::ROLE_EVERYONE always exists.


<?php
/**
 * Created by PhpStorm.
 * User: rahman
 * Date: 11/4/14
 * Time: 5:09 AM
 */

Validator::extend('must_alpha_num', function($attribute, $value, $parameters)
{
    $ret = FALSE;
    if (preg_match("/^[A-Za-z][A-Za-z0-9]{5,31}$/", $value)) {
        $ret = TRUE;
    }
    return $ret;
});

<?php
/**
 * Created by PhpStorm.
 * User: rahman
 * Date: 11/4/14
 * Time: 5:09 AM
 */

Validator::extend('must_alpha_num', function($attribute, $value, $parameters)
{
    $ret = FALSE;
    if (preg_match("/^[a-z][a-z0-9]{5,31}$/", $value)) {
        $ret = TRUE;
    }
    return $ret;
});

Fix username validation lowercase only

Fix username validation lowercase only


<?php
namespace Janitor\TestCases;

use Illuminate\Container\Container;
use Janitor\JanitorServiceProvider;
use PHPUnit_Framework_TestCase;

class JanitorTestCase extends PHPUnit_Framework_TestCase
{
	/**
	 * @type Container
	 */
	protected $app;

	/**
	 * Setup the tests
	 */
	public function setUp()
	{
		$this->app = new Container();
		$provider  = new JanitorServiceProvider($this->app);
		$provider->register();
		$provider->boot();
	}
}

<?php
namespace Janitor\TestCases;

use Illuminate\Container\Container;
use Janitor\JanitorServiceProvider;
use PHPUnit_Framework_TestCase;

abstract class JanitorTestCase extends PHPUnit_Framework_TestCase
{
	/**
	 * @type Container
	 */
	protected $app;

	/**
	 * Setup the tests
	 */
	public function setUp()
	{
		$this->app = new Container();
		$provider  = new JanitorServiceProvider($this->app);
		$provider->register();
		$provider->boot();
	}
}

Fix non abstract test case

Fix non abstract test case


<?php
//require_once 'PHPUnit/Autoload.php';
//require_once 'PHPUnit/Framework/Assert/Functions.php';

class TestBrowser extends \Symfony\Bundle\FrameworkBundle\Test\WebTestCase
{
  protected function createKernel(array $options = array())
  {
    return new AppKernel('test',true);
  }
  public static function getAgent(){
    $browser = new TestBrowser;
    return $browser->createClient();
  }
}

<?php
require_once 'PHPUnit/Autoload.php';
require_once 'PHPUnit/Framework/Assert/Functions.php';

class TestBrowser extends \Symfony\Bundle\FrameworkBundle\Test\WebTestCase
{
  protected function createKernel(array $options = array())
  {
    return new AppKernel('test',true);
  }
  public static function getAgent(){
    $browser = new TestBrowser;
    return $browser->createClient();
  }
}

Revert "[from now] 2011年 3月27日 日曜日 08時04分41秒 JST"

This reverts commit 888ad7d68908ec2651068eefbb0541b26700a52e.


<?php

namespace Symfony\Cmf\Bundle\BlockBundle\Document;

use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
use Doctrine\ODM\PHPCR\ChildrenCollection;

/**
 * Block that contains other blocks ...
 *
 * @PHPCRODM\Document(referenceable=true)
 */
class ContainerBlock extends BaseBlock
{
    /** @PHPCRODM\Children */
    protected  $children;

    public function getType()
    {
        return 'symfony_cmf.block.container';
    }

    public function getChildren()
    {
        return $this->children;
    }

    public function setChildren(ChildrenCollection $children)
    {
        return $this->children = $children;
    }
}

<?php

namespace Symfony\Cmf\Bundle\BlockBundle\Document;

use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
use Doctrine\ODM\PHPCR\ChildrenCollection;
use Doctrine\Common\Collections\ArrayCollection;
use Sonata\BlockBundle\Model\BlockInterface;

/**
 * Block that contains other blocks ...
 *
 * @PHPCRODM\Document(referenceable=true)
 */
class ContainerBlock extends BaseBlock
{
    /** @PHPCRODM\Children */
    protected  $children;

    public function getType()
    {
        return 'symfony_cmf.block.container';
    }

    public function getChildren()
    {
        return $this->children;
    }

    public function setChildren(ChildrenCollection $children)
    {
        return $this->children = $children;
    }

    /**
     * Add a child to this container
     *
     * @param  BlockInterface $child
     * @param  string $key OPTIONAL
     * @return boolean
     */
    public function addChild(BlockInterface $child, $key = null)
    {
        if (null === $this->children) {
            $this->children = new ArrayCollection();
        }
        if ($key != null) {
            return $this->children->set($key, $child);
        }

        return $this->children->add($child);
    }
}

Add a addChild method to container block


<?php

use Movim\Controller\Ajax;

class System extends \Movim\Widget\Base
{
    function load()
    {
    }

    function display()
    {
        header('Cache-Control:public, max-age=31536000');

        $this->view->assign('base_host',    BASE_HOST);
        $this->view->assign('small_picture_limit', SMALL_PICTURE_LIMIT);
        $this->view->assign('error_uri',    $this->route('disconnect'));
        $this->view->assign('secure_websocket',    file_get_contents(CACHE_PATH.'websocket'));
    }
}

<?php

use Movim\Controller\Ajax;

class System extends \Movim\Widget\Base
{
    function load()
    {
    }

    function display()
    {
        header('Cache-Control:public, max-age=31536000');
        header('Content-Type: application/javascript');

        $this->view->assign('base_host',    BASE_HOST);
        $this->view->assign('small_picture_limit', SMALL_PICTURE_LIMIT);
        $this->view->assign('error_uri',    $this->route('disconnect'));
        $this->view->assign('secure_websocket',    file_get_contents(CACHE_PATH.'websocket'));
    }
}

Add application/javascript header to prevent MIME type checking issue


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

<a href="<?php the_permalink(); ?>"><?php the_title(); ?>

    <?php get_template_part('templates/entry-meta'); ?>

    <?php the_content('続きを読む'); ?>

Change a position of the entry meta template


<?php
// src/Acme/TestBundle/Controller/TestController.php

namespace Acme\TestBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

class TestController extends Controller
{
    public function indexAction()
    {
        // return new Response('le jeuj a encore frappé');
        // $response = $this->forward('AcmeHelloBundle:Hello:index', array('foo' => 'get', 'bar' => 'rekt'));
        $response = $this->forward('AcmeTestBundle:Test:update');

    return $response;

	}

    public function updateAction()
    {
    	die('here');
    }
}

<?php
// src/Acme/TestBundle/Controller/TestController.php

namespace Acme\TestBundle\Controller;

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

class TestController extends Controller
{
    public function indexAction()
    {
        throw new HttpException(418,
        	"This message is displayed only in dev mod.");
	}

    public function updateAction()
    {
    	die('here');
    }
}

Test sur les exceptions réussi

Test sur les exceptions réussi


<?php
/**
 * Single Re Google Review
 *
 * @package Google Review
 */

?>
<?php get_header(); ?>

Use Google
to leave your review?

	<a href="http://search.google.com/local/writereview?placeid=<?php the_title(); ?>" class="button">Yes

<?php get_footer(); ?>

<?php
/**
 * Single Re Google Review
 *
 * @package Google Review
 */

?>
<?php get_header(); ?>
<?php
$google_review = get_post_meta( $post->ID, 're-google-review-google-place-id', true );
?>

Use Google
to leave your review?

	<a href="http://search.google.com/local/writereview?placeid=<?php echo esc_html( $google_review ); ?>" class="button">Yes

<?php get_footer(); ?>

Update Google Place ID to grab from new meta box rather than title.


<?php

namespace Bauhaus\DI;

class FakeService
{
    public function pokemon()
    {
       return 'Charmander';
    }

    public function pirate()
    {
        return 'Barbossa';
    }

    public function music()
    {
        return 'Right Now';
    }

    public function instrument()
    {
        return 'Bass';
    }
}

<?php

namespace Bauhaus\DI;

class FakeService
{
}

Remove unused method from test double

Remove unused method from test double


<?php

namespace Horne\OutputFilter;

use Horne\MetaBag;
use Horne\OutputFilter\AbstractOutputFilter;

class KramdownOutputFilter extends AbstractOutputFilter
{
    public function run($content, MetaBag $mb)
    {
        $file = __DIR__ . '/bla';

        file_put_contents($file, $content);

        $data = shell_exec('kramdown < ' . $file);

        unlink($file);

        return $data;
    }
}

<?php

namespace Horne\OutputFilter;

use Horne\MetaBag;
use Horne\OutputFilter\AbstractOutputFilter;

class KramdownOutputFilter extends AbstractOutputFilter
{
    public function run($content, MetaBag $mb)
    {
        $file = __DIR__ . '/bla';

        file_put_contents($file, $content);

        $data = shell_exec('kramdown --coderay-css :class --coderay-line-numbers nil < ' . $file);

        unlink($file);

        return $data;
    }
}

Use CSS classes and hide line numbers for code blocks in kramdown filter


<?php namespace Picqer\Carriers\SendCloud\Query;

trait FindOne {

    public function find($id)
    {
        $result = $this->connection()->get($this->url . '/' . urlencode($id));

        return new self($this->connection(), $result[$this->namespaces['singular']]);
    }

}

<?php namespace Picqer\Carriers\SendCloud\Query;

trait FindOne {

    public function find($id)
    {
        $result = $this->connection()->get($this->url . '/' . urlencode($id));

        if (!array_key_exists($this->namespaces['singular'], $result)) {
            return null;
        }

        return new self($this->connection(), $result[$this->namespaces['singular']]);
    }

}

Return null if nothing found in case if find()


<?php
    namespace MVC\Controller;

    use Attw\Controller\AbstractController;

    class Index extends AbstractController{
        public function index(){
		$vars = [ 'message' => 'This message was puted here with <b>Smarty</b>.' ];
		$this->view( 'index.html', $vars );
        }
    }

<?php
    namespace MVC\Controller;

    use Attw\Controller\AbstractController;
    use Attw\View\Html\Element\Form;
    use Attw\HTTP\Request;
    use Attw\File\File;
    use Attw\File\Validator\Extension;
    use Attw\File\Uploader\Upload;

    class Index extends AbstractController{
        public function index(){
            $vars = [ 'message' => 'This message was puted here with <b>Smarty</b>.' ];
            $this->render( 'index.html', $vars );
        }
    }

Set name of method to render templates

Set name of method to render templates


<?php

namespace WyriHaximus\Pimple;

use League\Flysystem\Filesystem;

trait FlysystemServiceProviderTrait
{
    /**
     * Register this service provider with the Application.
     *
     * @param \Pimple $app Application.
     *
     * @return void
     */
    protected function registerFlysystems(\Pimple $app)
    {
        $app['flysystem.filesystems'] = [];
        $app['flysystems'] = $app->share(function (\Pimple $app) {
            $flysystems = new \Pimple();
            foreach ($app['flysystem.filesystems'] as $alias => $parameters) {
                $flysystems[$alias] = $this->buildFilesystem($parameters);
            }
            return $flysystems;
        });
    }

    /**
     * Instantiate an adapter and wrap it in a filesystem.
     *
     * @param array $parameters Array containing the adapter classname and arguments that need to be passed into it.
     *
     * @return Filesystem
     */
    protected function buildFilesystem(array $parameters)
    {
        $adapter = new \ReflectionClass($parameters['adapter']);
        return new Filesystem($adapter->newInstanceArgs($parameters['args']));
    }
}

<?php

namespace WyriHaximus\Pimple;

use League\Flysystem\Filesystem;
use League\Flysystem\Plugin\EmptyDir;
use League\Flysystem\Plugin\GetWithMetadata;
use League\Flysystem\Plugin\ListFiles;
use League\Flysystem\Plugin\ListPaths;
use League\Flysystem\Plugin\ListWith;

trait FlysystemServiceProviderTrait
{
    /**
     * Register this service provider with the Application.
     *
     * @param \Pimple $app Application.
     *
     * @return void
     */
    protected function registerFlysystems(\Pimple $app)
    {
        $app['flysystem.filesystems'] = [];
        $app['flysystem.plugins'] = [
            new EmptyDir(),
            new GetWithMetadata(),
            new ListFiles(),
            new ListPaths(),
            new ListWith(),
        ];
        $app['flysystems'] = $app->share(function (\Pimple $app) {
            $flysystems = new \Pimple();
            foreach ($app['flysystem.filesystems'] as $alias => $parameters) {
                $flysystems[$alias] = $this->buildFilesystem($app, $parameters);
            }
            return $flysystems;
        });
    }

    /**
     * Instantiate an adapter and wrap it in a filesystem.
     *
     * @param array $parameters Array containing the adapter classname and arguments that need to be passed into it.
     *
     * @return Filesystem
     */
    protected function buildFilesystem(\Pimple $app, array $parameters)
    {
        $adapter = new \ReflectionClass($parameters['adapter']);
        $filesystem = new Filesystem($adapter->newInstanceArgs($parameters['args']));

        foreach ($app['flysystem.plugins'] as $plugin) {
            $plugin->setFilesystem($filesystem);
            $filesystem->addPlugin($plugin);
        }

        return $filesystem;
    }
}

Add all available plugins by default

Add all available plugins by default


<?php

namespace Graze\Dal\Generator;

class RepositoryGenerator extends AbstractClassGenerator implements GeneratorInterface
{
    /**
     * @var array
     */
    private $config;

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

    /**
     * @param array $config
     * @param bool $generateInterfaces
     */
    public function __construct(array $config, $generateInterfaces = false)
    {
        $this->config = $config;
        $this->generateInterfaces = $generateInterfaces;
    }

    /**
     * @return array
     */
    protected function buildClassGenerators()
    {
        $repositories = [];

        foreach ($this->config as $config) {
            if (! array_key_exists('repository', $config)) {
                continue;
            }

            $repository = $this->getClassGenerator($config['repository']);
            $repository->setExtendedClass('\\Graze\Dal\Repository\EntityRepository');

            if ($this->generateInterfaces) {
                $interfaceGenerator = $this->buildInterfaceGeneratorFromClassGenerator($repository);
                $repositories[$interfaceGenerator->getName()] = $interfaceGenerator;
            }

            $repositories[$config['repository']] = $repository;
        }

        return $repositories;
    }
}

<?php

namespace Graze\Dal\Generator;

class RepositoryGenerator extends AbstractClassGenerator implements GeneratorInterface
{
    /**
     * @var array
     */
    private $config;

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

    /**
     * @param array $config
     * @param bool $generateInterfaces
     */
    public function __construct(array $config, $generateInterfaces = false)
    {
        $this->config = $config;
        $this->generateInterfaces = $generateInterfaces;
    }

    /**
     * @return array
     */
    protected function buildClassGenerators()
    {
        $repositories = [];

        foreach ($this->config as $config) {
            if (! array_key_exists('repository', $config)) {
                continue;
            }

            $repository = $this->getClassGenerator($config['repository']);
            $repository->setExtendedClass('\\Graze\Dal\Repository\EntityRepository');

            if ($this->generateInterfaces) {
                $interfaceGenerator = $this->buildInterfaceGeneratorFromClassGenerator($repository);
                $repositories[$interfaceGenerator->getNamespaceName() . '\\' . $interfaceGenerator->getName()] = $interfaceGenerator;
            }

            $repositories[$config['repository']] = $repository;
        }

        return $repositories;
    }
}

Fix repository interface generator bug that ignores their namespace


<?php

namespace duncan3dc\MetaAudio;

use duncan3dc\MetaAudio\Modules\ModuleInterface;

/**
 * Manage which modules are active and their priority sequence.
 */
trait ModuleManager
{
    /**
     * @var ModuleInterface[] $modules The modules used to read tags.
     */
    protected $modules = [];

     /**
     * Add a module to the stack.
     *
     * @param ModuleInterface The module object to add
     *
     * @return static
     */
    public function addModule(ModuleInterface $module)
    {
        $this->modules[] = $module;

        return $this;
    }

    /**
     * Add the default set of modules the library ships with.
     *
     * @return static
     */
    public function addDefaultModules()
    {
        $this->addModule(new Modules\Audio\Ape);
        $this->addModule(new Modules\Audio\Mp3);

        return $this;
    }

    /**
     * Remove all previously defined modules.
     *
     * @return static
     */
    public function clearModules()
    {
        $this->modules = [];

        return $this;
    }
}

<?php

namespace duncan3dc\MetaAudio;

use duncan3dc\MetaAudio\Modules\ModuleInterface;

/**
 * Manage which modules are active and their priority sequence.
 */
trait ModuleManager
{
    /**
     * @var ModuleInterface[] $modules The modules used to read tags.
     */
    protected $modules = [];

     /**
     * Add a module to the stack.
     *
     * @param ModuleInterface The module object to add
     *
     * @return static
     */
    public function addModule(ModuleInterface $module)
    {
        $this->modules[] = $module;

        return $this;
    }

    /**
     * Add the default set of modules the library ships with.
     *
     * @return static
     */
    public function addDefaultModules()
    {
        $this->addModule(new Modules\Ape);
        $this->addModule(new Modules\Id3);

        return $this;
    }

    /**
     * Remove all previously defined modules.
     *
     * @return static
     */
    public function clearModules()
    {
        $this->modules = [];

        return $this;
    }
}

Correct the names of the default modules


<?php

class MenuAdmin extends ModelAdmin {

	private static $url_segment = 'menus';
    private static $menu_title = 'Menus';
    private static $managed_models = array('Menu');

	private $showImportForm = false;

}

<?php

class MenuAdmin extends ModelAdmin {

	private static $url_segment = 'menus';
    private static $menu_title = 'Menus';
    private static $managed_models = array('Menu');

	public $showImportForm = false;

}

Fix access level fatal error.

Fix access level fatal error.


<?php

/**
 * This file is part of the GeocoderLaravel library.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use Geocoder\Provider\Chain\Chain;
use Geocoder\Provider\GeoPlugin\GeoPlugin;
use Geocoder\Provider\GoogleMaps\GoogleMaps;
use Http\Client\Curl\Client;

return [
    'cache-duration' => 999999999,
    'providers' => [
        Chain::class => [
            GoogleMaps::class => [
                'en-US',
                env('GOOGLE_MAPS_API_KEY'),
            ],
            GeoPlugin::class  => [],
        ],
    ],
    'adapter'  => Client::class,
];

<?php

/**
 * This file is part of the GeocoderLaravel library.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use Geocoder\Provider\Chain\Chain;
use Geocoder\Provider\GeoPlugin\GeoPlugin;
use Geocoder\Provider\GoogleMaps\GoogleMaps;
use Http\Client\Curl\Client;

return [
    'cache-duration' => 9999999,
    'providers' => [
        Chain::class => [
            GoogleMaps::class => [
                'en-US',
                env('GOOGLE_MAPS_API_KEY'),
            ],
            GeoPlugin::class  => [],
        ],
    ],
    'adapter'  => Client::class,
];

Fix cache duration to work on 32-bit systems

Fixes #107


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

  <?php
    do_action('get_header');
    get_template_part('templates/header');
  ?>

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

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

      <?php endif; ?>

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

Add shadow to header on all pages.

Add shadow to header on all pages.


<?php

namespace Ramsey\Uuid\Test\Generator;

use Ramsey\Uuid\Test\TestCase;
use Ramsey\Uuid\Generator\SodiumRandomGenerator;

class SodiumRandomGeneratorTest extends TestCase
{
    public function setUp()
    {
        if (!extension_loaded('libsodium')) {
            $this->markTestSkipped(
                'The libsodium extension is not available.'
            );
        }
    }

    public function testGenerateReturnsBytes()
    {
        $generator = new SodiumRandomGenerator();

        $bytes = $generator->generate(16);

        $this->assertInternalType('string', $bytes);
        $this->assertEquals(16, strlen($bytes));
    }

    public function testFactoryUsesSodiumRandomGenerator()
    {
        $uuidFactory = new \Ramsey\Uuid\UuidFactory();
        $uuidFactory->setRandomGenerator(new SodiumRandomGenerator());
        \Ramsey\Uuid\Uuid::setFactory($uuidFactory);

        $uuid = \Ramsey\Uuid\Uuid::uuid4();

        $this->assertInstanceOf(
            SodiumRandomGenerator::class,
            $uuid->getFactory()->getRandomGenerator()
        );
    }
}

<?php

namespace Ramsey\Uuid\Test\Generator;

use Ramsey\Uuid\Test\TestCase;
use Ramsey\Uuid\Generator\SodiumRandomGenerator;

class SodiumRandomGeneratorTest extends TestCase
{
    public function setUp()
    {
        if (!extension_loaded('libsodium')) {
            $this->markTestSkipped(
                'The libsodium extension is not available.'
            );
        }
    }

    public function testGenerateReturnsBytes()
    {
        $generator = new SodiumRandomGenerator();

        $bytes = $generator->generate(16);

        $this->assertInternalType('string', $bytes);
        $this->assertEquals(16, strlen($bytes));
    }

    public function testFactoryUsesSodiumRandomGenerator()
    {
        $uuidFactory = new \Ramsey\Uuid\UuidFactory();
        $uuidFactory->setRandomGenerator(new SodiumRandomGenerator());
        \Ramsey\Uuid\Uuid::setFactory($uuidFactory);

        $uuid = \Ramsey\Uuid\Uuid::uuid4();

        $this->assertInstanceOf(
            'Ramsey\Uuid\Generator\SodiumRandomGenerator',
            $uuid->getFactory()->getRandomGenerator()
        );
    }
}

Fix test failing on PHP 5.4 because of ::class keyword name resolution


<?php
/**
 * @author    Igor Nikolaev <igor.sv.n@gmail.com>
 * @copyright Copyright (c) 2015, Darvin Studio
 * @link      https://www.darvin-studio.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Darvin\ImageBundle\Controller;

use Darvin\ImageBundle\Entity\Image\AbstractImage;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

/**
 * Image controller
 */
class ImageController extends Controller
{
    /**
     * @param int $id Image ID
     *
     * @return \Symfony\Component\HttpFoundation\Response
     * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
     */
    public function deleteAction($id)
    {
        $em = $this->getEntityManager();

        $image = $em->getRepository(AbstractImage::ABSTRACT_IMAGE_CLASS)->find($id);

        if (empty($image)) {
            throw $this->createNotFoundException(sprintf('Unable to find image by ID "%d".', $id));
        }

        $em->remove($image);
        $em->flush();

        return new Response();
    }

    /**
     * @return \Doctrine\ORM\EntityManager
     */
    private function getEntityManager()
    {
        return $this->container->get('doctrine.orm.entity_manager');
    }
}

<?php
/**
 * @author    Igor Nikolaev <igor.sv.n@gmail.com>
 * @copyright Copyright (c) 2015, Darvin Studio
 * @link      https://www.darvin-studio.ru
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Darvin\ImageBundle\Controller;

use Darvin\ImageBundle\Entity\Image\AbstractImage;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

/**
 * Image controller
 */
class ImageController extends Controller
{
    /**
     * @param int $id Image ID
     *
     * @return \Symfony\Component\HttpFoundation\Response
     * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
     */
    public function deleteAction($id)
    {
        $em = $this->getEntityManager();

        $image = $em->getRepository(AbstractImage::ABSTRACT_IMAGE_CLASS)->find($id);

        if (empty($image)) {
            throw $this->createNotFoundException(sprintf('Unable to find image by ID "%d".', $id));
        }

        $em->remove($image);
        $em->flush();

        return new Response();
    }

    /**
     * @return \Doctrine\ORM\EntityManager
     */
    private function getEntityManager()
    {
        return $this->get('doctrine.orm.entity_manager');
    }
}

Replace $this->container->get() with $this->get() in controllers extending abstract controller.


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

$submittedData='';
foreach($questionAnswerPairs as $questionAnswerPair){
	$submittedData .= $questionAnswerPair['question']."\r\n".$questionAnswerPair['answer']."\r\n"."\r\n";
}
$formDisplayUrl=BASE_URL.DIR_REL.'/index.php/dashboard/form_results/?qsid='.$questionSetId;

$body = t("
There has been a submission of the form %s on through your Concrete5 website.

%s

To view all of this form's submissions, visit %s

", $formName, $submittedData, $formDisplayUrl);
?>

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

$submittedData='';
foreach($questionAnswerPairs as $questionAnswerPair){
	$submittedData .= $questionAnswerPair['question']."\r\n".$questionAnswerPair['answer']."\r\n"."\r\n";
}
$formDisplayUrl=BASE_URL.DIR_REL.'/index.php/dashboard/reports/forms/?qsid='.$questionSetId;

$body = t("
There has been a submission of the form %s on through your Concrete5 website.

%s

To view all of this form's submissions, visit %s

", $formName, $submittedData, $formDisplayUrl);
?>

Update form_results link in submission email template

git-svn-id: http://svn.concrete5.org/svn/concrete5@476 b0551a0c-1e16-4222-a7d5-975db1aca215

Former-commit-id: 239b2c07b4639a4e2801f0a312baee64b0316781


<?php namespace Anomaly\RelationshipFieldType;

use Anomaly\Streams\Platform\Addon\FieldType\FieldTypeModifier;
use Anomaly\Streams\Platform\Model\EloquentModel;

/**
 * Class RelationshipFieldTypeModifier
 *
 * @link          http://anomaly.is/streams-platform
 * @author        AnomalyLabs, Inc. <hello@anomaly.is>
 * @author        Ryan Thompson <ryan@anomaly.is>
 * @package       Anomaly\RelationshipFieldType
 */
class RelationshipFieldTypeModifier extends FieldTypeModifier
{

    /**
     * The field type instance.
     * This is for IDE support.
     *
     * @var RelationshipFieldType
     */
    protected $fieldType;

    /**
     * Restore the value.
     *
     * @param $value
     * @return null|EloquentModel
     */
    public function restore($value)
    {
        if (is_numeric($value)) {

            $relation = $this->fieldType->getRelatedModel();

            return $relation->find($value);
        }

        return $value;
    }
}

<?php namespace Anomaly\RelationshipFieldType;

use Anomaly\Streams\Platform\Addon\FieldType\FieldTypeModifier;
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
use Anomaly\Streams\Platform\Model\EloquentModel;

/**
 * Class RelationshipFieldTypeModifier
 *
 * @link          http://anomaly.is/streams-platform
 * @author        AnomalyLabs, Inc. <hello@anomaly.is>
 * @author        Ryan Thompson <ryan@anomaly.is>
 * @package       Anomaly\RelationshipFieldType
 */
class RelationshipFieldTypeModifier extends FieldTypeModifier
{

    /**
     * The field type instance.
     * This is for IDE support.
     *
     * @var RelationshipFieldType
     */
    protected $fieldType;

    /**
     * Modify the value.
     *
     * @param $value
     * @return integer
     */
    public function modify($value)
    {
        if ($value instanceof EntryInterface) {
            return $value->getId();
        }

        return $value;
    }

    /**
     * Restore the value.
     *
     * @param $value
     * @return null|EloquentModel
     */
    public function restore($value)
    {
        if (is_numeric($value)) {

            $relation = $this->fieldType->getRelatedModel();

            return $relation->find($value);
        }

        return $value;
    }
}

Return IDs if sent the object

Return IDs if sent the object


<?php

namespace Concrete\Core\Page\Type\Composer\Control\CorePageProperty;

use Core;
use UserInfo;
use Concrete\Core\Page\Page;

class UserCorePageProperty extends CorePageProperty
{
    public function __construct()
    {
        $this->setCorePagePropertyHandle('user');
        $this->setPageTypeComposerControlName(tc('PageTypeComposerControlName', 'User'));
        $this->setPageTypeComposerControlIconSRC(ASSETS_URL . '/attributes/text/icon.png');
    }

    public function publishToPage(Page $c, $data, $controls)
    {
        if (Core::make('helper/validation/numbers')->integer($data['user'])) {
            $this->addPageTypeComposerControlRequestValue('uID', $data['user']);
        }
        parent::publishToPage($c, $data, $controls);
    }

    public function validate()
    {
        $uID = $this->getPageTypeComposerControlDraftValue();
        $ux = UserInfo::getByID($uID);
        $e = Core::make('helper/validation/error');
        if (!is_object($ux)) {
            $control = $this->getPageTypeComposerFormLayoutSetControlObject();
            $e->add(t('You haven\'t chosen a valid %s', $control->getPageTypeComposerControlLabel()));

            return $e;
        }
    }

    public function getPageTypeComposerControlDraftValue()
    {
        if (is_object($this->page)) {
            $c = $this->page;

            return $c->getCollectionUserID();
        }
    }
}

<?php

namespace Concrete\Core\Page\Type\Composer\Control\CorePageProperty;

use Core;
use UserInfo;
use Page;

class UserCorePageProperty extends CorePageProperty
{
    public function __construct()
    {
        $this->setCorePagePropertyHandle('user');
        $this->setPageTypeComposerControlName(tc('PageTypeComposerControlName', 'User'));
        $this->setPageTypeComposerControlIconSRC(ASSETS_URL . '/attributes/text/icon.png');
    }

    public function publishToPage(Page $c, $data, $controls)
    {
        if (Core::make('helper/validation/numbers')->integer($data['user'])) {
            $this->addPageTypeComposerControlRequestValue('uID', $data['user']);
        }
        parent::publishToPage($c, $data, $controls);
    }

    public function validate()
    {
        $uID = $this->getPageTypeComposerControlDraftValue();
        $ux = UserInfo::getByID($uID);
        $e = Core::make('helper/validation/error');
        if (!is_object($ux)) {
            $control = $this->getPageTypeComposerFormLayoutSetControlObject();
            $e->add(t('You haven\'t chosen a valid %s', $control->getPageTypeComposerControlLabel()));

            return $e;
        }
    }

    public function getPageTypeComposerControlDraftValue()
    {
        if (is_object($this->page)) {
            $c = $this->page;

            return $c->getCollectionUserID();
        }
    }
}

Use \Page instead of Concrete\Core\Page\Page

Former-commit-id: 5f27527c65b9ed3815ca1a37eef8d3e6dccee225
Former-commit-id: 5b239b1afa020bcaebcb90fa58cc461a91098c82


<?php namespace Flarum\Core\Models;

abstract class ActivityPost extends Post implements MergeableInterface
{
    use MergeableTrait;

    /**
     * Unserialize the content attribute.
     *
     * @param  string  $value
     * @return string
     */
    public function getContentAttribute($value)
    {
        return json_decode($value);
    }

    /**
     * Serialize the content attribute.
     *
     * @param  string  $value
     */
    public function setContentAttribute($value)
    {
        $this->attributes['content'] = json_encode($value);
    }
}

<?php namespace Flarum\Core\Models;

abstract class ActivityPost extends Post implements MergeableInterface
{
    use MergeableTrait;

    /**
     * Unserialize the content attribute.
     *
     * @param  string  $value
     * @return string
     */
    public function getContentAttribute($value)
    {
        return json_decode($value, true);
    }

    /**
     * Serialize the content attribute.
     *
     * @param  string  $value
     */
    public function setContentAttribute($value)
    {
        $this->attributes['content'] = json_encode($value);
    }
}

Fix content attribute decoding into an object


<?php
/**
 * SiteFilter.php
 *
 * Created By: jonathan
 * Date: 28/09/2017
 * Time: 13:33
 */

namespace Stati\Liquid\Filter;

class SiteFilter
{
    /**
     * Escapes an xml string
     *
     * @param string $input
     *
     * @return string
     */
    public static function xml_escape($input)
    {
        return htmlentities($input);
    }

    /**
     * Counts the number of words in a string
     *
     * @param string $input
     *
     * @return string
     */
    public static function number_of_words($input)
    {
        return str_word_count($input);
    }
}

<?php
/**
 * SiteFilter.php
 *
 * Created By: jonathan
 * Date: 28/09/2017
 * Time: 13:33
 */

namespace Stati\Liquid\Filter;

class SiteFilter
{
    /**
     * Escapes an xml string
     *
     * @param string $input
     *
     * @return string
     */
    public static function xml_escape($input)
    {
        return htmlentities($input);
    }

    /**
     * Counts the number of words in a string
     *
     * @param string $input
     *
     * @return string
     */

    public static function number_of_words($input)
    {
        return str_word_count(strip_tags($input), 0);
    }

    public static function tojson($input)
    {
        return json_encode($input);
    }

    public static function jsonify($input)
    {
        return json_encode($input);
    }

}

Add some filters for more compatibility with Jekyll


<?php get_header(); ?>

	<?php do_action('brewtah_before_content'); ?>

	<?php while (have_posts()) : the_post(); ?>
		<article <?php post_class() ?> id="post-<?php the_ID(); ?>">

<?php the_title(); ?>

					<a href="<?php dabc_the_store_tel_link(); ?>"><?php dabc_the_store_phone_number(); ?>

					<?php dabc_the_store_address(); ?>

			<?php do_action('brewtah_post_before_entry_content'); ?>

			<?php if ( has_post_thumbnail() ): ?>

						<?php the_post_thumbnail('', array('class' => 'th')); ?>

			<?php endif; ?>

			<?php the_content(); ?>
			<?php get_template_part( 'parts/store-inventory' ); ?>

			<?php do_action('brewtah_post_before_comments'); ?>
			<?php comments_template(); ?>
			<?php do_action('brewtah_post_after_comments'); ?>

	<?php endwhile;?>

	<?php do_action('brewtah_after_content'); ?>

	<?php get_sidebar(); ?>

<?php get_footer(); ?>

<?php get_header(); ?>

	<?php do_action('brewtah_before_content'); ?>

	<?php while (have_posts()) : the_post(); ?>
		<article <?php post_class() ?> id="post-<?php the_ID(); ?>">

				<?php get_template_part( 'parts/store-info' ); ?>

			<?php do_action('brewtah_post_before_entry_content'); ?>

			<?php get_template_part( 'parts/store-inventory' ); ?>

			<?php do_action('brewtah_post_before_comments'); ?>
			<?php comments_template(); ?>
			<?php do_action('brewtah_post_after_comments'); ?>

	<?php endwhile;?>

	<?php do_action('brewtah_after_content'); ?>

	<?php get_sidebar(); ?>

<?php get_footer(); ?>

Use store info template part on single store.


<?php

return [

    /**
     * Displaying project name.
     */
    'name' => 'Deplink: Dependency Manager for C/C++',

    /**
     * CLI version using semantic versioning.
     *
     * @link http://semver.org/
     */
    'version' => '0.1.0',

    /**
     * Available commands via cli.
     *
     * @link https://github.com/symfony/console
     */
    'commands' => [
        \Deplink\Console\Commands\InitCommand::class,
        \Deplink\Console\Commands\InstallCommand::class,
        //\Deplink\Console\Commands\ListCommand::class,
        //\Deplink\Console\Commands\UninstallCommand::class,
        \Deplink\Console\Commands\BuildCommand::class,
        //\Deplink\Console\Commands\RebuildCommand::class,
        //\Deplink\Console\Commands\CleanCommand::class,
        \Deplink\Console\Commands\RunCommand::class,
        //\Deplink\Console\Commands\ScriptCommand::class,
    ],
];

<?php

return [

    /**
     * Displaying project name.
     */
    'name' => 'Deplink: Dependency Manager for C/C++',

    /**
     * CLI version using semantic versioning.
     *
     * @link http://semver.org/
     */
    'version' => 'dev-build',

    /**
     * Available commands via cli.
     *
     * @link https://github.com/symfony/console
     */
    'commands' => [
        \Deplink\Console\Commands\InitCommand::class,
        \Deplink\Console\Commands\InstallCommand::class,
        //\Deplink\Console\Commands\ListCommand::class,
        //\Deplink\Console\Commands\UninstallCommand::class,
        \Deplink\Console\Commands\BuildCommand::class,
        //\Deplink\Console\Commands\RebuildCommand::class,
        //\Deplink\Console\Commands\CleanCommand::class,
        \Deplink\Console\Commands\RunCommand::class,
        //\Deplink\Console\Commands\ScriptCommand::class,
    ],
];

Change default version to "dev-build"

Change default version to "dev-build"


<?php

if (!function_exists('auth')) {
    function auth()
    {
        return sentinel();
    }
}

if (!function_exists('sentinel')) {
    function sentinel()
    {
        return Cartalyst\Sentinel\Native\Facades\Sentinel::instance()->getSentinel();
    }
}

if (!function_exists('user')) {
    function user($user = null)
    {
        if ($user == null)
            return sentinel()->getUser();
        elseif ($user instanceof \Cartalyst\Sentinel\Users\UserInterface)
            return sentinel()->findById($user->id);
        elseif (is_numeric($user))
            return sentinel()->findById($user);
        else
            return null;
    }
}

<?php

if (!function_exists('auth')) {
    function auth()
    {
        return sentinel();
    }
}

if (!function_exists('sentinel')) {
    function sentinel()
    {
        $config = new Library\Sentinel\SentinelBootstrapper(__DIR__.'/../config/sentinel.php');

        return Cartalyst\Sentinel\Native\Facades\Sentinel::instance($config)->getSentinel();
    }
}

if (!function_exists('user')) {
    function user($user = null)
    {
        if ($user == null)
            return sentinel()->getUser();
        elseif ($user instanceof \Cartalyst\Sentinel\Users\UserInterface)
            return sentinel()->findById($user->id);
        elseif (is_numeric($user))
            return sentinel()->findById($user);
        else
            return null;
    }
}

Set return with config SentinelBootstraper instance


<?php

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

require 'SharedConfigurations.php';

// Additionally to the EVAL command defined in the current development profile, the new
// Predis\Commands\ScriptedCommand base class can be used to build an higher abstraction
// for our "scripted" commands so that they will appear just like any other command on
// the client-side. This is a quick example used to implement INCREX.

use Predis\Commands\ScriptedCommand;

class IncrementExistingKey extends ScriptedCommand
{
    protected function keysCount()
    {
        return 1;
    }

    public function getScript()
    {
        return
<<<LUA
    if redis('exists', KEYS[1]) == 1 then
        return redis('incr', KEYS[1])
    end
LUA;
    }
}

$client = new Predis\Client($single_server, 'dev');

$client->getProfile()->defineCommand('increx', 'IncrementExistingKey');

$client->set('foo', 10);

var_dump($client->increx('foo'));       // int(11)
var_dump($client->increx('bar'));       // NULL

<?php

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

require 'SharedConfigurations.php';

// Additionally to the EVAL command defined in the current development profile, the new
// Predis\Commands\ScriptedCommand base class can be used to build an higher abstraction
// for our "scripted" commands so that they will appear just like any other command on
// the client-side. This is a quick example used to implement INCREX.

use Predis\Commands\ScriptedCommand;

class IncrementExistingKey extends ScriptedCommand
{
    protected function keysCount()
    {
        return 1;
    }

    public function getScript()
    {
        return
<<<LUA
    local cmd = redis.call
    if cmd('exists', KEYS[1]) == 1 then
        return cmd('incr', KEYS[1])
    end
LUA;
    }
}

$client = new Predis\Client($single_server, 'dev');

$client->getProfile()->defineCommand('increx', 'IncrementExistingKey');

$client->set('foo', 10);

var_dump($client->increx('foo'));       // int(11)
var_dump($client->increx('bar'));       // NULL

Update the server-side scripting example to use the current Redis unstable.