Skip to content

Commit e0c0b31

Browse files
committed
Add initial stub
1 parent f20a1bb commit e0c0b31

File tree

6 files changed

+141
-0
lines changed

6 files changed

+141
-0
lines changed

.gitattributes

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# https://php.watch/articles/composer-gitattributes
2+
3+
# Exclude build/test files from archive
4+
/.github export-ignore
5+
/build export-ignore
6+
/tests export-ignore
7+
/.gitattributes export-ignore
8+
/.gitignore export-ignore
9+
/phpunit.xml.dist export-ignore
10+
11+
# Configure diff output for .php and .phar files.
12+
*.php diff=php

.github/workflows/ci.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
on:
2+
- pull_request
3+
- push
4+
5+
name: CI
6+
7+
jobs:
8+
tests:
9+
name: Tests
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
matrix:
14+
os:
15+
- ubuntu-latest
16+
- windows-latest
17+
php:
18+
- "7.1"
19+
- "7.2"
20+
- "7.3"
21+
- "7.4"
22+
- "8.0"
23+
- "8.1"
24+
- "8.2"
25+
- "8.3"
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Install PHP with extensions
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: ${{ matrix.php }}
35+
coverage: pcov
36+
ini-values: assert.exception=1, zend.assertions=1
37+
38+
- name: Install composer dependencies
39+
run: composer update --no-ansi --no-interaction --no-progress
40+
41+
- name: Run tests with phpunit
42+
run: vendor/bin/phpunit

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vendor/
2+
/build/
3+
composer.lock

README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# `array_find`, `array_find_key`, `array_any` and `array_all` polyfills
2+
3+
[![Latest Stable Version](https://poser.pugx.org/polyfills/array-find/v)](https://packagist.org/packages/polyfills/array-find) [![License](https://poser.pugx.org/polyfills/array-find/license)](https://packagist.org/packages/polyfills/array-find) [![PHP Version Require](https://poser.pugx.org/polyfills/array-find/require/php)](https://packagist.org/packages/polyfills/array-find)
4+
5+
Provides user-land PHP polyfills for the `array_find`, `array_find_key`, `array_any` and `array_all` functions added in PHP 8.4.
6+
7+
Requires PHP 7.1 or later. Not supported on PHP 8.4 because these functions are natively implemented in PHP 8.4.
8+
9+
## Installation
10+
11+
```bash
12+
composer require polyfills/array-find
13+
```
14+
15+
## Usage
16+
17+
Simply use the `array_find`, `array_find_key`, `array_any` and `array_all` functions as if they were declared already.
18+
19+
## Contributions
20+
21+
Contributions are welcome either as a GitHub issue or a PR to this repo.
22+

composer.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "polyfills/array-find",
3+
"description": "PHP: Provides a user-land polyfill for `array_find`, `array_find_key`, `array_any` and `array_all` functions added in PHP 8.4.",
4+
"type": "library",
5+
"homepage": "https://php.watch/versions/8.4/array_find-array_find_key-array_any-array_all",
6+
"keywords": ["php84", "phpwatch", "polyfills", "polyfill", "compatibility", "compat", "shim"],
7+
"require": {
8+
"php": "^8.0"
9+
},
10+
"require-dev": {
11+
"phpunit/phpunit": "^10.5.20"
12+
},
13+
"conflict": {
14+
"php": "^8.4"
15+
},
16+
"license": "MIT",
17+
"autoload": {
18+
"files": [
19+
"src/array_find.php"
20+
]
21+
},
22+
"authors": [
23+
{
24+
"name": "Ayesh Karunaratne",
25+
"email": "[email protected]"
26+
}
27+
]
28+
}

phpunit.xml.dist

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
executionOrder="depends,defects"
6+
beStrictAboutOutputDuringTests="true"
7+
colors="true"
8+
cacheDirectory=".phpunit.cache"
9+
failOnWarning="true"
10+
failOnRisky="true"
11+
failOnDeprecation="true"
12+
failOnIncomplete="true"
13+
failOnNotice="true"
14+
failOnEmptyTestSuite="true"
15+
beStrictAboutChangesToGlobalState="true"
16+
testdox="true"
17+
beStrictAboutCoverageMetadata="true">
18+
<testsuites>
19+
<testsuite name="default">
20+
<directory>tests</directory>
21+
</testsuite>
22+
</testsuites>
23+
<coverage>
24+
<report>
25+
<html outputDirectory="build/coverage-html"/>
26+
<text outputFile="php://stdout"/>
27+
</report>
28+
</coverage>
29+
<source>
30+
<include>
31+
<directory>src</directory>
32+
</include>
33+
</source>
34+
</phpunit>

0 commit comments

Comments
 (0)