Laravel version update

Laravel version update
This commit is contained in:
Manish Verma
2018-08-06 18:48:58 +05:30
parent d143048413
commit 126fbb0255
13678 changed files with 1031482 additions and 778530 deletions

View File

@@ -20,7 +20,7 @@ class BinaryNoFuncOverload
{
public static function strlen($s)
{
return strlen($s);
return \strlen($s);
}
public static function strpos($haystack, $needle, $offset = 0)

View File

@@ -1,4 +1,4 @@
Copyright (c) 2014-2016 Fabien Potencier
Copyright (c) 2015-2018 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -0,0 +1,84 @@
<?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\Polyfill\Util;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
class LegacyTestListener extends \PHPUnit_Framework_TestSuite implements \PHPUnit_Framework_TestListener
{
private $suite;
private $trait;
public function __construct(\PHPUnit_Framework_TestSuite $suite = null)
{
if ($suite) {
$this->suite = $suite;
$this->setName($suite->getName().' with polyfills enabled');
$this->addTest($suite);
}
$this->trait = new TestListenerTrait();
}
public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
{
$this->trait->startTestSuite($suite);
}
protected function setUp()
{
TestListenerTrait::$enabledPolyfills = $this->suite->getName();
}
protected function tearDown()
{
TestListenerTrait::$enabledPolyfills = false;
}
public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
$this->trait->addError($test, $e, $time);
}
public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time)
{
}
public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time)
{
$this->trait->addError($test, $e, $time);
}
public function addIncompleteTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
}
public function addRiskyTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
}
public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
}
public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
{
}
public function startTest(\PHPUnit_Framework_Test $test)
{
}
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
}
}

View File

@@ -11,144 +11,86 @@
namespace Symfony\Polyfill\Util;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
class TestListener extends \PHPUnit_Framework_TestSuite implements \PHPUnit_Framework_TestListener
{
public static $enabledPolyfills;
private $suite;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\TestListener as TestListenerInterface;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Framework\Warning;
public function __construct(\PHPUnit_Framework_TestSuite $suite = null)
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
class_alias('Symfony\Polyfill\Util\LegacyTestListener', 'Symfony\Polyfill\Util\TestListener');
// Using an early return instead of a else does not work when using the PHPUnit phar due to some weird PHP behavior (the class
// gets defined without executing the code before it and so the definition is not properly conditional)
} else {
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
class TestListener extends TestSuite implements TestListenerInterface
{
if ($suite) {
$this->suite = $suite;
$this->setName($suite->getName().' with polyfills enabled');
$this->addTest($suite);
}
}
private $suite;
private $trait;
public function startTestSuite(\PHPUnit_Framework_TestSuite $mainSuite)
{
if (null !== self::$enabledPolyfills) {
return;
}
self::$enabledPolyfills = false;
foreach ($mainSuite->tests() as $suite) {
$testClass = $suite->getName();
if (!$tests = $suite->tests()) {
continue;
}
if (!preg_match('/^(.+)\\\\Tests(\\\\.*)Test$/', $testClass, $m)) {
$mainSuite->addTest(self::warning('Unknown naming convention for '.$testClass));
continue;
}
if (!class_exists($m[1].$m[2])) {
continue;
}
$testedClass = new \ReflectionClass($m[1].$m[2]);
$bootstrap = new \SplFileObject(dirname($testedClass->getFileName()).'/bootstrap.php');
$warnings = array();
$defLine = null;
foreach (new \RegexIterator($bootstrap, '/return p\\\\'.$testedClass->getShortName().'::/') as $defLine) {
if (!preg_match('/^\s*function (?P<name>[^\(]++)(?P<signature>\([^\)]*+\)) \{ (?<return>return p\\\\'.$testedClass->getShortName().'::[^\(]++)(?P<args>\([^\)]*+\)); \}$/', $defLine, $f)) {
$warnings[] = self::warning('Invalid line in bootstrap.php: '.trim($defLine));
continue;
}
$testNamespace = substr($testClass, 0, strrpos($testClass, '\\'));
if (function_exists($testNamespace.'\\'.$f['name'])) {
continue;
}
try {
$r = new \ReflectionFunction($f['name']);
if ($r->isUserDefined()) {
throw new \ReflectionException();
}
if (false !== strpos($f['signature'], '&')) {
$defLine = sprintf('return \\%s%s', $f['name'], $f['args']);
} else {
$defLine = sprintf("return \\call_user_func_array('%s', func_get_args())", $f['name']);
}
} catch (\ReflectionException $e) {
$defLine = sprintf("throw new \PHPUnit_Framework_SkippedTestError('Internal function not found: %s')", $f['name']);
}
eval(<<<EOPHP
namespace {$testNamespace};
use Symfony\Polyfill\Util\TestListener;
use {$testedClass->getNamespaceName()} as p;
function {$f['name']}{$f['signature']}
{
if ('{$testClass}' === TestListener::\$enabledPolyfills) {
{$f['return']}{$f['args']};
}
{$defLine};
}
EOPHP
);
}
if (!$warnings && null === $defLine) {
$warnings[] = new \PHPUnit_Framework_SkippedTestCase('No Polyfills found in bootstrap.php for '.$testClass);
} else {
$mainSuite->addTest(new static($suite));
public function __construct(TestSuite $suite = null)
{
if ($suite) {
$this->suite = $suite;
$this->setName($suite->getName().' with polyfills enabled');
$this->addTest($suite);
}
$this->trait = new TestListenerTrait();
}
foreach ($warnings as $w) {
$mainSuite->addTest($w);
public function startTestSuite(TestSuite $suite)
{
$this->trait->startTestSuite($suite);
}
}
protected function setUp()
{
self::$enabledPolyfills = $this->suite->getName();
}
protected function tearDown()
{
self::$enabledPolyfills = false;
}
public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
if (false !== self::$enabledPolyfills) {
$r = new \ReflectionProperty('Exception', 'message');
$r->setAccessible(true);
$r->setValue($e, 'Polyfills enabled, '.$r->getValue($e));
protected function setUp()
{
TestListenerTrait::$enabledPolyfills = $this->suite->getName();
}
}
public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time)
{
$this->addError($test, $e, $time);
}
protected function tearDown()
{
TestListenerTrait::$enabledPolyfills = false;
}
public function addIncompleteTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
}
public function addError(Test $test, \Exception $e, $time)
{
$this->trait->addError($test, $e, $time);
}
public function addRiskyTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
}
public function addWarning(Test $test, Warning $e, $time)
{
}
public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
}
public function addFailure(Test $test, AssertionFailedError $e, $time)
{
$this->trait->addError($test, $e, $time);
}
public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
{
}
public function addIncompleteTest(Test $test, \Exception $e, $time)
{
}
public function startTest(\PHPUnit_Framework_Test $test)
{
}
public function addRiskyTest(Test $test, \Exception $e, $time)
{
}
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
public function addSkippedTest(Test $test, \Exception $e, $time)
{
}
public function endTestSuite(TestSuite $suite)
{
}
public function startTest(Test $test)
{
}
public function endTest(Test $test, $time)
{
}
}
}

