<?php

abstract class ShippingEasy
{
  public static $apiKey;
  public static $apiSecret;
  public static $apiBase = 'https://app.shippingeasy.com';
  public static $apiVersion = null;
  const VERSION = '0.4.0';

  public static function getApiKey()
  {
    return self::$apiKey;
  }

  public static function setApiKey($apiKey)
  {
    self::$apiKey = $apiKey;
  }

  public static function setApiSecret($apiSecret)
  {
    self::$apiSecret = $apiSecret;
  }

  public static function getApiVersion()
  {
    return self::$apiVersion;
  }

  public static function setApiVersion($apiVersion)
  {
    self::$apiVersion = $apiVersion;
  }

  public static function setApiBase($apiBase)
  {
    self::$apiBase = $apiBase;
  }
}

<?php

abstract class ShippingEasy
{
  public static $apiKey;
  public static $apiSecret;
  public static $partnerApiKey;
  public static $partnerApiSecret;
  public static $apiBase = 'https://app.shippingeasy.com';
  public static $apiVersion = null;
  const VERSION = '0.4.0';

  public static function getApiKey()
  {
    return self::$apiKey;
  }

  public static function setApiKey($apiKey)
  {
    self::$apiKey = $apiKey;
  }

  public static function getPartnerApiKey()
    {
      return self::$partnerApiKey;
    }

  public static function setPartnerApiKey($partnerApiKey)
  {
    self::$partnerApiKey = $partnerApiKey;
  }

  public static function setApiSecret($apiSecret)
  {
    self::$apiSecret = $apiSecret;
  }

  public static function setPartnerApiSecret($partnerApiSecret)
  {
    self::$partnerApiSecret = $partnerApiSecret;
  }

  public static function getApiVersion()
  {
    return self::$apiVersion;
  }

  public static function setApiVersion($apiVersion)
  {
    self::$apiVersion = $apiVersion;
  }

  public static function setApiBase($apiBase)
  {
    self::$apiBase = $apiBase;
  }
}

Store partner credentials as config.

Store partner credentials as config.


Hi {{ $user }},

Thank you for submitting stats for team {{ $centerName }}.
@if ($isLate)
Your stats are late. They were due on {{ $due }}.
@endif
We received them on {{ $time }} your local time. Please find the submitted sheet attached.

@if (isset($sheet['errors']) && $sheet['errors'])
    Your sheet contained errors. Please review the errors below and correct them for your report next week. If you have any questions please reach out to your regional statistician.

@else
    You are not complete yet. Your regional statistician will review your sheet and declare you complete by {{ $respondByTime }} your local time Saturday morning.

@endif

@if ($reportUrl)
View your report online: {{ $centerName }} - {{ $reportingDate->format('M j, Y') }}

@endif
@if ($comment)
    You provided the following comment:

    -----

    {{ $comment }}

    -----

@endif

@if ($sheet)
    @include('import.results', ['sheet' => $sheet, 'includeUl' => true])
@endif

Best,

Your Regional Statisticans

Hi {{ $user }},

Thank you for submitting stats for team {{ $centerName }}.

@if ($isLate)
Your stats are late. They were due on {{ $due }}.
@endif

We received them on {{ $time }} your local time. Please find the submitted sheet attached.

@if (isset($sheet['errors']) && $sheet['errors'])
    Your sheet contained errors. Please review the errors below and correct them. If you have any questions please reach out to your regional statistician.

@endif

You are not complete yet. Your regional statistician will review your sheet and declare you complete by {{ $respondByTime }} your local time Saturday morning.

@if ($reportUrl)
View your report online: {{ $centerName }} - {{ $reportingDate->format('M j, Y') }}

@endif
@if ($comment)
    You provided the following comment:

    -----

    {{ $comment }}

    -----

@endif

@if ($sheet)
    @include('import.results', ['sheet' => $sheet, 'includeUl' => true])
@endif

Best,

Your Regional Statisticans

Fix email message sent when sheet contained errors.

- Updated so the message about it including errors doesn't say to complete them by next week.
- Always include message that stats aren't complete until regional declares them complete.


<?php

namespace Tests\Firebase\Database\Reference;

use Firebase\Database\Reference\Validator;
use Firebase\Exception\InvalidArgumentException;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;
use Tests\FirebaseTestCase;

class ValidatorTest extends FirebaseTestCase
{
    /**
     * @var UriInterface
     */
    private $uri;

    /**
     * @var Validator
     */
    private $validator;

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

        $this->uri = new Uri('http://domain.tld');
        $this->validator = new Validator();
    }

    public function testValidateDepth()
    {
        $uri = $this->uri->withPath(str_pad('', (\Firebase\Database\Reference\Validator::MAX_DEPTH + 1) * 2, 'x/'));

        $this->expectException(InvalidArgumentException::class);
        $this->validator->validateUri($uri);
    }

    public function testValidateKeySize()
    {
        $uri = $this->uri->withPath(str_pad('', \Firebase\Database\Reference\Validator::MAX_KEY_SIZE + 1, 'x'));

        $this->expectException(InvalidArgumentException::class);
        $this->validator->validateUri($uri);
    }

    public function testValidateChars()
    {
        $invalid = str_shuffle(\Firebase\Database\Reference\Validator::INVALID_KEY_CHARS)[0];
        $uri = $this->uri->withPath($invalid);

        $this->expectException(InvalidArgumentException::class);
        $this->validator->validateUri($uri);
    }
}

<?php

namespace Tests\Firebase\Database\Reference;

use Firebase\Database\Reference\Validator;
use Firebase\Exception\InvalidArgumentException;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\UriInterface;
use Tests\FirebaseTestCase;

class ValidatorTest extends FirebaseTestCase
{
    /**
     * @var UriInterface
     */
    private $uri;

    /**
     * @var Validator
     */
    private $validator;

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

        $this->uri = new Uri('http://domain.tld');
        $this->validator = new Validator();
    }

    public function testValidateDepth()
    {
        $uri = $this->uri->withPath(str_pad('', (Validator::MAX_DEPTH + 1) * 2, 'x/'));

        $this->expectException(InvalidArgumentException::class);
        $this->validator->validateUri($uri);
    }

    public function testValidateKeySize()
    {
        $uri = $this->uri->withPath(str_pad('', Validator::MAX_KEY_SIZE + 1, 'x'));

        $this->expectException(InvalidArgumentException::class);
        $this->validator->validateUri($uri);
    }

    public function testValidateChars()
    {
        $invalid = str_shuffle(Validator::INVALID_KEY_CHARS)[0];
        $uri = $this->uri->withPath($invalid);

        $this->expectException(InvalidArgumentException::class);
        $this->validator->validateUri($uri);
    }
}

Use imported class name instead of FQN

Use imported class name instead of FQN


<?php

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

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password', 60);
            $table->rememberToken();
            $table->timestamps();
        });
    }

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

<?php

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

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }

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

Fix password column for future hashing

Fix password column for future hashing


<?php

namespace Ilios\WebBundle\Controller;

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

class IndexController extends Controller
{
    public function indexAction()
    {
        $file = $this->get('iliosweb.assets')->getIndex();
        if (!$file) {
            throw new \Exception('Unable to retrieve the index file');
        }
        $response = new Response($file);
        $response->headers->set('Content-Type', 'text/html');

        $response->setPublic();
        $response->setMaxAge(60);

        return $response;
    }
}

<?php

namespace Ilios\WebBundle\Controller;

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

class IndexController extends Controller
{
    public function indexAction()
    {

        $file = $this->get('iliosweb.redisindex')->getIndex('current-content');
        if (!$file) {
            throw new \Exception('Unable to retrieve the index file');
        }

        $response = new Response($file);
        $response->headers->set('Content-Type', 'text/html');

        $response->setPublic();
        $response->setMaxAge(60);

        return $response;
    }
}

Use redis method to distribute index.html file


<?php defined('C5_EXECUTE') or die("Access Denied.") ?>

<?php $pk = PermissionKey::getByID($_REQUEST['pkID']) ?>
<?php Loader::element('permission/detail', array('permissionKey' => $pk), 'front_end_permissions') ?>
<script type="text/javascript">
	var ccm_permissionDialogURL = '<?= REL_DIR_FILES_TOOLS_REQUIRED ?>/permissions/dialogs/front_end';
</script>

<?php defined('C5_EXECUTE') or die("Access Denied.") ?>

<?php $pk = PermissionKey::getByID($_REQUEST['pkID']) ?>
<?php Loader::element('permission/detail', array('permissionKey' => $pk)) ?>
<script type="text/javascript">
	var ccm_permissionDialogURL = '<?= REL_DIR_FILES_TOOLS_REQUIRED ?>/permissions/dialogs/front_end';
</script>

Fix loader element permission detail

Fix loader element permission detail

Fix loader element permission detail


{{-- General social metadata --}}
<link rel="canonical" href="{{ URL::current() }}"/>
<meta name="description"
      content="@yield('meta_description', 'Vote for your favorite ' . setting('candidate_type') . ' who has done kickass things in the world this year.')"/>

{{-- Twitter --}}
<meta name="twitter:site" content="@dosomething"/>
<meta name="twitter:creator" content="@dosomething"/>
<meta name="twitter:url" content="{{ URL::current() }}"/>
<meta name="twitter:title" content="@yield('meta_title', setting('site_title'))"/>
<meta name="twitter:description"
      content="@yield('meta_description', 'Vote for your favorite ' . setting('candidate_type')  . ' who has done kickass things in the world.')"/>
<meta name="twitter:image" content="@yield('meta_image', asset(setting('facebook_share', 'assets/images/facebook_share.default.jpg')))"/>

{{-- Facebook --}}
<meta property="og:site_name" content="{{ setting('site_title') }}"/>
<meta property="og:title" content="@yield('meta_title', setting('site_title'))"/>
<meta property="og:image" content="@yield('meta_image', asset(setting('twitter_share', 'assets/images/twitter_share.default.jpg')))"/>

{{-- General social metadata --}}
<link rel="canonical" href="{{ URL::current() }}"/>
<meta name="description"
      content="@yield('meta_description', 'Vote for your favorite ' . setting('candidate_type') . ' who has done kickass things in the world this year.')"/>

{{-- Twitter --}}
<meta name="twitter:site" content="@dosomething"/>
<meta name="twitter:creator" content="@dosomething"/>
<meta name="twitter:url" content="{{ URL::current() }}"/>
<meta name="twitter:title" content="@yield('meta_title', setting('site_title'))"/>
<meta name="twitter:description"
      content="@yield('meta_description', 'Vote for your favorite ' . setting('candidate_type')  . ' who has done kickass things in the world.')"/>
