Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 27, 2024 via composer

symfony/contracts v2.5.2

A set of abstractions extracted out of the Symfony components
Package summary
Share
0
issues
1
license
4
MIT
Package created
13 Jul 2018
Version published
27 Jun 2022
Maintainers
1
Total deps
4
Direct deps
3
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
4 Packages, Including:
psr/cache@3.0.0
psr/container@1.1.2
psr/event-dispatcher@1.0.0
symfony/contracts@v2.5.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

3
All Dependencies CSV
β“˜ This is a list of symfony/contracts 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
psr/cache3.0.06.01 kBMIT
prod
psr/container1.1.23.5 kBMIT
prod
psr/event-dispatcher1.0.04.17 kBMIT
prod

Visualizations

Frequently Asked Questions

What does symfony/contracts do?

Symfony/Contracts, a set of abstractions extracted from the Symfony components, are designed to build on semantic ideas that have proved useful within the Symfony components, and which have been implementatively tested. These contracts are small and consistent sets of PHP interfaces, traits, normative docblocks, and reference test suites where applicable. All contracts must have a proven implementation to enter this repository and are required to be backward compatible with existing Symfony components.

How do you use symfony/contracts?

You can utilize Symfony/Contracts to achieve loose coupling and interoperability in your coding. By using the interfaces provided as type hints within your code, you improve reusability as implementations that match the contracts can be utilized. It could be a Symfony component or another one provided by the PHP community at large. Here's an example of how that might look in your code:

// use the Cache contract
use Symfony\Contracts\Cache\CacheInterface;

// ...

public function someFunction(CacheInterface $cache)
{
    // use the cache service
    $value = $cache->get('some_key', function ($item) {
        // The code here will only run if there is no existing cache for 'some_key'
        $item->expiresAfter(3600);
        return 'Some expensive resource';
    });
}

In this code, you're using the CacheInterface from Symfony/Contracts as a type hint in a function. This means that you can pass in any implementation of the CacheInterface into this function, and it will work as expected.

Depending on their semantics, some interfaces can be combined with autowiring to seamlessly inject a service in your classes. Others might be valuable as labeling interfaces to hint at specific behavior that could be enabled when using autoconfiguration or manual service tagging.

Where are the symfony/contracts docs?

The Symfony/Contracts resources are available on the Symfony website. Documentation pertaining to Symfony/Contracts can be found at this URL: https://symfony.com/doc/current/components/contracts.html. In these documents, you can learn more details about what each contract does, and how to use them efficiently. Also, for contributing to the Symfony/Contracts project, you can crosscheck this link: https://symfony.com/doc/current/contributing/index.html. Any issues and pull requests can be reported and sent respectively in the main Symfony repository: https://github.com/symfony/symfony.