Skip to content

Commit

Permalink
Merge pull request #506: Update metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk authored Jan 7, 2025
2 parents bde8ea3 + ae2f06f commit f2d32fb
Show file tree
Hide file tree
Showing 17 changed files with 246 additions and 48 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/cs-fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---

on: # yamllint disable-line rule:truthy
push:
branches:
- '*'

name: Fix Code Style

jobs:
cs-fix:
permissions:
contents: write
uses: spiral/gh-actions/.github/workflows/cs-fix.yml@master

...
15 changes: 15 additions & 0 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on:
pull_request: null
push:
branches:
- master
- '*.*'

name: static analysis

jobs:
psalm:
uses: spiral/gh-actions/.github/workflows/psalm.yml@master
with:
os: >-
['ubuntu-latest']
15 changes: 15 additions & 0 deletions .idea/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 17 additions & 15 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@
</file>
<file src="src/Config/RelationConfig.php">
<TooManyArguments>
<code><![CDATA[new Autowire($this->config[$type][self::LOADER])]]></code>
<code><![CDATA[new Autowire($this->config[$type][self::RELATION])]]></code>
<code>new Autowire($loader)</code>
<code>new Autowire($relation)</code>
</TooManyArguments>
</file>
<file src="src/EntityManager.php">
Expand Down
6 changes: 0 additions & 6 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,4 @@
</errorLevel>
</UndefinedClass>
</issueHandlers>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
2 changes: 1 addition & 1 deletion .phpstorm.meta.php → resources/.phpstorm.meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// .phpstorm.meta.php

namespace PHPSTORM_META {

override(\Cycle\ORM\ORMInterface::make(0), map(['' => '@']));
override(\Cycle\ORM\ORMInterface::get(0), map(['' => '@']));
}
34 changes: 34 additions & 0 deletions resources/factory.meta-storm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<meta-storm xmlns="meta-storm">
<definitions>
<classMethod class="\Cycle\ORM\FactoryInterface" method="mapper" argument="1">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\FactoryInterface" method="loader" argument="2">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\FactoryInterface" method="repository" argument="2">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\FactoryInterface" method="typecast" argument="2">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\FactoryInterface" method="source" argument="1">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\FactoryInterface" method="relation" argument="2">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>
</definitions>
</meta-storm>
14 changes: 14 additions & 0 deletions resources/iterator.meta-storm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<meta-storm xmlns="meta-storm">
<definitions>
<classMethod class="\Cycle\ORM\Iterator" method="createWithOrm" argument="1">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\Iterator" method="createWithServices" argument="3">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>
</definitions>
</meta-storm>
19 changes: 19 additions & 0 deletions resources/orm.meta-storm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<meta-storm xmlns="meta-storm">
<definitions>
<classMethod class="\Cycle\ORM\ORMInterface" method="resolveRole" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\MapperInterface" method="init" argument="1">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\Heap\HeapInterface" method="find" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>
</definitions>
</meta-storm>
34 changes: 34 additions & 0 deletions resources/schema.meta-storm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<meta-storm xmlns="meta-storm">
<definitions>
<classMethod class="\Cycle\ORM\SchemaInterface" method="getRelations" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\SchemaInterface" method="defines" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\SchemaInterface" method="define" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\SchemaInterface" method="defineRelation" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\SchemaInterface" method="resolveAlias" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\SchemaInterface" method="getInheritedRoles" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>
</definitions>
</meta-storm>
9 changes: 9 additions & 0 deletions resources/select.meta-storm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<meta-storm xmlns="meta-storm">
<definitions>
<classConstructor class="\Cycle\ORM\Select" argument="1">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classConstructor>
</definitions>
</meta-storm>
44 changes: 44 additions & 0 deletions resources/services.meta-storm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" ?>
<meta-storm xmlns="meta-storm">
<definitions>
<classMethod class="\Cycle\ORM\Service\SourceProviderInterface" method="getSource" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\Service\EntityProviderInterface" method="get" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\Service\EntityFactoryInterface" method="make" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\Service\IndexProviderInterface" method="getIndexes" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\Service\RelationProviderInterface" method="getRelationMap" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\Service\MapperProviderInterface" method="getMapper" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\Service\RepositoryProviderInterface" method="getRepository" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>

<classMethod class="\Cycle\ORM\Service\TypecastProviderInterface" method="getTypecast" argument="0">
<collection name="cycle/orm:entity-class" argument="0" />
<collection name="cycle/orm:entity-role" argument="0" />
</classMethod>
</definitions>
</meta-storm>
18 changes: 10 additions & 8 deletions src/Config/RelationConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,21 @@ public static function getDefault(): self

public function getLoader(int|string $type): Autowire
{
if (!isset($this->config[$type][self::LOADER])) {
throw new ConfigException("Unable to get relation loader `{$type}`.");
}
$loader = $this->config[$type][self::LOADER] ?? throw new ConfigException(
"Unable to get relation loader `{$type}`.",
);

return new Autowire($this->config[$type][self::LOADER]);
\assert(\is_string($loader) && $loader !== '');
return new Autowire($loader);
}

public function getRelation(int|string $type): Autowire
{
if (!isset($this->config[$type][self::RELATION])) {
throw new ConfigException("Unable to get relation `{$type}`.");
}
$relation = $this->config[$type][self::RELATION] ?? throw new ConfigException(
"Unable to get relation `{$type}`.",
);

return new Autowire($this->config[$type][self::RELATION]);
\assert(\is_string($relation) && $relation !== '');
return new Autowire($relation);
}
}
2 changes: 1 addition & 1 deletion src/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function wherePK(string|int|array|object ...$ids): self
/**
* Attention, column will be quoted by driver!
*
* @param string|null $column When column is null DISTINCT(PK) will be generated.
* @param non-empty-string|null $column When column is null DISTINCT(PK) will be generated.
*/
public function count(?string $column = null): int
{
Expand Down
28 changes: 14 additions & 14 deletions tests/ORM/Functional/Driver/Common/Integration/Case6/CaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ abstract class CaseTest extends BaseTest
use IntegrationTestTrait;
use TableTrait;

public function testSelect(): void
{
/** @var User $model */
$model = (new Select($this->orm, User::class))
->wherePK(1)
->fetchOne();

$this->assertSame('foo', $model->getLogin());
$this->expectException(\Error::class);
$this->expectExceptionMessage('Cannot access non-public property ' . User::class . '::$login');

$model->login = 'new login';
}

public function setUp(): void
{
// Init DB
Expand All @@ -35,18 +49,4 @@ public function setUp(): void
],
);
}

public function testSelect(): void
{
/** @var User $model */
$model = (new Select($this->orm,User::class))
->wherePK(1)
->fetchOne();

$this->assertSame('foo', $model->getLogin());
$this->expectException(\Error::class);
$this->expectExceptionMessage('Cannot access non-public property ' . User::class . '::$login');

$model->login = 'new login';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(string $login)

public function getId(): ?string
{
return $this->id === null ? null : (string)$this->id;
return $this->id === null ? null : (string) $this->id;
}

public function getLogin(): string
Expand Down

0 comments on commit f2d32fb

Please sign in to comment.