Download the PHP package adeptoas/sniff-array without Composer

On this page you can find all versions of the php package adeptoas/sniff-array. 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 sniff-array

SniffArray

This is a lightweight library to check if a given array conforms to a certain specification

Installation

Add this to composer.json:

Make sure to merge your require-blocks!

Usage

ArraySniffer

Initialize an ArraySniffer with the given spec. Error handling can be specified via throw, else every sniff will simply return false.

Start checking array for conformity in respect to the current ArraySniffer instance's specification.

Check if array conforms to spec. This does the same as calling sniff on an ArraySniffer instance, but is mainly for one-time-only checks

SplSniffer

This library provides several sniffers for primitive / SPL types in PHP. They are mainly needed for internal verification purposes, but you can use them as stand-alone verification sniffers if you want to.

Return a subclass of SplSniffer suitable for checking conformity to type.

Check if val conforms to the specification implied by the current SplSniffer instance's type. isStrict specifies if certain edge cases should be deemed valid or not (see below for further explanation)

Specification

Base types

The basic type identifications delivered with this library are

Some common aliases are also implemented:

Strict specifications are denoted by the type followed by an exclamation sign ! and narrow down the possible accepted values. In particular:

array as primitive specification simply denotes any arbitrary array of whatever form, while an explicitly specified nested array specification demands exact matches

Array specifications

Any array specification is itself arranged as an associative array.

for example is a valid specification for

Specifications can of course be nested.

matches for example

but (obviously) not

Specification keys can be appended by some RegExp-like features to expand matching functionality, namely:

Keys that allow for 0 matches by use of this RegExp typeset can either be explicitly set to null or implicitly dropped.

These RegExp rules can of course also be applied to nested array specification structures.

matches

as well as

Multiple types can be joined by using the bar | sign. This does not infer with any of the other type rules.

is a valid specification for

as well as

and

Arrays that are sequential at root level can be checked for specification match by using the key __root. This can be especially useful for bulk mode handling a given specification

matches

Colon notation

Some Sniffers, particularly StringSniffer, ObjectSniffer and MixedArraySniffer, support specifying additional sniff data via the usage of ::

This colon "operator" supports multiple repeated arguments. The effect of an argument is specified by the respective Sniffer class.

For StringSniffer, the colon data can be used to specify a matching regular expression (RegExp). The conformity to this RegExp will be checked in addition to the usual check by using preg_match as specified in the PHP standard library

matches

but not

Please note that the RegExp will automatically be wrapped in convenient PCRE bounds, (i.e. //) if not wrapped already

For ObjectSniffer, the colon data can be used to specify instance class names. They can be fully namespaced, but standard "short name" checks will also be performed.

matches

but neither

nor

Please also note that multiple classes can be specified using the same colon :: operator in a repeated fashion

accounts for both

and

For MixedArraySniffer, the colon data can be used to specify whether an associative or a sequential array is desired.

matches

but not

whereas the specification

matches

but not the values example from above. Common aliases seq for sequential and assoc for associative are installed for convenience, so that

is a valid specification. More than one specified array type will be discarded and sniffed as false or throw an exception, respectively.

Examples

Examples will be added to the Examples/ directory once I come up with meaningful examples that don't involve confidential data from my dayjob.


All versions of sniff-array with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
ext-json Version *
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 adeptoas/sniff-array contains the following files

Loading the files please wait ....