<meta name="twitter:image" content="@yield('meta_image', asset(setting('twitter_share', 'assets/images/twitter_share.default.jpg')))"/>

{{-- Facebook --}}
<meta property="og:site_name" content="{{ setting('site_title') }}"/>
<meta property="og:title" content="@yield('meta_title', setting('site_title'))"/>
<meta property="og:image" content="@yield('meta_image', asset(setting('facebook_share', 'assets/images/facebook_share.default.jpg')))"/>

Fix incorrect default share images.

Fix incorrect default share images.


<?php

namespace Knp\Bundle\MarkdownBundle\Twig\Extension;

use Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper;

class MarkdownTwigExtension extends \Twig_Extension
{
    protected $helper;

    function __construct(MarkdownHelper $helper)
    {
        $this->helper = $helper;
    }

    public function getFilters()
    {
        return array(
            'markdown' => new \Twig_Filter_Method($this, 'markdown', array('is_safe' => array('html'))),
        );
    }

    public function markdown($text, $parser = null)
    {
        return $this->helper->transform($text, $parser);
    }

    public function getName()
    {
        return 'markdown';
    }
}

<?php

namespace Knp\Bundle\MarkdownBundle\Twig\Extension;

use Knp\Bundle\MarkdownBundle\Helper\MarkdownHelper;

class MarkdownTwigExtension extends \Twig_Extension
{
    protected $helper;

    public function __construct(MarkdownHelper $helper)
    {
        $this->helper = $helper;
    }

    public function getFilters()
    {
        return array(
            return new \Twig_SimpleFilter('markdown', array($this, 'markdown'), array('is_safe' => array('html'))),
        );
    }

    public function markdown($text, $parser = null)
    {
        return $this->helper->transform($text, $parser);
    }

    public function getName()
    {
        return 'markdown';
    }
}

Switch the Twig integration to use non-deprecated APIs


<?php

namespace Orchestra\Database\Console\Migrations;

trait Packages
{
    /**
     * The path to the packages directory (vendor).
     *
     * @var string
     */
    protected $packagePath;

    /**
     * Set package path.
     *
     * @param  string  $packagePath
     *
     * @return $this
     */
    public function setPackagePath(string $packagePath)
    {
        $this->packagePath = $packagePath;

        return $this;
    }

    /**
     * Get the path to the package migration directory.
     *
     * @param  string  $package
     *
     * @return array
     */
    protected function getPackageMigrationPaths(string $package): array
    {
        $packagePath = $this->packagePath;

        return \collect($this->option('path') ?: 'database/migrations')
                    ->map(static function ($path) use ($packagePath, $package) {
                        return $packagePath.'/'.$package.'/'.$path;
                    })->all();
    }
}

<?php

namespace Orchestra\Database\Console\Migrations;

use Illuminate\Support\Collection;

trait Packages
{
    /**
     * The path to the packages directory (vendor).
     *
     * @var string
     */
    protected $packagePath;

    /**
     * Set package path.
     *
     * @param  string  $packagePath
     *
     * @return $this
     */
    public function setPackagePath(string $packagePath)
    {
        $this->packagePath = $packagePath;

        return $this;
    }

    /**
     * Get the path to the package migration directory.
     *
     * @param  string  $package
     *
     * @return array
     */
    protected function getPackageMigrationPaths(string $package): array
    {
        $packagePath = $this->packagePath;

        return Collection::make($this->option('path') ?: 'database/migrations')
                    ->map(static function ($path) use ($packagePath, $package) {
                        return $packagePath.'/'.$package.'/'.$path;
                    })->all();
    }
}

Use class instead of helper.

Use class instead of helper.

Signed-off-by: Mior Muhammad Zaki <e1a543840a942eb68427510a8a483282a7bfeddf@gmail.com>


<?php

namespace Rych\Silex\Provider;

use Silex\Application;
use Silex\ServiceProviderInterface;
use Rych\Plates\Extension\RoutingExtension;
use Rych\Plates\Extension\SecurityExtension;

class PlatesServiceProvider implements ServiceProviderInterface
{

    public function register(Application $app)
    {
        $app['plates.path'] = null;
        $app['plates.folders'] = array ();

        $app['plates.engine'] = $app->share(function ($app) {
            $engine = new \League\Plates\Engine($app['plates.path']);
            foreach ($app['plates.folders'] as $name => $path) {
                $engine->addFolder($name, $path);
            }

            if (isset($app['url_generator'])) {
                $engine->loadExtension(new RoutingExtension($app['url_generator']));
            }

            if (isset($app['security'])) {
                $engine->loadExtension(new SecurityExtension($app['security']));
            }

            return $engine;
        });

        $app['plates'] = function ($app) {
            $plates      = $app['plates.engine'];
            $plates->addData([
                'app' => $app
            ]);

            return $plates;
        };
    }

    public function boot(Application $app)
    {
    }

}

<?php

namespace Rych\Silex\Provider;

use Silex\Application;
use Silex\ServiceProviderInterface;
use Rych\Plates\Extension\RoutingExtension;
use Rych\Plates\Extension\SecurityExtension;

class PlatesServiceProvider implements ServiceProviderInterface
{

    public function register(Application $app)
    {
        $app['plates.path']      = null;
        $app['plates.extension'] = 'php';
        $app['plates.folders']   = array();

        $app['plates.engine'] = $app->share(function ($app) {
            $engine = new \League\Plates\Engine(
                $app['plates.path'],
                $app['plates.extension']
            );
            foreach ($app['plates.folders'] as $name => $path) {
                $engine->addFolder($name, $path);
            }

            if (isset($app['url_generator'])) {
                $engine->loadExtension(new RoutingExtension($app['url_generator']));
            }

            if (isset($app['security'])) {
                $engine->loadExtension(new SecurityExtension($app['security']));
            }

            return $engine;
        });

        $app['plates'] = function ($app) {
            $plates      = $app['plates.engine'];
            $plates->addData([
                'app' => $app
            ]);

            return $plates;
        };
    }

    public function boot(Application $app)
    {
    }

}

Allow setting the plates file extension

Allow setting the plates file extension


<?php
namespace Dersam\RequestTracker\Action\Ticket;

use Dersam\RequestTracker\Action;

/**
 *
 *
 * @author Sam Schmidt <samuel@dersam.net>
 * @since 2016-02-09
 */
class CreateTicket extends Action
{
    protected $endpoint = "/ticket/new";

    function processResponse()
    {
        // TODO: Implement processResponse() method.
    }
}

<?php
namespace Dersam\RequestTracker\Action\Ticket;

use Dersam\RequestTracker\Action;

/**
 *
 *
 * @author Sam Schmidt <samuel@dersam.net>
 * @since 2016-02-09
 */
class CreateTicket extends Action
{
    protected $endpoint = "/ticket/new";
}

Use default parser on create.

Use default parser on create.


<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;

class ForgotPasswordController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Password Reset Controller
    |--------------------------------------------------------------------------
    |
    | This controller is responsible for handling password reset emails and
    | includes a trait which assists in sending these notifications from
    | your application to your users. Feel free to explore this trait.
    |
    */

    use SendsPasswordResetEmails;

    /**
     * Create a new controller instance.
     */
    public function __construct()
    {
        $this->middleware('guest');
    }
}

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Http\Request;

class ForgotPasswordController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Password Reset Controller
    |--------------------------------------------------------------------------
    |
    | This controller is responsible for handling password reset emails and
    | includes a trait which assists in sending these notifications from
    | your application to your users. Feel free to explore this trait.
    |
    */

    use SendsPasswordResetEmails;

    /**
     * Create a new controller instance.
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    /**
     * Validate the email for the given request.
     *
     * @param \Illuminate\Http\Request $request
     * @return void
     */
    protected function validateEmail(Request $request)
    {
        $this->validate($request, ['email' => 'required|email|domainos:block']);
    }
}

Use email domain blacklist on reset password


<?php

namespace App\Units\Home\Http\Controllers;

use App\Domains\Graphics\FrameworkRadar;
use App\Domains\Graphics\LanguagesIndex;
use App\Domains\Graphics\LearningCurve;
use App\Domains\Graphics\LearningCurveAll;
use App\Domains\Graphics\Trend;
use Codecasts\Support\Http\Controller;

/**
 * Class GraphicsController.
 */
class GraphicsController extends Controller
{
    public function showGraphicsLcLang()
    {
        $languages = LearningCurveAll::getTopLanguages();

        return view('home::Graphics.learning_curve.languages', compact(['languages']));
    }

    public function showGraphicsLearningCurve($language = 'actionscript')
    {
        $learning = LearningCurve::getLearningCurveByLanguage($language);

        if (!$learning) {
            abort(404);
        }

        return view('home::Graphics.learning_curve.language', compact(['learning']));
    }

    public function showGraphicsStars()
    {
        $repositories = Trend::getMostStaredRepositories();

        return view('home::Graphics.Trends.stars', compact(['repositories']));
    }

    public function showGraphicsForks()
    {
        $repositories = Trend::getMostForkedRepositories();

        return view('home::Graphics.Trends.forks', compact(['repositories']));
    }

    public function showGraphicsFrameworks()
    {
        $radar = FrameworkRadar::getTrendingFrameworks();

        return view('home::Graphics.radar', compact(['radar']));
    }

    public function showGraphicsLanguages()
    {
        $languages = LanguagesIndex::getIndexedLanguages();

        return view('home::Graphics.tiobe', compact(['languages']));
    }
}

<?php

namespace App\Units\Home\Http\Controllers;

use App\Domains\Graphics\FrameworkRadar;
use App\Domains\Graphics\LanguagesIndex;
use App\Domains\Graphics\LearningCurve;
use App\Domains\Graphics\LearningCurveAll;
use App\Domains\Graphics\Trend;
use Codecasts\Support\Http\Controller;

/**
 * Class GraphicsController.
 */
class GraphicsController extends Controller
{
    public function showGraphicsLcLang()
    {
        $languages = LearningCurveAll::getTopLanguages();

        return view('home::Graphics.learning_curve.languages', compact(['languages']));
    }

    public function showGraphicsLearningCurve($language = 'python')
    {
        $learning = LearningCurve::getLearningCurveByLanguage($language);

        if (!$learning) {
            abort(404);
        }

        return view('home::Graphics.learning_curve.language', compact(['learning']));
    }

    public function showGraphicsStars()
    {
        $repositories = Trend::getMostStaredRepositories();

        return view('home::Graphics.Trends.stars', compact(['repositories']));
    }

    public function showGraphicsForks()
    {
        $repositories = Trend::getMostForkedRepositories();

        return view('home::Graphics.Trends.forks', compact(['repositories']));
    }

    public function showGraphicsFrameworks()
    {
        $radar = FrameworkRadar::getTrendingFrameworks();

        return view('home::Graphics.radar', compact(['radar']));
    }

