@@ -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