Skip to content

Commit

Permalink
minor #33000 Fix deprecations on 4.3 (jderusse)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.3 branch.

Discussion
----------

Fix deprecations on 4.3

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #32844
| License       | MIT
| Doc PR        | NA

Fix deprecations in branch 4.3
note: remaining deprecation `assertStringContainsString` will be fixed in #32977

* [ ] fix tests in branch 3.4 in #32981

Commits
-------

8fd16a6 Fix deprecation on 4.3
  • Loading branch information
nicolas-grekas committed Aug 8, 2019
2 parents 3ae9910 + 8fd16a6 commit f773217
Show file tree
Hide file tree
Showing 23 changed files with 278 additions and 176 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -29,6 +29,9 @@ matrix:
env: deps=high
- php: 7.3
env: deps=low
- php: 7.4snapshot
allow_failures:
- php: 7.4snapshot
fast_finish: true

cache:
Expand Down
@@ -1,21 +1,21 @@
<?php

class SunnyInterface_1eff735 implements \ProxyManager\Proxy\VirtualProxyInterface, \Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\DummyInterface, \Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\SunnyInterface
class SunnyInterface_%s implements \ProxyManager\Proxy\VirtualProxyInterface, \Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\DummyInterface, \Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\SunnyInterface
{

private $valueHolder1eff735 = null;
private $valueHolder%s = null;

private $initializer1eff735 = null;
private $initializer%s = null;

private static $publicProperties1eff735 = [
private static $publicProperties%s = [
%S
];

public function dummy()
{
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, 'dummy', array(), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'dummy', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;

if ($this->valueHolder1eff735 === $returnValue = $this->valueHolder1eff735->dummy()) {
if ($this->valueHolder%s === $returnValue = $this->valueHolder%s->dummy()) {
$returnValue = $this;
}

Expand All @@ -24,9 +24,9 @@ public function dummy()

public function & dummyRef()
{
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, 'dummyRef', array(), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'dummyRef', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;

if ($this->valueHolder1eff735 === $returnValue = &$this->valueHolder1eff735->dummyRef()) {
if ($this->valueHolder%s === $returnValue = &$this->valueHolder%s->dummyRef()) {
$returnValue = $this;
}

Expand All @@ -35,9 +35,9 @@ public function & dummyRef()

public function sunny()
{
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, 'sunny', array(), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'sunny', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;

if ($this->valueHolder1eff735 === $returnValue = $this->valueHolder1eff735->sunny()) {
if ($this->valueHolder%s === $returnValue = $this->valueHolder%s->sunny()) {
$returnValue = $this;
}

Expand All @@ -49,9 +49,9 @@ public static function staticProxyConstructor($initializer)
static $reflection;

$reflection = $reflection ?? new \ReflectionClass(__CLASS__);
$instance = $reflection->newInstanceWithoutConstructor();
$instance%w= $reflection->newInstanceWithoutConstructor();

$instance->initializer1eff735 = $initializer;
$instance->initializer%s = $initializer;

return $instance;
}
Expand All @@ -60,21 +60,21 @@ public function __construct()
{
static $reflection;

if (! $this->valueHolder1eff735) {
if (! $this->valueHolder%s) {
$reflection = $reflection ?? new \ReflectionClass(__CLASS__);
$this->valueHolder1eff735 = $reflection->newInstanceWithoutConstructor();
$this->valueHolder%s = $reflection->newInstanceWithoutConstructor();
}
}

public function & __get($name)
{
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, '__get', ['name' => $name], $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__get', ['name' => $name], $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;

if (isset(self::$publicProperties1eff735[$name])) {
return $this->valueHolder1eff735->$name;
if (isset(self::$publicProperties%s[$name])) {
return $this->valueHolder%s->$name;
}

$targetObject = $this->valueHolder1eff735;
$targetObject = $this->valueHolder%s;

$backtrace = debug_backtrace(false);
trigger_error(
Expand All @@ -92,73 +92,73 @@ public function & __get($name)

public function __set($name, $value)
{
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, '__set', array('name' => $name, 'value' => $value), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__set', array('name' => $name, 'value' => $value), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;

$targetObject = $this->valueHolder1eff735;
$targetObject = $this->valueHolder%s;

return $targetObject->$name = $value;
}

public function __isset($name)
{
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, '__isset', array('name' => $name), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__isset', array('name' => $name), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;

$targetObject = $this->valueHolder1eff735;
$targetObject = $this->valueHolder%s;

return isset($targetObject->$name);
}

public function __unset($name)
{
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, '__unset', array('name' => $name), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__unset', array('name' => $name), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;

$targetObject = $this->valueHolder1eff735;
$targetObject = $this->valueHolder%s;

unset($targetObject->$name);
return;
}

public function __clone()
{
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, '__clone', array(), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__clone', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;

$this->valueHolder1eff735 = clone $this->valueHolder1eff735;
$this->valueHolder%s = clone $this->valueHolder%s;
}

public function __sleep()
{
$this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, '__sleep', array(), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
$this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__sleep', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;

return array('valueHolder1eff735');
return array('valueHolder%s');
}

public function __wakeup()
{
}

public function setProxyInitializer(\Closure $initializer = null)
public function setProxyInitializer(\Closure $initializer = null)%S
{
$this->initializer1eff735 = $initializer;
$this->initializer%s = $initializer;
}

public function getProxyInitializer()
public function getProxyInitializer()%S
{
return $this->initializer1eff735;
return $this->initializer%s;
}

public function initializeProxy() : bool
{
return $this->initializer1eff735 && ($this->initializer1eff735->__invoke($valueHolder1eff735, $this, 'initializeProxy', array(), $this->initializer1eff735) || 1) && $this->valueHolder1eff735 = $valueHolder1eff735;
return $this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'initializeProxy', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
}

public function isProxyInitialized() : bool
{
return null !== $this->valueHolder1eff735;
return null !== $this->valueHolder%s;
}

public function getWrappedValueHolderValue()
public function getWrappedValueHolderValue()%S
{
return $this->valueHolder1eff735;
return $this->valueHolder%s;
}


Expand Down
Expand Up @@ -168,12 +168,12 @@ protected function createProxy(\$class, \Closure \$factory)
EOPHP;

$implem = preg_replace('#\n /\*\*.*?\*/#s', '', $implem);
$implem = str_replace('getWrappedValueHolderValue() : ?object', 'getWrappedValueHolderValue()', $implem);
$implem = str_replace("array(\n \n );", "[\n \n ];", $implem);
$this->assertStringEqualsFile(__DIR__.'/Fixtures/proxy-implem.php', $implem);

$this->assertStringMatchesFormatFile(__DIR__.'/Fixtures/proxy-implem.php', $implem);
$this->assertStringEqualsFile(__DIR__.'/Fixtures/proxy-factory.php', $factory);

require_once __DIR__.'/Fixtures/proxy-implem.php';
eval(preg_replace('/^<\?php/', '', $implem));
$factory = require __DIR__.'/Fixtures/proxy-factory.php';

$foo = $factory->getFooService();
Expand Down
Expand Up @@ -57,8 +57,8 @@ public function testPrivateAlias()

$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:container', '--show-hidden' => true]);
$this->assertNotContains('public', $tester->getDisplay());
$this->assertNotContains('private_alias', $tester->getDisplay());
$this->assertStringNotContainsString('public', $tester->getDisplay());
$this->assertStringNotContainsString('private_alias', $tester->getDisplay());

$tester->run(['command' => 'debug:container']);
$this->assertStringContainsString('public', $tester->getDisplay());
Expand All @@ -77,7 +77,7 @@ public function testIgnoreBackslashWhenFindingService(string $validServiceId)

$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:container', 'name' => $validServiceId]);
$this->assertNotContains('No services found', $tester->getDisplay());
$this->assertStringNotContainsString('No services found', $tester->getDisplay());
}

public function testDescribeEnvVars()
Expand Down
Expand Up @@ -227,7 +227,7 @@ public function testEncodePasswordSodiumOutput()
'user-class' => 'Custom\Class\Sodium\User',
], ['interactive' => false]);

$this->assertNotContains(' Generated salt ', $this->passwordEncoderCommandTester->getDisplay());
$this->assertStringNotContainsString(' Generated salt ', $this->passwordEncoderCommandTester->getDisplay());
}

public function testEncodePasswordNoConfigForGivenUserClass()
Expand Down
12 changes: 11 additions & 1 deletion src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php
Expand Up @@ -13,6 +13,7 @@

use Cache\IntegrationTests\CachePoolTest;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\Warning;
use Psr\Cache\CacheItemInterface;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\CacheItem;
Expand Down Expand Up @@ -120,7 +121,7 @@ public function testGetMetadata()
CacheItem::METADATA_EXPIRY => 9.5 + time(),
CacheItem::METADATA_CTIME => 1000,
];
$this->assertEquals($expected, $item->getMetadata(), 'Item metadata should embed expiry and ctime.', .6);
$this->assertEqualsWithDelta($expected, $item->getMetadata(), .6, 'Item metadata should embed expiry and ctime.');
}

public function testDefaultLifeTime()
Expand Down Expand Up @@ -252,6 +253,15 @@ public function testPrune()
$this->assertFalse($this->isPruned($cache, 'foo'));
$this->assertTrue($this->isPruned($cache, 'qux'));
}

public function testSavingObject()
{
if (\PHP_VERSION_ID >= 70400) {
throw new Warning('PHP 7.4 breaks this test, see https://bugs.php.net/78351.');
}

parent::testSavingObject();
}
}

class NotUnserializable
Expand Down
Expand Up @@ -14,26 +14,25 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition;

class NodeDefinitionTest extends TestCase
{
public function testDefaultPathSeparatorIsDot()
{
$node = $this->getMockForAbstractClass(NodeDefinition::class, ['foo']);

$this->assertAttributeSame('.', 'pathSeparator', $node);
}

public function testSetPathSeparatorChangesChildren()
{
$node = new ArrayNodeDefinition('foo');
$scalar = new ScalarNodeDefinition('bar');
$node->append($scalar);

$node->setPathSeparator('/');

$this->assertAttributeSame('/', 'pathSeparator', $node);
$this->assertAttributeSame('/', 'pathSeparator', $scalar);
$parentNode = new ArrayNodeDefinition('name');
$childNode = $this->createMock(NodeDefinition::class);

$childNode
->expects($this->once())
->method('setPathSeparator')
->with('/');
$childNode
->expects($this->once())
->method('setParent')
->with($parentNode)
->willReturn($childNode);
$parentNode->append($childNode);

$parentNode->setPathSeparator('/');
}
}

0 comments on commit f773217

Please sign in to comment.