Skip to content

Commit d87fdca

Browse files
authored
feat: Unlock intellisense for the finder component (#1104)
1 parent 1b67fdc commit d87fdca

File tree

4 files changed

+30
-25
lines changed

4 files changed

+30
-25
lines changed

.github/ISSUE_TEMPLATE/Bug_report.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ For general support, please use the #humbug Slack channel: https://symfony.com/s
2929

3030
<details>
3131
<summary>scoper.inc.php</summary>
32-
32+
3333
```php
3434
<?php
35-
35+
3636
declare(strict_types=1);
37-
38-
use Isolated\Symfony\Component\Finder\Finder;
39-
37+
38+
/** @var Symfony\Component\Finder\Finder $finder */
39+
$finder = Isolated\Symfony\Component\Finder\Finder::class;
40+
4041
return [
4142
];
4243

@@ -45,7 +46,7 @@ For general support, please use the #humbug Slack channel: https://symfony.com/s
4546

4647
<details>
4748
<summary>Output</summary>
48-
49+
4950
```bash
5051
$ command
5152
> output

docs/configuration.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ Complete configuration reference (details about each entry is available):
2525

2626
// scoper.inc.php
2727

28-
use Isolated\Symfony\Component\Finder\Finder;
28+
/** @var Symfony\Component\Finder\Finder $finder */
29+
$finder = Isolated\Symfony\Component\Finder\Finder::class;
2930

3031
return [
3132
'prefix' => null, // string|null
@@ -39,11 +40,11 @@ return [
3940
'exclude-constants' => [], // list<string|regex>
4041
'exclude-classes' => [], // list<string|regex>
4142
'exclude-functions' => [], // list<string|regex>
42-
43+
4344
'expose-global-constants' => true, // bool
4445
'expose-global-classes' => true, // bool
4546
'expose-global-functions' => true, // bool
46-
47+
4748
'expose-namespaces' => [], // list<string|regex>
4849
'expose-constants' => [], // list<string|regex>
4950
'expose-classes' => [], // list<string|regex>
@@ -60,7 +61,7 @@ then a random prefix will be automatically generated.
6061

6162
### PHP Version
6263

63-
The PHP version provided is used to configure the underlying [PHP-Parser] Parser and Printer.
64+
The PHP version provided is used to configure the underlying [PHP-Parser] Parser and Printer.
6465

6566
The version used by the Parser will affect what code it can understand, e.g. if it is configured in PHP 8.2 it will not
6667
understand a PHP 8.3 construct (e.g. typed class constants). However, what symbols are interpreted as internal will
@@ -95,12 +96,13 @@ files should be scoped by using [Finders][symfony_finder] in the configuration:
9596

9697
// scoper.inc.php
9798

98-
use Isolated\Symfony\Component\Finder\Finder;
99+
/** @var Symfony\Component\Finder\Finder $finder */
100+
$finder = Isolated\Symfony\Component\Finder\Finder::class;
99101

100102
return [
101103
'finders' => [
102-
Finder::create()->files()->in('src'),
103-
Finder::create()
104+
$finder::create()->files()->in('src'),
105+
$finder::create()
104106
->files()
105107
->ignoreVCS(true)
106108
->notName('/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.json|composer\\.lock/')
@@ -113,7 +115,7 @@ return [
113115
'vendor-bin',
114116
])
115117
->in('vendor'),
116-
Finder::create()->append([
118+
$finder::create()->append([
117119
'bin/php-scoper',
118120
'composer.json',
119121
])
@@ -129,7 +131,7 @@ php-scoper add-prefix file1.php bin/file2.php
129131

130132
Paths added manually are appended to the paths found by the finders.
131133

132-
If you are using [Box][box], all the (non-binary) files included are used
134+
If you are using [Box][box], all the (non-binary) files included are used
133135
instead of the `finders` setting.
134136

135137

@@ -232,7 +234,7 @@ return [
232234
```
233235

234236
This enriches the list of Symbols PHP-Scoper's Reflector considers as "internal",
235-
i.e. PHP engine or extension symbols. Such symbols will be left completely
237+
i.e. PHP engine or extension symbols. Such symbols will be left completely
236238
untouched.*
237239

238240
*: There is _one_ exception, which is declarations of functions. If you have the function
@@ -337,7 +339,7 @@ Notes:
337339
- An excluded symbol will not be exposed. If for example you expose the class
338340
`Acme\Foo` but the `Acme` namespace is excluded, then `Acme\Foo` will NOT
339341
be exposed.
340-
- Exposing a namespace also exposes its sub-namespaces (with the aforementioned
342+
- Exposing a namespace also exposes its sub-namespaces (with the aforementioned
341343
note applying)
342344
- Exposing symbols will most likely require PHP-Scoper to adjust the Composer
343345
autoloader. To do so with minimal conflicts, PHP-Scoper dumps everything
@@ -358,7 +360,7 @@ The namespace configuration is identical to [excluding namespaces](#excluding-na
358360

359361
How the symbols are exposed is done as described in the next sections. Note
360362
however that some symbols cannot be exposed (see [exposing/excluding traits](limitations.md#exposingexcluding-traits)
361-
and [exposing/excluding enums](limitations.md#exposingexcluding-enums))
363+
and [exposing/excluding enums](limitations.md#exposingexcluding-enums))
362364

363365

364366
### Exposing classes

docs/further-reading.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ supported and that is the views. However, this can be fixed by hand without too
7777
// scoper.inc.php
7878
<?php declare(strict_types=1);
7979

80-
use Isolated\Symfony\Component\Finder\Finder;
80+
/** @var Symfony\Component\Finder\Finder $finder */
81+
$finder = Isolated\Symfony\Component\Finder\Finder::class;
8182

8283
$consoleViewFiles = array_map(
8384
static fn (SplFileInfo $fileInfo) => $fileInfo->getPathname(),
8485
iterator_to_array(
85-
Finder::create()
86+
$finder::create()
8687
->in('vendor/laravel/framework/src/Illuminate/Console/resources/views')
8788
->files(),
8889
false,

src/scoper.inc.php.tpl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
declare(strict_types=1);
44

5-
use Isolated\Symfony\Component\Finder\Finder;
5+
/** @var Symfony\Component\Finder\Finder $finder */
6+
$finder = Isolated\Symfony\Component\Finder\Finder::class;
67

78
// You can do your own things here, e.g. collecting symbols to expose dynamically
89
// or files to exclude.
@@ -16,7 +17,7 @@ use Isolated\Symfony\Component\Finder\Finder;
1617
// $excludedFiles = array_map(
1718
// static fn (SplFileInfo $fileInfo) => $fileInfo->getPathName(),
1819
// iterator_to_array(
19-
// Finder::create()->files()->in(__DIR__),
20+
// $finder::create()->files()->in(__DIR__),
2021
// false,
2122
// ),
2223
// );
@@ -42,8 +43,8 @@ return [
4243
// For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#finders-and-paths
4344
'finders' => [
4445
/*
45-
Finder::create()->files()->in('src'),
46-
Finder::create()
46+
$finder::create()->files()->in('src'),
47+
$finder::create()
4748
->files()
4849
->ignoreVCS(true)
4950
->notName('/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.json|composer\\.lock/')
@@ -56,7 +57,7 @@ return [
5657
'vendor-bin',
5758
])
5859
->in('vendor'),
59-
Finder::create()->append([
60+
$finder::create()->append([
6061
'composer.json',
6162
]),
6263
*/

0 commit comments

Comments
 (0)