Updated Rector to commit 52ef7b830be95c27141d893308d7fa27ff4a2290

52ef7b830b [Scoped] Remove unused vendor/symfony/service-contracts/Test on downgrade build (#5252)
This commit is contained in:
Tomas Votruba 2023-11-16 03:14:11 +00:00
parent 4f6134d1be
commit 0f9778fc13
8 changed files with 18 additions and 117 deletions

View File

@ -120,8 +120,13 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo
return null;
}
$namespaces = \array_filter($file->getNewStmts(), static function (Stmt $stmt) : bool {
return $stmt instanceof Namespace_;
return $stmt instanceof Namespace_ || $stmt instanceof FileWithoutNamespace;
});
// handle overlapped resolve last new stmts
// @see https://github.com/rectorphp/rector-src/pull/5251
if ($namespaces === []) {
return null;
}
if (\count($namespaces) > 1) {
return null;
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '5647e1b818482552a447d7f79392c7e2f0dce86e';
public const PACKAGE_VERSION = '52ef7b830be95c27141d893308d7fa27ff4a2290';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-11-15 07:38:05';
public const RELEASE_DATE = '2023-11-16 03:11:58';
/**
* @var int
*/

View File

@ -2396,17 +2396,17 @@
},
{
"name": "symfony\/service-contracts",
"version": "v3.3.0",
"version_normalized": "3.3.0.0",
"version": "v3.4.0",
"version_normalized": "3.4.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/service-contracts.git",
"reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4"
"reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/service-contracts\/zipball\/40da9cc13ec349d9e4966ce18b5fbcd724ab10a4",
"reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4",
"url": "https:\/\/api.github.com\/repos\/symfony\/service-contracts\/zipball\/b3313c2dbffaf71c8de2934e2ea56ed2291a3838",
"reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838",
"shasum": ""
},
"require": {
@ -2416,7 +2416,7 @@
"conflict": {
"ext-psr": "<1.1|>=2"
},
"time": "2023-05-23T14:45:45+00:00",
"time": "2023-07-30T20:28:31+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -2461,7 +2461,7 @@
"standards"
],
"support": {
"source": "https:\/\/github.com\/symfony\/service-contracts\/tree\/v3.3.0"
"source": "https:\/\/github.com\/symfony\/service-contracts\/tree\/v3.4.0"
},
"funding": [
{

File diff suppressed because one or more lines are too long

View File

@ -36,7 +36,7 @@ trait ServiceLocatorTrait
*/
private $providedTypes;
/**
* @param callable[] $factories
* @param array<string, callable> $factories
*/
public function __construct(array $factories)
{

View File

@ -35,7 +35,7 @@ interface ServiceProviderInterface extends ContainerInterface
* * ['foo' => '?'] means the container provides service name "foo" of unspecified type
* * ['bar' => '?Bar\Baz'] means the container provides a service "bar" of type Bar\Baz|null
*
* @return string[] The provided service types, keyed by service names
* @return array<string, string> The provided service types, keyed by service names
*/
public function getProvidedServices() : array;
}

View File

@ -1,21 +0,0 @@
<?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 RectorPrefix202311\Symfony\Contracts\Service\Test;
\class_alias(ServiceLocatorTestCase::class, ServiceLocatorTest::class);
if (\false) {
/**
* @deprecated since PHPUnit 9.6
*/
class ServiceLocatorTest
{
}
}

View File

@ -1,83 +0,0 @@
<?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 RectorPrefix202311\Symfony\Contracts\Service\Test;
use PHPUnit\Framework\TestCase;
use RectorPrefix202311\Psr\Container\ContainerInterface;
use RectorPrefix202311\Symfony\Contracts\Service\ServiceLocatorTrait;
abstract class ServiceLocatorTestCase extends TestCase
{
protected function getServiceLocator(array $factories) : ContainerInterface
{
return new class($factories) implements ContainerInterface
{
use ServiceLocatorTrait;
};
}
public function testHas()
{
$locator = $this->getServiceLocator(['foo' => function () {
return 'bar';
}, 'bar' => function () {
return 'baz';
}, function () {
return 'dummy';
}]);
$this->assertTrue($locator->has('foo'));
$this->assertTrue($locator->has('bar'));
$this->assertFalse($locator->has('dummy'));
}
public function testGet()
{
$locator = $this->getServiceLocator(['foo' => function () {
return 'bar';
}, 'bar' => function () {
return 'baz';
}]);
$this->assertSame('bar', $locator->get('foo'));
$this->assertSame('baz', $locator->get('bar'));
}
public function testGetDoesNotMemoize()
{
$i = 0;
$locator = $this->getServiceLocator(['foo' => function () use(&$i) {
++$i;
return 'bar';
}]);
$this->assertSame('bar', $locator->get('foo'));
$this->assertSame('bar', $locator->get('foo'));
$this->assertSame(2, $i);
}
public function testThrowsOnUndefinedInternalService()
{
if (!$this->getExpectedException()) {
$this->expectException(\RectorPrefix202311\Psr\Container\NotFoundExceptionInterface::class);
$this->expectExceptionMessage('The service "foo" has a dependency on a non-existent service "bar". This locator only knows about the "foo" service.');
}
$locator = $this->getServiceLocator(['foo' => function () use(&$locator) {
return $locator->get('bar');
}]);
$locator->get('foo');
}
public function testThrowsOnCircularReference()
{
$this->expectException(\RectorPrefix202311\Psr\Container\ContainerExceptionInterface::class);
$this->expectExceptionMessage('Circular reference detected for service "bar", path: "bar -> baz -> bar".');
$locator = $this->getServiceLocator(['foo' => function () use(&$locator) {
return $locator->get('bar');
}, 'bar' => function () use(&$locator) {
return $locator->get('baz');
}, 'baz' => function () use(&$locator) {
return $locator->get('bar');
}]);
$locator->get('foo');
}
}