Skip to content

Commit 5af97f3

Browse files
authored
Merge pull request #93 from php-school/more-cleanup
More code cleanup
2 parents 6a084eb + f2c26ea commit 5af97f3

23 files changed

+32
-260
lines changed

src/Exercise/ArrayWeGo.php

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,24 @@ class ArrayWeGo extends AbstractExercise implements ExerciseInterface, FunctionR
2828
*/
2929
private $faker;
3030

31-
/**
32-
* @param Filesystem $filesystem
33-
* @param Generator $faker
34-
*/
3531
public function __construct(Filesystem $filesystem, Generator $faker)
3632
{
3733
$this->filesystem = $filesystem;
3834
$this->faker = $faker;
3935
}
4036

41-
/**
42-
* @return string
43-
*/
4437
public function getName(): string
4538
{
4639
return 'Array We Go!';
4740
}
4841

49-
/**
50-
* @return string
51-
*/
5242
public function getDescription(): string
5343
{
5444
return 'Filter an array of file paths and map to SplFile objects';
5545
}
5646

5747
/**
58-
* @return array<array<string>>
48+
* @inheritdoc
5949
*/
6050
public function getArgs(): array
6151
{
@@ -82,32 +72,26 @@ public function tearDown(): void
8272
}
8373

8474
/**
85-
* @return string[]
75+
* @inheritdoc
8676
*/
8777
public function getRequiredFunctions(): array
8878
{
8979
return ['array_shift', 'array_filter', 'array_map'];
9080
}
9181

9282
/**
93-
* @return string[]
83+
* @inheritdoc
9484
*/
9585
public function getBannedFunctions(): array
9686
{
9787
return ['basename'];
9888
}
9989

100-
/**
101-
* @return ExerciseType
102-
*/
10390
public function getType(): ExerciseType
10491
{
10592
return new ExerciseType(ExerciseType::CLI);
10693
}
10794

