Skip to content

Commit

Permalink
Merge 585a828 into 4371fbb
Browse files Browse the repository at this point in the history
  • Loading branch information
msvrtan committed Jan 4, 2018
2 parents 4371fbb + 585a828 commit a7a4e87
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 8 deletions.
3 changes: 3 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
- run:
name: Composer install
command: composer install --no-interaction
- run:
name: Composer dump autoload (bug on autoload)
command: composer dump-autoload -o
- run:
name: PHPUnit
command: ./vendor/bin/phpunit --fail-on-warning --log-junit build/phpunit/junit.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace NullDevelopment\Skeleton\Command;

use Exception;
use NullDevelopment\Skeleton\SourceCode;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Throwable;

/**
* @codeCoverageIgnore
Expand All @@ -28,11 +28,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
/** @var SourceCode $sourceCodeDefinition */
foreach ($sourceCodeDefinitions as $sourceCodeDefinition) {
try {

$this->io->writeln('Processing ' .$sourceCodeDefinition->getInstanceOfName());

$results = $this->commandBus->handle($sourceCodeDefinition);
foreach ($results as $result) {
$this->fileSystem->dumpFile($result->getFileName(), $result->getOutput());
}
} catch (Exception $e) {
} catch (Throwable $e) {
$this->io->writeln($e->getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace NullDevelopment\Skeleton\Command;

use Exception;
use NullDevelopment\Skeleton\SourceCode;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Throwable;

/**
* @codeCoverageIgnore
Expand All @@ -28,6 +28,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
/** @var SourceCode $sourceCodeDefinition */
foreach ($sourceCodeDefinitions as $sourceCodeDefinition) {
try {

$this->io->writeln('Processing ' .$sourceCodeDefinition->getInstanceOfName());

$results = $this->commandBus->handle($sourceCodeDefinition);
foreach ($results as $result) {
if (false === $this->fileSystem->exists($result->getFileName())) {
Expand All @@ -36,7 +39,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->io->writeln('Skipping '.$result->getFileName().' as it already exists');
}
}
} catch (Exception $e) {
} catch (Throwable $e) {
$this->io->writeln($e->getMessage());
}
}
Expand Down
12 changes: 10 additions & 2 deletions src/NullDevelopment/Skeleton/ExampleMaker/ArrayExample.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ public function __toString(): string
$results = [];

foreach ($this->values as $value) {
$results[] = $value->__toString();
if (true === is_string($value)) {
$results[] = '"'.$value.'"';
} elseif ($value instanceof Example) {
$results[] = $value->__toString();
} else {
$results[] = $value;
}
}

return '['.implode(', ', $results).']';
Expand All @@ -34,7 +40,9 @@ public function classesToImport(): array
$result = [];

foreach ($this->values as $value) {
$result = array_merge($result, $value->classesToImport());
if ($value instanceof Example) {
$result = array_merge($result, $value->classesToImport());
}
}

return $result;
Expand Down
4 changes: 4 additions & 0 deletions src/NullDevelopment/Skeleton/ExampleMaker/ExampleMaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ public function value(Variable $variable): Example
$refl = (new BetterReflection())
->classReflector()
->reflect($variable->getInstanceFullName());

if ($refl->isInterface()) {
return new MockeryMockExample($variable->getInstanceName());
}

$zz = $refl;
while ($parent = $zz->getParentClass()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use NullDevelopment\PhpStructure\DataType\Property;
use NullDevelopment\PhpStructure\DataType\Visibility;
use NullDevelopment\PhpStructure\DataTypeName\ClassName;
use NullDevelopment\Skeleton\ExampleMaker\ArrayExample;
use NullDevelopment\Skeleton\ExampleMaker\SimpleExample;
use NullDevelopment\SkeletonSourceCodeExtension\Method\ConstructorMethod;

Expand All @@ -30,7 +31,11 @@ public function create(?array $input): ?ConstructorMethod
$examples = [];

foreach ($parameter['examples'] as $example) {
$examples[] = new SimpleExample($example);
if (true === is_array($example)) {
$examples[] = new ArrayExample($example);
} else {
$examples[] = new SimpleExample($example);
}
}

$parameters[] = new Property(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use NullDevelopment\PhpStructure\DataType\Property;
use NullDevelopment\PhpStructure\DataType\Visibility;
use NullDevelopment\PhpStructure\DataTypeName\ClassName;
use NullDevelopment\Skeleton\ExampleMaker\ArrayExample;
use NullDevelopment\Skeleton\ExampleMaker\SimpleExample;

/**
Expand All @@ -30,7 +31,11 @@ public function create(?array $input): array
$examples = [];

foreach ($data['examples'] as $example) {
$examples[] = new SimpleExample($example);
if (true === is_array($example)) {
$examples[] = new ArrayExample($example);
} else {
$examples[] = new SimpleExample($example);
}
}

$result[] = new Property(
Expand Down

0 comments on commit a7a4e87

Please sign in to comment.