Skip to content

Commit 316e212

Browse files
committed
renamed Contract to Contracts
0 parents  commit 316e212

File tree

7 files changed

+191
-0
lines changed

7 files changed

+191
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
composer.lock
2+
phpunit.xml
3+
vendor/

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CHANGELOG
2+
=========
3+
4+
1.0.0
5+
-----
6+
7+
* added `Service\ResetInterface` to provides a way to reset an object to its initial state

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2018 Fabien Potencier
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is furnished
8+
to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
Symfony Contracts
2+
=================
3+
4+
A set of abstractions extracted out of the Symfony components.
5+
6+
Can be used to build on semantics that the Symfony components proved useful - and
7+
that already have battle tested implementations.
8+
9+
Design Principles
10+
-----------------
11+
12+
* contracts are split by domain, each into their own sub-namespaces;
13+
* contracts are small and consistent sets of PHP interfaces, traits, normative
14+
docblocks and reference test suites when applicable, etc.;
15+
* all contracts must have a proven implementation to enter this repository;
16+
* they must be backward compatible with existing Symfony components.
17+
18+
FAQ
19+
---
20+
21+
### How to use this package?
22+
23+
The abstractions in this package are useful to achieve loose coupling and
24+
interoperability. By using the provided interfaces as type hints, you are able
25+
to reuse any implementations that match their contracts. It could be a Symfony
26+
component, or another one provided by the PHP community at large.
27+
28+
Depending on their semantics, some interfaces can be combined with autowiring to
29+
seamlessly inject a service in your classes.
30+
31+
Others might be useful as labeling interfaces, to hint about a specific behavior
32+
that could be enabled when using autoconfiguration or manual service tagging (or
33+
any other means provided by your framework.)
34+
35+
### How is this different from PHP-FIG's PSRs?
36+
37+
When applicable, the provided contracts are built on top of PHP-FIG's PSR. We
38+
encourage relying on them and won't duplicate the effort. Still, the FIG has
39+
different goals and different processes. Here, we don't need to seek universal
40+
standards. Instead, we're providing abstractions that are compatible with the
41+
implementations provided by Symfony. This should actually also contribute
42+
positively to the PHP-FIG (from which Symfony is a member), by hinting the group
43+
at some abstractions the PHP world might like to take inspiration from.
44+
45+
### Why isn't this package split into several packages?
46+
47+
Putting all interfaces in one package eases discoverability and dependency
48+
management. Instead of dealing with a myriad of small packages and the
49+
corresponding matrix of versions, you just need to deal with one package and one
50+
version. Also when using IDE autocompletion or just reading the source code, it
51+
makes it easier to figure out which contracts are provided.
52+
53+
There are two downsides to this approach: you may have unused files in your
54+
`vendor/` directory, and in the future, it will be impossible to use two
55+
different sub-namespaces in different major versions of the package. For the
56+
"unused files" downside, it has no practical consequences: their file sizes are
57+
very small, and there is no performance overhead at all since they are never
58+
loaded. For major versions, this package follows the Symfony BC + deprecation
59+
policies, with an additional restriction to never remove deprecated interfaces.
60+
61+
Resources
62+
---------
63+
64+
* [Documentation](https://symfony.com/doc/current/components/contracts.html)
65+
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
66+
* [Report issues](https://github.com/symfony/symfony/issues) and
67+
[send Pull Requests](https://github.com/symfony/symfony/pulls)
68+
in the [main Symfony repository](https://github.com/symfony/symfony)

Service/ResetInterface.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Contracts\Service;
13+
14+
/**
15+
* Provides a way to reset an object to its initial state.
16+
*
17+
* When calling the "reset()" method on an object, it should be put back to its
18+
* initial state. This usually means clearing any internal buffers and forwarding
19+
* the call to internal dependencies. All properties of the object should be put
20+
* back to the same state it had when it was first ready to use.
21+
*
22+
* This method could be called, for example, to recycle objects that are used as
23+
* services, so that they can be used to handle several requests in the same
24+
* process loop (note that we advise making your services stateless instead of
25+
* implementing this interface when possible.)
26+
*/
27+
interface ResetInterface
28+
{
29+
public function reset();
30+
}

composer.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "symfony/contracts",
3+
"type": "library",
4+
"description": "A set of abstractions extracted out of the Symfony components",
5+
"keywords": ["abstractions", "contracts", "decoupling", "interfaces", "interoperability", "standards"],
6+
"homepage": "https://symfony.com",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Nicolas Grekas",
11+
"email": "[email protected]"
12+
},
13+
{
14+
"name": "Symfony Community",
15+
"homepage": "https://symfony.com/contributors"
16+
}
17+
],
18+
"require": {
19+
"php": "^7.1.3"
20+
},
21+
"autoload": {
22+
"psr-4": { "Symfony\\Contracts\\": "" },
23+
"exclude-from-classmap": [
24+
"**/Tests/"
25+
]
26+
},
27+
"minimum-stability": "dev",
28+
"extra": {
29+
"branch-alias": {
30+
"dev-master": "1.0-dev"
31+
}
32+
}
33+
}

phpunit.xml.dist

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
5+
backupGlobals="false"
6+
colors="true"
7+
bootstrap="vendor/autoload.php"
8+
failOnRisky="true"
9+
failOnWarning="true"
10+
>
11+
<php>
12+
<ini name="error_reporting" value="-1" />
13+
</php>
14+
15+
<testsuites>
16+
<testsuite name="Symfony Contracts Test Suite">
17+
<directory>./Tests/</directory>
18+
</testsuite>
19+
</testsuites>
20+
21+
<filter>
22+
<whitelist>
23+
<directory>./</directory>
24+
<exclude>
25+
<directory>./Tests</directory>
26+
<directory>./vendor</directory>
27+
</exclude>
28+
</whitelist>
29+
</filter>
30+
31+
</phpunit>

0 commit comments

Comments
 (0)