Skip to content

Commit

Permalink
update dependencies,
Browse files Browse the repository at this point in the history
support for php 8.3
  • Loading branch information
dakorpar committed Jan 18, 2024
1 parent ca8959d commit f303444
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 31 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yml → .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

strategy:
matrix:
php-version: ["8.0"]
php-version: ["8.3"]
operating-system: ["ubuntu-latest"]
fail-fast: false

Expand Down Expand Up @@ -80,11 +80,11 @@ jobs:
runs-on: "${{ matrix.operating-system }}"
strategy:
matrix:
php-version: ["8.1"]
php-version: ["8.3"]
operating-system: ["ubuntu-latest"]
composer-args: [ "" ]
include:
- php-version: "8.0"
- php-version: "8.1"
operating-system: "ubuntu-latest"
composer-args: "--ignore-platform-reqs"
fail-fast: false
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:

strategy:
matrix:
php-version: ["8.1"]
php-version: ["8.3"]
operating-system: ["ubuntu-latest"]
fail-fast: false

Expand Down Expand Up @@ -200,7 +200,7 @@ jobs:

strategy:
matrix:
php-version: ["8.1"]
php-version: ["8.3"]
operating-system: ["ubuntu-latest"]
fail-fast: false

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
}
},
"require": {
"php": "^8.0",
"nette/utils": "^3.0",
"nette/php-generator": "^3.0",
"php": "^8.1",
"nette/utils": "^3.1",
"nette/php-generator": "^4.0",
"doctrine/inflector": "^2.0"
},
"require-dev": {
"contributte/qa": "^0.1",
"contributte/qa": "^0.3",
"phpunit/phpunit": ">=9.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0"
Expand Down
6 changes: 3 additions & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="tests/bootstrap.php" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
</source>
</phpunit>
2 changes: 0 additions & 2 deletions ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
<property name="indent" value="4"/>
<property name="tabIndent" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="allowFullyQualifiedGlobalClasses" value="true"/>
<property name="tabIndent" value="true"/>
</properties>
</rule>
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent"/>
Expand Down
11 changes: 6 additions & 5 deletions src/Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function generateEntity(string $table): void
$phpDocProperties = [];

if (!$this->config->rewrite && class_exists($fqnClassName)) {
$this->cloneEntityFromExistingEntity($entity, ClassType::from($fqnClassName));
$this->cloneEntityFromExistingEntity($entity, ClassType::from($fqnClassName)); //@phpstan-ignore-line
$phpDocProperties = Helper::getPhpDocComments($entity->getComment() ?? '');
}

Expand All @@ -98,7 +98,7 @@ public function generateEntity(string $table): void
$this->validateColumnName($table, $column);
$this->generateColumnConstant($entity, $column);

if (isset($entity->properties[$column->getField()]) || in_array($column->getField(), $phpDocProperties, true)) {
if ($entity->hasProperty($column->getField()) || in_array($column->getField(), $phpDocProperties, true)) {
continue;
}

Expand All @@ -107,7 +107,7 @@ public function generateEntity(string $table): void
}

if ($this->config->generateMapping) {
if (isset($entity->properties['mapping'])) {
if ($entity->hasProperty('mapping')) {
$mapping += $entity->getProperty('mapping')->getValue();
}

Expand Down Expand Up @@ -167,7 +167,7 @@ protected function generateColumn(ClassType $entity, Column $column): void
if ($this->config->generateSetters) {
$setter = $entity->addMethod('set' . $this->inflector->classify($column->getField()));
$setter->setVisibility($this->config->setterVisibility);
$setter->addParameter('value')->setTypeHint($type)->setNullable($column->isNullable());
$setter->addParameter('value')->setType($type)->setNullable($column->isNullable());
$setter->addBody(str_replace('__FIELD__', $column->getField(), $this->config->setterBody));
$setter->setReturnType('self');
}
Expand Down Expand Up @@ -218,8 +218,9 @@ private function cloneEntityFromExistingEntity(ClassType $entity, ClassType $fro
$entity->setProperties($from->getProperties());
$entity->setComment($from->getComment());
$entity->setMethods($from->getMethods());
$methods = $entity->getMethods();

foreach ($entity->methods as $method) {
foreach ($methods as $method) {
$fqnClassName = '\\' . $this->config->namespace . '\\' . $entity->getName();
$body = $this->getMethodBody($fqnClassName, $method->getName());
$method->setBody($body);
Expand Down
3 changes: 1 addition & 2 deletions tests/Generator/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ public function testGenerate_WithoutParameters_ShouldGenerateEntitiesForWholeTab
$this->config->path = __DIR__ . '/../TestEntities';

$this->repository->expects($this->once())->method('getTables')->willReturn(['table1', 'table2']);
$this->repository->expects($this->exactly(2))->method('getTableColumns')
->withConsecutive(['table1'], ['table2'])->willReturn($this->tableColumns);
$this->repository->expects($this->exactly(2))->method('getTableColumns')->willReturn($this->tableColumns);
$this->generator->generate();

$entityFile = $this->config->path . '/Table1Entity.php';
Expand Down
19 changes: 9 additions & 10 deletions tests/TestEntities/PhpDocPropertyEntity.php
Original file line number Diff line number Diff line change
@@ -1,66 +1,65 @@
<?php declare(strict_types = 1);
<?php

namespace DodoIt\EntityGenerator\Tests\TestEntities;

use DodoIt\EntityGenerator\Entity\Entity;

/**
* @property int $id
* @property string $title
* @property int $published
* @property \DateTimeInterface $created_at
*/
class PhpDocPropertyEntity extends Entity
class PhpDocPropertyEntity extends \DodoIt\EntityGenerator\Entity\Entity
{

public const TABLE_NAME = 'php_doc_properties';

public function getId(): int
{
return $this->id;
}


public function setId(int $value): self
{
$this['id'] = $value;

return $this;
}


public function getTitle(): ?string
{
return $this->title;
}


public function setTitle(?string $value): self
{
$this['title'] = $value;

return $this;
}


public function getPublished(): bool
{
return $this->published;
}


public function setPublished(bool $value): self
{
$this['published'] = $value;

return $this;
}


public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}


public function setCreatedAt(?\DateTimeInterface $value): self
{
$this['created_at'] = $value;

return $this;
}

}

0 comments on commit f303444

Please sign in to comment.