Skip to content

Commit 95068d4

Browse files
committedMar 1, 2023
Merge branch 'master' into taint_analysis
2 parents c718d39 + 0b42a51 commit 95068d4

21 files changed

+1457
-831
lines changed
 

‎.github/workflows/test.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Tests
22

33
on:
4+
workflow_dispatch:
45
push:
56
paths:
67
- '**.php'
@@ -20,6 +21,7 @@ on:
2021
jobs:
2122

2223
unit_tests:
24+
name: Unit tests
2325
runs-on: ubuntu-latest
2426
steps:
2527
- name: Checkout code
@@ -53,7 +55,7 @@ jobs:
5355
exclude:
5456
- php: 8.0
5557
laravel: ^10.0
56-
name: P${{ matrix.php }} | L${{ matrix.laravel }} | ${{ matrix.dependencies == 'highest' && '↑' || '↓' }}
58+
name: Acceptance P${{ matrix.php }} | L${{ matrix.laravel }} | ${{ matrix.dependencies == 'highest' && '↑' || '↓' }}
5759
steps:
5860
- name: Checkout code
5961
uses: actions/checkout@v3
@@ -62,8 +64,9 @@ jobs:
6264
uses: shivammathur/setup-php@v2
6365
with:
6466
php-version: ${{ matrix.php }}
67+
ini-values: opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=256M
6568
coverage: none
66-
tools: composer:v2
69+
tools: composer
6770

6871
- name: Install lowest dependencies from composer.json
6972
if: "matrix.dependencies == 'lowest'"

‎composer.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
"require": {
1414
"php": "^8.0.2",
1515
"ext-simplexml": "*",
16-
"barryvdh/laravel-ide-helper": "^2.12",
17-
"illuminate/config": "^9.48 || ^10.0.0",
18-
"illuminate/container": "^9.48 || ^10.0.0",
19-
"illuminate/contracts": "^9.48 || ^10.0.0",
20-
"illuminate/database": "^9.48 || ^10.0.0",
21-
"illuminate/events": "^9.48 || ^10.0.0",
22-
"illuminate/http": "^9.48 || ^10.0.0",
23-
"illuminate/routing": "^9.48 || ^10.0.0",
24-
"illuminate/support": "^9.48 || ^10.0.0",
25-
"illuminate/view": "^9.48 || ^10.0.0",
16+
"barryvdh/laravel-ide-helper": "^2.13",
17+
"illuminate/config": "^9.48 || ^10.0",
18+
"illuminate/container": "^9.48 || ^10.0",
19+
"illuminate/contracts": "^9.48 || ^10.0",
20+
"illuminate/database": "^9.48 || ^10.0",
21+
"illuminate/events": "^9.48 || ^10.0",
22+
"illuminate/http": "^9.48 || ^10.0",
23+
"illuminate/routing": "^9.48 || ^10.0",
24+
"illuminate/support": "^9.48 || ^10.0",
25+
"illuminate/view": "^9.48 || ^10.0",
2626
"nikic/php-parser": "^4.13",
27-
"orchestra/testbench": "^7.19 || ^8.0.0",
27+
"orchestra/testbench": "^7.19 || ^8.0",
2828
"symfony/console": "^6.0",
2929
"vimeo/psalm": "^4.30 || ^5.1"
3030
},
@@ -34,7 +34,7 @@
3434
"codeception/module-cli": "^2.0",
3535
"codeception/module-filesystem": "^3.0",
3636
"codeception/module-phpbrowser": "^3.0",
37-
"phpunit/phpunit": "^9.5",
37+
"phpunit/phpunit": "^9.6 || ^10.0",
3838
"ramsey/collection": "^1.3",
3939
"slevomat/coding-standard": "^8.8",
4040
"squizlabs/php_codesniffer": "*",

‎phpunit.xml

+12-16
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
<?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/9.5/phpunit.xsd"
4-
bootstrap="vendor/autoload.php"
5-
cacheResultFile=".phpunit.cache/test-results"
6-
executionOrder="depends,defects"
7-
forceCoversAnnotation="true"
8-
beStrictAboutCoversAnnotation="true"
9-
beStrictAboutOutputDuringTests="true"
10-
beStrictAboutTodoAnnotatedTests="true"
11-
convertDeprecationsToExceptions="true"
12-
failOnRisky="true"
13-
failOnWarning="true"
14-
verbose="true">
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
5+
bootstrap="vendor/autoload.php"
6+
executionOrder="depends,defects"
7+
beStrictAboutOutputDuringTests="true"
8+
failOnRisky="true"
9+
failOnWarning="true"
10+
cacheDirectory=".phpunit.cache"
11+
requireCoverageMetadata="true"
12+
beStrictAboutCoverageMetadata="true">
1513
<testsuites>
1614
<testsuite name="default">
1715
<directory>tests/Unit</directory>
1816
</testsuite>
1917
</testsuites>
20-
21-
<coverage cacheDirectory=".phpunit.cache/code-coverage"
22-
processUncoveredFiles="true">
18+
<coverage>
2319
<include>
2420
<directory suffix=".php">src</directory>
2521
</include>

