Skip to content

Commit f2d32fb

Browse files
authored
Merge pull request #506: Update metadata
2 parents bde8ea3 + ae2f06f commit f2d32fb

17 files changed

+246
-48
lines changed

.github/workflows/cs-fix.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
3+
on: # yamllint disable-line rule:truthy
4+
push:
5+
branches:
6+
- '*'
7+
8+
name: Fix Code Style
9+
10+
jobs:
11+
cs-fix:
12+
permissions:
13+
contents: write
14+
uses: spiral/gh-actions/.github/workflows/cs-fix.yml@master
15+
16+
...

.github/workflows/psalm.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
on:
2+
pull_request: null
3+
push:
4+
branches:
5+
- master
6+
- '*.*'
7+
8+
name: static analysis
9+
10+
jobs:
11+
psalm:
12+
uses: spiral/gh-actions/.github/workflows/psalm.yml@master
13+
with:
14+
os: >-
15+
['ubuntu-latest']

.idea/icon.svg

+15
Loading

README.md

+17-15
Large diffs are not rendered by default.

psalm-baseline.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@
229229
</file>
230230
<file src="src/Config/RelationConfig.php">
231231
<TooManyArguments>
232-
<code><![CDATA[new Autowire($this->config[$type][self::LOADER])]]></code>
233-
<code><![CDATA[new Autowire($this->config[$type][self::RELATION])]]></code>
232+
<code>new Autowire($loader)</code>
233+
<code>new Autowire($relation)</code>
234234
</TooManyArguments>
235235
</file>
236236
<file src="src/EntityManager.php">

psalm.xml

-6
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,4 @@
2626
</errorLevel>
2727
</UndefinedClass>
2828
</issueHandlers>
29-
<projectFiles>
30-
<directory name="src" />
31-
<ignoreFiles>
32-
<directory name="vendor" />
33-
</ignoreFiles>
34-
</projectFiles>
3529
</psalm>

.phpstorm.meta.php resources/.phpstorm.meta.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
// .phpstorm.meta.php
33

44
namespace PHPSTORM_META {
5-
65
override(\Cycle\ORM\ORMInterface::make(0), map(['' => '@']));
6+
override(\Cycle\ORM\ORMInterface::get(0), map(['' => '@']));
77
}

resources/factory.meta-storm.xml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<meta-storm xmlns="meta-storm">
3+
<definitions>
4+
<classMethod class="\Cycle\ORM\FactoryInterface" method="mapper" argument="1">
5+
<collection name="cycle/orm:entity-class" argument="0" />
6+
<collection name="cycle/orm:entity-role" argument="0" />
7+
</classMethod>
8+
9+
<classMethod class="\Cycle\ORM\FactoryInterface" method="loader" argument="2">
10+
<collection name="cycle/orm:entity-class" argument="0" />
11+
<collection name="cycle/orm:entity-role" argument="0" />
12+
</classMethod>
13+
14+
<classMethod class="\Cycle\ORM\FactoryInterface" method="repository" argument="2">
15+
<collection name="cycle/orm:entity-class" argument="0" />
16+
<collection name="cycle/orm:entity-role" argument="0" />
17+
</classMethod>
18+
19+
<classMethod class="\Cycle\ORM\FactoryInterface" method="typecast" argument="2">
20+
<collection name="cycle/orm:entity-class" argument="0" />
21+
<collection name="cycle/orm:entity-role" argument="0" />
22+
</classMethod>
23+
24+
<classMethod class="\Cycle\ORM\FactoryInterface" method="source" argument="1">
25+
<collection name="cycle/orm:entity-class" argument="0" />
26+
<collection name="cycle/orm:entity-role" argument="0" />
27+
</classMethod>
28+
29+
<classMethod class="\Cycle\ORM\FactoryInterface" method="relation" argument="2">
30+
<collection name="cycle/orm:entity-class" argument="0" />
31+
<collection name="cycle/orm:entity-role" argument="0" />
32+
</classMethod>
33+
</definitions>
34+
</meta-storm>