    public function showGraphicsLanguages()
    {
        $languages = LanguagesIndex::getIndexedLanguages();

        return view('home::Graphics.tiobe', compact(['languages']));
    }
}

Set Python as default language.

Set Python as default language.


<?php

class Philwinkle_Fixerio_Model_Import extends Mage_Directory_Model_Currency_Import_Abstract
{
    protected $_url = 'http://api.fixer.io/latest?base={{CURRENCY_FROM}}&symbols={{CURRENCY_TO}}';
	protected $_messages = array();

     /**
     * HTTP client
     *
     * @var Varien_Http_Client
     */
    protected $_httpClient;

    public function __construct()
    {
        $this->_httpClient = new Varien_Http_Client();
    }

    protected function _convert($currencyFrom, $currencyTo, $retry=0)
    {
        $url = str_replace('{{CURRENCY_FROM}}', $currencyFrom, $this->_url);
        $url = str_replace('{{CURRENCY_TO}}', $currencyTo, $url);

        try {
            $response = $this->_httpClient
                ->setUri($url)
                ->setConfig(array('timeout' => Mage::getStoreConfig('currency/fixerio/timeout')))
                ->request('GET')
                ->getBody();

            $converted = json_decode($response);

            $xml = new SimpleXmlElement("<double>{$converted->rates->$currencyTo}</double>");

            if( !$xml ) {
                $this->_messages[] = Mage::helper('directory')->__('Cannot retrieve rate from %s.', $url);
                return null;
            }
            return (float) $xml;
        }
        catch (Exception $e) {
            if( $retry == 0 ) {
                $this->_convert($currencyFrom, $currencyTo, 1);
            } else {
                $this->_messages[] = Mage::helper('directory')->__('Cannot retrieve rate from %s.', $url);
            }
        }
    }
}

<?php

class Philwinkle_Fixerio_Model_Import extends Mage_Directory_Model_Currency_Import_Abstract
{
    protected $_url = 'http://api.fixer.io/latest?base=%1$s&symbols=%2$s';
	protected $_messages = array();

     /**
     * HTTP client
     *
     * @var Varien_Http_Client
     */
    protected $_httpClient;

    public function __construct()
    {
        $this->_httpClient = new Varien_Http_Client();
    }

    protected function _convert($currencyFrom, $currencyTo, $retry = 0)
    {
        $url = sprintf($this->_url, $currencyFrom, $currencyTo);

        try {
            $response = $this->_httpClient
                ->setUri($url)
                ->setConfig(array('timeout' => Mage::getStoreConfig('currency/fixerio/timeout')))
                ->request('GET')
                ->getBody();

            $converted = json_decode($response);

            $xml = new SimpleXmlElement("<double>{$converted->rates->$currencyTo}</double>");

            if( !$xml ) {
                $this->_messages[] = Mage::helper('directory')->__('Cannot retrieve rate from %s.', $url);
                return null;
            }
            return (float) $xml;
        }
        catch (Exception $e) {
            if( $retry == 0 ) {
                $this->_convert($currencyFrom, $currencyTo, 1);
            } else {
                $this->_messages[] = Mage::helper('directory')->__('Cannot retrieve rate from %s.', $url);
            }
        }
    }
}

Remove string replace in favor of sprintf


<?php

namespace Maqe\LaravelSqsFifo;

use Illuminate\Support\ServiceProvider;
use Maqe\LaravelSqsFifo\Connectors\SqsFifoConnector;

class LaravelSqsFifoServiceProvider extends ServiceProvider
{
    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var bool
     */
    protected $defer = true;

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $queueManager = $this->app['queue'];

        $this->registerSqsFifoConnector($queueManager);
    }

    /**
     * Register the Amazon SQS FIFO queue connector.
     *
     * @param  \Illuminate\Queue\QueueManager  $manager
     * @return void
     */
    protected function registerSqsFifoConnector($manager)
    {
        $manager->addConnector('sqsfifo', function () {
            return new SqsFifoConnector;
        });
    }
}

<?php

namespace Maqe\LaravelSqsFifo;

use Illuminate\Support\ServiceProvider;
use Maqe\LaravelSqsFifo\Connectors\SqsFifoConnector;

class LaravelSqsFifoServiceProvider extends ServiceProvider
{
    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->afterResolving('queue', function ($manager) {
            $this->registerSqsFifoConnector($manager);
        });
    }

    /**
     * Register the Amazon SQS FIFO queue connector.
     *
     * @param  \Illuminate\Queue\QueueManager  $manager
     * @return void
     */
    protected function registerSqsFifoConnector($manager)
    {
        $manager->addConnector('sqsfifo', function () {
            return new SqsFifoConnector;
        });
    }
}

Fix service provider not registering SQS FIFO connector


<?php
/**
 * @author      Guillaume Gagnaire <contact@42php.com>
 * @link        https://www.github.com/42php/42php
 * @license     https://opensource.org/licenses/mit-license.html MIT
 * @copyright   2015-2017 42php
 */

session_start();

\Core\Session::init();

Call Session::init() to synchronize Session with $_SESSION


<?php

/*
 * This file is part of the Symfony framework.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\Yaml\Yaml;

/**
 * This pass adds Assetic routes when use_controller is true.
 *
 * @author Kris Wallsmith <kris@symfony.com>
 */
class RouterResourcePass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        if (!$container->getParameter('assetic.use_controller') || !$container->getParameter('router.resource')) {
            return;
        }

        $file = $container->getParameter('kernel.cache_dir').'/assetic/routing.yml';

        if (!is_dir($dir = dirname($file))) {
            mkdir($dir, 0777, true);
        }

        file_put_contents($file, Yaml::dump(array(
            '_assetic' => array('resource' => '.', 'type' => 'assetic'),
            '_app'     => array('resource' => $container->getParameter('router.resource')),
        )));

        $container->setParameter('router.resource', $file);
    }
}

<?php

/*
 * This file is part of the Symfony framework.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */

namespace Symfony\Bundle\AsseticBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\Yaml\Yaml;

/**
 * This pass adds Assetic routes when use_controller is true.
 *
 * @author Kris Wallsmith <kris@symfony.com>
 */
class RouterResourcePass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container)
    {
        $useController = $container->getParameterBag()->resolveValue($container->getParameter('assetic.use_controller'));
        $routerResource = $container->getParameterBag()->resolveValue($container->getParameter('router.resource'));

        if (!$useController || !$routerResource) {
            return;
        }

        $file = $container->getParameter('kernel.cache_dir').'/assetic/routing.yml';

        if (!is_dir($dir = dirname($file))) {
            mkdir($dir, 0777, true);
        }

        file_put_contents($file, Yaml::dump(array(
            '_assetic' => array('resource' => '.', 'type' => 'assetic'),
            '_app'     => array('resource' => $container->getParameter('router.resource')),
        )));

        $container->setParameter('router.resource', $file);
    }
}

Resolve values before looking at them

Resolve values before looking at them

At least for use_controller the default value defined in Symfony\Bundle\AsseticBundle\DependencyInjection\Configuration is "%kernel.debug%", which you will get literally as a string if you don't call resolveValue().


<?php

/*
 * This file is part of Laravel Database.
 *
 * (c) Brian Faust <hello@brianfaust.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

/*
 * This file is part of Laravel Database.
 *
 * (c) Brian Faust <hello@brianfaust.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace BrianFaust\Database;

use BrianFaust\Database\Connectors\ConnectionFactory;
use BrianFaust\ServiceProvider\ServiceProvider;
use Sofa\Eloquence\ServiceProvider as SofaServiceProvider;

class DatabaseServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        if (class_exists(SofaServiceProvider::class)) {
            $this->app->register(SofaServiceProvider::class);
        }

        $this->app->singleton('db.factory', function ($app) {
            return new ConnectionFactory($app);
        });
    }

    public function provides(): array
    {
        $services = [];

        if (class_exists(SofaServiceProvider::class)) {
            $services[] = SofaServiceProvider::class;
        }

        return $services;
    }
}

<?php

/*
 * This file is part of Laravel Database.
 *
 * (c) Brian Faust <hello@brianfaust.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

/*
 * This file is part of Laravel Database.
 *
 * (c) Brian Faust <hello@brianfaust.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace BrianFaust\Database;

use BrianFaust\Database\Connectors\ConnectionFactory;
use BrianFaust\ServiceProvider\AbstractServiceProvider;
use Sofa\Eloquence\ServiceProvider as SofaServiceProvider;

class DatabaseServiceProvider extends AbstractServiceProvider
{
    public function register(): void
    {
        if (class_exists(SofaServiceProvider::class)) {
            $this->app->register(SofaServiceProvider::class);
        }

        $this->app->singleton('db.factory', function ($app) {
            return new ConnectionFactory($app);
        });
    }

    public function provides(): array
    {
        $services = [];

        if (class_exists(SofaServiceProvider::class)) {
            $services[] = SofaServiceProvider::class;
        }

        return $services;
    }
}

Fix extending service provider name

Fix extending service provider name


<?php

namespace Articstudio\SlimInterfaces\Contracts;

use Slim\App as SlimApp;

interface RouteGroup {

    public function __invoke(SlimApp $app);
}

<?php

namespace Articstudio\SlimInterfaces\Contracts;

use Slim\App as SlimApp;

interface RouteGroup {

    public static function getPattern(): string;

    public function __invoke(SlimApp $app);
}

Fix Route Group interface. Added GetPattern method


<?php
	/** @var $_ array */
	/** @var $l \OCP\IL10N */
	style('files_sharing', 'authenticate');
	script('files_sharing', 'authenticate');
?>
<form method="post">
	<fieldset class="warning">
		<?php if (!isset($_['wrongpw'])): ?>

<?php p($l->t('This share is password-protected')); ?>

		<?php endif; ?>
		<?php if (isset($_['wrongpw'])): ?>

<?php p($l->t('The password is wrong. Try again.')); ?>

		<?php endif; ?>

			<?php p($l->t('Password')); ?>
			<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
			<input type="password" name="password" id="password"
				placeholder="<?php p($l->t('Password')); ?>" value=""
				autocomplete="off" autocapitalize="off" autocorrect="off"
				autofocus />
			<input type="submit" id="password-submit"
				class="svg icon-confirm input-button-inline" value="" disabled="disabled" />

	</fieldset>
</form>

<?php
	/** @var $_ array */
	/** @var $l \OCP\IL10N */
	style('files_sharing', 'authenticate');
	script('files_sharing', 'authenticate');
?>
<form method="post">
	<fieldset class="warning">
		<?php if (!isset($_['wrongpw'])): ?>

