forked from tectalic/CopyCraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscoper.php
51 lines (47 loc) · 1.45 KB
/
scoper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
return array(
'patchers' => array(
// Handle Tectalic/OpenAi package.
function ( string $file_path, string $prefix, string $content ): string {
// Ensure PHPdoc comments for Models are prefixed correctly.
if ( ! \str_contains( $file_path, 'vendor/tectalic/openai/' ) ) {
return $content;
}
return str_replace(
' \Tectalic\OpenAi\Models\\',
" \\$prefix\Tectalic\OpenAi\Models\\",
$content
);
},
// Handle art4/requests-psr18-adapter package.
function ( string $file_path, string $prefix, string $content ): string {
// Ensure art4/requests-psr18-adapter uses the Requests library that is bundled with WordPress core.
if ( ! \str_contains( $file_path, 'vendor/art4/' ) ) {
return $content;
}
return str_replace(
'OM4\CopyCraft\Vendor\WpOrg\Requests\\',
'WpOrg\Requests\\',
$content
);
},
// Handle v1-compat inside art4/requests-psr18-adapter package.
function ( string $file_path, string $prefix, string $content ): string {
// Ensure art4/requests-psr18-adapter uses the Requests library that is bundled with WordPress core.
if ( ! \str_contains( $file_path, 'vendor/art4/' ) ) {
return $content;
}
return str_replace(
array(
'WpOrg\Requests\Exception\InvalidArgument',
'WpOrg\Requests\Post',
),
array(
'OM4\CopyCraft\Vendor\WpOrg\Requests\Exception\InvalidArgument',
'OM4\CopyCraft\Vendor\WpOrg\Requests\Post',
),
$content
);
},
),
);