Skip to content

Commit 6494e09

Browse files
Install PHPStan using Composer in order to be able to use phpstan/phpstan-strict-rules
1 parent c92a16b commit 6494e09

File tree

82 files changed

+5988
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+5988
-1
lines changed

.phive/phars.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
<phar name="php-cs-fixer" version="^3.69" installed="3.70.2" location="./tools/php-cs-fixer" copy="true"/>
55
<phar name="humbug/php-scoper" version="^0.18" installed="0.18.17" location="./tools/php-scoper" copy="true"/>
66
<phar name="composer" version="^2.8" installed="2.8.6" location="./tools/composer" copy="true"/>
7-
<phar name="phpstan" version="^2.1" installed="2.1.6" location="./tools/phpstan" copy="true"/>
87
</phive>

build.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@
4848
<arg value="--no-progress"/>
4949
<arg value="update"/>
5050
</exec>
51+
52+
<exec executable="${basedir}/tools/composer" dir="${basedir}/tools/.phpstan" taskname="composer">
53+
<arg value="update"/>
54+
<arg value="--no-interaction"/>
55+
<arg value="--no-progress"/>
56+
<arg value="--no-ansi"/>
57+
</exec>
58+
59+
<exec executable="${basedir}/tools/composer" dir="${basedir}/tools/.phpstan" taskname="composer">
60+
<arg value="bump"/>
61+
<arg value="--no-interaction"/>
62+
<arg value="--no-ansi"/>
63+
</exec>
5164
</target>
5265

5366
<target name="generate-global-assert-wrappers" description="Generate global function wrappers for static methods in Assert and TestCase that are commonly used">

tools/.phpstan/composer.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"require-dev": {
3+
"phpstan/phpstan": "^2.1",
4+
"phpstan/extension-installer": "^1.4",
5+
"phpstan/phpstan-strict-rules": "^2.0"
6+
},
7+
"config": {
8+
"allow-plugins": {
9+
"phpstan/extension-installer": true
10+
}
11+
}
12+
}

tools/.phpstan/composer.lock

Lines changed: 173 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/.phpstan/vendor/autoload.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
// autoload.php @generated by Composer
4+
5+
if (PHP_VERSION_ID < 50600) {
6+
if (!headers_sent()) {
7+
header('HTTP/1.1 500 Internal Server Error');
8+
}
9+
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
10+
if (!ini_get('display_errors')) {
11+
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
12+
fwrite(STDERR, $err);
13+
} elseif (!headers_sent()) {
14+
echo $err;
15+
}
16+
}
17+
trigger_error(
18+
$err,
19+
E_USER_ERROR
20+
);
21+
}
22+
23+
require_once __DIR__ . '/composer/autoload_real.php';
24+
25+
return ComposerAutoloaderInitf9e7218f71d5874b5632927df4f72bd7::getLoader();

tools/.phpstan/vendor/bin/phpstan

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
/**
5+
* Proxy PHP file generated by Composer
6+
*
7+
* This file includes the referenced bin path (../phpstan/phpstan/phpstan)
8+
* using a stream wrapper to prevent the shebang from being output on PHP<8
9+
*
10+
* @generated
11+
*/
12+
13+
namespace Composer;
14+
15+
$GLOBALS['_composer_bin_dir'] = __DIR__;
16+
$GLOBALS['_composer_autoload_path'] = __DIR__ . '/..'.'/autoload.php';
17+
18+
if (PHP_VERSION_ID < 80000) {
19+
if (!class_exists('Composer\BinProxyWrapper')) {
20+
/**
21+
* @internal
22+
*/
23+
final class BinProxyWrapper
24+
{
25+
private $handle;
26+
private $position;
27+
private $realpath;
28+
29+
public function stream_open($path, $mode, $options, &$opened_path)
30+
{
31+
// get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
32+
$opened_path = substr($path, 17);
33+
$this->realpath = realpath($opened_path) ?: $opened_path;
34+
$opened_path = $this->realpath;
35+
$this->handle = fopen($this->realpath, $mode);
36+
$this->position = 0;
37+
38+
return (bool) $this->handle;
39+
}
40+
41+
public function stream_read($count)
42+
{
43+
$data = fread($this->handle, $count);
44+
45+
if ($this->position === 0) {
46+
$data = preg_replace('{^#!.*\r?\n}', '', $data);
47+
}
48+
49+
$this->position += strlen($data);
50+
51+
return $data;
52+
}
53+
54+
public function stream_cast($castAs)
55+
{
56+
return $this->handle;
57+
}
58+
59+
public function stream_close()
60+
{
61+
fclose($this->handle);
62+
}
63+
64+
public function stream_lock($operation)
65+
{
66+
return $operation ? flock($this->handle, $operation) : true;
67+
}
68+
69+
public function stream_seek($offset, $whence)
70+
{
71+
if (0 === fseek($this->handle, $offset, $whence)) {
72+
$this->position = ftell($this->handle);
73+
return true;
74+
}
75+
76+
return false;
77+
}
78+
79+
public function stream_tell()
80+
{
81+
return $this->position;
82+
}
83+
84+
public function stream_eof()
85+
{
86+
return feof($this->handle);
87+
}
88+
89+
public function stream_stat()
90+
{
91+
return array();
92+
}
93+
94+
public function stream_set_option($option, $arg1, $arg2)
95+
{
96+
return true;
97+
}
98+
99+
public function url_stat($path, $flags)
100+
{
101+
$path = substr($path, 17);
102+
if (file_exists($path)) {
103+
return stat($path);
104+
}
105+
106+
return false;
107+
}
108+
}
109+
}
110+
111+
if (
112+
(function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true))
113+
|| (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper'))
114+
) {
115+
return include("phpvfscomposer://" . __DIR__ . '/..'.'/phpstan/phpstan/phpstan');
116+
}
117+
}
118+
119+
return include __DIR__ . '/..'.'/phpstan/phpstan/phpstan';

0 commit comments

Comments
 (0)