<?php p($l->t('This share is password-protected')); ?>

		<?php endif; ?>
		<?php if (isset($_['wrongpw'])): ?>

<?php p($l->t('The password is wrong. Try again.')); ?>

		<?php endif; ?>

			<?php p($l->t('Password')); ?>
			<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>" />
			<input type="password" name="password" id="password"
				placeholder="<?php p($l->t('Password')); ?>" value=""
				autocomplete="new-password" autocapitalize="off" autocorrect="off"
				autofocus />
			<input type="submit" id="password-submit"
				class="svg icon-confirm input-button-inline" value="" disabled="disabled" />

	</fieldset>
</form>

Use new-password as autocomplete on share auth page

Fixes #6821

This makes sure that (supported) browsers will not prefill the password
field if a user has a password saved for that nextcloud.

Signed-off-by: Roeland Jago Douma <982d370f7dc34a05b4abe8788f899578d515262d@famdouma.nl>


<?php
/**
 * http parse decorator class
 * @author Lancer He <lancer.he@gmail.com>
 * @since  2014-10-28
 */

namespace Http\Parse;

use Http\Parse\ParseAbstract;

abstract class Decorator extends ParseAbstract {

    public function __construct(ParseAbstract $parse) {
        $this->_http_parse = $parse;
    }

    public function parse() {
        return $this->_http_parse->parse();
    }

    public function getRequest() {
        return $this->_http_parse->getRequest();
    }
}

<?php
/**
 * http parse decorator class
 * @author Lancer He <lancer.he@gmail.com>
 * @since  2014-10-28
 */

namespace Http\Parse;

use Http\Parse\ParseAbstract;

abstract class Decorator extends ParseAbstract {

    public function __construct(ParseAbstract $parse) {
        $this->_http_parse = $parse;
    }

    /**
     * 装饰类方法不存在时，使用被装饰类方法
     */
    public function __call($func, $params = null) {
        return call_user_func_array( array($this->_http_parse, $func), $params);
    }

    public function parse() {
        return $this->_http_parse->parse();
    }

    public function getRequest() {
        return $this->_http_parse->getRequest();
    }
}

Add magic method for http parse decorator.


<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Laravel PHP Framework</title>

	<link rel="stylesheet" type="text/css" href="/css/global.css">
	<script type="text/javascript" src="http://js.pusher.com/2.1/pusher.min.js"></script>
</head>
<body>

	<div class="container">
		@yield('content')
	</div>

</body>
</html>

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Laravel PHP Framework</title>

	<link rel="stylesheet" type="text/css" href="/css/global.css">
	<script type="text/javascript" src="http://js.pusher.com/2.1/pusher.min.js"></script>
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>
	<script type="text/javascript" src="/js/global.js"></script>
</head>
<body>

	<div class="container">
		@yield('content')
	</div>

</body>
</html>

Include jQuery in master layout

Include jQuery in master layout


<?php

namespace Yolo;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\TerminableInterface;

class FrontController
{
    private $kernel;

    public function __construct(HttpKernelInterface $kernel)
    {
        $this->kernel = $kernel;
    }

    public function run()
    {
        $request = Request::createFromGlobals();
        $response = $this->kernel->handle($request)->send();

        if ($this->kernel instanceof TerminableInterface) {
            $this->kernel->terminate($request, $response);
        }
    }
}

<?php

namespace Yolo;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\TerminableInterface;

class FrontController
{
    private $kernel;

    public function __construct(HttpKernelInterface $kernel)
    {
        $this->kernel = $kernel;
    }

    public function run()
    {
        $request = Request::createFromGlobals();
        $response = $this->kernel->handle($request);

        $response->send();

        if ($this->kernel instanceof TerminableInterface) {
            $this->kernel->terminate($request, $response);
        }
    }
}

Move response::send to own line

Move response::send to own line


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

class Emailing
{
    private $ci;
    private $config;

    public function __construct()
    {
        $this->ci =& get_instance();

        // initialize email configuration
        $this->config = array(
            'protocol' => 'smtp',
            'smtp_host' => $_SERVER['SMTP_HOST'],
            'smtp_user' => $_SERVER['SMTP_USER'],
            'smtp_pass' => $_SERVER['SMTP_PASS'],
            'mailtype' => 'html',
            'smtp_port' => $_SERVER['SMTP_PORT'],
        );

        $this->ci->load->library('email', $this->config);
    }

    public function send_email($emailTo, $subject, $msg)
    {
        $this->ci->email->from($_SERVER['EMAIL_FROM'], $_SERVER['EMAIL_ALIAS']);
        $this->ci->email->to($emailTo);

        $this->ci->email->subject($subject);
        $this->ci->email->message($msg);

        $this->ci->email->send();

        // TODO: create log table to log all outgoing email
    }

}

/* End of file Emailing.php */
/* Location: ./application/libraries/Emailing.php */

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

class Emailing
{
    private $ci;
    private $config;

    public function __construct()
    {
        $this->ci =& get_instance();

        // initialize email configuration
        $this->config = array(
            'protocol' => 'smtp',
            'smtp_host' => $_SERVER['SMTP_HOST'],
            'smtp_user' => $_SERVER['SMTP_USER'],
            'smtp_pass' => $_SERVER['SMTP_PASS'],
            'mailtype' => 'html',
            'smtp_port' => $_SERVER['SMTP_PORT'],
            'charset'   => 'iso-8859-1'
        );

        $this->ci->load->library('email', $this->config);
    }

    public function send_email($emailTo, $subject, $msg)
    {
        $this->ci->email->from($_SERVER['EMAIL_FROM'], $_SERVER['EMAIL_ALIAS']);
        $this->ci->email->to($emailTo);

        $this->ci->email->subject($subject);
        $this->ci->email->message($msg);

        $this->ci->email->send();

        // TODO: create log table to log all outgoing email
    }

}

/* End of file Emailing.php */
/* Location: ./application/libraries/Emailing.php */

Update charset of email config

Update charset of email config


<?php

namespace Heyday\MenuManager;

use SilverStripe\ORM\DataObject;
use SilverStripe\View\TemplateGlobalProvider;

class MenuManagerTemplateProvider implements TemplateGlobalProvider
{
    /**
     * @return array
     */
    public static function get_template_global_variables()
    {
        return [
            'MenuSet' => 'MenuSet'
        ];
    }

    /**
     * @param $name
     * @return DataObject
     */
    public static function MenuSet($name)
    {
        return MenuSet::get()
            ->filter(
                [
                    'Name' => $name
                ]
            )->first();
    }
}

<?php

namespace Heyday\MenuManager;

use InvalidArgumentException;
use SilverStripe\Core\Extensible;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\View\TemplateGlobalProvider;

class MenuManagerTemplateProvider implements TemplateGlobalProvider
{
    use Extensible;

    /**
     * @return array
     */
    public static function get_template_global_variables()
    {
        return [
            'MenuSet' => 'MenuSet'
        ];
    }

    /**
     * @param $name
     * @return MenuSet|null
     */
    public static function MenuSet($name)
    {
        return Injector::inst()->get(self::class)->findMenuSetByName($name);
    }

    /**
     * Find a MenuSet by name
     *
     * @param string $name
     * @return MenuSet|null
     * @throws InvalidArgumentException
     */
    public function findMenuSetByName($name)
    {
        if (empty($name)) {
            throw new InvalidArgumentException("Please pass in the name of the MenuSet you're trying to find");
        }
        $result = MenuSet::get()->filter('Name', $name);
        $this->extend('updateFindMenuSetByName', $result);
        return $result->first();
    }
}

FIX integration issues with Subsites

FIX integration issues with Subsites

via guttmann/silverstripe-menumanager-subsites one can use the
Menu Manager module while keeping menus segregated by Subsite and
managable by each. However on dev/build the configured default
menus (see MenuSet::requireDefaultRecords) error each time, as the
system attempts to create the same menus for each subsite. Since
fd5caf63e9d5e789ae7ca9c6adca5f893564266c the system sees that a
menu by the given name is already in the database (without
filtering by subsite) and throws an emergency validation error,
halting the dev/build from completing properly.

The validation issue itself was brought in to handle an issue
where duplicate entries in the database could not be cleared out
via usage of the CMS. We should instead consider adding extension
hooks to allow sub-modules as such to alter the filters used to
find a MenuSet by a given name.


<?php
namespace Icicle\WebSocket\Protocol\Message;

use Icicle\Http\Message\BasicRequest;
use Icicle\Http\Message\Uri;

class WebSocketRequest extends BasicRequest
{
    /**
     * @param \Icicle\Http\Message\Uri $uri
     * @param string[][] $headers
     * @param string|null $target
     */
    public function __construct(Uri $uri, array $headers, $target = null)
    {
        parent::__construct('GET', $uri, $headers, null, $target, '1.1');
    }
}

<?php
namespace Icicle\WebSocket\Protocol\Message;

use Icicle\Http\Message\BasicRequest;
use Icicle\Http\Message\Uri;
use Icicle\Stream\ReadableStream;

class WebSocketRequest extends BasicRequest
{
    /**
     * @param \Icicle\Http\Message\Uri $uri
     * @param string[][] $headers
     * @param \Icicle\Stream\ReadableStream|null $stream
     * @param string|null $target
     */
    public function __construct(Uri $uri, array $headers, ReadableStream $stream = null, $target = null)
    {
        parent::__construct('GET', $uri, $headers, $stream, $target, '1.1');
    }
}

Add stream parameter on request

Add stream parameter on request


<?php
declare(strict_types=1);

namespace Moka\Tests;

abstract class IncompleteAbstractTestClass implements TestInterface
{
    public $public;

    protected $protected;

    private $private;

    public $isTrue;

    public static $getInt;

    public function isTrue(): bool
    {
        return true;
    }

    public function getInt(): int
    {
        return 11;
    }

    public function getSelf(): TestInterface
    {
        return $this;
    }

    public function getCallable(): callable
    {
        return function () {
        };
    }

    public function withArgument(int $argument): int
    {
        return $argument;
    }

    public function withArguments(
        int $required,
        $nullable = null,
        string &$byReference = PHP_EOL,
        FooTestClass $class = null,
        array $array = [3],
        callable $callable = null,
        ...$variadic
    ): int {
        return $required;
    }

    public function throwException()
    {
    }

    abstract public function abstractMethod();
}

<?php
declare(strict_types=1);

namespace Moka\Tests;

abstract class IncompleteAbstractTestClass implements TestInterface
{
    public $public;

    protected $protected;

    private $private;

    public $isTrue;

    public static $getInt;

    public function isTrue(): bool
    {
        return true;
    }

    public function getInt(): int
    {
        return 11;
    }

    public function getSelf(): TestInterface
    {
        return $this;
    }

    public function getCallable(): callable
    {
        return function () {
        };
    }