108-
/**
109-
* @param ExerciseDispatcher $dispatcher
110-
*/
11195
public function configure(ExerciseDispatcher $dispatcher): void
11296
{
11397
$dispatcher->requireCheck(FunctionRequirementsCheck::class);

src/Exercise/BabySteps.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,18 @@
1010

1111
class BabySteps extends AbstractExercise implements ExerciseInterface, CliExercise
1212
{
13-
14-
/**
15-
* @return string
16-
*/
1713
public function getName(): string
1814
{
1915
return 'Baby Steps';
2016
}
2117

22-
/**
23-
* @return string
24-
*/
2518
public function getDescription(): string
2619
{
2720
return 'Simple Addition';
2821
}
2922

3023
/**
31-
* @return array<array<string>>
24+
* @inheritdoc
3225
*/
3326
public function getArgs(): array
3427
{
@@ -42,9 +35,6 @@ public function getArgs(): array
4235
return [$args];
4336
}
4437

45-
/**
46-
* @return ExerciseType
47-
*/
4838
public function getType(): ExerciseType
4939
{
5040
return new ExerciseType(ExerciseType::CLI);

src/Exercise/ConcernedAboutSeparation.php

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use PhpSchool\PhpWorkshop\Exercise\TemporaryDirectoryTrait;
1313
use PhpSchool\PhpWorkshop\ExerciseCheck\SelfCheck;
1414
use PhpSchool\PhpWorkshop\ExerciseCheck\StdOutExerciseCheck;
15-
use PhpSchool\PhpWorkshop\ExerciseDispatcher;
1615
use PhpSchool\PhpWorkshop\Input\Input;
1716
use PhpSchool\PhpWorkshop\Result\Failure;
1817
use PhpSchool\PhpWorkshop\Result\ResultInterface;
@@ -31,46 +30,29 @@ class ConcernedAboutSeparation extends AbstractExercise implements ExerciseInter
3130
*/
3231
private $filesystem;
3332

34-
/**
35-
* @var Generator
36-
*/
37-
private $faker;
38-
3933
/**
4034
* @var Parser
4135
*/
4236
private $parser;
4337

44-
/**
45-
* @param Filesystem $filesystem
46-
* @param Generator $faker
47-
* @param Parser $parser
48-
*/
49-
public function __construct(Filesystem $filesystem, Generator $faker, Parser $parser)
38+
public function __construct(Filesystem $filesystem, Parser $parser)
5039
{
5140
$this->filesystem = $filesystem;
52-
$this->faker = $faker;
5341
$this->parser = $parser;
5442
}
5543

56-
/**
57-
* @return string
58-
*/
5944
public function getName(): string
6045
{
6146
return 'Concerned about Separation?';
6247
}
6348

64-
/**
65-
* @return string
66-
*/
6749
public function getDescription(): string
6850
{
6951
return 'Separate code and utilise files and classes';
7052
}
7153

7254
/**
73-
* @return array<array<string>>
55+
* @inheritdoc
7456
*/
7557
public function getArgs(): array
7658
{
@@ -112,9 +94,6 @@ public function getArgs(): array
11294
return [[$folder, $ext]];
11395
}
11496

115-
/**
116-
* @return SolutionInterface
117-
*/
11897
public function getSolution(): SolutionInterface
11998
{
12099
return DirectorySolution::fromDirectory(__DIR__ . '/../../exercises/concerned-about-separation/solution');
@@ -125,10 +104,6 @@ public function tearDown(): void
125104
$this->filesystem->remove($this->getTemporaryPath());
126105
}
127106

128-
/**
129-
* @param Input $input
130-
* @return ResultInterface
131-
*/
132107
public function check(Input $input): ResultInterface
133108
{
134109
$statements = $this->parser->parse((string) file_get_contents($input->getRequiredArgument('program')));
@@ -152,9 +127,6 @@ public function check(Input $input): ResultInterface
152127
return new Success($this->getName());
153128
}
154129

155-
/**
156-
* @return ExerciseType
157-
*/
158130
public function getType(): ExerciseType
159131
{
160132
return new ExerciseType(ExerciseType::CLI);

src/Exercise/DatabaseRead.php

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
class DatabaseRead extends AbstractExercise implements ExerciseInterface, DatabaseExerciseCheck, CliExercise
2121
{
22-
2322
/**
2423
* @var Generator
2524
*/
@@ -30,42 +29,29 @@ class DatabaseRead extends AbstractExercise implements ExerciseInterface, Databa
3029
*/
3130
private $randomRecord;
3231

33-
/**
34-
* @param Generator $faker
35-
*/
3632
public function __construct(Generator $faker)
3733
{
3834
$this->faker = $faker;
3935
}
4036

41-
/**
42-
* @return string
43-
*/
4437
public function getName(): string
4538
{
4639
return 'Database Read';
4740
}
4841

49-
/**
50-
* @return string
51-
*/
5242
public function getDescription(): string
5343
{
5444
return 'Read an SQL databases contents';
5545
}
5646

5747
/**
58-
* @return array<array<string>>
48+
* @inheritdoc
5949
*/
6050
public function getArgs(): array
6151
{
6252
return [[$this->randomRecord['name']]];
6353
}
6454

65-
/**
66-
* @param PDO $db
67-
* @return void
68-
*/
6955
public function seed(PDO $db): void
7056
{
7157
$db
@@ -86,10 +72,6 @@ public function seed(PDO $db): void
8672
$this->randomRecord = ['id' => $randomId, 'name' => (string) $names[$randomId]];
8773
}
8874

89-
/**
90-
* @param PDO $db
91-
* @return bool
92-
*/
9375
public function verify(PDO $db): bool
9476
{
9577
$sql = 'SELECT name FROM users WHERE id = :id';
@@ -101,17 +83,11 @@ public function verify(PDO $db): bool
10183
return $result === 'David Attenborough';
10284
}
10385

104-
/**
105-
* @return ExerciseType
106-
*/
10786
public function getType(): ExerciseType
10887
{
10988
return new ExerciseType(ExerciseType::CLI);
11089
}
11190

112-
/**
113-
* @param ExerciseDispatcher $dispatcher
114-
*/
11591
public function configure(ExerciseDispatcher $dispatcher): void
11692
{
11793
$dispatcher->requireCheck(DatabaseCheck::class);

src/Exercise/DependencyHeaven.php

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,40 +26,28 @@ class DependencyHeaven extends AbstractExercise implements
2626
*/
2727
private $faker;
2828

29-
/**
30-
* @param Generator $faker
31-
*/
3229
public function __construct(Generator $faker)
3330
{
3431
$this->faker = $faker;
3532
}
3633

37-
/**
38-
* @return string
39-
*/
4034
public function getName(): string
4135
{
4236
return 'Dependency Heaven';
4337
}
4438

45-
/**
46-
* @return string
47-
*/
4839
public function getDescription(): string
4940
{
5041
return 'An introduction to Composer dependency management';
5142
}
5243

53-
/**
54-
* @return SolutionInterface
55-
*/
5644
public function getSolution(): SolutionInterface
5745
{
5846
return DirectorySolution::fromDirectory(__DIR__ . '/../../exercises/dependency-heaven/solution');
5947
}
6048

6149
/**
62-
* @return RequestInterface[]
50+
* @inheritdoc
6351
*/
6452
public function getRequests(): array
6553
{
@@ -74,10 +62,6 @@ public function getRequests(): array
7462
return $requests;
7563
}
7664

77-
/**
78-
* @param string $endpoint
79-
* @return RequestInterface
80-
*/
8165
private function newApiRequest(string $endpoint): RequestInterface
8266
{
8367
$request = (new Request('POST', $endpoint))
@@ -91,7 +75,7 @@ private function newApiRequest(string $endpoint): RequestInterface
9175
}
9276

9377
/**
94-
* @return array<string>
78+
* @inheritdoc
9579
*/
9680
public function getRequiredPackages(): array
9781
{
@@ -101,17 +85,11 @@ public function getRequiredPackages(): array
10185
];
10286
}
10387

104-
/**
105-
* @return ExerciseType
106-
*/
10788
public function getType(): ExerciseType
10889
{
10990
return new ExerciseType(ExerciseType::CGI);
11091
}
11192

112-
/**
113-
* @param ExerciseDispatcher $dispatcher
114-
*/
11593
public function configure(ExerciseDispatcher $dispatcher): void
11694
{
11795
$dispatcher->requireCheck(ComposerCheck::class);

0 commit comments

Comments
 (0)