resources/iterator.meta-storm.xml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<meta-storm xmlns="meta-storm">
3+
<definitions>
4+
<classMethod class="\Cycle\ORM\Iterator" method="createWithOrm" argument="1">
5+
<collection name="cycle/orm:entity-class" argument="0" />
6+
<collection name="cycle/orm:entity-role" argument="0" />
7+
</classMethod>
8+
9+
<classMethod class="\Cycle\ORM\Iterator" method="createWithServices" argument="3">
10+
<collection name="cycle/orm:entity-class" argument="0" />
11+
<collection name="cycle/orm:entity-role" argument="0" />
12+
</classMethod>
13+
</definitions>
14+
</meta-storm>

resources/orm.meta-storm.xml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<meta-storm xmlns="meta-storm">
3+
<definitions>
4+
<classMethod class="\Cycle\ORM\ORMInterface" method="resolveRole" argument="0">
5+
<collection name="cycle/orm:entity-class" argument="0" />
6+
<collection name="cycle/orm:entity-role" argument="0" />
7+
</classMethod>
8+
9+
<classMethod class="\Cycle\ORM\MapperInterface" method="init" argument="1">
10+
<collection name="cycle/orm:entity-class" argument="0" />
11+
<collection name="cycle/orm:entity-role" argument="0" />
12+
</classMethod>
13+
14+
<classMethod class="\Cycle\ORM\Heap\HeapInterface" method="find" argument="0">
15+
<collection name="cycle/orm:entity-class" argument="0" />
16+
<collection name="cycle/orm:entity-role" argument="0" />
17+
</classMethod>
18+
</definitions>
19+
</meta-storm>

resources/schema.meta-storm.xml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<meta-storm xmlns="meta-storm">
3+
<definitions>
4+
<classMethod class="\Cycle\ORM\SchemaInterface" method="getRelations" argument="0">
5+
<collection name="cycle/orm:entity-class" argument="0" />
6+
<collection name="cycle/orm:entity-role" argument="0" />
7+
</classMethod>
8+
9+
<classMethod class="\Cycle\ORM\SchemaInterface" method="defines" argument="0">
10+
<collection name="cycle/orm:entity-class" argument="0" />
11+
<collection name="cycle/orm:entity-role" argument="0" />
12+
</classMethod>
13+
14+
<classMethod class="\Cycle\ORM\SchemaInterface" method="define" argument="0">
15+
<collection name="cycle/orm:entity-class" argument="0" />
16+
<collection name="cycle/orm:entity-role" argument="0" />
17+
</classMethod>
18+
19+
<classMethod class="\Cycle\ORM\SchemaInterface" method="defineRelation" argument="0">
20+
<collection name="cycle/orm:entity-class" argument="0" />
21+
<collection name="cycle/orm:entity-role" argument="0" />
22+
</classMethod>
23+
24+
<classMethod class="\Cycle\ORM\SchemaInterface" method="resolveAlias" argument="0">
25+
<collection name="cycle/orm:entity-class" argument="0" />
26+
<collection name="cycle/orm:entity-role" argument="0" />
27+
</classMethod>
28+
29+
<classMethod class="\Cycle\ORM\SchemaInterface" method="getInheritedRoles" argument="0">
30+
<collection name="cycle/orm:entity-class" argument="0" />
31+
<collection name="cycle/orm:entity-role" argument="0" />
32+
</classMethod>
33+
</definitions>
34+
</meta-storm>

resources/select.meta-storm.xml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<meta-storm xmlns="meta-storm">
3+
<definitions>
4+
<classConstructor class="\Cycle\ORM\Select" argument="1">
5+
<collection name="cycle/orm:entity-class" argument="0" />
6+
<collection name="cycle/orm:entity-role" argument="0" />
7+
</classConstructor>
8+
</definitions>
9+
</meta-storm>