‎src/Plugin.php

+16-2
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,23 @@ public function __invoke(RegistrationInterface $registration, ?SimpleXMLElement
5050
protected function getCommonStubs(): array
5151
{
5252
return array_merge(
53+
glob(dirname(__DIR__) . '/stubs/Collections/*.stubphp'),
5354
glob(dirname(__DIR__) . '/stubs/Contracts/*.stubphp'),
5455
glob(dirname(__DIR__) . '/stubs/Database/*.stubphp'),
56+
glob(dirname(__DIR__) . '/stubs/Foundation/*.stubphp'),
5557
glob(dirname(__DIR__) . '/stubs/Http/*.stubphp'),
58+
glob(dirname(__DIR__) . '/stubs/legacy-factories/*.stubphp'),
5659
glob(dirname(__DIR__) . '/stubs/Lumen/*.stubphp'),
5760
glob(dirname(__DIR__) . '/stubs/Pagination/*.stubphp'),
5861
glob(dirname(__DIR__) . '/stubs/Support/*.stubphp'),
59-
glob(dirname(__DIR__) . '/stubs/*.stubphp')
62+
);
63+
}
64+
65+
/** @return array<array-key, string> */
66+
protected function getTaintAnalysisStubs(): array
67+
{
68+
return array_merge(
69+
glob(dirname(__DIR__) . '/stubs/TaintAnalysis/Http/*.stubphp'),
6070
);
6171
}
6272

@@ -65,14 +75,18 @@ protected function getStubsForVersion(string $version): array
6575
{
6676
[$majorVersion] = explode('.', $version);
6777

68-
return glob(dirname(__DIR__) . '/stubs/' . $majorVersion . '/*.stubphp');
78+
return array_merge(
79+
glob(dirname(__DIR__) . '/stubs/' . $majorVersion . '/*.stubphp'),
80+
glob(dirname(__DIR__) . '/stubs/' . $majorVersion . '/**/*.stubphp'),
81+
);
6982
}
7083

7184
private function registerStubs(RegistrationInterface $registration): void
7285
{
7386
$stubs = array_merge(
7487
$this->getCommonStubs(),
7588
$this->getStubsForVersion(Application::VERSION),
89+
$this->getTaintAnalysisStubs(),
7690
);
7791

7892
foreach ($stubs as $stubFilePath) {

‎stubs/9/Foundation/helpers.stubphp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
/**
4+
* Dispatch a command to its appropriate handler in the current process.
5+
*
6+
* @param object|callable $job
7+
* @param mixed $handler
8+
* @return mixed
9+
*
10+
* @deprecated Will be removed in a future Laravel version.
11+
*/
12+
function dispatch_now($job, $handler = null) {}

‎stubs/Collections/helpers.stubphp

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
/**
4+
* Stubs for {@see https://github.com/laravel/framework/blob/master/src/Illuminate/Collections/helpers.php}
5+
*/
6+
7+
// collect: nothing to stub
8+
9+
/**
10+
* Fill in data where it's missing.
11+
*
12+
* @template TTarget
13+
*
14+
* @param TTarget $target
15+
* @param string|array $key
16+
* @param mixed $value
17+
* @return mixed
18+
* @psalm-return TTarget is array ? array : TTarget
19+
*/
20+
function data_fill(&$target, $key, $value) {}
21+
22+
// data_get: nothing to stub
23+
24+
/**
25+
* Set an item on an array or object using dot notation.
26+
*
27+
* @template TTarget
28+
*
29+
* @param TTarget $target
30+
* @param string|array $key
31+
* @param mixed $value
32+
* @param bool $overwrite
33+
* @psalm-return TTarget is array ? array : TTarget
34+
*/
35+
function data_set(&$target, $key, $value, $overwrite = true) {}
36+
37+
/**
38+
* Get the first element of an array. Useful for method chaining.
39+
*
40+
* @template TValue
41+
* @template TParam of TValue[]
42+
* @param TParam $array
43+
* @return (TParam is non-empty-array ? TValue : false)
44+
*/
45+
function head($array) {}
46+
47+
/**
48+
* Get the last element from an array.
49+
*
50+
* @template TValue
51+
* @template TParam of TValue[]
52+
*
53+
* @param TParam $array
54+
* @return (TParam is non-empty-array ? TValue : false)
55+
*/
56+
function last($array) {}
57+
58+
/**
59+
* Return the default value of the given value.
60+
*
61+
* @template TValue
62+
* @template TClosureReturn
63+
*
64+
* @param mixed|(Closure(): TClosureReturn) $value
65+
* @param mixed ...$args
66+
* @return (TValue is Closure ? TClosureReturn : TValue)
67+
*/
68+
function value($value, ...$args) {}

0 commit comments

Comments
 (0)