Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4100102
Filter.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
Filter.php
View Options
<?php
declare
(
strict_types
=
1
);
/*
* This file is part of phpunit/php-code-coverage.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
SebastianBergmann\CodeCoverage
;
use
function
array_keys
;
use
function
is_file
;
use
function
realpath
;
use
function
strpos
;
use
SebastianBergmann\FileIterator\Facade
as
FileIteratorFacade
;
final
class
Filter
{
/**
* @psalm-var array<string,true>
*/
private
$files
=
[];
/**
* @psalm-var array<string,bool>
*/
private
$isFileCache
=
[];
public
function
includeDirectory
(
string
$directory
,
string
$suffix
=
'.php'
,
string
$prefix
=
''
):
void
{
foreach
((
new
FileIteratorFacade
)->
getFilesAsArray
(
$directory
,
$suffix
,
$prefix
)
as
$file
)
{
$this
->
includeFile
(
$file
);
}
}
/**
* @psalm-param list<string> $files
*/
public
function
includeFiles
(
array
$filenames
):
void
{
foreach
(
$filenames
as
$filename
)
{
$this
->
includeFile
(
$filename
);
}
}
public
function
includeFile
(
string
$filename
):
void
{
$filename
=
realpath
(
$filename
);
if
(!
$filename
)
{
return
;
}
$this
->
files
[
$filename
]
=
true
;
}
public
function
excludeDirectory
(
string
$directory
,
string
$suffix
=
'.php'
,
string
$prefix
=
''
):
void
{
foreach
((
new
FileIteratorFacade
)->
getFilesAsArray
(
$directory
,
$suffix
,
$prefix
)
as
$file
)
{
$this
->
excludeFile
(
$file
);
}
}
public
function
excludeFile
(
string
$filename
):
void
{
$filename
=
realpath
(
$filename
);
if
(!
$filename
||
!
isset
(
$this
->
files
[
$filename
]))
{
return
;
}
unset
(
$this
->
files
[
$filename
]);
}
public
function
isFile
(
string
$filename
):
bool
{
if
(
isset
(
$this
->
isFileCache
[
$filename
]))
{
return
$this
->
isFileCache
[
$filename
];
}
if
(
$filename
===
'-'
||
strpos
(
$filename
,
'vfs://'
)
===
0
||
strpos
(
$filename
,
'xdebug://debug-eval'
)
!==
false
||
strpos
(
$filename
,
'eval()
\'
d code'
)
!==
false
||
strpos
(
$filename
,
'runtime-created function'
)
!==
false
||
strpos
(
$filename
,
'runkit created function'
)
!==
false
||
strpos
(
$filename
,
'assert code'
)
!==
false
||
strpos
(
$filename
,
'regexp code'
)
!==
false
||
strpos
(
$filename
,
'Standard input code'
)
!==
false
)
{
$isFile
=
false
;
}
else
{
$isFile
=
is_file
(
$filename
);
}
$this
->
isFileCache
[
$filename
]
=
$isFile
;
return
$isFile
;
}
public
function
isExcluded
(
string
$filename
):
bool
{
return
!
isset
(
$this
->
files
[
$filename
])
||
!
$this
->
isFile
(
$filename
);
}
/**
* @psalm-return list<string>
*/
public
function
files
():
array
{
return
array_keys
(
$this
->
files
);
}
public
function
isEmpty
():
bool
{
return
empty
(
$this
->
files
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Aug 18, 16:14 (3 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e0/1c/3822960f5045842f9408460cfd64
Default Alt Text
Filter.php (3 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment