Skip to content

Commit 34a6e4f

Browse files
committed
Add package code
1 parent 6ebf637 commit 34a6e4f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2196
-15
lines changed

.gitattributes

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
/.github export-ignore
2-
/.editorconfig export-ignore
3-
/.gitattributes export-ignore
4-
/.gitignore export-ignore
5-
/tests export-ignore
1+
.github export-ignore
2+
.editorconfig export-ignore
3+
.gitattributes export-ignore
4+
.gitignore export-ignore
5+
.styleci.yml export-ignore
6+
.php-cs-fixer.dist.php export-ignore
7+
phpunit.xml export-ignore
8+
psalm.xml export-ignore
9+
/tests export-ignore

.github/FUNDING.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: roadrunner-server

.github/ISSUE_TEMPLATE/bug-report.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Bug Report
2+
description: 🐛 File a bug report
3+
title: "🐛 Something went wrong"
4+
labels: ["type:bug", "status:to be verified"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for taking the time to fill out this bug report!
10+
11+
- type: checkboxes
12+
id: search-done
13+
attributes:
14+
label: No duplicates 🥲.
15+
options:
16+
- label: I have searched for a similar issue in our bug tracker and didn't find any solutions.
17+
required: true
18+
19+
- type: textarea
20+
id: what-happened
21+
attributes:
22+
label: What happened?
23+
description: Also tell us, what did you expect to happen? Please write only in English.
24+
placeholder: Tell us what you see!
25+
value: "A bug happened!"
26+
validations:
27+
required: true
28+
- type: textarea
29+
id: version
30+
attributes:
31+
label: Version
32+
description: What version of our software are you running?
33+
render: shell
34+
value: |
35+
Schema Provider 1.0.0
36+
PHP 8.3
37+
validations:
38+
required: true

.github/ISSUE_TEMPLATE/config.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
blank_issues_enabled: false
2+
3+
contact_links:
4+
- name: ❓ Start a discussion or ask a question.
5+
url: https://github.com/cycle/orm/discussions
6+
about: Please ask and answer questions here.
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Feature request
2+
description: 💡 Suggest an idea for this project
3+
title: "💡 "
4+
labels: ["type:feature", "type:under discussion"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for taking the time to share your idea!
10+
11+
- type: textarea
12+
id: idea
13+
attributes:
14+
label: I have an idea!
15+
description: Clear and concise description of your idea. Please write only in English.
16+
placeholder: Tell us what you see!
17+
value: "I have an idea, listen to me!!"
18+
validations:
19+
required: true

.github/workflows/cs.yml

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

.github/workflows/phpunit.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on:
2+
pull_request: null
3+
push:
4+
branches:
5+
- '*.*'
6+
7+
name: phpunit
8+
9+
jobs:
10+
phpunit:
11+
uses: spiral/gh-actions/.github/workflows/phpunit.yml@master
12+
with:
13+
os: >-
14+
['ubuntu-latest']
15+
php: >-
16+
['8.0', '8.1', '8.2', '8.3']
17+
stability: >-
18+
['prefer-lowest', 'prefer-stable']

.github/workflows/psalm.yml

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

.php-cs-fixer.dist.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
if (!file_exists(__DIR__.'/src')) {
6+
exit(0);
7+
}
8+
9+
return (new PhpCsFixer\Config())
10+
->setRules([
11+
'@PSR12' => true,
12+
'ternary_operator_spaces' => false,
13+
])
14+
->setRiskyAllowed(true)
15+
->setFinder(
16+
(new PhpCsFixer\Finder())
17+
->in(__DIR__.'/src')
18+
->append([__FILE__])
19+
)
20+
->setCacheFile('.php-cs-fixer.cache');

composer.json

+46-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,54 @@
11
{
22
"name": "cycle/schema-provider",
33
"type": "library",
4-
"license": "MIT",
54
"description": "Cycle ORM Schema providers",
6-
"minimum-stability": "dev",
7-
"prefer-stable": true,
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Anton Titov (wolfy-j)",
9+
"email": "[email protected]"
10+
},
11+
{
12+
"name": "Pavel Buchnev (butschster)",
13+
"email": "[email protected]"
14+
},
15+
{
16+
"name": "Aleksei Gagarin (roxblnfk)",
17+
"email": "[email protected]"
18+
},
19+
{
20+
"name": "Maksim Smakouz (msmakouz)",
21+
"email": "[email protected]"
22+
}
23+
],
24+
"homepage": "https://cycle-orm.dev",
25+
"support": {
26+
"docs": "https://cycle-orm.dev/docs",
27+
"issues": "https://github.com/cycle/schema-provider/issues",
28+
"forum": "https://forum.spiral.dev",
29+
"chat": "https://discord.gg/V6EK4he"
30+
},
31+
"funding": [
32+
{
33+
"type": "github",
34+
"url": "https://github.com/sponsors/roadrunner-server"
35+
}
36+
],
837
"require": {
938
"php": ">=8.0",
10-
"cycle/orm": "^2.0"
39+
"psr/simple-cache": "^2.0 || ^3.0",
40+
"psr/container": "^1.0 || ^2.0",
41+
"webmozart/glob": "^4.6",
42+
"spiral/files": "^3.11",
43+
"cycle/orm": "^2.0",
44+
"cycle/schema-renderer": "^1.2"
1145
},
1246
"require-dev": {
13-
"phpunit/phpunit": "^10.0",
14-
"vimeo/psalm": "^5.6"
47+
"roave/security-advisories": "dev-latest",
48+
"phpunit/phpunit": "^9.6",
49+
"friendsofphp/php-cs-fixer": "^3.48",
50+
"vimeo/psalm": "^4.30.0 || ^5.21",
51+
"yiisoft/test-support": "^3.0"
1552
},
1653
"autoload": {
1754
"psr-4": {
@@ -22,5 +59,7 @@
2259
"psr-4": {
2360
"Cycle\\Schema\\Provider\\Tests\\": "tests/"
2461
}
25-
}
62+
},
63+
"minimum-stability": "dev",
64+
"prefer-stable": true
2665
}

phpunit.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4-
bootstrap="tests/bootstrap.php"
54
backupGlobals="false"
65
backupStaticAttributes="false"
76
colors="true"
@@ -19,7 +18,7 @@
1918
</include>
2019
</coverage>
2120
<testsuites>
22-
<testsuite name="Cycle: DataMapper and ORM">
21+
<testsuite name="Cycle: Schema Provider">
2322
<directory>./tests/</directory>
2423
</testsuite>
2524
</testsuites>

psalm.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?xml version="1.0"?>
22
<psalm
3-
errorLevel="4"
3+
errorLevel="2"
44
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xmlns="https://getpsalm.org/schema/config"
66
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
7+
findUnusedBaselineEntry="true"
8+
findUnusedCode="false"
79
>
810
<projectFiles>
911
<directory name="src" />
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Cycle\Schema\Provider\Exception;
6+
7+
class BadDeclarationException extends \Exception
8+
{
9+
/**
10+
* @param non-empty-string $parameter
11+
* @param class-string $class
12+
*/
13+
public function __construct(string $parameter, string $class, mixed $argument)
14+
{
15+
$type = \is_object($argument)
16+
? 'Instance of ' . \get_class($argument)
17+
: \ucfirst(\get_debug_type($argument));
18+
parent::__construct(\sprintf(
19+
'%s should be instance of %s or its declaration. %s was received instead.',
20+
$parameter,
21+
$class,
22+
$type
23+
));
24+
}
25+
}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Cycle\Schema\Provider\Exception;
6+
7+
final class ConfigurationException extends \InvalidArgumentException
8+
{
9+
}

src/Exception/CumulativeException.php

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Cycle\Schema\Provider\Exception;
6+
7+
final class CumulativeException extends \RuntimeException
8+
{
9+
/**
10+
* @var array<\Throwable>
11+
*/
12+
private array $exceptions;
13+
14+
public function __construct(\Throwable ...$exceptions)
15+
{
16+
$this->exceptions = $exceptions;
17+
$count = count($exceptions);
18+
$message = $count === 1 ? 'One exception was thrown.' : $count . ' exceptions were thrown.';
19+
parent::__construct($message . $this->getMessageDetails());
20+
}
21+
22+
/**
23+
* @return array<\Throwable>
24+
*/
25+
public function getExceptions(): array
26+
{
27+
return $this->exceptions;
28+
}
29+
30+
private function getMessageDetails(): string
31+
{
32+
$result = '';
33+
$num = 0;
34+
foreach ($this->exceptions as $exception) {
35+
$result .= \sprintf(
36+
"\n\n%d) %s:%s\n[%s] #%d: %s",
37+
++$num,
38+
$exception->getFile(),
39+
$exception->getLine(),
40+
\get_class($exception),
41+
$exception->getCode(),
42+
$exception->getMessage()
43+
);
44+
}
45+
return $result;
46+
}
47+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Cycle\Schema\Provider\Exception;
6+
7+
final class DuplicateRoleException extends \LogicException
8+
{
9+
public function __construct(string $role)
10+
{
11+
parent::__construct(\sprintf('The `%s` role already exists in the DB schema.', $role));
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Cycle\Schema\Provider\Exception;
6+
7+
final class SchemaFileNotFoundException extends \RuntimeException
8+
{
9+
public function __construct(string $file)
10+
{
11+
parent::__construct(\sprintf('Schema file `%s` not found.', $file));
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Cycle\Schema\Provider\Exception;
6+
7+
final class SchemaProviderException extends \RuntimeException
8+
{
9+
}

0 commit comments

Comments
 (0)