Skip to content

Commit

Permalink
Added PHP 8.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrankruijter committed Feb 23, 2021
1 parent e78cf48 commit bfe60a2
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 28 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php
php:
- '7.3'
- '7.4'
- '8.0'

before_script:
- composer install
Expand Down
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.1.1 - 2020-11-05
## 1.2.0 - 2021-02-23
### Added
- Compatibility for PHP 8.0

## 1.1.1 - 2020-11-05
### Fixed
- Added missing backslashes to generate correct references.

## 1.1.0 - 2020-11-03

### Added
- Option to include private methods.
- Option to include parent methods.

## 1.0.0 - 2020-10-19

### Added
- The initial implementation of the package.

# Versions
- [1.1.1 > Unreleased](https://github.com/grizz-it/php-ast-generator/compare/1.1.1...HEAD)
- [1.2.0 > Unreleased](https://github.com/grizz-it/php-ast-generator/compare/1.2.0...HEAD)
- [1.1.1 > 1.2.0](https://github.com/grizz-it/php-ast-generator/compare/1.1.1...1.2.0)
- [1.1.0 > 1.1.1](https://github.com/grizz-it/php-ast-generator/compare/1.1.0...1.1.1)
- [1.0.0 > 1.1.0](https://github.com/grizz-it/php-ast-generator/compare/1.0.0...1.1.0)
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"prefer-stable": true,
"minimum-stability": "stable",
"require": {
"php": "^7.3",
"grizz-it/ast": "^1.2"
"php": "^8.0",
"grizz-it/ast": "^1.3"
},
"authors": [
{
Expand Down Expand Up @@ -47,7 +47,7 @@
]
},
"require-dev": {
"phpunit/phpunit": "^9.4",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.5"
}
}
4 changes: 3 additions & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
<arg name="colors" />
<arg value="s" />

<rule ref="PSR12" />
<rule ref="PSR12">
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols"/>
</rule>
</ruleset>
2 changes: 1 addition & 1 deletion src/Common/PropertyGeneratorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ interface PropertyGeneratorInterface
*/
public function generate(
ReflectionProperty $property,
$defaultValue = null
mixed $defaultValue = null
): PropertyInterface;
}
10 changes: 6 additions & 4 deletions src/Component/Generator/Definition/ClassGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,28 @@ class ClassGenerator implements DefinitionGeneratorInterface
*
* @var bool
*/
private $includeParent;
private bool $includeParent;

/**
* Determines whether interfaces should be copied.
*
* @var bool
*/
private $includeInterfaces;
private bool $includeInterfaces;

/**
* Whether the parents methods should be inherited.
*
* @var bool
*/
private $includeParentMethods;
private bool $includeParentMethods;

/**
* Whether the private methods should be inherited.
*
* @var bool
*/
private $includePrivateMethods;
private bool $includePrivateMethods;

/**
* Constructor.
Expand All @@ -66,6 +66,8 @@ class ClassGenerator implements DefinitionGeneratorInterface
* @param MethodGeneratorInterface|null $methodGenerator
* @param ConstantGeneratorInterface|null $constantGenerator
* @param PropertyGeneratorInterface|null $propertyGenerator
* @param bool $includeParentMethods
* @param bool $includePrivateMethods
*/
public function __construct(
bool $includeParent,
Expand Down
6 changes: 3 additions & 3 deletions src/Component/Generator/Definition/InterfaceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ class InterfaceGenerator implements DefinitionGeneratorInterface
*
* @var bool
*/
private $includeParent;
private bool $includeParent;

/**
* Whether the parents methods should be inherited.
*
* @var bool
*/
private $includeParentMethods;
private bool $includeParentMethods;

/**
* Whether the private methods should be inherited.
*
* @var bool
*/
private $includePrivateMethods;
private bool $includePrivateMethods;

/**
* Constructor.
Expand Down
4 changes: 2 additions & 2 deletions src/Component/Generator/DefinitionGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class DefinitionGenerator implements DefinitionGeneratorInterface
*
* @var DefinitionGeneratorInterface
*/
private $classGenerator;
private DefinitionGeneratorInterface $classGenerator;

/**
* Contains the interface generator.
*
* @var DefinitionGeneratorInterface
*/
private $interfaceGenerator;
private DefinitionGeneratorInterface $interfaceGenerator;

/**
* Constructor.
Expand Down
3 changes: 2 additions & 1 deletion src/Component/Generator/Extractor/ExtractConstantsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use ReflectionClass;
use GrizzIt\Ast\Common\Php\PropertyInterface;
use GrizzIt\PhpAstGenerator\Common\ConstantGeneratorInterface;

trait ExtractConstantsTrait
{
Expand All @@ -17,7 +18,7 @@ trait ExtractConstantsTrait
*
* @var ConstantGeneratorInterface|null
*/
private $constantGenerator;
private ?ConstantGeneratorInterface $constantGenerator;

/**
* Retrieves the direct interfaces.
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Generator/Extractor/ExtractMethodsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait ExtractMethodsTrait
*
* @var MethodGeneratorInterface|null
*/
private $methodGenerator;
private ?MethodGeneratorInterface $methodGenerator;

/**
* Retrieves the methods.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait ExtractPropertiesTrait
*
* @var PropertyGeneratorInterface|null
*/
private $propertyGenerator;
private ?PropertyGeneratorInterface $propertyGenerator;

/**
* Retrieves the properties of the reflection object.
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Generator/Extractor/ExtractTraitsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait ExtractTraitsTrait
*
* @var ReferenceGeneratorInterface|null
*/
private $referenceGenerator;
private ?ReferenceGeneratorInterface $referenceGenerator;

/**
* Retrieves the traits of the reflection object.
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Generator/MethodGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MethodGenerator implements MethodGeneratorInterface
*
* @var VariableGeneratorInterface
*/
private $variableGenerator;
private VariableGeneratorInterface $variableGenerator;

/**
* Constructor
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Generator/PropertyGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PropertyGenerator implements PropertyGeneratorInterface
*/
public function generate(
ReflectionProperty $property,
$defaultValue = null
mixed $defaultValue = null
): PropertyInterface {
$type = method_exists($property, 'getType') ? $property->getType() : null;
$astProperty = new Property(
Expand Down
2 changes: 2 additions & 0 deletions src/Factory/ClassGeneratorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class ClassGeneratorFactory
* @param bool $includeMethods
* @param bool $includeConstants
* @param bool $includeProperties
* @param bool $includeParentMethods
* @param bool $includePrivateMethods
*
* @return DefinitionGeneratorInterface
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Factory/DuplicateGeneratorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class DuplicateGeneratorFactory
* @param bool $includeMethods
* @param bool $includeConstants
* @param bool $includeProperties
* @param bool $includeParentMethods
* @param bool $includePrivateMethods
*
* @return DefinitionGeneratorInterface
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Factory/InterfaceGeneratorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class InterfaceGeneratorFactory
* @param bool $includeParent
* @param bool $includeMethods
* @param bool $includeConstants
* @param bool $includeParentMethods
* @param bool $includePrivateMethods
*
* @return DefinitionGeneratorInterface
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/MockObjects/MockClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class MockClass implements MockInterface
{
use MockTrait;

private $privateProperty = 'foo';
private string $privateProperty = 'foo';

public static $publicStaticProperty;

Expand Down
2 changes: 1 addition & 1 deletion tests/MockObjects/MockTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

trait MockTrait
{
public $publicProperty = [];
public array $publicProperty = [];

public function setPublicProperty(array $publicProperty): void
{
Expand Down

0 comments on commit bfe60a2

Please sign in to comment.