    public function & getReference(): array
    {
        return [];
    }

    public function withArgument(int $argument): int
    {
        return $argument;
    }

    public function withArguments(
        int $required,
        $nullable = null,
        string &$byReference = PHP_EOL,
        FooTestClass $class = null,
        array $array = [3],
        callable $callable = null,
        ...$variadic
    ): int {
        return $required;
    }

    public function throwException()
    {
    }

    abstract public function abstractMethod();
}

Test mocking classes with methods returning references


<?php

namespace Oro\Bundle\ApiBundle\Form\Type;

use Oro\Bundle\SoapBundle\Form\EventListener\PatchSubscriber;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
 * This abstract form type may be used to be extended from to adapt any form type to be used as root form type
 * for REST and SOAP API.
 */
abstract class AbstractPatchableApiType extends AbstractType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->addEventSubscriber(new PatchSubscriber());
    }

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'cascade_validation' => true,
                'csrf_protection'    => false
            ]
        );
    }

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

<?php

namespace Oro\Bundle\ApiBundle\Form\Type;

use Oro\Bundle\SoapBundle\Form\EventListener\PatchSubscriber;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
 * This abstract form type may be used to be extended from to adapt any form type to be used as root form type
 * for REST and SOAP API.
 */
abstract class AbstractPatchableApiType extends AbstractType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->addEventSubscriber(new PatchSubscriber());
    }

    /**
     * {@inheritdoc}
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'csrf_protection' => false
            ]
        );
    }

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

BAP-16729: Remove DecoratorApiType and refactor dependent types
- remove deprecated 'cascade_validation' option


<?php
set_include_path(dirname(__FILE__) . '/../' . PATH_SEPARATOR . get_include_path());

// Enable Composer autoloader
require dirname(__DIR__) . '/vendor/autoload.php';

//Register non-Slim autoloader
function customAutoLoader($class)
{
    $file = dirname(__FILE__) . '/' . $class . '.php';
    if (file_exists($file)) {
        require $file;
    } else {
        return;
    }
}
spl_autoload_register('customAutoLoader');

// Prevent session cookies
ini_set('session.use_cookies', 0);

<?php
set_include_path(dirname(__FILE__) . '/../' . PATH_SEPARATOR . get_include_path());

// Set timezone
date_default_timezone_set('America/New_York');

// Enable Composer autoloader
require dirname(__DIR__) . '/vendor/autoload.php';

//Register non-Slim autoloader
function customAutoLoader($class)
{
    $file = dirname(__FILE__) . '/' . $class . '.php';
    if (file_exists($file)) {
        require $file;
    } else {
        return;
    }
}
spl_autoload_register('customAutoLoader');

// Prevent session cookies
ini_set('session.use_cookies', 0);

Set timezone for PHPUnit tess

Set timezone for PHPUnit tess


<?php

/**
 * Class MaintenanceModeExtension
 *
 * @property Controller $owner
 */
class MaintenanceModeExtension extends Extension
{

    /**
     * @throws SS_HTTPResponse_Exception
     */
    public function onBeforeInit()
    {
        if($this->isDownForMaintenance())
        {
            $this->respond503();
        }
    }

    /**
     * @return bool
     */
    public function isDownForMaintenance()
    {
        return file_exists(BASE_PATH.'/mysite/down');
    }

    /**
     * Somehow $this->owner->httpError puts a burden on de Database.
     *
     * Maybe not very Silverstripe'sch, but at least this works
     */
    protected function respond503()
    {
        $message = 'Website is down for maintenance';
        $content = '<h1>'.$message.'</h1>';

        header($message, true, 503);

        $errorFile = BASE_PATH.'/assets/error-503.html';
        if(is_file($errorFile)) {
            $content = file_get_contents($errorFile);
        }

        echo $content;
        exit();
    }

}

<?php

/**
 * Class MaintenanceModeExtension
 *
 * @property Controller $owner
 */
class MaintenanceModeExtension extends Extension
{

    /**
     * @throws SS_HTTPResponse_Exception
     */
    public function onBeforeInit()
    {
        if($this->isDownForMaintenance())
        {
            $this->respond503();
        }
    }

    /**
     * @return bool
     */
    public function isDownForMaintenance()
    {
        return file_exists(BASE_PATH.'/mysite/down');
    }

    /**
     * Somehow $this->owner->httpError puts a burden on de Database.
     *
     * Maybe not very Silverstripe'sch, but at least this works
     */
    protected function respond503()
    {
        $message = 'Website is down for maintenance';
        $content = '<h1>'.$message.'</h1>';

        header($message, true, 503);

        $errorFile = $this->get503File();

        if(is_file($errorFile)) {
            $content = file_get_contents($errorFile);
        }

        echo $content;
        exit();
    }

    protected function get503File()
    {
        $custom = BASE_PATH.(string)Config::inst()->get('MaintenanceMode', 'file');

        if(is_file($custom)) {
            return $custom;
        }

        return BASE_PATH.'/assets/error-503.html';
    }

}

Add option to set a custom 503 content file with Config::inst()->update('MaintenanceMode', 'file', 'my503file');

This as fall back for a ErrorPage 503 file in assets.


@extends('layout')

@section('title')Folder - {{$path}}@stop

@section('content')

{{$path}}

    <?php
        if (strpos($path, "/")) {
            if(strpos($path, "/"))
                $url = "/lists/" . substr($path, 0, strrpos($path, "/"));
            else
                $url = "/lists";
            echo "..
";
        }

        foreach (SourceController::getDir("query/" . $path) as $file)
        {
            if (strpos($file, "."))
                $url = "/lists/" . $path . "/" . substr($file, 0, strpos($file, "."));
            else
                $url = "/lists/" . $path . "/" . $file;
			echo "" . $file . "
";
        }
    ?>

@stop

@extends('layout')

@section('title')Folder - {{$path}}@stop

@section('content')

{{SourceController::linkedPath($path)}}

    <?php

        foreach (SourceController::getDir("query/" . $path) as $file)
        {
            if (strpos($file, "."))
                $url = "/lists/" . $path . "/" . substr($file, 0, strpos($file, "."));
            else
                $url = "/lists/" . $path . "/" . $file;
			echo "" . $file . "
";
        }
    ?>

@stop

Add nice looking path instead of the obscure '..'


<?php
/**
 * @author Marc Pantel <pantel.m@gmail.com>
 */
namespace Payum\Core\Bridge\Symfony\Validator\Constraints;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

/**
 * CreditCardDateValidator
 *
 * Validate if the Credit Card is not expired
 */
class CreditCardDateValidator extends ConstraintValidator
{
    /**
     * {@inheritDoc}
     */
    public function validate($value, Constraint $constraint)
    {
        if (null === $value) {
            return;
        }

        if (!($value instanceof \DateTime)) {
            $this->context->buildViolation($constraint->invalidMessage, array(
                '{{ value }}' => $value,
            ))
            ->addViolation();

            return;
        }

        /**
         * The Credit Card is not expired until last day of the month
         */
        $value->modify('last day of this month');

        if (null !== $constraint->min && $value < $constraint->min) {
            $this->context->buildViolation($constraint->minMessage)
                ->atPath('expireAt')
                ->addViolation();
        }
    }
}

<?php
/**
 * @author Marc Pantel <pantel.m@gmail.com>
 */
namespace Payum\Core\Bridge\Symfony\Validator\Constraints;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

/**
 * CreditCardDateValidator
 *
 * Validate if the Credit Card is not expired
 */
class CreditCardDateValidator extends ConstraintValidator
{
    /**
     * {@inheritDoc}
     */
    public function validate($value, Constraint $constraint)
    {
        if (null === $value) {
            return;
        }

        if (!($value instanceof \DateTime)) {
            if (method_exists($this->context, 'buildViolation')) {
                $this->context->buildViolation($constraint->invalidMessage, array(
                             '{{ value }}' => $value,
                         ))
                     ->addViolation();

                return;
            }

            $this->context->addViolationAt('expireAt', $constraint->invalidMessage, array(
                '{{ value }}' => $value,
            ));
        }

        /**
         * The Credit Card is not expired until last day of the month
         */
        $value->modify('last day of this month');

        if (null !== $constraint->min && $value < $constraint->min) {
            if (method_exists($this->context, 'buildViolation')) {

                $this->context->buildViolation($constraint->minMessage)
                    ->atPath('expireAt')
                    ->addViolation();

                return;
            }

            $this->context->addViolationAt('expireAt', $constraint->minMessage);

        }
    }
}

Test if method buildViolation exist and fallback to addViolation for symfony < 2.5


<?php namespace CodeIgniter\Exceptions;

/**
 * Model Exceptions.
 */

class ModelException extends FrameworkException
{
	public static function forNoPrimaryKey(string $modelName)
	{
		return new static(lang('Database.noPrimaryKey', [$modelName]));
	}
}

<?php namespace CodeIgniter\Exceptions;

/**
 * Model Exceptions.
 */

class ModelException extends FrameworkException
{
	public static function forNoPrimaryKey(string $modelName)
	{
		return new static(lang('Database.noPrimaryKey', [$modelName]));
	}

	public static function forNoDateFormat(string $modelName)
	{
		return new static(lang('Database.noDateFormat', [$modelName]));
	}
}

Add exception for missing/invalid dateFormat


<?php

namespace Gaufrette\Functional\FileStream;

use Gaufrette\Filesystem;
use Gaufrette\Adapter\Local as LocalAdapter;
use Gaufrette\Functional\LocalDirectoryDeletor;

class LocalTest extends FunctionalTestCase
{
    protected $directory;

    public function setUp()
    {
        $this->directory = __DIR__.DIRECTORY_SEPARATOR.'filesystem';
        @mkdir($this->directory.DIRECTORY_SEPARATOR.'subdir', 0777, true);
        $this->filesystem = new Filesystem(new LocalAdapter($this->directory, true));

        $this->registerLocalFilesystemInStream();
    }

    public function tearDown()
    {
        LocalDirectoryDeletor::deleteDirectory($this->directory);
    }

    /**
     * @test
     */
    public function shouldSupportsDirectory()
    {
        $this->assertTrue(file_exists('gaufrette://filestream/subdir'));
        $this->assertTrue(is_dir('gaufrette://filestream/subdir'));
    }
}

<?php

namespace Gaufrette\Functional\FileStream;

use Gaufrette\Filesystem;
use Gaufrette\Adapter\Local as LocalAdapter;
use Gaufrette\Functional\LocalDirectoryDeletor;

class LocalTest extends FunctionalTestCase
{
    protected $directory;