View File

@@ -0,0 +1,107 @@
<?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\Polyfill\Util;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
class TestListenerTrait
{
public static $enabledPolyfills;
public function startTestSuite($mainSuite)
{
if (null !== self::$enabledPolyfills) {
return;
}
self::$enabledPolyfills = false;
$SkippedTestError = class_exists('PHPUnit\Framework\SkippedTestError') ? 'PHPUnit\Framework\SkippedTestError' : 'PHPUnit_Framework_SkippedTestError';
$TestListener = class_exists('Symfony\Polyfill\Util\TestListener', false) ? 'Symfony\Polyfill\Util\TestListener' : 'Symfony\Polyfill\Util\LegacyTestListener';
foreach ($mainSuite->tests() as $suite) {
$testClass = $suite->getName();
if (!$tests = $suite->tests()) {
continue;
}
if (!preg_match('/^(.+)\\\\Tests(\\\\.*)Test$/', $testClass, $m)) {
$mainSuite->addTest($TestListener::warning('Unknown naming convention for '.$testClass));
continue;
}
if (!class_exists($m[1].$m[2])) {
continue;
}
$testedClass = new \ReflectionClass($m[1].$m[2]);
$bootstrap = new \SplFileObject(dirname($testedClass->getFileName()).'/bootstrap.php');
$warnings = array();
$defLine = null;
foreach (new \RegexIterator($bootstrap, '/return p\\\\'.$testedClass->getShortName().'::/') as $defLine) {
if (!preg_match('/^\s*function (?P<name>[^\(]++)(?P<signature>\([^\)]*+\)) \{ (?<return>return p\\\\'.$testedClass->getShortName().'::[^\(]++)(?P<args>\([^\)]*+\)); \}$/', $defLine, $f)) {
$warnings[] = $TestListener::warning('Invalid line in bootstrap.php: '.trim($defLine));
continue;
}
$testNamespace = substr($testClass, 0, strrpos($testClass, '\\'));
if (function_exists($testNamespace.'\\'.$f['name'])) {
continue;
}
try {
$r = new \ReflectionFunction($f['name']);
if ($r->isUserDefined()) {
throw new \ReflectionException();
}
if (false !== strpos($f['signature'], '&')) {
$defLine = sprintf('return \\%s%s', $f['name'], $f['args']);
} else {
$defLine = sprintf("return \\call_user_func_array('%s', func_get_args())", $f['name']);
}
} catch (\ReflectionException $e) {
$defLine = sprintf("throw new \\{$SkippedTestError}('Internal function not found: %s')", $f['name']);
}
eval(<<<EOPHP
namespace {$testNamespace};
use Symfony\Polyfill\Util\TestListenerTrait;
use {$testedClass->getNamespaceName()} as p;
function {$f['name']}{$f['signature']}
{
if ('{$testClass}' === TestListenerTrait::\$enabledPolyfills) {
{$f['return']}{$f['args']};
}
{$defLine};
}
EOPHP
);
}
if (!$warnings && null === $defLine) {
$warnings[] = new $SkippedTestError('No Polyfills found in bootstrap.php for '.$testClass);
} else {
$mainSuite->addTest(new $TestListener($suite));
}
}
foreach ($warnings as $w) {
$mainSuite->addTest($w);
}
}
public function addError($test, \Exception $e, $time)
{
if (false !== self::$enabledPolyfills) {
$r = new \ReflectionProperty('Exception', 'message');
$r->setAccessible(true);
$r->setValue($e, 'Polyfills enabled, '.$r->getValue($e));
}
}
}

View File

@@ -24,7 +24,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-master": "1.2-dev"
"dev-master": "1.8-dev"
}
}
}