Skip to content

Commit 482db3e

Browse files
committed
Resolve 8.5 deprecation
1 parent 95591e5 commit 482db3e

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/PhpFile.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function save(string $directory): bool
8383

8484
protected function addObject(PhpClass|PhpTrait|PhpInterface $class, string $type): static
8585
{
86-
if ($this->classes->contains($class->getIdentifier())) {
86+
if ($this->classes->offsetExists($class->getIdentifier())) {
8787
throw new DuplicateValue(sprintf(
8888
'A %s of the name (%s) does already exist.',
8989
$type,
@@ -145,16 +145,16 @@ public function addUse(Identifier|string $identifier, ?string $alias = null): se
145145
if ($alias) {
146146
$identifier->setAlias($alias);
147147
}
148-
if (!$this->use->contains($identifier)) {
149-
$this->use->attach($identifier);
148+
if (!$this->use->offsetExists($identifier)) {
149+
$this->use->offsetSet($identifier);
150150
}
151151

152152
return $this;
153153
}
154154

155155
public function hasClass(Identifier|string $identifier): bool
156156
{
157-
return $this->classes->contains(Identifier::fromUnknown($identifier));
157+
return $this->classes->offsetExists(Identifier::fromUnknown($identifier));
158158
}
159159

160160
public function hasFunction(Identifier|string $identifier): bool

src/PhpTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function getUses(): array
8484
*/
8585
public function addConstant(PhpConstant $constant): static
8686
{
87-
if ($this->constants->contains($constant->getIdentifier())) {
87+
if ($this->constants->offsetExists($constant->getIdentifier())) {
8888
throw new DuplicateValue(sprintf(
8989
'A constant of the name (%s) does already exist.',
9090
$constant->getIdentifier()->getName(),
@@ -131,7 +131,7 @@ public function addVariable(PhpVariable $variable, bool $createGetterSetter = fa
131131
*/
132132
public function addMethod(PhpMethod $method): static
133133
{
134-
if ($this->methods->contains($method->getIdentifier())) {
134+
if ($this->methods->offsetExists($method->getIdentifier())) {
135135
throw new DuplicateValue(sprintf(
136136
'A method of the name (%s) is already defined.',
137137
$method->getIdentifier()->getName(),
@@ -160,7 +160,7 @@ public function replaceMethod(Identifier|string $identifier, PhpMethod $method):
160160
public function hasVariable(Identifier|string $identifier): bool
161161
{
162162
$identifier = Identifier::fromUnknown($identifier);
163-
return $this->variables->contains($identifier);
163+
return $this->variables->offsetExists($identifier);
164164
}
165165

166166
/**
@@ -169,7 +169,7 @@ public function hasVariable(Identifier|string $identifier): bool
169169
public function hasMethod(Identifier|string $identifier): bool
170170
{
171171
$identifier = Identifier::fromUnknown($identifier);
172-
return $this->methods->contains($identifier);
172+
return $this->methods->offsetExists($identifier);
173173
}
174174

175175
/**
@@ -178,7 +178,7 @@ public function hasMethod(Identifier|string $identifier): bool
178178
public function hasConstant(Identifier|string $identifier): bool
179179
{
180180
$identifier = Identifier::fromUnknown($identifier);
181-
return $this->constants->contains($identifier);
181+
return $this->constants->offsetExists($identifier);
182182
}
183183

184184
public function getVariable(Identifier|string $identifier): ?PhpVariable

0 commit comments

Comments
 (0)