PHPackages                             sematico/wp-phpscoper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. sematico/wp-phpscoper

ActiveLibrary

sematico/wp-phpscoper
=====================

0.1.0(1y ago)41151[1 PRs](https://github.com/alessandrotesoro/wp-phpscoper/pulls)MITPHP

Since Jun 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/alessandrotesoro/wp-phpscoper)[ Packagist](https://packagist.org/packages/sematico/wp-phpscoper)[ RSS](/packages/sematico-wp-phpscoper/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (12)Versions (2)Used By (0)

ℹ️ WP-PHPScoper
===============

[](#ℹ️-wp-phpscoper)

This package provides an opinionated PHP-Scoper configuration for WordPress plugins. Built-in CLI commands are provided to generate exclusions and to install php-scoper.

The package has been built for my own projects and it has been open-sourced in the hope that it will be useful to others.

- [ℹ️ WP-PHPScoper](#%E2%84%B9%EF%B8%8F-wp-phpscoper)
    - [📦 Installation](#-installation)
    - [📝 Usage](#-usage)
        - [Setup](#setup)
        - [Exclusions](#exclusions)
        - [About the exclusions](#about-the-exclusions)
            - [WordPress](#wordpress)
    - [⚙️ Scoper Configuration](#%EF%B8%8F-scoper-configuration)
        - [`Configurator::makeFinder()`](#configuratormakefinder)
        - [`Configurator::addFinder()`](#configuratoraddfinder)
        - [`Configurator::getScoperConfiguration()`](#configuratorgetscoperconfiguration)
    - [📄 Aknowledgements](#-aknowledgements)
    - [❔ Support](#-support)
    - [🚨 Security Issues](#-security-issues)
    - [🔖 License](#-license)

📦 Installation
--------------

[](#-installation)

Navigate to the folder of your WordPress plugin and run the following command:

```
composer require sematico/wp-phpscoper --dev
```

This will install the package and add the `php-scoper` binary to your project's `vendor/bin` directory.

📝 Usage
-------

[](#-usage)

### Setup

[](#setup)

To install php-scoper, run the following command:

```
vendor/bin/wp-phpscoper setup
```

This will run specific composer commands to install php-scoper.

### Exclusions

[](#exclusions)

To generate exclusions, run the following command:

```
vendor/bin/wp-phpscoper generate:exclusions
```

This will generate a list of exclusions for php-scoper. Follow the prompts to select the types of exclusions you want to generate.

### About the exclusions

[](#about-the-exclusions)

Exclusions are generated inside the `.phpscoper` folder in your project's root directory. The exclusions files are JSON files that contain an array of classes, functions, and constants that should be excluded from being scoped.

The currently supported exclusions are:

- `WordPress`

#### WordPress

[](#wordpress)

WordPress exclusions are generated by using the `php-stubs/wordpress-globals` and `php-stubs/wordpress-stubs` packages. Your plugin must have those packages installed in order for the exclusions to be generated.

Attempting to generate exclusions for a plugin that does not have those packages installed will result in an error.

⚙️ Scoper Configuration
-----------------------

[](#️-scoper-configuration)

The package provides a `Configurator` class that can be used to generate the scoper configuration file.

```
