Download the PHP package serafim/dbc without Composer

On this page you can find all versions of the php package serafim/dbc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dbc

Contracts

Contracts for PHP, is a contract programming framework and test tool for PHP, which uses attributes to provide run-time checking. (In particular, this is not a static analysis tool.)

Latest Stable Version Latest Unstable Version Total Downloads License MIT

Contents

Requirements

Installation

Library is available as composer repository and can be installed using the following command in a root of your project.

Configuration

By default, the behavior of contracts depends on whether assertions (assert.active in php.ini configuration) are enabled on your system.

However, you can force them to enable or disable contracts:

By default, the framework does not listen to any namespaces. To add a namespace for your application, use the Runtime::listen() method.

In addition, you can specify the directory where the cache files should be stored.

Please note that these cache files are included by the PHP, therefore they are cached by opcache extension and do not degrade performance.

Usage

Contracts are written as PHP code within quoted strings, embedded in attributes. E.g., #[Verify('$x < 100')] states that $x must be less than 100. Any PHP expression, except anonymous classes, may be used, provided the string is properly escaped.

An annotation binds a contract to a code element: either a method or a class. Library defines three main annotation types, which live in the Serafim\Contracts\Attribute namespace:

Contract annotations work only (yet) with classes.

Invariants

A class may have associated invariants. Instead of specifying a contract between a caller and a callee, those invariants describe the state of a valid object of the qualified type. Calling methods on an object may cause it to change; invariants guarantee that after any such change, the object remains in a consistent state.

Of course, internal operations are allowed to muck around and temporarily invalidate invariants to do their job, but they agree to eventually put everything back into their proper places. Intuitively, any operation made against this is considered internal and does not need to obey the invariants. Only method invocations on other variables do.

Any defined invariant in a class has access to all of its fields, including any protected and private.

When determining such an invariant, the account's balance will always be greater or equal than zero.

Method contracts

A method may have preconditions and postconditions attached to it. Together, they specify the contract between caller and callee: if the precondition is satisfied on entry of the method, then the caller may assume the postcondition on exit. The precondition is what the callee demands of the caller, and in return the caller expects the postcondition to hold after the call.

As an example, consider the following specification of the square root function, which states that for any non-negative double x given, sqrt will return a non-negative result.

As shown in this example, a precondition may access parameter values; in fact, preconditions and postconditions are evaluated in the context of the method they are bound to. More precisely, each annotation behaves as if it were a method, with the same arguments and in the same scope as the qualified method. In terms of scoping, the previous code is equivalent to the following:

In addition, postconditions may contain a few extensions:

At run time, when contracts are enabled, preconditions and postconditions translate to checks on entry and exit, respectively, of the method. A failure results in a PreconditionException or PostconditionException being thrown, depending on the origin: failure to meet a precondition means that the method was called incorrectly, whereas an unsatisfied postcondition points to a bug in the implementation of the method itself.

Keywords

Keyword May appear in Description
$old #[Ensure] Value on method entry
$result #[Ensure] Value to be returned

Features


All versions of dbc with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
nikic/php-parser Version ^4.13
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package serafim/dbc contains the following files

Loading the files please wait ....