@vituum/vite-plugin-latte 1.0.0-beta.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -2
- package/package.json +13 -11
- package/types/index.d.ts +2 -0
- package/vendor/autoload.php +19 -1
- package/vendor/bin/latte-lint +16 -4
- package/vendor/composer/ClassLoader.php +72 -65
- package/vendor/composer/InstalledVersions.php +21 -12
- package/vendor/composer/autoload_classmap.php +12 -8
- package/vendor/composer/autoload_namespaces.php +1 -1
- package/vendor/composer/autoload_psr4.php +1 -1
- package/vendor/composer/autoload_real.php +7 -26
- package/vendor/composer/autoload_static.php +13 -9
- package/vendor/composer/installed.json +8 -8
- package/vendor/composer/installed.php +10 -10
- package/vendor/latte/latte/bin/latte-lint +8 -2
- package/vendor/latte/latte/composer.json +1 -1
- package/vendor/latte/latte/readme.md +6 -6
- package/vendor/latte/latte/src/Bridges/Tracy/BlueScreenPanel.php +1 -0
- package/vendor/latte/latte/src/Bridges/Tracy/LattePanel.php +3 -2
- package/vendor/latte/latte/src/Latte/Compiler/Block.php +0 -3
- package/vendor/latte/latte/src/Latte/Compiler/Escaper.php +103 -88
- package/vendor/latte/latte/src/Latte/Compiler/ExpressionBuilder.php +2 -1
- package/vendor/latte/latte/src/Latte/Compiler/Node.php +0 -4
- package/vendor/latte/latte/src/Latte/Compiler/NodeHelpers.php +0 -4
- package/vendor/latte/latte/src/Latte/Compiler/NodeTraverser.php +0 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AuxiliaryNode.php +11 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/FragmentNode.php +10 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/AttributeNode.php +22 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ElementNode.php +35 -12
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArgumentNode.php +6 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArrayItemNode.php +12 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayNode.php +4 -31
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignNode.php +15 -1
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignOpNode.php +11 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AuxiliaryNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClassConstantFetchNode.php +2 -2
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ConstantFetchNode.php +8 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/IssetNode.php +15 -1
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PostOpNode.php +11 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PreOpNode.php +11 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/{StaticCallNode.php → StaticMethodCallNode.php} +11 -1
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/{StaticCallableNode.php → StaticMethodCallableNode.php} +11 -1
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/TemporaryNode.php +38 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ExpressionNode.php +24 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ListItemNode.php +48 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ListNode.php +56 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ModifierNode.php +3 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/InterpolatedStringNode.php +1 -8
- package/vendor/latte/latte/src/Latte/Compiler/PhpHelpers.php +30 -0
- package/vendor/latte/latte/src/Latte/Compiler/Position.php +4 -8
- package/vendor/latte/latte/src/Latte/Compiler/PrintContext.php +14 -7
- package/vendor/latte/latte/src/Latte/Compiler/Tag.php +13 -14
- package/vendor/latte/latte/src/Latte/Compiler/TagLexer.php +3 -7
- package/vendor/latte/latte/src/Latte/Compiler/TagParser.php +52 -3
- package/vendor/latte/latte/src/Latte/Compiler/TagParserData.php +354 -322
- package/vendor/latte/latte/src/Latte/Compiler/TemplateGenerator.php +6 -5
- package/vendor/latte/latte/src/Latte/Compiler/TemplateLexer.php +95 -176
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParser.php +40 -33
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParserHtml.php +182 -126
- package/vendor/latte/latte/src/Latte/Compiler/Token.php +5 -9
- package/vendor/latte/latte/src/Latte/Compiler/TokenStream.php +6 -22
- package/vendor/latte/latte/src/Latte/Engine.php +37 -8
- package/vendor/latte/latte/src/Latte/Essential/Blueprint.php +0 -2
- package/vendor/latte/latte/src/Latte/Essential/CachingIterator.php +0 -4
- package/vendor/latte/latte/src/Latte/Essential/CoreExtension.php +14 -3
- package/vendor/latte/latte/src/Latte/Essential/Filters.php +8 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/BlockNode.php +1 -2
- package/vendor/latte/latte/src/Latte/Essential/Nodes/CaptureNode.php +2 -13
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ContentTypeNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DefineNode.php +1 -2
- package/vendor/latte/latte/src/Latte/Essential/Nodes/EmbedNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ExtendsNode.php +0 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/FirstLastSepNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForeachNode.php +4 -13
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfChangedNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfContentNode.php +4 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfNode.php +5 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeBlockNode.php +5 -2
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IterateWhileNode.php +6 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/JumpNode.php +26 -23
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NElseNode.php +88 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NTagNode.php +20 -28
- package/vendor/latte/latte/src/Latte/Essential/Nodes/PrintNode.php +7 -12
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RollbackNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SpacelessNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SwitchNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TranslateNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TryNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/WhileNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Passes.php +9 -11
- package/vendor/latte/latte/src/Latte/Essential/RawPhpExtension.php +0 -2
- package/vendor/latte/latte/src/Latte/Essential/TranslatorExtension.php +6 -1
- package/vendor/latte/latte/src/Latte/Loaders/FileLoader.php +0 -2
- package/vendor/latte/latte/src/Latte/Loaders/StringLoader.php +0 -2
- package/vendor/latte/latte/src/Latte/PositionAwareException.php +1 -1
- package/vendor/latte/latte/src/Latte/Runtime/Block.php +0 -4
- package/vendor/latte/latte/src/Latte/Runtime/FilterExecutor.php +43 -51
- package/vendor/latte/latte/src/Latte/Runtime/FilterInfo.php +0 -2
- package/vendor/latte/latte/src/Latte/Runtime/Filters.php +64 -30
- package/vendor/latte/latte/src/Latte/Runtime/Html.php +0 -4
- package/vendor/latte/latte/src/Latte/Runtime/Template.php +2 -2
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallNode.php +2 -1
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/SandboxNode.php +3 -3
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/{StaticCallNode.php → StaticMethodCallNode.php} +3 -3
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/{StaticCallableNode.php → StaticMethodCallableNode.php} +2 -2
- package/vendor/latte/latte/src/Latte/Sandbox/RuntimeChecker.php +0 -2
- package/vendor/latte/latte/src/Latte/Sandbox/SandboxExtension.php +11 -9
- package/vendor/latte/latte/src/Latte/Sandbox/SecurityPolicy.php +0 -2
- package/vendor/latte/latte/src/Latte/exceptions.php +2 -11
- package/vendor/latte/latte/src/Tools/Linter.php +13 -37
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/QuotedValue.php +0 -53
- package/vendor/latte/latte/src/Latte/Strict.php +0 -101
package/index.js
CHANGED
|
@@ -139,8 +139,8 @@ const plugin = (options = {}) => {
|
|
|
139
139
|
await renameBuildEnd(resolvedConfig.build.rollupOptions.input, options.formats)
|
|
140
140
|
},
|
|
141
141
|
transformIndexHtml: {
|
|
142
|
-
|
|
143
|
-
async
|
|
142
|
+
order: 'pre',
|
|
143
|
+
async handler (content, { path, filename, server }) {
|
|
144
144
|
if (options.ignoredPaths.find(ignoredPath => minimatch(path.replace('.html', ''), ignoredPath) === true)) {
|
|
145
145
|
return content
|
|
146
146
|
}
|
package/package.json
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vituum/vite-plugin-latte",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
6
7
|
"scripts": {
|
|
8
|
+
"tsc": "tsc",
|
|
9
|
+
"eslint": "eslint '**/*.js' --fix",
|
|
7
10
|
"dev": "vite dev",
|
|
8
11
|
"build": "vite build",
|
|
9
12
|
"preview": "vite preview"
|
|
10
13
|
},
|
|
11
14
|
"dependencies": {
|
|
12
|
-
"vituum": "^1.
|
|
13
|
-
"fast-glob": "^3.
|
|
14
|
-
"lodash": "^4.17
|
|
15
|
-
"minimatch": "^9.0
|
|
15
|
+
"vituum": "^1.1",
|
|
16
|
+
"fast-glob": "^3.3",
|
|
17
|
+
"lodash": "^4.17",
|
|
18
|
+
"minimatch": "^9.0"
|
|
16
19
|
},
|
|
17
20
|
"devDependencies": {
|
|
18
|
-
"@types/node": "^20.
|
|
19
|
-
"vite": "^
|
|
20
|
-
"eslint": "^8.
|
|
21
|
+
"@types/node": "^20.9.1",
|
|
22
|
+
"vite": "^5.0.0",
|
|
23
|
+
"eslint": "^8.53.0",
|
|
21
24
|
"eslint-config-standard": "^17.1.0",
|
|
22
|
-
"typescript": "^5.
|
|
25
|
+
"typescript": "^5.2.2"
|
|
23
26
|
},
|
|
24
27
|
"files": [
|
|
25
28
|
"index.js",
|
|
@@ -35,8 +38,7 @@
|
|
|
35
38
|
"./types": "./types/*"
|
|
36
39
|
},
|
|
37
40
|
"engines": {
|
|
38
|
-
"node": ">=
|
|
39
|
-
"npm": ">=8.0.0"
|
|
41
|
+
"node": "^18.0.0 || >=20.0.0"
|
|
40
42
|
},
|
|
41
43
|
"repository": {
|
|
42
44
|
"type": "git",
|
package/types/index.d.ts
CHANGED
package/vendor/autoload.php
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
// autoload.php @generated by Composer
|
|
4
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
|
+
|
|
5
23
|
require_once __DIR__ . '/composer/autoload_real.php';
|
|
6
24
|
|
|
7
|
-
return
|
|
25
|
+
return ComposerAutoloaderInitda1ce49ef3085539a79eddbb995629f3::getLoader();
|
package/vendor/bin/latte-lint
CHANGED
|
@@ -66,6 +66,16 @@ if (PHP_VERSION_ID < 80000) {
|
|
|
66
66
|
return $operation ? flock($this->handle, $operation) : true;
|
|
67
67
|
}
|
|
68
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
|
+
|
|
69
79
|
public function stream_tell()
|
|
70
80
|
{
|
|
71
81
|
return $this->position;
|
|
@@ -98,10 +108,12 @@ if (PHP_VERSION_ID < 80000) {
|
|
|
98
108
|
}
|
|
99
109
|
}
|
|
100
110
|
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
|
|
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__ . '/..'.'/latte/latte/bin/latte-lint');
|
|
104
116
|
}
|
|
105
117
|
}
|
|
106
118
|
|
|
107
|
-
include __DIR__ . '/..'.'/latte/latte/bin/latte-lint';
|
|
119
|
+
return include __DIR__ . '/..'.'/latte/latte/bin/latte-lint';
|
|
@@ -42,35 +42,37 @@ namespace Composer\Autoload;
|
|
|
42
42
|
*/
|
|
43
43
|
class ClassLoader
|
|
44
44
|
{
|
|
45
|
-
/** @var
|
|
45
|
+
/** @var \Closure(string):void */
|
|
46
|
+
private static $includeFile;
|
|
47
|
+
|
|
48
|
+
/** @var string|null */
|
|
46
49
|
private $vendorDir;
|
|
47
50
|
|
|
48
51
|
// PSR-4
|
|
49
52
|
/**
|
|
50
|
-
* @var array
|
|
51
|
-
* @psalm-var array<string, array<string, int>>
|
|
53
|
+
* @var array<string, array<string, int>>
|
|
52
54
|
*/
|
|
53
55
|
private $prefixLengthsPsr4 = array();
|
|
54
56
|
/**
|
|
55
|
-
* @var array
|
|
56
|
-
* @psalm-var array<string, array<int, string>>
|
|
57
|
+
* @var array<string, list<string>>
|
|
57
58
|
*/
|
|
58
59
|
private $prefixDirsPsr4 = array();
|
|
59
60
|
/**
|
|
60
|
-
* @var
|
|
61
|
-
* @psalm-var array<string, string>
|
|
61
|
+
* @var list<string>
|
|
62
62
|
*/
|
|
63
63
|
private $fallbackDirsPsr4 = array();
|
|
64
64
|
|
|
65
65
|
// PSR-0
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
67
|
+
* List of PSR-0 prefixes
|
|
68
|
+
*
|
|
69
|
+
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
|
|
70
|
+
*
|
|
71
|
+
* @var array<string, array<string, list<string>>>
|
|
69
72
|
*/
|
|
70
73
|
private $prefixesPsr0 = array();
|
|
71
74
|
/**
|
|
72
|
-
* @var
|
|
73
|
-
* @psalm-var array<string, string>
|
|
75
|
+
* @var list<string>
|
|
74
76
|
*/
|
|
75
77
|
private $fallbackDirsPsr0 = array();
|
|
76
78
|
|
|
@@ -78,8 +80,7 @@ class ClassLoader
|
|
|
78
80
|
private $useIncludePath = false;
|
|
79
81
|
|
|
80
82
|
/**
|
|
81
|
-
* @var string
|
|
82
|
-
* @psalm-var array<string, string>
|
|
83
|
+
* @var array<string, string>
|
|
83
84
|
*/
|
|
84
85
|
private $classMap = array();
|
|
85
86
|
|
|
@@ -87,29 +88,29 @@ class ClassLoader
|
|
|
87
88
|
private $classMapAuthoritative = false;
|
|
88
89
|
|
|
89
90
|
/**
|
|
90
|
-
* @var bool
|
|
91
|
-
* @psalm-var array<string, bool>
|
|
91
|
+
* @var array<string, bool>
|
|
92
92
|
*/
|
|
93
93
|
private $missingClasses = array();
|
|
94
94
|
|
|
95
|
-
/** @var
|
|
95
|
+
/** @var string|null */
|
|
96
96
|
private $apcuPrefix;
|
|
97
97
|
|
|
98
98
|
/**
|
|
99
|
-
* @var self
|
|
99
|
+
* @var array<string, self>
|
|
100
100
|
*/
|
|
101
101
|
private static $registeredLoaders = array();
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
|
-
* @param
|
|
104
|
+
* @param string|null $vendorDir
|
|
105
105
|
*/
|
|
106
106
|
public function __construct($vendorDir = null)
|
|
107
107
|
{
|
|
108
108
|
$this->vendorDir = $vendorDir;
|
|
109
|
+
self::initializeIncludeClosure();
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
/**
|
|
112
|
-
* @return string
|
|
113
|
+
* @return array<string, list<string>>
|
|
113
114
|
*/
|
|
114
115
|
public function getPrefixes()
|
|
115
116
|
{
|
|
@@ -121,8 +122,7 @@ class ClassLoader
|
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
/**
|
|
124
|
-
* @return array
|
|
125
|
-
* @psalm-return array<string, array<int, string>>
|
|
125
|
+
* @return array<string, list<string>>
|
|
126
126
|
*/
|
|
127
127
|
public function getPrefixesPsr4()
|
|
128
128
|
{
|
|
@@ -130,8 +130,7 @@ class ClassLoader
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
|
-
* @return
|
|
134
|
-
* @psalm-return array<string, string>
|
|
133
|
+
* @return list<string>
|
|
135
134
|
*/
|
|
136
135
|
public function getFallbackDirs()
|
|
137
136
|
{
|
|
@@ -139,8 +138,7 @@ class ClassLoader
|
|
|
139
138
|
}
|
|
140
139
|
|
|
141
140
|
/**
|
|
142
|
-
* @return
|
|
143
|
-
* @psalm-return array<string, string>
|
|
141
|
+
* @return list<string>
|
|
144
142
|
*/
|
|
145
143
|
public function getFallbackDirsPsr4()
|
|
146
144
|
{
|
|
@@ -148,8 +146,7 @@ class ClassLoader
|
|
|
148
146
|
}
|
|
149
147
|
|
|
150
148
|
/**
|
|
151
|
-
* @return string
|
|
152
|
-
* @psalm-return array<string, string>
|
|
149
|
+
* @return array<string, string> Array of classname => path
|
|
153
150
|
*/
|
|
154
151
|
public function getClassMap()
|
|
155
152
|
{
|
|
@@ -157,8 +154,7 @@ class ClassLoader
|
|
|
157
154
|
}
|
|
158
155
|
|
|
159
156
|
/**
|
|
160
|
-
* @param string
|
|
161
|
-
* @psalm-param array<string, string> $classMap
|
|
157
|
+
* @param array<string, string> $classMap Class to filename map
|
|
162
158
|
*
|
|
163
159
|
* @return void
|
|
164
160
|
*/
|
|
@@ -175,24 +171,25 @@ class ClassLoader
|
|
|
175
171
|
* Registers a set of PSR-0 directories for a given prefix, either
|
|
176
172
|
* appending or prepending to the ones previously set for this prefix.
|
|
177
173
|
*
|
|
178
|
-
* @param string
|
|
179
|
-
* @param string
|
|
180
|
-
* @param bool
|
|
174
|
+
* @param string $prefix The prefix
|
|
175
|
+
* @param list<string>|string $paths The PSR-0 root directories
|
|
176
|
+
* @param bool $prepend Whether to prepend the directories
|
|
181
177
|
*
|
|
182
178
|
* @return void
|
|
183
179
|
*/
|
|
184
180
|
public function add($prefix, $paths, $prepend = false)
|
|
185
181
|
{
|
|
182
|
+
$paths = (array) $paths;
|
|
186
183
|
if (!$prefix) {
|
|
187
184
|
if ($prepend) {
|
|
188
185
|
$this->fallbackDirsPsr0 = array_merge(
|
|
189
|
-
|
|
186
|
+
$paths,
|
|
190
187
|
$this->fallbackDirsPsr0
|
|
191
188
|
);
|
|
192
189
|
} else {
|
|
193
190
|
$this->fallbackDirsPsr0 = array_merge(
|
|
194
191
|
$this->fallbackDirsPsr0,
|
|
195
|
-
|
|
192
|
+
$paths
|
|
196
193
|
);
|
|
197
194
|
}
|
|
198
195
|
|
|
@@ -201,19 +198,19 @@ class ClassLoader
|
|
|
201
198
|
|
|
202
199
|
$first = $prefix[0];
|
|
203
200
|
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
|
204
|
-
$this->prefixesPsr0[$first][$prefix] =
|
|
201
|
+
$this->prefixesPsr0[$first][$prefix] = $paths;
|
|
205
202
|
|
|
206
203
|
return;
|
|
207
204
|
}
|
|
208
205
|
if ($prepend) {
|
|
209
206
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
|
210
|
-
|
|
207
|
+
$paths,
|
|
211
208
|
$this->prefixesPsr0[$first][$prefix]
|
|
212
209
|
);
|
|
213
210
|
} else {
|
|
214
211
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
|
215
212
|
$this->prefixesPsr0[$first][$prefix],
|
|
216
|
-
|
|
213
|
+
$paths
|
|
217
214
|
);
|
|
218
215
|
}
|
|
219
216
|
}
|
|
@@ -222,9 +219,9 @@ class ClassLoader
|
|
|
222
219
|
* Registers a set of PSR-4 directories for a given namespace, either
|
|
223
220
|
* appending or prepending to the ones previously set for this namespace.
|
|
224
221
|
*
|
|
225
|
-
* @param string
|
|
226
|
-
* @param string
|
|
227
|
-
* @param bool
|
|
222
|
+
* @param string $prefix The prefix/namespace, with trailing '\\'
|
|
223
|
+
* @param list<string>|string $paths The PSR-4 base directories
|
|
224
|
+
* @param bool $prepend Whether to prepend the directories
|
|
228
225
|
*
|
|
229
226
|
* @throws \InvalidArgumentException
|
|
230
227
|
*
|
|
@@ -232,17 +229,18 @@ class ClassLoader
|
|
|
232
229
|
*/
|
|
233
230
|
public function addPsr4($prefix, $paths, $prepend = false)
|
|
234
231
|
{
|
|
232
|
+
$paths = (array) $paths;
|
|
235
233
|
if (!$prefix) {
|
|
236
234
|
// Register directories for the root namespace.
|
|
237
235
|
if ($prepend) {
|
|
238
236
|
$this->fallbackDirsPsr4 = array_merge(
|
|
239
|
-
|
|
237
|
+
$paths,
|
|
240
238
|
$this->fallbackDirsPsr4
|
|
241
239
|
);
|
|
242
240
|
} else {
|
|
243
241
|
$this->fallbackDirsPsr4 = array_merge(
|
|
244
242
|
$this->fallbackDirsPsr4,
|
|
245
|
-
|
|
243
|
+
$paths
|
|
246
244
|
);
|
|
247
245
|
}
|
|
248
246
|
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
|
@@ -252,18 +250,18 @@ class ClassLoader
|
|
|
252
250
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
|
253
251
|
}
|
|
254
252
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
|
255
|
-
$this->prefixDirsPsr4[$prefix] =
|
|
253
|
+
$this->prefixDirsPsr4[$prefix] = $paths;
|
|
256
254
|
} elseif ($prepend) {
|
|
257
255
|
// Prepend directories for an already registered namespace.
|
|
258
256
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
|
259
|
-
|
|
257
|
+
$paths,
|
|
260
258
|
$this->prefixDirsPsr4[$prefix]
|
|
261
259
|
);
|
|
262
260
|
} else {
|
|
263
261
|
// Append directories for an already registered namespace.
|
|
264
262
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
|
265
263
|
$this->prefixDirsPsr4[$prefix],
|
|
266
|
-
|
|
264
|
+
$paths
|
|
267
265
|
);
|
|
268
266
|
}
|
|
269
267
|
}
|
|
@@ -272,8 +270,8 @@ class ClassLoader
|
|
|
272
270
|
* Registers a set of PSR-0 directories for a given prefix,
|
|
273
271
|
* replacing any others previously set for this prefix.
|
|
274
272
|
*
|
|
275
|
-
* @param string
|
|
276
|
-
* @param string
|
|
273
|
+
* @param string $prefix The prefix
|
|
274
|
+
* @param list<string>|string $paths The PSR-0 base directories
|
|
277
275
|
*
|
|
278
276
|
* @return void
|
|
279
277
|
*/
|
|
@@ -290,8 +288,8 @@ class ClassLoader
|
|
|
290
288
|
* Registers a set of PSR-4 directories for a given namespace,
|
|
291
289
|
* replacing any others previously set for this namespace.
|
|
292
290
|
*
|
|
293
|
-
* @param string
|
|
294
|
-
* @param string
|
|
291
|
+
* @param string $prefix The prefix/namespace, with trailing '\\'
|
|
292
|
+
* @param list<string>|string $paths The PSR-4 base directories
|
|
295
293
|
*
|
|
296
294
|
* @throws \InvalidArgumentException
|
|
297
295
|
*
|
|
@@ -425,7 +423,8 @@ class ClassLoader
|
|
|
425
423
|
public function loadClass($class)
|
|
426
424
|
{
|
|
427
425
|
if ($file = $this->findFile($class)) {
|
|
428
|
-
includeFile
|
|
426
|
+
$includeFile = self::$includeFile;
|
|
427
|
+
$includeFile($file);
|
|
429
428
|
|
|
430
429
|
return true;
|
|
431
430
|
}
|
|
@@ -476,9 +475,9 @@ class ClassLoader
|
|
|
476
475
|
}
|
|
477
476
|
|
|
478
477
|
/**
|
|
479
|
-
* Returns the currently registered loaders
|
|
478
|
+
* Returns the currently registered loaders keyed by their corresponding vendor directories.
|
|
480
479
|
*
|
|
481
|
-
* @return self
|
|
480
|
+
* @return array<string, self>
|
|
482
481
|
*/
|
|
483
482
|
public static function getRegisteredLoaders()
|
|
484
483
|
{
|
|
@@ -555,18 +554,26 @@ class ClassLoader
|
|
|
555
554
|
|
|
556
555
|
return false;
|
|
557
556
|
}
|
|
558
|
-
}
|
|
559
557
|
|
|
560
|
-
/**
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
558
|
+
/**
|
|
559
|
+
* @return void
|
|
560
|
+
*/
|
|
561
|
+
private static function initializeIncludeClosure()
|
|
562
|
+
{
|
|
563
|
+
if (self::$includeFile !== null) {
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Scope isolated include.
|
|
569
|
+
*
|
|
570
|
+
* Prevents access to $this/self from included files.
|
|
571
|
+
*
|
|
572
|
+
* @param string $file
|
|
573
|
+
* @return void
|
|
574
|
+
*/
|
|
575
|
+
self::$includeFile = \Closure::bind(static function($file) {
|
|
576
|
+
include $file;
|
|
577
|
+
}, null, null);
|
|
578
|
+
}
|
|
572
579
|
}
|
|
@@ -21,12 +21,14 @@ use Composer\Semver\VersionParser;
|
|
|
21
21
|
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
|
22
22
|
*
|
|
23
23
|
* To require its presence, you can require `composer-runtime-api ^2.0`
|
|
24
|
+
*
|
|
25
|
+
* @final
|
|
24
26
|
*/
|
|
25
27
|
class InstalledVersions
|
|
26
28
|
{
|
|
27
29
|
/**
|
|
28
30
|
* @var mixed[]|null
|
|
29
|
-
* @psalm-var array{root: array{name: string,
|
|
31
|
+
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
|
|
30
32
|
*/
|
|
31
33
|
private static $installed;
|
|
32
34
|
|
|
@@ -37,7 +39,7 @@ class InstalledVersions
|
|
|
37
39
|
|
|
38
40
|
/**
|
|
39
41
|
* @var array[]
|
|
40
|
-
* @psalm-var array<string, array{root: array{name: string,
|
|
42
|
+
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
|
41
43
|
*/
|
|
42
44
|
private static $installedByVendor = array();
|
|
43
45
|
|
|
@@ -96,7 +98,7 @@ class InstalledVersions
|
|
|
96
98
|
{
|
|
97
99
|
foreach (self::getInstalled() as $installed) {
|
|
98
100
|
if (isset($installed['versions'][$packageName])) {
|
|
99
|
-
return $includeDevRequirements ||
|
|
101
|
+
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
|
|
@@ -117,7 +119,7 @@ class InstalledVersions
|
|
|
117
119
|
*/
|
|
118
120
|
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
|
119
121
|
{
|
|
120
|
-
$constraint = $parser->parseConstraints($constraint);
|
|
122
|
+
$constraint = $parser->parseConstraints((string) $constraint);
|
|
121
123
|
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
|
122
124
|
|
|
123
125
|
return $provided->matches($constraint);
|
|
@@ -241,7 +243,7 @@ class InstalledVersions
|
|
|
241
243
|
|
|
242
244
|
/**
|
|
243
245
|
* @return array
|
|
244
|
-
* @psalm-return array{name: string,
|
|
246
|
+
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
|
|
245
247
|
*/
|
|
246
248
|
public static function getRootPackage()
|
|
247
249
|
{
|
|
@@ -255,7 +257,7 @@ class InstalledVersions
|
|
|
255
257
|
*
|
|
256
258
|
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
|
257
259
|
* @return array[]
|
|
258
|
-
* @psalm-return array{root: array{name: string,
|
|
260
|
+
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
|
|
259
261
|
*/
|
|
260
262
|
public static function getRawData()
|
|
261
263
|
{
|
|
@@ -278,7 +280,7 @@ class InstalledVersions
|
|
|
278
280
|
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
|
279
281
|
*
|
|
280
282
|
* @return array[]
|
|
281
|
-
* @psalm-return list<array{root: array{name: string,
|
|
283
|
+
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
|
282
284
|
*/
|
|
283
285
|
public static function getAllRawData()
|
|
284
286
|
{
|
|
@@ -301,7 +303,7 @@ class InstalledVersions
|
|
|
301
303
|
* @param array[] $data A vendor/composer/installed.php data set
|
|
302
304
|
* @return void
|
|
303
305
|
*
|
|
304
|
-
* @psalm-param array{root: array{name: string,
|
|
306
|
+
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
|
|
305
307
|
*/
|
|
306
308
|
public static function reload($data)
|
|
307
309
|
{
|
|
@@ -311,7 +313,7 @@ class InstalledVersions
|
|
|
311
313
|
|
|
312
314
|
/**
|
|
313
315
|
* @return array[]
|
|
314
|
-
* @psalm-return list<array{root: array{name: string,
|
|
316
|
+
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
|
|
315
317
|
*/
|
|
316
318
|
private static function getInstalled()
|
|
317
319
|
{
|
|
@@ -326,7 +328,9 @@ class InstalledVersions
|
|
|
326
328
|
if (isset(self::$installedByVendor[$vendorDir])) {
|
|
327
329
|
$installed[] = self::$installedByVendor[$vendorDir];
|
|
328
330
|
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
|
329
|
-
|
|
331
|
+
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
|
332
|
+
$required = require $vendorDir.'/composer/installed.php';
|
|
333
|
+
$installed[] = self::$installedByVendor[$vendorDir] = $required;
|
|
330
334
|
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
|
331
335
|
self::$installed = $installed[count($installed) - 1];
|
|
332
336
|
}
|
|
@@ -338,12 +342,17 @@ class InstalledVersions
|
|
|
338
342
|
// only require the installed.php file if this file is loaded from its dumped location,
|
|
339
343
|
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
|
340
344
|
if (substr(__DIR__, -8, 1) !== 'C') {
|
|
341
|
-
|
|
345
|
+
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
|
|
346
|
+
$required = require __DIR__ . '/installed.php';
|
|
347
|
+
self::$installed = $required;
|
|
342
348
|
} else {
|
|
343
349
|
self::$installed = array();
|
|
344
350
|
}
|
|
345
351
|
}
|
|
346
|
-
|
|
352
|
+
|
|
353
|
+
if (self::$installed !== array()) {
|
|
354
|
+
$installed[] = self::$installed;
|
|
355
|
+
}
|
|
347
356
|
|
|
348
357
|
return $installed;
|
|
349
358
|
}
|