Skip to content

Commit

Permalink
Merge pull request #127 from samsonasik/step4-php81
Browse files Browse the repository at this point in the history
[Step 4 Upgrade] Bump requirement to php 8.1
  • Loading branch information
lisachenko authored Jan 20, 2024
2 parents c5c467f + f002967 commit bd12c88
Show file tree
Hide file tree
Showing 24 changed files with 271 additions and 234 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- "lowest"
- "highest"
php-version:
- "8.0"
- "8.1"
operating-system:
- "ubuntu-latest"

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
}
},
"require": {
"php": ">=8.0",
"php": ">=8.1",
"nikic/php-parser": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^10.5.7",
"tracy/tracy": "^2.10"
},
"extra": {
Expand Down
12 changes: 6 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" colors="true" bootstrap="./vendor/autoload.php">
<coverage>
<include>
<directory>./src/</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" colors="true" bootstrap="./vendor/autoload.php">
<testsuites>
<testsuite name="Parser Reflection Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>./src/</directory>
</include>
</source>
</phpunit>
14 changes: 7 additions & 7 deletions src/ReflectionClassConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ public function __debugInfo(): array
/**
* @inheritDoc
*/
public function getDeclaringClass()
public function getDeclaringClass(): \ReflectionClass
{
return new ReflectionClass($this->className);
}

/**
* @inheritDoc
*/
public function getDocComment()
public function getDocComment(): string|false
{
$docBlock = $this->classConstantNode->getDocComment();

Expand All @@ -129,7 +129,7 @@ public function getDocComment()
/**
* @inheritDoc
*/
public function getModifiers()
public function getModifiers(): int
{
$modifiers = 0;
if ($this->isPublic()) {
Expand Down Expand Up @@ -166,31 +166,31 @@ public function getValue()
/**
* @inheritDoc
*/
public function isPrivate()
public function isPrivate(): bool
{
return $this->classConstantNode->isPrivate();
}

/**
* @inheritDoc
*/
public function isProtected()
public function isProtected(): bool
{
return $this->classConstantNode->isProtected();
}

/**
* @inheritDoc
*/
public function isPublic()
public function isPublic(): bool
{
return $this->classConstantNode->isPublic();
}

/**
* @inheritDoc
*/
public function __toString()
public function __toString(): string
{
# Starting from PHP7.3 gettype returns different names, need to remap them
static $typeMap = [
Expand Down
2 changes: 1 addition & 1 deletion src/ReflectionFileNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function getConstants(bool $withDefined = false): array
*
* @return string|false The doc comment if it exists, otherwise "false"
*/
public function getDocComment()
public function getDocComment(): string|false
{
$docComment = false;
$comments = $this->namespaceNode->getAttribute('comments');
Expand Down
8 changes: 3 additions & 5 deletions src/ReflectionFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function getNode(): Function_
/**
* {@inheritDoc}
*/
public function getClosure()
public function getClosure(): \Closure
{
$this->initializeInternalReflection();

Expand Down Expand Up @@ -100,17 +100,15 @@ public function invokeArgs(array $args)
* Only internal functions can be disabled using disable_functions directive.
* User-defined functions are unaffected.
*/
public function isDisabled()
public function isDisabled(): bool
{
return false;
}

/**
* Returns textual representation of function
*
* @return string
*/
public function __toString()
public function __toString(): string
{
$paramFormat = ($this->getNumberOfParameters() > 0) ? "\n\n - Parameters [%d] {%s\n }" : '';
$reflectionFormat = "%sFunction [ <user> function %s ] {\n @@ %s %d - %d{$paramFormat}\n}\n";
Expand Down
30 changes: 14 additions & 16 deletions src/ReflectionMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ public function __debugInfo(): array
* Returns the string representation of the Reflection method object.
*
* @link http://php.net/manual/en/reflectionmethod.tostring.php
*
* @return string
*/
public function __toString()
public function __toString(): string
{
// Internally $this->getReturnType() !== null is the same as $this->hasReturnType()
$returnType = $this->getReturnType();
Expand Down Expand Up @@ -138,7 +136,7 @@ public function __toString()
/**
* {@inheritDoc}
*/
public function getClosure($object = null)
public function getClosure($object = null): \Closure
{
$this->initializeInternalReflection();

Expand All @@ -148,15 +146,15 @@ public function getClosure($object = null)
/**
* {@inheritDoc}
*/
public function getDeclaringClass()
public function getDeclaringClass(): \ReflectionClass
{
return $this->declaringClass ?? new ReflectionClass($this->className);
}

/**
* {@inheritDoc}
*/
public function getModifiers()
public function getModifiers(): int
{
$modifiers = 0;
if ($this->isPublic()) {
Expand Down Expand Up @@ -184,7 +182,7 @@ public function getModifiers()
/**
* {@inheritDoc}
*/
public function getPrototype()
public function getPrototype(): \ReflectionMethod
{
$parent = $this->getDeclaringClass()->getParentClass();
if (!$parent) {
Expand Down Expand Up @@ -222,71 +220,71 @@ public function invokeArgs(?object $object, array $args): mixed
/**
* {@inheritDoc}
*/
public function isAbstract()
public function isAbstract(): bool
{
return $this->getDeclaringClass()->isInterface() || $this->getClassMethodNode()->isAbstract();
}

/**
* {@inheritDoc}
*/
public function isConstructor()
public function isConstructor(): bool
{
return $this->getClassMethodNode()->name->toLowerString() === '__construct';
}

/**
* {@inheritDoc}
*/
public function isDestructor()
public function isDestructor(): bool
{
return $this->getClassMethodNode()->name->toLowerString() === '__destruct';
}

/**
* {@inheritDoc}
*/
public function isFinal()
public function isFinal(): bool
{
return $this->getClassMethodNode()->isFinal();
}

/**
* {@inheritDoc}
*/
public function isPrivate()
public function isPrivate(): bool
{
return $this->getClassMethodNode()->isPrivate();
}

/**
* {@inheritDoc}
*/
public function isProtected()
public function isProtected(): bool
{
return $this->getClassMethodNode()->isProtected();
}

/**
* {@inheritDoc}
*/
public function isPublic()
public function isPublic(): bool
{
return $this->getClassMethodNode()->isPublic();
}

/**
* {@inheritDoc}
*/
public function isStatic()
public function isStatic(): bool
{
return $this->getClassMethodNode()->isStatic();
}

/**
* {@inheritDoc}
*/
public function setAccessible($accessible)
public function setAccessible($accessible): void
{
$this->initializeInternalReflection();

Expand Down
8 changes: 4 additions & 4 deletions src/ReflectionNamedType.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,31 +51,31 @@ public function __construct($type, $allowsNull, $isBuiltin)
/**
* @inheritDoc
*/
public function allowsNull()
public function allowsNull(): bool
{
return $this->allowsNull;
}

/**
* @inheritDoc
*/
public function isBuiltin()
public function isBuiltin(): bool
{
return $this->isBuiltin;
}

/**
* @inheritDoc
*/
public function __toString()
public function __toString(): string
{
return $this->type;
}

/**
* @inheritDoc
*/
public function getName()
public function getName(): string
{
return $this->type;
}
Expand Down
Loading

0 comments on commit bd12c88

Please sign in to comment.