Skip to content

Commit 9d67127

Browse files
committed
revert composer.json... update it via post-update-cmd
1 parent d89c25d commit 9d67127

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

composer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@
118118
"config": {
119119
"allow-plugins": {
120120
"dealerdirect/phpcodesniffer-composer-installer": false
121-
},
122-
"audit": {
123-
"block-insecure": false
124121
}
125122
}
126123
}

dev/ComposerScripts.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ private static function installDependencies()
126126
*/
127127
private static function installUnitTestDependencies()
128128
{
129+
// disable audit block-insecure (needed for older twig versions)
130+
self::updateComposerJson('audit.block-insecure', false);
131+
129132
$composer = self::getComposerCommand();
130133
\version_compare(self::$phpVersion, '8.0.0', '>=')
131134
// need a newer version to avoid ReturnTypeWillChange fatal
@@ -141,6 +144,35 @@ private static function installUnitTestDependencies()
141144
}
142145
}
143146

147+
/**
148+
* Update composer.json
149+
*
150+
* https://github.com/composer/composer/issues/12611
151+
* `composer config audit.block-insecure false`
152+
* Setting audit.block-insecure does not exist or is not supported by this command
153+
*
154+
* @param string|null $path Dot notation path to value to set
155+
* @param mixed $value Value to set
156+
*
157+
* @return void
158+
*/
159+
private static function updateComposerJson($path, $value)
160+
{
161+
$composerJsonPath = __DIR__ . '/../composer.json';
162+
$json = \file_get_contents($composerJsonPath);
163+
$data = \json_decode($json, true);
164+
$path = \explode('.', $path);
165+
foreach ($path as $key) {
166+
if (!isset($data[$key]) || !\is_array($data[$key])) {
167+
$data[$key] = array();
168+
}
169+
$data = &$data[$key];
170+
}
171+
$data = $value;
172+
$newJson = \json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
173+
\file_put_contents($composerJsonPath, $newJson);
174+
}
175+
144176
/**
145177
* Update phpcs.slevomat.xml
146178
*

0 commit comments

Comments
 (0)