    public function setUp()
    {
        $this->directory = __DIR__.DIRECTORY_SEPARATOR.'filesystem';
        @mkdir($this->directory.DIRECTORY_SEPARATOR.'subdir', 0777, true);
        $this->filesystem = new Filesystem(new LocalAdapter($this->directory, true, 0770));

        $this->registerLocalFilesystemInStream();
    }

    public function testDirectoryChmod()
    {
        $r = fopen('gaufrette://filestream/foo/bar', 'a+');
        fclose($r);

        $perms = fileperms($this->directory . '/foo/');
        $this->assertEquals('0770', substr(sprintf('%o', $perms), -4));
    }

    public function tearDown()
    {
        LocalDirectoryDeletor::deleteDirectory($this->directory);
    }

    /**
     * @test
     */
    public function shouldSupportsDirectory()
    {
        $this->assertTrue(file_exists('gaufrette://filestream/subdir'));
        $this->assertTrue(is_dir('gaufrette://filestream/subdir'));
    }
}

Test chmod of directory created by LocalStream


<?php
/**
 * Created by PhpStorm.
 * User: thomas
 * Date: 27/03/15
 * Time: 01:15
 */

namespace BitWasp\Bitcoin\Test\Network\Messages;

use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Network\Messages\Ping;
use BitWasp\Bitcoin\Tests\AbstractTestCase;

class PingTest extends AbstractTestCase
{
    public function testPing()
    {
        $ping = new Ping();
        $this->assertInternalType('string', $ping->getNonce());
        $this->assertEquals('ping', $ping->getNetworkCommand());
        $math = Bitcoin::getMath();
        $this->assertEquals($math->decHex($ping->getNonce()), $ping->getBuffer()->getHex());

    }
}

<?php
/**
 * Created by PhpStorm.
 * User: thomas
 * Date: 27/03/15
 * Time: 01:15
 */

namespace BitWasp\Bitcoin\Test\Network\Messages;

use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Network\Messages\Ping;
use BitWasp\Bitcoin\Tests\AbstractTestCase;

class PingTest extends AbstractTestCase
{
    public function testPing()
    {
        $ping = new Ping();
        $this->assertInternalType('string', $ping->getNonce());
        $this->assertEquals('ping', $ping->getNetworkCommand());
        $math = Bitcoin::getMath();
        $this->assertEquals(str_pad($math->decHex($ping->getNonce()), 16, '0', STR_PAD_LEFT), $ping->getBuffer()->getHex());

    }
}

Add padding to ping nonce check - fixes failures


<?php

/**
 * Created by PhpStorm.
 * User: Conrad
 * Date: 9/11/2015
 * Time: 5:28 PM
 */
class ContentModuleSiteTreeTranslatableExtension extends DataExtension
{
    public function onTranslatableCreate($saveTranslation)
    {
        if ($saveTranslation) {
            //create new modules
            $manyManys = array_reverse($page->manyMany());

            if (!empty($manyManys)) {
                foreach ($manyManys as $relationship => $class) {
                    if ($class === 'ContentModule' || ($class instanceof ContentModule)) {
                        if ($original = $this->owner->getTranslation(Translatable::default_locale())) {
                            foreach ($original->$relationship() as $module) {
                                //create new module
                                $newModule = Object::create(get_class($module));
                                $newModule->Title = $module->Title . ' - ' . Translatable::get_current_locale();
                                $newModule->Locale = Translatable::get_current_locale();
                                $newModule->OriginalID = $original->ID;
                                $newModule->write();
                                $this->owner->$relationship()->add($newModule);
                            }
                        }
                    }
                }
        }
    }
}

<?php

/**
 * Created by PhpStorm.
 * User: Conrad
 * Date: 9/11/2015
 * Time: 5:28 PM
 */
class ContentModuleSiteTreeTranslatableExtension extends DataExtension
{
    public function onTranslatableCreate($saveTranslation)
    {
        if ($saveTranslation) {
            //create new modules
            $manyManys = array_reverse($this->owner->manyMany());

            if (!empty($manyManys)) {
                foreach ($manyManys as $relationship => $class) {
                    if ($class === 'ContentModule' || ($class instanceof ContentModule)) {
                        if ($original = $this->owner->getTranslation(Translatable::default_locale())) {
                            foreach ($original->$relationship() as $module) {
                                //create new module
                                $newModule = Object::create(get_class($module));
                                $newModule->Title = $module->Title . ' - ' . $this->owner->Locale;
                                $newModule->Locale = $this->owner->Locale;
                                $newModule->OriginalID = $original->ID;
                                $newModule->write();
                                $this->owner->$relationship()->add($newModule);
                            }
                        }
                    }
                }
            }
        }
    }
}

Fix generation of translated modules

Fix generation of translated modules


<?php

namespace AlgoWeb\PODataLaravel\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;

class MetadataRouteProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        self::setupRoute();
    }

    private static function setupRoute()
    {
        Route::any(
            'odata.svc/{section}',
            [ 'uses' => 'AlgoWeb\PODataLaravel\Controllers\ODataController@index', 'middleware' => 'auth.basic']
        )
            ->where(['section' => '.*']);
        Route::any(
            'odata.svc',
            [ 'uses' => 'AlgoWeb\PODataLaravel\Controllers\ODataController@index', 'middleware' => 'auth.basic']
        );
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

<?php

namespace AlgoWeb\PODataLaravel\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;

class MetadataRouteProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        self::setupRoute();
    }

    private static function setupRoute()
    {
        Route::any(
            'odata.svc/{section}',
            [ 'uses' => 'AlgoWeb\PODataLaravel\Controllers\ODataController@index', 'middleware' => 'auth:api']
        )
            ->where(['section' => '.*']);
        Route::any(
            'odata.svc',
            [ 'uses' => 'AlgoWeb\PODataLaravel\Controllers\ODataController@index', 'middleware' => 'auth:api']
        );
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}

Use 'auth:api' middleware instead 'auth:basic' to support Passport authenticated requests


<?php
/**
 * Created by PhpStorm.
 * User: alex
 * Date: 20/10/2016
 * Time: 23:36
 */

namespace vr\api\doc\components;

use yii\base\BaseObject;

/**
 * Class DocCommentParser
 * @package vr\api\doc\components
 * @property string $description
 */
class DocCommentParser extends BaseObject
{
    /**
     * @var
     */
    public $source;

    /**
     * @var
     */
    public $params;

    /**
     *
     */
    public function init()
    {
    }

    /**
     * @return string
     */
    public function getDescription()
    {
        $string = explode(PHP_EOL, $this->source);
        $values = array_splice($string, 1);

        array_walk($values, function (&$item) {
            $item = trim($item, '* /\t\r\n');
        });

        return implode(array_filter($values), '<br/>');
    }
}

<?php
/**
 * Created by PhpStorm.
 * User: alex
 * Date: 20/10/2016
 * Time: 23:36
 */

namespace vr\api\doc\components;

use yii\base\BaseObject;

/**
 * Class DocCommentParser
 * @package vr\api\doc\components
 * @property string $description
 */
class DocCommentParser extends BaseObject
{
    /**
     * @var
     */
    public $source;

    /**
     * @var
     */
    public $params;

    /**
     *
     */
    public function init()
    {
    }

    /**
     * @return string
     */
    public function getDescription()
    {
        $string = explode(PHP_EOL, $this->source);
        $values = array_splice($string, 1);

        array_walk($values, function (&$item) {
            $item = trim($item, "* /\t\r\n");
        });

        $filtered = array_filter($values, function ($string) {
            return !empty($string)
                   && strpos($string, '@throws') === false
                   && strpos($string, '@return') === false;
        });

        return implode($filtered, '<br/>');
    }
}

Change the parsing doc comments algorithm to show full method documentation but not just the first string


<?php
declare (strict_types = 1);

namespace GrottoPress\Jentil\Setups\Customizer\Colophon\Settings;

use GrottoPress\Jentil\Setups\Customizer\Colophon\Colophon as Section;
use GrottoPress\Jentil\Setups\Customizer\AbstractSetting;

final class Colophon extends AbstractSetting
{
    public function __construct(Section $colophon)
    {
        parent::__construct($colophon->customizer);

        $theme_mod = $this->customizer->app->utilities->themeMods->colophon;

        $this->id = $theme_mod->id;

        $this->args['default'] = $theme_mod->default;
        $this->args['transport'] = 'postMessage';
        $this->args['sanitize_callback'] = function (string $value): string {
            return \wp_kses($value, 'pre_user_description');
        };
    }
}

<?php
declare (strict_types = 1);

namespace GrottoPress\Jentil\Setups\Customizer\Colophon\Settings;

use GrottoPress\Jentil\Setups\Customizer\Colophon\Colophon as Section;
use GrottoPress\Jentil\Setups\Customizer\AbstractSetting;

final class Colophon extends AbstractSetting
{
    public function __construct(Section $colophon)
    {
        parent::__construct($colophon->customizer);

        $theme_mod = $this->customizer->app->utilities->themeMods->colophon;

        $this->id = $theme_mod->id;

        $this->args['default'] = $theme_mod->default;
        $this->args['transport'] = 'postMessage';
        $this->args['sanitize_callback'] = function ($value): string {
            return \wp_kses($value, 'pre_user_description');
        };
    }
}

Remove type hint from closure parameter

Remove type hint from closure parameter


<?php

namespace Tests\Feature;

use App\Actions\ValetSecure;
use App\Shell\Shell;
use Exception;
use Illuminate\Support\Facades\Config;
use Tests\Feature\Fakes\FakeProcess;
use Tests\TestCase;

class ValetSecureTest extends TestCase
{
    /** @test */
    function it_runs_valet_link()
    {
        $shell = $this->mock(Shell::class);

        Config::set('lambo.store.valet_secure', true);

        $shell->shouldReceive('execInProject')
            ->with('valet secure')
            ->once()
            ->andReturn(FakeProcess::success());

        app(ValetSecure::class)();
    }

    /** @test */
    function it_throws_an_exception_if_the_after_script_fails()
    {
        $shell = $this->mock(Shell::class);

        Config::set('lambo.store.valet_secure', true);

        $command = 'valet secure';
        $shell->shouldReceive('execInProject')
            ->with($command)
            ->once()
            ->andReturn(FakeProcess::fail($command));

        $this->expectException(Exception::class);

        app(ValetSecure::class)();
    }
}

<?php

namespace Tests\Feature;

use App\Actions\ValetSecure;
use App\Shell\Shell;
use Exception;
use Illuminate\Support\Facades\Config;
use Tests\Feature\Fakes\FakeProcess;
use Tests\TestCase;

class ValetSecureTest extends TestCase
{
    private $shell;

    public function setUp(): void
    {
        parent::setUp(); // TODO: Change the autogenerated stub
        $this->shell = $this->mock(Shell::class);
    }

