Skip to content

Commit

Permalink
#2407 - Adjust definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Aug 31, 2023
1 parent fec8f76 commit 25ce077
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions Library/ClassProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function __construct(
protected array $visibility,
protected string $name,
protected ?array $defaultValue,
protected string $docBlock,
protected array $original,
protected ?string $docBlock = null,
protected ?array $original = null,
) {
$this->checkVisibility($visibility, $name, $original);

Expand Down Expand Up @@ -96,13 +96,11 @@ public function getOriginal(): mixed
/**
* Checks for visibility congruence.
*
* @param array $visibility
* @param array $visibility
* @param string $name
* @param array $original
*
* @throws CompilerException
* @param array|null $original
*/
public function checkVisibility($visibility, $name, $original): void
public function checkVisibility(array $visibility, string $name, ?array $original = null): void
{
if (in_array('public', $visibility) && in_array('protected', $visibility)) {
throw new CompilerException("Property '$name' cannot be 'public' and 'protected' at the same time", $original);
Expand All @@ -122,7 +120,7 @@ public function checkVisibility($visibility, $name, $original): void
*
* @return string
*/
public function getVisibilityAccessor()
public function getVisibilityAccessor(): string
{
$modifiers = [];

Expand Down Expand Up @@ -155,9 +153,9 @@ public function getVisibilityAccessor()
/**
* Returns the docblock related to the property.
*
* @return string
* @return string|null
*/
public function getDocBlock(): string
public function getDocBlock(): ?string
{
return $this->docBlock;
}
Expand Down Expand Up @@ -422,10 +420,10 @@ private function initializeArray(): void
$parentClassDefinition = $classDefinition->getExtendsClassDefinition();

if (!$this->isStatic()) {
$constructParentMethod = $parentClassDefinition ? $parentClassDefinition->getInitMethod() : null;
$constructParentMethod = $parentClassDefinition?->getInitMethod();
$constructMethod = $classDefinition->getInitMethod();
} else {
$constructParentMethod = $parentClassDefinition ? $parentClassDefinition->getStaticInitMethod() : null;
$constructParentMethod = $parentClassDefinition?->getStaticInitMethod();
$constructMethod = $classDefinition->getStaticInitMethod();
}

Expand Down

0 comments on commit 25ce077

Please sign in to comment.