resources/services.meta-storm.xml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<meta-storm xmlns="meta-storm">
3+
<definitions>
4+
<classMethod class="\Cycle\ORM\Service\SourceProviderInterface" method="getSource" argument="0">
5+
<collection name="cycle/orm:entity-class" argument="0" />
6+
<collection name="cycle/orm:entity-role" argument="0" />
7+
</classMethod>
8+
9+
<classMethod class="\Cycle\ORM\Service\EntityProviderInterface" method="get" argument="0">
10+
<collection name="cycle/orm:entity-class" argument="0" />
11+
<collection name="cycle/orm:entity-role" argument="0" />
12+
</classMethod>
13+
14+
<classMethod class="\Cycle\ORM\Service\EntityFactoryInterface" method="make" argument="0">
15+
<collection name="cycle/orm:entity-class" argument="0" />
16+
<collection name="cycle/orm:entity-role" argument="0" />
17+
</classMethod>
18+
19+
<classMethod class="\Cycle\ORM\Service\IndexProviderInterface" method="getIndexes" argument="0">
20+
<collection name="cycle/orm:entity-class" argument="0" />
21+
<collection name="cycle/orm:entity-role" argument="0" />
22+
</classMethod>
23+
24+
<classMethod class="\Cycle\ORM\Service\RelationProviderInterface" method="getRelationMap" argument="0">
25+
<collection name="cycle/orm:entity-class" argument="0" />
26+
<collection name="cycle/orm:entity-role" argument="0" />
27+
</classMethod>
28+
29+
<classMethod class="\Cycle\ORM\Service\MapperProviderInterface" method="getMapper" argument="0">
30+
<collection name="cycle/orm:entity-class" argument="0" />
31+
<collection name="cycle/orm:entity-role" argument="0" />
32+
</classMethod>
33+
34+
<classMethod class="\Cycle\ORM\Service\RepositoryProviderInterface" method="getRepository" argument="0">
35+
<collection name="cycle/orm:entity-class" argument="0" />
36+
<collection name="cycle/orm:entity-role" argument="0" />
37+
</classMethod>
38+
39+
<classMethod class="\Cycle\ORM\Service\TypecastProviderInterface" method="getTypecast" argument="0">
40+
<collection name="cycle/orm:entity-class" argument="0" />
41+
<collection name="cycle/orm:entity-role" argument="0" />
42+
</classMethod>
43+
</definitions>
44+
</meta-storm>

src/Config/RelationConfig.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,21 @@ public static function getDefault(): self
6161

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

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

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

77-
return new Autowire($this->config[$type][self::RELATION]);
78+
\assert(\is_string($relation) && $relation !== '');
79+
return new Autowire($relation);
7880
}
7981
}

src/Select.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function wherePK(string|int|array|object ...$ids): self
136136
/**
137137
* Attention, column will be quoted by driver!
138138
*
139-
* @param string|null $column When column is null DISTINCT(PK) will be generated.
139+
* @param non-empty-string|null $column When column is null DISTINCT(PK) will be generated.
140140
*/
141141
public function count(?string $column = null): int
142142
{

tests/ORM/Functional/Driver/Common/Integration/Case6/CaseTest.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ abstract class CaseTest extends BaseTest
1515
use IntegrationTestTrait;
1616
use TableTrait;
1717

18+
public function testSelect(): void
19+
{
20+
/** @var User $model */
21+
$model = (new Select($this->orm, User::class))
22+
->wherePK(1)
23+
->fetchOne();
24+
25+
$this->assertSame('foo', $model->getLogin());
26+
$this->expectException(\Error::class);
27+
$this->expectExceptionMessage('Cannot access non-public property ' . User::class . '::$login');
28+
29+
$model->login = 'new login';
30+
}
31+
1832
public function setUp(): void
1933
{
2034
// Init DB
@@ -35,18 +49,4 @@ public function setUp(): void
3549
],
3650
);
3751
}
38-
39-
public function testSelect(): void
40-
{
41-
/** @var User $model */
42-
$model = (new Select($this->orm,User::class))
43-
->wherePK(1)
44-
->fetchOne();
45-
46-
$this->assertSame('foo', $model->getLogin());
47-
$this->expectException(\Error::class);
48-
$this->expectExceptionMessage('Cannot access non-public property ' . User::class . '::$login');
49-
50-
$model->login = 'new login';
51-
}
5252
}

tests/ORM/Functional/Driver/Common/Integration/Case6/Entity/User.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function __construct(string $login)
1616

1717
public function getId(): ?string
1818
{
19-
return $this->id === null ? null : (string)$this->id;
19+
return $this->id === null ? null : (string) $this->id;
2020
}
2121

2222
public function getLogin(): string

0 commit comments

Comments
 (0)