    /** @test */
    function it_runs_valet_link()
    {
        Config::set('lambo.store.valet_secure', true);

        $this->shell->shouldReceive('execInProject')
            ->with('valet secure')
            ->once()
            ->andReturn(FakeProcess::success());

        app(ValetSecure::class)();
    }

    /** @test */
    function it_throws_an_exception_if_the_after_script_fails()
    {
        Config::set('lambo.store.valet_secure', true);

        $this->shell->shouldReceive('execInProject')
            ->with('valet secure')
            ->once()
            ->andReturn(FakeProcess::fail('valet secure'));

        $this->expectException(Exception::class);

        app(ValetSecure::class)();
    }
}

Apply consistent code style as used in other tests.


<?php
namespace EdpModuleLayouts;

class Module
{
    public function onBootstrap($e)
    {
        $e->getApplication()->getEventManager()->getSharedManager()->attach(array('Zend\Mvc\Controller\AbstractRestfulController', 'Zend\Mvc\Controller\AbstractActionController'),
                            'dispatch', function($e) {
            $controller      = $e->getTarget();
            $controllerClass = get_class($controller);
            $moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
            $config          = $e->getApplication()->getServiceManager()->get('config');
            if (isset($config['module_layouts'][$moduleNamespace])) {
                $controller->layout($config['module_layouts'][$moduleNamespace]);
            }
        }, 100);
    }
}

<?php
namespace EdpModuleLayouts;

class Module
{
    public function onBootstrap($e)
    {
        $e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\Mvc\Controller\AbstractController', 'dispatch', function($e) {
            $controller      = $e->getTarget();
            $controllerClass = get_class($controller);
            $moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
            $config          = $e->getApplication()->getServiceManager()->get('config');
            if (isset($config['module_layouts'][$moduleNamespace])) {
                $controller->layout($config['module_layouts'][$moduleNamespace]);
            }
        }, 100);
    }
}

Generalize controllers to abstract one

Generalize controllers to abstract one


<?php
namespace WuifDesign\SEO;

use \Illuminate\Support\ServiceProvider as IlluminateServiceProvider;

class ServiceProvider extends IlluminateServiceProvider
{
    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->mergeConfigFrom(
            __DIR__.'/config/seo.php', 'seo'
        );

        $this->app->singleton('metaTags', function ($app) {
            return new MetaTags($app);
        });

        $this->app->singleton('openGraph', function ($app) {
            return new OpenGraph($app);
        });

        $this->app->singleton('twitterCard', function ($app) {
            return new TwitterCard($app);
        });

        $this->app->singleton('schema', function ($app) {
            return new Schema($app);
        });

        $this->app->singleton('seoTool', function ($app) {
            return new SEOTool($app);
        });
    }

    /**
     * Perform post-registration booting of services.
     *
     * @return void
     */
    public function boot()
    {
        $this->publishes([
            __DIR__.'/config/wuifdesign-seo.php' => config_path('seo.php'),
        ]);
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return array(
            'metaTags',
            'openGraph',
            'twitterCard',
            'schema',
            'seoTools'
        );
    }
}

<?php
namespace WuifDesign\SEO;

use \Illuminate\Support\ServiceProvider as IlluminateServiceProvider;

class ServiceProvider extends IlluminateServiceProvider
{
    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->mergeConfigFrom(
            __DIR__.'/config/seo.php', 'seo'
        );

        $this->app->singleton('metaTags', function ($app) {
            return new MetaTags($app);
        });

        $this->app->singleton('openGraph', function ($app) {
            return new OpenGraph($app);
        });

        $this->app->singleton('twitterCard', function ($app) {
            return new TwitterCard($app);
        });

        $this->app->singleton('schema', function ($app) {
            return new Schema($app);
        });

        $this->app->singleton('seoTool', function ($app) {
            return new SEOTool($app);
        });
    }

    /**
     * Perform post-registration booting of services.
     *
     * @return void
     */
    public function boot()
    {
        $this->publishes([
            __DIR__.'/config/seo.php' => config_path('seo.php'),
        ]);
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return array(
            'metaTags',
            'openGraph',
            'twitterCard',
            'schema',
            'seoTools'
        );
    }
}

Fix path to config file

Fix path to config file

Get Can't locate path: </home/vagrant/Code/herbax.dev/vendor/wuifdesign/laravel-seo/src/config/wuifdesign-seo.php> when doing php artisan vendor:publish ... Config file name is seo.php not wuifdesign-seo.php


<?php

namespace PragmaRX\Tracker\Support;

use Carbon\Carbon;

class Minutes {

	private $minutes;

	private $start;

	private $end;

	public function __construct($minutes)
	{
	    $this->minutes = $minutes;

		if ($minutes instanceof Minutes)
		{
			$this->start = $minutes->getStart();

			$this->end = $minutes->getEnd();
		}
		else
		{
			$this->calculateStartEnd();
		}
	}

	public function getStart()
	{
		return $this->start;
	}

	public function getEnd()
	{
		return $this->end;
	}

	private function calculateStartEnd()
	{
		if($this->minutes == 0)
		{
			$this->setToday();
		}
		else
		{
			$this->start = Carbon::now()->subMinutes($this->minutes);

			$this->end = Carbon::now();
		}
	}

	private function setToday()
	{
		$this->start = Carbon::now()->setTime(0,0,0);

		$this->end = Carbon::now()->setTime(23,59,59);
	}

	public static function make($minutes)
	{
		return new static($minutes);
	}
}

<?php

namespace PragmaRX\Tracker\Support;

use Carbon\Carbon;

class Minutes
{
    /**
     * @var
     */
    private $minutes;

    /**
     * @var
     */
    private $start;

    /**
     * @var
     */
    private $end;

    /**
     * Minutes constructor.
     * @param $minutes
     */
    public function __construct($minutes) {
        $this->minutes = $minutes;

        if ($minutes instanceof Minutes) {
            $this->start = $minutes->getStart();

            $this->end = $minutes->getEnd();
        }
        else {
            $this->calculateStartEnd();
        }
    }

    /**
     * Calculate start and end dates
     */
    private function calculateStartEnd() {
        if ($this->minutes == 0) {
            $this->setToday();
        }
        else {
            $this->start = Carbon::now()->subMinutes($this->minutes);

            $this->end = Carbon::now();
        }
    }

    /**
     * @return mixed
     */
    public function getEnd() {
        return $this->end;
    }

    /**
     * @return mixed
     */
    public function getStart() {
        return $this->start;
    }

    /**
     * @param $minutes
     * @return static
     */
    public static function make($minutes) {
        return new static($minutes);
    }

    /**
     * @param mixed $end
     */
    public function setEnd($end) {
        $this->end = $end;
    }

    /**
     * @param mixed $start
     */
    public function setStart($start) {
        $this->start = $start;
    }

    /**
     * Today
     */
    private function setToday() {
        $this->start = Carbon::now()->setTime(0, 0, 0);

        $this->end = Carbon::now()->setTime(23, 59, 59);
    }
}

Add getter and setter for dates

Add getter and setter for dates


<?php

namespace Tienvx\Bundle\MbtBundle;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Tienvx\Bundle\MbtBundle\DependencyInjection\Compiler\AddGeneratorDirectoriesCompilerPass;

class TienvxMbtBundle extends Bundle
{
    public function build(ContainerBuilder $container)
    {
        $container->addCompilerPass(new AddGeneratorDirectoriesCompilerPass());

        // Read models configurations. Add these code in a compiler pass is too late.
        $paths = [];
        foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
            $path = $bundle['path'] . '/Resources/config/models';
            if (is_dir($path)) {
                $paths[] = $path;
            }
        }
        $path = $container->getParameter('kernel.root_dir') . '/config/models';
        if (is_dir($path)) {
            $paths[] = $path;
        }
        $loader = new YamlFileLoader($container, new FileLocator($paths));
        foreach (Finder::create()->followLinks()->files()->in($paths)->name('/\.(ya?ml)$/') as $file) {
            $loader->load($file->getRelativePathname());
        }
    }
}

<?php

namespace Tienvx\Bundle\MbtBundle;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Tienvx\Bundle\MbtBundle\DependencyInjection\Compiler\AddGeneratorDirectoriesCompilerPass;

class TienvxMbtBundle extends Bundle
{
    public function build(ContainerBuilder $container)
    {
        $container->addCompilerPass(new AddGeneratorDirectoriesCompilerPass());

        // Read models configurations. Add these code in a compiler pass is too late.
        $paths = [];
        foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
            $path = $bundle['path'] . '/Resources/config/models';
            if (is_dir($path)) {
                $paths[] = $path;
            }
        }
        $path = $container->getParameter('kernel.root_dir') . '/config/models';
        if (is_dir($path)) {
            $paths[] = $path;
        }
        if ($paths) {
            $loader = new YamlFileLoader($container, new FileLocator($paths));
            foreach (Finder::create()->followLinks()->files()->in($paths)->name('/\.(ya?ml)$/') as $file) {
                $loader->load($file->getRelativePathname());
            }
        }
    }
}

Fix 'You must call one of in() or append() methods before iterating over a Finder.'


<?php

namespace Laracasts\Matryoshka;

trait Cacheable
{
    /**
     * Calculate a unique cache key for the model instance.
     */
    public function getCacheKey()
    {
        return sprintf("%s/%s-%s",
            get_class($this),
            $this->id,
            $this->updated_at->timestamp
        );
    }
}

<?php

namespace Laracasts\Matryoshka;

trait Cacheable
{
    /**
     * Calculate a unique cache key for the model instance.
     */
    public function getCacheKey()
    {
        return sprintf("%s/%s-%s",
            get_class($this),
            $this->getKey(),
            $this->updated_at->timestamp
        );
    }
}

Use more safer getKey() method instead of assumption that key is named id


<?php

declare(strict_types=1);

namespace Scheb\Tombstone\Analyzer\Cli;

use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Output\OutputInterface;

class ConsoleOutput
{
    /**
     * @var OutputInterface
     */
    private $output;

    public function __construct(OutputInterface $output)
    {
        $this->output = $output;
    }

    public function write(string $string): void
    {
        $this->output->write($string);
    }

    public function writeln(?string $string = null): void
    {
        $this->output->writeln($string ?? '');
    }

    public function debug(string $string): void
    {
        if ($this->output->isDebug()) {
            $this->writeln($string);
        }
    }

    public function createProgressBar(int $width): ProgressBar
    {
        $progress = new ProgressBar($this->output, $width);
        $progress->setBarWidth(50);
        $progress->display();

        return $progress;
    }
}

<?php

declare(strict_types=1);

namespace Scheb\Tombstone\Analyzer\Cli;

use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Output\OutputInterface;

