58
58
use PhpSchool \PhpWorkshop \Logger \ConsoleLogger ;
59
59
use PhpSchool \PhpWorkshop \Logger \Logger ;
60
60
use PhpSchool \PhpWorkshop \Markdown \CurrentContext ;
61
- use PhpSchool \PhpWorkshop \Markdown \Parser \ContextSpecificBlockParser ;
62
61
use PhpSchool \PhpWorkshop \Markdown \ProblemFileExtension ;
63
62
use PhpSchool \PhpWorkshop \Markdown \Renderer \ContextSpecificRenderer ;
64
63
use PhpSchool \PhpWorkshop \Markdown \Shorthands \Cli \AppName ;
104
103
use Psr \Container \ContainerInterface ;
105
104
use Psr \Log \LoggerInterface ;
106
105
use Symfony \Component \Filesystem \Filesystem ;
106
+
107
107
use function DI \create ;
108
108
use function DI \factory ;
109
109
use function PhpSchool \PhpWorkshop \canonicalise_path ;
147
147
$ c ->get (ComposerCheck::class),
148
148
$ c ->get (FunctionRequirementsCheck::class),
149
149
$ c ->get (DatabaseCheck::class),
150
- $ c ->get (FileComparisonCheck::class)
150
+ $ c ->get (FileComparisonCheck::class),
151
151
]);
152
152
},
153
153
CommandRouter::class => function (ContainerInterface $ c ) {
158
158
new CommandDefinition ('print ' , [], PrintCommand::class),
159
159
new CommandDefinition ('verify ' , [], VerifyCommand::class),
160
160
new CommandDefinition ('run ' , [], RunCommand::class),
161
- new CommandDefinition ('credits ' , [], CreditsCommand::class)
161
+ new CommandDefinition ('credits ' , [], CreditsCommand::class),
162
162
],
163
163
'menu ' ,
164
164
$ c ->get (EventDispatcher::class),
165
- $ c
165
+ $ c,
166
166
);
167
167
},
168
168
169
169
Color::class => function () {
170
- $ colors = new Color ;
170
+ $ colors = new Color () ;
171
171
$ colors ->setForceStyle (true );
172
172
return $ colors ;
173
173
},
179
179
return new ExerciseRepository (
180
180
array_map (function ($ exerciseClass ) use ($ c ) {
181
181
return $ c ->get ($ exerciseClass );
182
- }, $ c ->get ('exercises ' ))
182
+ }, $ c ->get ('exercises ' )),
183
183
);
184
184
},
185
185
196
196
$ manager ->addFactory (new CliRunnerFactory (
197
197
$ c ->get (EventDispatcher::class),
198
198
$ c ->get (ProcessFactory::class),
199
- $ c ->get (EnvironmentManager::class)
199
+ $ c ->get (EnvironmentManager::class),
200
200
));
201
201
$ manager ->addFactory (new CgiRunnerFactory (
202
202
$ c ->get (EventDispatcher::class),
203
203
$ c ->get (ProcessFactory::class),
204
- $ c ->get (EnvironmentManager::class)
204
+ $ c ->get (EnvironmentManager::class),
205
205
));
206
206
$ manager ->addFactory (new CustomVerifyingRunnerFactory ());
207
207
return $ manager ;
222
222
$ c ->get (ExerciseRepository::class),
223
223
$ c ->get (UserState::class),
224
224
$ c ->get (MarkdownRenderer::class),
225
- $ c ->get (OutputInterface::class)
225
+ $ c ->get (OutputInterface::class),
226
226
);
227
227
},
228
228
233
233
$ c ->get (UserState::class),
234
234
$ c ->get (Serializer::class),
235
235
$ c ->get (OutputInterface::class),
236
- $ c ->get (ResultsRenderer::class)
236
+ $ c ->get (ResultsRenderer::class),
237
237
);
238
238
},
239
239
242
242
$ c ->get (ExerciseRepository::class),
243
243
$ c ->get (ExerciseDispatcher::class),
244
244
$ c ->get (UserState::class),
245
- $ c ->get (OutputInterface::class)
245
+ $ c ->get (OutputInterface::class),
246
246
);
247
247
},
248
248
251
251
$ c ->get ('coreContributors ' ),
252
252
$ c ->get ('appContributors ' ),
253
253
$ c ->get (OutputInterface::class),
254
- $ c ->get (Color::class)
254
+ $ c ->get (Color::class),
255
255
);
256
256
},
257
257
258
258
HelpCommand::class => function (ContainerInterface $ c ) {
259
259
return new HelpCommand (
260
260
$ c ->get ('appName ' ),
261
261
$ c ->get (OutputInterface::class),
262
- $ c ->get (Color::class)
262
+ $ c ->get (Color::class),
263
263
);
264
264
},
265
265
269
269
},
270
270
PrepareSolutionListener::class => function (ContainerInterface $ c ) {
271
271
return new PrepareSolutionListener (
272
- $ c ->get (ProcessFactory::class)
272
+ $ c ->get (ProcessFactory::class),
273
273
);
274
274
},
275
275
CodePatchListener::class => function (ContainerInterface $ c ) {
276
276
return new CodePatchListener (
277
277
$ c ->get (CodePatcher::class),
278
278
$ c ->get (LoggerInterface::class),
279
- $ c ->get ('debugMode ' )
279
+ $ c ->get ('debugMode ' ),
280
280
);
281
281
},
282
282
SelfCheckListener::class => function (ContainerInterface $ c ) {
289
289
return new ConfigureCommandListener (
290
290
$ c ->get (UserState::class),
291
291
$ c ->get (ExerciseRepository::class),
292
- $ c ->get (RunnerManager::class)
292
+ $ c ->get (RunnerManager::class),
293
293
);
294
294
},
295
295
RealPathListener::class => create (),
320
320
//Utils
321
321
Filesystem::class => create (),
322
322
Parser::class => function () {
323
- $ parserFactory = new ParserFactory ;
323
+ $ parserFactory = new ParserFactory () ;
324
324
return $ parserFactory ->create (ParserFactory::PREFER_PHP7 );
325
325
},
326
326
CodePatcher::class => function (ContainerInterface $ c ) {
327
327
$ patch = (new Patch ())
328
328
->withInsertion (new Insertion (Insertion::TYPE_BEFORE , 'ini_set("display_errors", "1"); ' ))
329
329
->withInsertion (new Insertion (Insertion::TYPE_BEFORE , 'error_reporting(E_ALL); ' ))
330
- ->withInsertion (new Insertion (Insertion ::TYPE_BEFORE , 'date_default_timezone_set("Europe/London"); ' ));
330
+ ->withInsertion (new Insertion (Insertion::TYPE_BEFORE , 'date_default_timezone_set("Europe/London"); ' ));
331
331
332
332
return new CodePatcher ($ c ->get (Parser::class), new Standard (), $ c ->get (LoggerInterface::class), $ patch );
333
333
},
347
347
$ c ->get (Serializer::class),
348
348
$ c ->get (MarkdownRenderer::class),
349
349
$ c ->get (Color::class),
350
- $ c ->get (OutputInterface::class)
350
+ $ c ->get (OutputInterface::class),
351
351
);
352
352
},
353
353
ContextSpecificRenderer::class => function (ContainerInterface $ c ) {
364
364
365
365
$ environment = new Environment ([
366
366
'renderer ' => [
367
- 'width ' => $ terminal ->getWidth ()
367
+ 'width ' => $ terminal ->getWidth (),
368
368
],
369
369
]);
370
370
377
377
new Documentation (),
378
378
new Run ($ c ->get ('appName ' )),
379
379
new Verify ($ c ->get ('appName ' )),
380
- $ c ->get (Context::class)
381
- ]
380
+ $ c ->get (Context::class),
381
+ ],
382
382
));
383
383
384
384
return $ environment ;
385
385
},
386
386
MarkdownRenderer::class => function (ContainerInterface $ c ) {
387
387
return new MarkdownRenderer (
388
388
new DocParser ($ c ->get (Environment::class)),
389
- $ c ->get (ElementRendererInterface::class)
389
+ $ c ->get (ElementRendererInterface::class),
390
390
);
391
391
},
392
392
ElementRendererInterface::class => function (ContainerInterface $ c ) {
393
393
return new CliRenderer (
394
394
$ c ->get (Environment::class),
395
- $ c ->get (Color::class)
395
+ $ c ->get (Color::class),
396
396
);
397
397
},
398
398
Serializer::class => function (ContainerInterface $ c ) {
399
399
return new LocalJsonSerializer (
400
400
getenv ('HOME ' ),
401
401
$ c ->get ('workshopTitle ' ),
402
- $ c ->get (ExerciseRepository::class)
402
+ $ c ->get (ExerciseRepository::class),
403
403
);
404
404
},
405
405
UserState::class => function (ContainerInterface $ c ) {
409
409
return new ResetProgress ($ c ->get (Serializer::class));
410
410
},
411
411
ResultRendererFactory::class => function (ContainerInterface $ c ) {
412
- $ factory = new ResultRendererFactory ;
412
+ $ factory = new ResultRendererFactory () ;
413
413
$ factory ->registerRenderer (FunctionRequirementsFailure::class, FunctionRequirementsFailureRenderer::class);
414
414
$ factory ->registerRenderer (Failure::class, FailureRenderer::class);
415
415
$ factory ->registerRenderer (
416
416
CgiResult::class,
417
417
CgiResultRenderer::class,
418
418
function (CgiResult $ result ) use ($ c ) {
419
419
return new CgiResultRenderer ($ result , $ c ->get (RequestRenderer::class));
420
- }
420
+ },
421
421
);
422
422
$ factory ->registerRenderer (CgiGenericFailure::class, FailureRenderer::class);
423
423
$ factory ->registerRenderer (CgiRequestFailure::class, CgiRequestFailureRenderer::class);
@@ -439,12 +439,12 @@ function (CgiResult $result) use ($c) {
439
439
$ c ->get (Terminal::class),
440
440
$ c ->get (ExerciseRepository::class),
441
441
$ c ->get (KeyLighter::class),
442
- $ c ->get (ResultRendererFactory::class)
442
+ $ c ->get (ResultRendererFactory::class),
443
443
);
444
444
},
445
445
446
446
KeyLighter::class => function () {
447
- $ keylighter = new KeyLighter ;
447
+ $ keylighter = new KeyLighter () ;
448
448
$ keylighter ->init ();
449
449
return $ keylighter ;
450
450
},
@@ -453,26 +453,26 @@ function (CgiResult $result) use ($c) {
453
453
'@AydinHassan ' => 'Aydin Hassan ' ,
454
454
'@mikeymike ' => 'Michael Woodward ' ,
455
455
'@shakeyShane ' => 'Shane Osbourne ' ,
456
- '@chris3ailey ' => 'Chris Bailey '
456
+ '@chris3ailey ' => 'Chris Bailey ' ,
457
457
],
458
458
'appContributors ' => [],
459
459
'eventListeners ' => [
460
460
'realpath-student-submission ' => [
461
461
'verify.start ' => [
462
- containerListener (RealPathListener::class)
462
+ containerListener (RealPathListener::class),
463
463
],
464
464
'run.start ' => [
465
- containerListener (RealPathListener::class)
465
+ containerListener (RealPathListener::class),
466
466
],
467
467
],
468
468
'check-exercise-assigned ' => [
469
469
'route.pre.resolve.args ' => [
470
- containerListener (CheckExerciseAssignedListener::class)
470
+ containerListener (CheckExerciseAssignedListener::class),
471
471
],
472
472
],
473
473
'configure-command-arguments ' => [
474
474
'route.pre.resolve.args ' => [
475
- containerListener (ConfigureCommandListener::class)
475
+ containerListener (ConfigureCommandListener::class),
476
476
],
477
477
],
478
478
'prepare-solution ' => [
@@ -511,26 +511,26 @@ function (CgiResult $result) use ($c) {
511
511
],
512
512
'self-check ' => [
513
513
'verify.post.check ' => [
514
- containerListener (SelfCheckListener::class)
514
+ containerListener (SelfCheckListener::class),
515
515
],
516
516
],
517
517
'create-initial-code ' => [
518
518
'exercise.selected ' => [
519
- containerListener (InitialCodeListener::class)
520
- ]
519
+ containerListener (InitialCodeListener::class),
520
+ ],
521
521
],
522
522
'cleanup-filesystem ' => [
523
523
'application.tear-down ' => [
524
- containerListener (TearDownListener::class, 'cleanupTempDir ' )
525
- ]
524
+ containerListener (TearDownListener::class, 'cleanupTempDir ' ),
525
+ ],
526
526
],
527
527
'decorate-run-output ' => [
528
528
'cli.run.student-execute.pre ' => [
529
- containerListener (OutputRunInfoListener::class)
529
+ containerListener (OutputRunInfoListener::class),
530
530
],
531
531
'cgi.run.student-execute.pre ' => [
532
- containerListener (OutputRunInfoListener::class)
533
- ]
532
+ containerListener (OutputRunInfoListener::class),
533
+ ],
534
534
],
535
535
],
536
536
];
0 commit comments