Download the PHP package reedware/is-attribute without Composer

On this page you can find all versions of the php package reedware/is-attribute. 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 is-attribute

Is Attribute

Automated Tests Coding Standards Code Coverage Static Analysis Latest Stable Version

This package adds a truth test helper for checking if class is an attribute.

Introduction

PHP Attributes were introduced in PHP 8.0. From the documentation, you can see that Attributes are defined similar to classes:

However, if you're handed the name of a class, there's no good way to know if that class is a PHP Attribute or not. This is where the is_attribute() method, as defined by this package, comes in.

Installation

Install this package using Composer:

Usage

Class Argument

Let's start with the basics. For more use-cases, you'll only need to pass one parameter to is_attribute(), being the class itself.

Here's an example of that:

Target Argument

If you care what targets the attributes support, this is where an optional second parameter comes in.

For example, you can define an attribute like so:

This defines a Serialize attribute that can applied to a class or property.

To check if an attribute can be applied to a class or property, you can pass in targets as the second parameter to is_attribute:

Note that checking one or the other will return false:

When the second argument is not specified (e.g. null), the specified class must simply be an Attribute, regardless of target. This is different from passing in Attribute::TARGET_ALL as the second argument, which will require the attribute to specify all targets (which is the default).

This is because the second parameter must be an exact match to the attribute.

Match Argument

If you don't want to do an exact match, you can use the optional third parameter.

TARGET_MATCH_EQUALS

This is the default value of the third argument, and exhibits the behavior already described above.

TARGET_MATCH_INCLUDES

This match setting requires ALL of the provided targets to be included (e.g. and/conjunction).

TARGET_MATCH_ANY

This match setting requires ANY of the provided targets to be included (e.g. or/disjunction).


All versions of is-attribute with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
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 reedware/is-attribute contains the following files

Loading the files please wait ....