class ConsoleOutput
{
    /**
     * @var OutputInterface
     */
    private $output;

    public function __construct(OutputInterface $output)
    {
        $this->output = $output;
    }

    public function write(string $string): void
    {
        $this->output->write($string);
    }

    public function writeln(?string $string = null): void
    {
        $this->output->writeln($string ?? '');
    }

    public function debug(string $string): void
    {
        if ($this->output->isDebug()) {
            $this->writeln($string);
        }
    }

    public function createProgressBar(int $width): ProgressBar
    {
        $progress = new ProgressBar($this->output, $width);
        $progress->setBarWidth(50);
        $progress->display();

        return $progress;
    }

    public function error(string $message, ?\Throwable $exception = null): void
    {
        $this->output->writeln(sprintf('<error>%s</error>', $message));
        if (null !== $exception && $this->output->isDebug()) {
            $this->output->writeln(sprintf(
                '%s: %s at %s line %s',
                \get_class($exception),
                $exception->getMessage(),
                $exception->getFile(),
                $exception->getLine()
            ));
        }
    }
}

Add method to log errors to console

Add method to log errors to console


<?php namespace Orchestra\Notifier;

use Illuminate\Support\Arr;
use Illuminate\Support\Fluent;
use Orchestra\Contracts\Notification\Message as MessageContract;

class Message extends Fluent implements MessageContract
{
    /**
     * Create a new Message instance.
     *
     * @param  string|array $view
     * @param  array        $data
     * @param  string|null  $subject
     * @return static
     */
    public static function create($view, array $data = [], $subject = null)
    {
        return new static([
            'view'    => $view,
            'data'    => $data,
            'subject' => $subject,
        ]);
    }

    /**
     * Get data.
     *
     * @return array
     */
    public function getData()
    {
        return Arr::get($this->attributes, 'data', []);
    }

    /**
     * Get subject.
     *
     * @return string
     */
    public function getSubject()
    {
        return Arr::get($this->attributes, 'subject', '');
    }

    /**
     * Get view.
     *
     * @return string|array
     */
    public function getView()
    {
        return Arr::get($this->attributes, 'view', '');
    }
}

<?php namespace Orchestra\Notifier;

use Illuminate\Support\Arr;
use Illuminate\Support\Fluent;
use Orchestra\Contracts\Notification\Message as MessageContract;

class Message extends Fluent implements MessageContract
{
    /**
     * Create a new Message instance.
     *
     * @param  string|array $view
     * @param  array        $data
     * @param  string|null  $subject
     * @return static
     */
    public static function create($view, array $data = [], $subject = null)
    {
        return new static([
            'view'    => $view,
            'data'    => $data,
            'subject' => $subject,
        ]);
    }

    /**
     * Get data.
     *
     * @return array
     */
    public function getData()
    {
        return Arr::get($this->attributes, 'data', []);
    }

    /**
     * Get subject.
     *
     * @return string
     */
    public function getSubject()
    {
        return Arr::get($this->attributes, 'subject', '');
    }

    /**
     * Get view.
     *
     * @return string|array
     */
    public function getView()
    {
        return Arr::get($this->attributes, 'view');
    }
}

Return null if view is not available.

Return null if view is not available.

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


<?php

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

namespace Symfony\Component\Security\Core\Authorization\Voter;

use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Event\VoteEvent;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

/**
 * Decorates voter classes to send result events.
 *
 * @author Laurent VOULLEMIER <laurent.voullemier@gmail.com>
 *
 * @internal
 */
class TraceableVoter implements VoterInterface
{
    private $voter;
    private $eventDispatcher;

    public function __construct(VoterInterface $voter, EventDispatcherInterface $eventDispatcher)
    {
        $this->voter = $voter;
        $this->eventDispatcher = $eventDispatcher;
    }

    public function vote(TokenInterface $token, $subject, array $attributes)
    {
        $result = $this->voter->vote($token, $subject, $attributes);

        $this->eventDispatcher->dispatch(new VoteEvent($this->voter, $subject, $attributes, $result), 'debug.security.authorization.vote');

        return $result;
    }

    public function getDecoratedVoter(): VoterInterface
    {
        return $this->voter;
    }
}

<?php

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

namespace Symfony\Component\Security\Core\Authorization\Voter;

use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Event\VoteEvent;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

/**
 * Decorates voter classes to send result events.
 *
 * @author Laurent VOULLEMIER <laurent.voullemier@gmail.com>
 *
 * @internal
 */
class TraceableVoter implements VoterInterface
{
    private $voter;
    private $eventDispatcher;

    public function __construct(VoterInterface $voter, EventDispatcherInterface $eventDispatcher)
    {
        $this->voter = $voter;
        $this->eventDispatcher = $eventDispatcher;
    }

    public function vote(TokenInterface $token, $subject, array $attributes): int
    {
        $result = $this->voter->vote($token, $subject, $attributes);

        $this->eventDispatcher->dispatch(new VoteEvent($this->voter, $subject, $attributes, $result), 'debug.security.authorization.vote');

        return $result;
    }

    public function getDecoratedVoter(): VoterInterface
    {
        return $this->voter;
    }
}

Add some missing return types to internal/final classes


<?php
function send_email($to_email,$subject,$message1)
{
    require_once 'Mandrill.php';
$apikey = '%API_key%'; // use this to encrypt your api key
$mandrill = new Mandrill($apikey);

$message = new stdClass();
$message->html = $message1;
$message->text = $message1;
$message->subject = $subject;
<<<<<<< HEAD
$message*>from_email = "arc-tech@visualstudio.com"; // Add your sending address

=======
$message*>from_email = "arc-tech@visualstudio.com";
>>>>>>> hax
}
?>

<?php
function send_email($to_email,$subject,$message1)
{
    require_once 'Mandrill.php';
$apikey = '%API_key%'; // use this to encrypt your api key
$mandrill = new Mandrill($apikey);

$message = new stdClass();
$message->html = $message1;
$message->text = $message1;
$message->subject = $subject;
<<<
$message*>from_email = "arc-tech@visualstudio.com"; // Add your sending address

>>> $cc =>hax
}
?>

Add local variable extensions to file

Add local variable extensions to file


<?php
namespace Vsmoraes\DynamoMapper;

use Vsmoraes\DynamoMapper\Exception\AnnotationNotFound;
use Vsmoraes\DynamoMapper\Exception\InvalidAttributeType;
use ICanBoogie\Inflector;

class Annotations
{
    const AVAILABLE_TYPES = ['int', 'string', 'array', 'bool', '\datetimeinterface'];

    /**
     * @var \ReflectionClass
     */
    private $reflectionClass;

    public function __construct(\ReflectionClass $reflectionClass)
    {
        $this->reflectionClass = $reflectionClass;
    }

    /**
     * @param string $attribute
     * @return string
     * @throws AnnotationNotFound
     * @throws InvalidAttributeType
     */
    public function getAttributeType(string $attribute): string
    {
        $attribute = Inflector::get()->camelize($attribute, Inflector::DOWNCASE_FIRST_LETTER);
        $docblock = $this->reflectionClass->getProperty($attribute)
            ->getDocComment();

        $annotations = [];
        preg_match_all('/@var\s*([^\s]+)/i', $docblock, $annotations, PREG_SET_ORDER);

        if (empty($annotations) || ! isset($annotations[0][1])) {
            throw new AnnotationNotFound;
        }

        $type = strtolower($annotations[0][1]);

        if (! in_array($type, self::AVAILABLE_TYPES)) {
            throw new InvalidAttributeType;
        }

        return $type;
    }
}

<?php
namespace Vsmoraes\DynamoMapper;

use Vsmoraes\DynamoMapper\Exception\AnnotationNotFound;
use Vsmoraes\DynamoMapper\Exception\InvalidAttributeType;
use ICanBoogie\Inflector;

class Annotations
{
    /**
     * @var \ReflectionClass
     */
    private $reflectionClass;

    public function __construct(\ReflectionClass $reflectionClass)
    {
        $this->reflectionClass = $reflectionClass;
    }

    /**
     * @param string $attribute
     * @return string
     * @throws AnnotationNotFound
     * @throws InvalidAttributeType
     */
    public function getAttributeType(string $attribute): string
    {
        $attribute = Inflector::get()->camelize($attribute, Inflector::DOWNCASE_FIRST_LETTER);
        $docblock = $this->reflectionClass->getProperty($attribute)
            ->getDocComment();

        $annotations = [];
        preg_match_all('/@var\s*([^\s]+)/i', $docblock, $annotations, PREG_SET_ORDER);

        if (empty($annotations) || ! isset($annotations[0][1])) {
            throw new AnnotationNotFound;
        }

        $type = strtolower($annotations[0][1]);

        return $type;
    }
}

Remove unnecessary constant and validation


<?php
namespace Concrete\Core\Foundation\Service;
use \Concrete\Core\Application\Application;

class ProviderList {

	public function __construct(Application $app) {
		$this->app = $app;
	}

	/**
	 * Loads and registers a class ServiceProvider class.
	 * @param  string $class
	 * @return void
	 */
	public function registerProvider($class) {
		$this->createInstance($class)->register();
	}

	/**
	 * Class for creating an instance of a passed class string, override this to add extra functionality
	 *
	 * @param string $class The class name
	 * @return \Concrete\Core\Foundation\Service\Provider
	 */
	protected function createInstance($class)
	{
		return new $class($this->app);
	}

	/**
	 * Registers an array of service group classes.
	 * @param  array $groups
	 * @return void
	 */
	public function registerProviders($groups) {
		foreach($groups as $group) {
			$this->registerProvider($group);
		}
	}

	/**
	 * We are not allowed to serialize $this->app
	 */
	public function __sleep() {
		unset($this->app);
	}

}

<?php
namespace Concrete\Core\Foundation\Service;
use \Concrete\Core\Application\Application;

class ProviderList {

	public function __construct(Application $app) {
		$this->app = $app;
	}

	/**
	 * Loads and registers a class ServiceProvider class.
	 * @param  string $class
	 * @return void
	 */
	public function registerProvider($class) {
		$this->createInstance($class)->register();
	}

	/**
	 * Creates an instance of the passed class string, override this to change how providers are instantiated
	 *
	 * @param string $class The class name
	 * @return \Concrete\Core\Foundation\Service\Provider
	 */
	protected function createInstance($class)
	{
		return new $class($this->app);
	}

	/**
	 * Registers an array of service group classes.
	 * @param  array $groups
	 * @return void
	 */
	public function registerProviders($groups) {
		foreach($groups as $group) {
			$this->registerProvider($group);
		}
	}

	/**
	 * We are not allowed to serialize $this->app
	 */
	public function __sleep() {
		unset($this->app);
	}

}

Docs: Update createInstance documentation to be more clear