Skip to content

Commit ae17c4b

Browse files
Various minor cleanups
1 parent 7452942 commit ae17c4b

File tree

11 files changed

+27
-27
lines changed

11 files changed

+27
-27
lines changed

src/ProxyManager/Factory/AbstractBaseFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ abstract class AbstractBaseFactory
3535

3636
public function __construct(?Configuration $configuration = null)
3737
{
38-
$this->configuration = $configuration ?: new Configuration();
38+
$this->configuration = $configuration ?? new Configuration();
3939
}
4040

4141
/**

src/ProxyManager/Generator/Util/IdentifierSuffixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static function getIdentifier(string $name): string
3636
/** @var string|null $salt */
3737
static $salt;
3838

39-
$salt ??= $salt = self::loadBaseHashSalt();
39+
$salt ??= self::loadBaseHashSalt();
4040
$suffix = substr(sha1($name . $salt), 0, 5);
4141

4242
if (! preg_match(self::VALID_IDENTIFIER_FORMAT, $name)) {

src/ProxyManager/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private function propertiesInitializationCode(Properties $properties): string
9696
foreach ($properties->getGroupedPrivateProperties() as $className => $privateProperties) {
9797
$cacheKey = 'cache' . str_replace('\\', '_', $className);
9898
$assignments[] = 'static $' . $cacheKey . ";\n\n"
99-
. '$' . $cacheKey . ' ?: $' . $cacheKey . " = \\Closure::bind(static function (\$instance) {\n"
99+
. '$' . $cacheKey . ' ?? $' . $cacheKey . " = \\Closure::bind(static function (\$instance) {\n"
100100
. $this->getPropertyDefaultsAssignments($privateProperties) . "\n"
101101
. '}, null, ' . var_export($className, true) . ");\n\n"
102102
. '$' . $cacheKey . "(\$this);\n\n";
@@ -139,7 +139,7 @@ private function propertiesReferenceArrayCode(Properties $properties): string
139139
$cacheKey = 'cacheFetch' . str_replace('\\', '_', $className);
140140

141141
$code .= 'static $' . $cacheKey . ";\n\n"
142-
. '$' . $cacheKey . ' ?: $' . $cacheKey
142+
. '$' . $cacheKey . ' ?? $' . $cacheKey
143143
. " = \\Closure::bind(function (\$instance, array & \$properties) {\n"
144144
. $this->generatePrivatePropertiesAssignmentsCode($classPrivateProperties)
145145
. '}, $this, ' . var_export($className, true) . ");\n\n"

src/ProxyManager/ProxyGenerator/Util/PublicScopeSimulator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private static function getUndefinedPropertyNotice(string $operationType, string
7979
return '';
8080
}
8181

82-
return ' $backtrace = debug_backtrace(false);' . "\n"
82+
return ' $backtrace = debug_backtrace(false, 1);' . "\n"
8383
. ' trigger_error(' . "\n"
8484
. ' sprintf(' . "\n"
8585
. ' \'Undefined property: %s::$%s in %s on line %s\',' . "\n"
@@ -147,7 +147,7 @@ private static function getOperation(string $operationType, string $nameParamete
147147
*/
148148
private static function getScopeReBind(): string
149149
{
150-
return '$backtrace = debug_backtrace(true);' . "\n"
150+
return '$backtrace = debug_backtrace(true, 2);' . "\n"
151151
. '$scopeObject = isset($backtrace[1][\'object\'])'
152152
. ' ? $backtrace[1][\'object\'] : new \ProxyManager\Stub\EmptyClassStub();' . "\n"
153153
. '$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));' . "\n";

src/ProxyManager/ProxyGenerator/ValueHolder/MethodGenerator/Constructor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function generateMethod(ReflectionClass $originalClass, PropertyGe
4040
$constructor->setBody(
4141
'static $reflection;' . "\n\n"
4242
. 'if (! $this->' . $valueHolder->getName() . ') {' . "\n"
43-
. ' $reflection = $reflection ?: new \ReflectionClass('
43+
. ' $reflection = $reflection ?? new \ReflectionClass('
4444
. var_export($originalClass->getName(), true)
4545
. ");\n"
4646
. ' $this->' . $valueHolder->getName() . ' = $reflection->newInstanceWithoutConstructor();' . "\n"

tests/ProxyManagerTest/Functional/AccessInterceptorValueHolderFunctionalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public function testPropertyUnset(
273273
AccessInterceptorValueHolderInterface $proxy,
274274
string $publicProperty
275275
): void {
276-
$instance = $proxy->getWrappedValueHolderValue() ?: $instance;
276+
$instance = $proxy->getWrappedValueHolderValue() ?? $instance;
277277
unset($proxy->$publicProperty);
278278

279279
self::assertFalse(isset($instance->$publicProperty));

tests/ProxyManagerTest/Functional/LazyLoadingValueHolderFunctionalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public function testPropertyAbsence(object $instance, VirtualProxyInterface $pro
203203
self::markTestSkipped('Non-nullable typed properties cannot be removed/unset');
204204
}
205205

206-
$instance = $proxy->getWrappedValueHolderValue() ?: $instance;
206+
$instance = $proxy->getWrappedValueHolderValue() ?? $instance;
207207
$instance->$publicProperty = null;
208208
self::assertFalse(isset($proxy->$publicProperty));
209209
self::assertTrue($proxy->isProxyInitialized());
@@ -214,7 +214,7 @@ public function testPropertyAbsence(object $instance, VirtualProxyInterface $pro
214214
*/
215215
public function testPropertyUnset(object $instance, VirtualProxyInterface $proxy, string $publicProperty): void
216216
{
217-
$instance = $proxy->getWrappedValueHolderValue() ?: $instance;
217+
$instance = $proxy->getWrappedValueHolderValue() ?? $instance;
218218
unset($proxy->$publicProperty);
219219

220220
self::assertTrue($proxy->isProxyInitialized());

tests/ProxyManagerTest/ProxyGenerator/LazyLoadingGhost/MethodGenerator/CallInitializerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function testBodyStructure(): void
5050
$this->protectedProperty2 = 'protectedProperty2';
5151
static $cacheProxyManagerTestAsset_ClassWithMixedProperties;
5252
53-
$cacheProxyManagerTestAsset_ClassWithMixedProperties ?: $cacheProxyManagerTestAsset_ClassWithMixedProperties = \Closure::bind(static function ($instance) {
53+
$cacheProxyManagerTestAsset_ClassWithMixedProperties ?? $cacheProxyManagerTestAsset_ClassWithMixedProperties = \Closure::bind(static function ($instance) {
5454
$instance->privateProperty0 = 'privateProperty0';
5555
$instance->privateProperty1 = 'privateProperty1';
5656
$instance->privateProperty2 = 'privateProperty2';
@@ -72,7 +72,7 @@ public function testBodyStructure(): void
7272
7373
static $cacheFetchProxyManagerTestAsset_ClassWithMixedProperties;
7474
75-
$cacheFetchProxyManagerTestAsset_ClassWithMixedProperties ?: $cacheFetchProxyManagerTestAsset_ClassWithMixedProperties = \Closure::bind(function ($instance, array & $properties) {
75+
$cacheFetchProxyManagerTestAsset_ClassWithMixedProperties ?? $cacheFetchProxyManagerTestAsset_ClassWithMixedProperties = \Closure::bind(function ($instance, array & $properties) {
7676
$properties['' . "\0" . 'ProxyManagerTestAsset\\ClassWithMixedProperties' . "\0" . 'privateProperty0'] = & $instance->privateProperty0;
7777
$properties['' . "\0" . 'ProxyManagerTestAsset\\ClassWithMixedProperties' . "\0" . 'privateProperty1'] = & $instance->privateProperty1;
7878
$properties['' . "\0" . 'ProxyManagerTestAsset\\ClassWithMixedProperties' . "\0" . 'privateProperty2'] = & $instance->privateProperty2;
@@ -175,7 +175,7 @@ public function testBodyStructureWithTypedProperties(): void
175175
$this->protectedNullableClassProperty = NULL;
176176
static $cacheProxyManagerTestAsset_ClassWithMixedTypedProperties;
177177
178-
$cacheProxyManagerTestAsset_ClassWithMixedTypedProperties ?: $cacheProxyManagerTestAsset_ClassWithMixedTypedProperties = \Closure::bind(static function ($instance) {
178+
$cacheProxyManagerTestAsset_ClassWithMixedTypedProperties ?? $cacheProxyManagerTestAsset_ClassWithMixedTypedProperties = \Closure::bind(static function ($instance) {
179179
$instance->privateUnTypedProperty = 'privateUnTypedProperty';
180180
$instance->privateUnTypedPropertyWithoutDefaultValue = NULL;
181181
$instance->privateBoolProperty = true;
@@ -262,7 +262,7 @@ public function testBodyStructureWithTypedProperties(): void
262262
263263
static $cacheFetchProxyManagerTestAsset_ClassWithMixedTypedProperties;
264264
265-
$cacheFetchProxyManagerTestAsset_ClassWithMixedTypedProperties ?: $cacheFetchProxyManagerTestAsset_ClassWithMixedTypedProperties = \Closure::bind(function ($instance, array & $properties) {
265+
$cacheFetchProxyManagerTestAsset_ClassWithMixedTypedProperties ?? $cacheFetchProxyManagerTestAsset_ClassWithMixedTypedProperties = \Closure::bind(function ($instance, array & $properties) {
266266
$properties['' . "\0" . 'ProxyManagerTestAsset\\ClassWithMixedTypedProperties' . "\0" . 'privateUnTypedProperty'] = & $instance->privateUnTypedProperty;
267267
$properties['' . "\0" . 'ProxyManagerTestAsset\\ClassWithMixedTypedProperties' . "\0" . 'privateUnTypedPropertyWithoutDefaultValue'] = & $instance->privateUnTypedPropertyWithoutDefaultValue;
268268
$properties['' . "\0" . 'ProxyManagerTestAsset\\ClassWithMixedTypedProperties' . "\0" . 'privateBoolProperty'] = & $instance->privateBoolProperty;

tests/ProxyManagerTest/ProxyGenerator/Util/PublicScopeSimulatorTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function testSimpleGet(): void
2525
if (! $realInstanceReflection->hasProperty($foo)) {
2626
$targetObject = $this;
2727
28-
$backtrace = debug_backtrace(false);
28+
$backtrace = debug_backtrace(false, 1);
2929
trigger_error(
3030
sprintf(
3131
'Undefined property: %s::$%s in %s on line %s',
@@ -44,7 +44,7 @@ public function testSimpleGet(): void
4444
$accessor = function & () use ($targetObject, $name) {
4545
return $targetObject->$foo;
4646
};
47-
$backtrace = debug_backtrace(true);
47+
$backtrace = debug_backtrace(true, 2);
4848
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
4949
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
5050
$bar = & $accessor();
@@ -78,7 +78,7 @@ public function testSimpleSet(): void
7878
$accessor = function & () use ($targetObject, $name, $value) {
7979
return $targetObject->$foo = $baz;
8080
};
81-
$backtrace = debug_backtrace(true);
81+
$backtrace = debug_backtrace(true, 2);
8282
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
8383
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
8484
$bar = & $accessor();
@@ -112,7 +112,7 @@ public function testSimpleIsset(): void
112112
$accessor = function () use ($targetObject, $name) {
113113
return isset($targetObject->$foo);
114114
};
115-
$backtrace = debug_backtrace(true);
115+
$backtrace = debug_backtrace(true, 2);
116116
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
117117
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
118118
$bar = $accessor();
@@ -146,7 +146,7 @@ public function testSimpleUnset(): void
146146
$accessor = function () use ($targetObject, $name) {
147147
unset($targetObject->$foo);
148148
};
149-
$backtrace = debug_backtrace(true);
149+
$backtrace = debug_backtrace(true, 2);
150150
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
151151
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
152152
$bar = $accessor();
@@ -193,7 +193,7 @@ public function testDelegatesToValueHolderWhenAvailable(): void
193193
$accessor = function & () use ($targetObject, $name, $value) {
194194
return $targetObject->$foo = $baz;
195195
};
196-
$backtrace = debug_backtrace(true);
196+
$backtrace = debug_backtrace(true, 2);
197197
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
198198
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
199199
$bar = & $accessor();
@@ -226,7 +226,7 @@ public function testWillReturnDirectlyWithNoReturnParam(): void
226226
if (! $realInstanceReflection->hasProperty($foo)) {
227227
$targetObject = $this;
228228
229-
$backtrace = debug_backtrace(false);
229+
$backtrace = debug_backtrace(false, 1);
230230
trigger_error(
231231
sprintf(
232232
'Undefined property: %s::$%s in %s on line %s',
@@ -245,7 +245,7 @@ public function testWillReturnDirectlyWithNoReturnParam(): void
245245
$accessor = function & () use ($targetObject, $name) {
246246
return $targetObject->$foo;
247247
};
248-
$backtrace = debug_backtrace(true);
248+
$backtrace = debug_backtrace(true, 2);
249249
$scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
250250
$accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
251251
$returnValue = & $accessor();

tests/ProxyManagerTest/ProxyGenerator/ValueHolder/MethodGenerator/ConstructorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testBodyStructure(): void
4141
'static $reflection;
4242
4343
if (! $this->foo) {
44-
$reflection = $reflection ?: new \ReflectionClass(\'ProxyManagerTestAsset\\\\ProxyGenerator\\\\LazyLoading\\\\'
44+
$reflection = $reflection ?? new \ReflectionClass(\'ProxyManagerTestAsset\\\\ProxyGenerator\\\\LazyLoading\\\\'
4545
. 'MethodGenerator\\\\ClassWithTwoPublicProperties\');
4646
$this->foo = $reflection->newInstanceWithoutConstructor();
4747
unset($this->bar, $this->baz);
@@ -68,7 +68,7 @@ public function testBodyStructureWithoutPublicProperties(): void
6868
'static $reflection;
6969
7070
if (! $this->foo) {
71-
$reflection = $reflection ?: new \ReflectionClass(\'ProxyManagerTestAsset\\\\EmptyClass\');
71+
$reflection = $reflection ?? new \ReflectionClass(\'ProxyManagerTestAsset\\\\EmptyClass\');
7272
$this->foo = $reflection->newInstanceWithoutConstructor();
7373
}',
7474
$constructor->getBody()
@@ -89,7 +89,7 @@ public function testBodyStructureWithStaticProperties(): void
8989
$expectedCode = 'static $reflection;
9090
9191
if (! $this->foo) {
92-
$reflection = $reflection ?: new \ReflectionClass(\'ProxyManagerTestAsset\\\\ClassWithMixedProperties\');
92+
$reflection = $reflection ?? new \ReflectionClass(\'ProxyManagerTestAsset\\\\ClassWithMixedProperties\');
9393
$this->foo = $reflection->newInstanceWithoutConstructor();
9494
unset($this->publicProperty0, $this->publicProperty1, $this->publicProperty2, $this->protectedProperty0, '
9595
. '$this->protectedProperty1, $this->protectedProperty2);
@@ -121,7 +121,7 @@ public function testBodyStructureWithVariadicArguments(): void
121121
static $reflection;
122122
123123
if (! $this->foo) {
124-
$reflection = $reflection ?: new \ReflectionClass('ProxyManagerTestAsset\\ClassWithVariadicConstructorArgument');
124+
$reflection = $reflection ?? new \ReflectionClass('ProxyManagerTestAsset\\ClassWithVariadicConstructorArgument');
125125
$this->foo = $reflection->newInstanceWithoutConstructor();
126126
\Closure::bind(function (\ProxyManagerTestAsset\ClassWithVariadicConstructorArgument $instance) {
127127
unset($instance->foo, $instance->bar);

0 commit comments

Comments
 (0)