Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update dependencies, #19

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 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 @@ -136,15 +136,15 @@ jobs:
run: 'echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"'

- name: "Tests"
run: "vendor/bin/phpunit"
run: "vendor/bin/phpunit tests"

static-analysis:
name: "Static analysis"
runs-on: "${{ matrix.operating-system }}"

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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ phpstan: vendor
vendor/bin/phpstan analyse -l max -c phpstan.neon src

tests: vendor
vendor/bin/phpunit
vendor/bin/phpunit tests

coverage: vendor
vendor/bin/phpunit --coverage-clover=coverage.xml
vendor/bin/phpunit tests --coverage-clover=coverage.xml
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
Loading