Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ nbproject

doc/html/
tmp/
zf-mkdoc-theme/
clover.xml
composer.lock
coveralls-upload.json
Expand Down
18 changes: 14 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,35 @@ language: php

branches:
except:
- /^release-.*$/
- /^release-\d+\.\d+\.\d+.*$/
- /^ghgfk-.*$/

cache:
directories:
- $HOME/.composer/cache
- $HOME/.local
- zf-mkdoc-theme

env:
global:
- TESTS_ZEND_CODE_ANNOTATION_DOCTRINE_SUPPORT=true
- SITE_URL=https://docs.zendframework.com/zend-code
- GH_USER_NAME="Matthew Weier O'Phinney"
- [email protected]
- GH_REF=github.com/zendframework/zend-code.git
- secure: "qgUppUW+xiQunsc07EvrYK7q9j4ewsYzN2ggxxFGaF694gkZ5V29Tb9W2qCkKEdMo6vE+X65P/lOoJceyavPm39/Ka/0V461qIiYX2ZcBVFI/eeVnpwLmU/E5YHn6fFNbiwFX0o4cJdVyTrSspMTXSuiQy+9bLSevDYmbpknR476nmsF8FRGdG6GMFx0XklF1QkoERSfy+FGlqp3VYOJZ2MH7eLhXQyGBKv471kyfmyyInUMVoDN9R8mjJ4Sxyt2qaQ5661DuWRXLaWEBaNOvfZ4++jJFipPLyqIEcE2GqTl9LH3suIBd0NAfHGgdakMJuBZfW3WA/OQ208qm+++qajnI30cxKiGkFoAR2plK9P5+09JAzbivglpEIEtq9a58/I1ahjy9+4sqJYyfxUC07o+REUleJl/ojO6QQ3JI/UUBbPSa3d78Sw9i8LUmLimiYEYQK9zwO1ZdKwJYCKaiYdYS8H0IwGci9t+MqlrllMG5M6f2HRkF1Ph05sWah8QwsGrJ7yiSiILaDHn7wFNvUiN3uw09W9AotQ0AEBzdM6U6CngDPVWKHI9L1d7+txuOLwGt6j8NKHWlgA1P9rMkeMGn2+46b5AlCkUxg6cVCA8ZLpr3a5WLK2F7qTHACtP9tckEb4G3vQjM79f6Nlpewcuc7p7uHWK5Y4UkojRN+U="

matrix:
fast_finish: true
include:
- php: 5.5
env:
- EXECUTE_CS_CHECK=true
- EXECUTE_DOC_CHECK=true
- php: 5.6
env:
- EXECUTE_TEST_COVERALLS=true
- DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)"
- PATH="$HOME/.local/bin:$PATH"
- php: 7
- php: hhvm
allow_failures:
Expand All @@ -37,7 +45,6 @@ notifications:
before_install:
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- composer self-update
- if [[ $EXECUTE_DOC_CHECK == 'true' ]]; then composer require --dev --no-update phly/bookdown2mkdocs ; fi
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi

install:
Expand All @@ -50,7 +57,10 @@ script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit --coverage-clover clover.xml ; fi
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then ./vendor/bin/phpunit ; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/phpcs ; fi
- if [[ $EXECUTE_DOC_CHECK == 'true' ]]; then make mkdocs ; diff mkdocs.yml mkdocs.yml.orig ; return $? ; fi
- if [[ $DEPLOY_DOCS == "true" && "$TRAVIS_TEST_RESULT" == "0" ]]; then wget -O theme-installer.sh "https://raw.githubusercontent.com/zendframework/zf-mkdoc-theme/master/theme-installer.sh" ; chmod 755 theme-installer.sh ; ./theme-installer.sh ; fi

after_success:
- if [[ $DEPLOY_DOCS == "true" ]]; then echo "Preparing to build and deploy documentation" ; ./zf-mkdoc-theme/deploy.sh ; echo "Completed deploying documentation" ; fi

after_script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls ; fi
152 changes: 76 additions & 76 deletions doc/book/generator/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ use Zend\Code\Generator\ClassGenerator;
use Zend\Code\Generator\DocBlockGenerator;

$foo = new ClassGenerator();
$docblock = DocBlockGenerator::fromArray(array(
$docblock = DocBlockGenerator::fromArray([
'shortDescription' => 'Sample generated class',
'longDescription' => 'This is a class generated with Zend\Code\Generator.',
'tags' => array(
array(
'tags' => [
[
'name' => 'version',
'description' => '$Rev:$',
),
array(
],
[
'name' => 'license',
'description' => 'New BSD',
),
),
));
],
],
]);
$foo->setName('Foo')
->setDocblock($docblock);
echo $foo->generate();
Expand Down Expand Up @@ -56,29 +56,29 @@ use Zend\Code\Generator\DocBlockGenerator;
use Zend\Code\Generator\PropertyGenerator;

$foo = new ClassGenerator();
$docblock = DocBlockGenerator::fromArray(array(
$docblock = DocBlockGenerator::fromArray([
'shortDescription' => 'Sample generated class',
'longDescription' => 'This is a class generated with Zend\Code\Generator.',
'tags' => array(
array(
'tags' => [
[
'name' => 'version',
'description' => '$Rev:$',
),
array(
],
[
'name' => 'license',
'description' => 'New BSD',
),
),
));
],
],
]);
$foo->setName('Foo')
->setDocblock($docblock)
->addProperties(array(
array('_bar', 'baz', PropertyGenerator::FLAG_PROTECTED),
array('baz', 'bat', PropertyGenerator::FLAG_PUBLIC)
))
->addConstants(array(
array('bat', 'foobarbazbat')
));
->addProperties([
['_bar', 'baz', PropertyGenerator::FLAG_PROTECTED],
['baz', 'bat', PropertyGenerator::FLAG_PUBLIC]
])
->addConstants([
['bat', 'foobarbazbat']
]);
echo $foo->generate();
```

Expand Down Expand Up @@ -120,66 +120,66 @@ use Zend\Code\Generator\MethodGenerator;
use Zend\Code\Generator\PropertyGenerator;

$foo = new ClassGenerator();
$docblock = DocBlockGenerator::fromArray(array(
$docblock = DocBlockGenerator::fromArray([
'shortDescription' => 'Sample generated class',
'longDescription' => 'This is a class generated with Zend\Code\Generator.',
'tags' => array(
array(
'tags' => [
[
'name' => 'version',
'description' => '$Rev:$',
),
array(
],
[
'name' => 'license',
'description' => 'New BSD',
),
),
));
],
],
]);
$foo->setName('Foo')
->setDocblock($docblock)
->addProperties(array(
array('_bar', 'baz', PropertyGenerator::FLAG_PROTECTED),
array('baz', 'bat', PropertyGenerator::FLAG_PUBLIC)
))
->addConstants(array(
array('bat', 'foobarbazbat', PropertyGenerator::FLAG_CONSTANT)
))
->addMethods(array(
->addProperties([
['_bar', 'baz', PropertyGenerator::FLAG_PROTECTED],
['baz', 'bat', PropertyGenerator::FLAG_PUBLIC]
])
->addConstants([
['bat', 'foobarbazbat', PropertyGenerator::FLAG_CONSTANT]
])
->addMethods([
// Method passed as array
MethodGenerator::fromArray(array(
MethodGenerator::fromArray([
'name' => 'setBar',
'parameters' => array('bar'),
'parameters' => ['bar'],
'body' => '$this->_bar = $bar;' . "\n" . 'return $this;',
'docblock' => DocBlockGenerator::fromArray(array(
'docblock' => DocBlockGenerator::fromArray([
'shortDescription' => 'Set the bar property',
'longDescription' => null,
'tags' => array(
new Tag\ParamTag(array(
'tags' => [
new Tag\ParamTag([
'paramName' => 'bar',
'datatype' => 'string'
)),
new Tag\ReturnTag(array(
]),
new Tag\ReturnTag([
'datatype' => 'string',
)),
),
)),
)),
]),
],
]),
]),
// Method passed as concrete instance
new MethodGenerator(
'getBar',
array(),
[],
MethodGenerator::FLAG_PUBLIC,
'return $this->_bar;',
DocBlockGenerator::fromArray(array(
DocBlockGenerator::fromArray([
'shortDescription' => 'Retrieve the bar property',
'longDescription' => null,
'tags' => array(
new Tag\ReturnTag(array(
'tags' => [
new Tag\ReturnTag([
'datatype' => 'string|null',
)),
),
))
]),
],
])
),
));
]);

echo $foo->generate();
```
Expand Down Expand Up @@ -242,20 +242,20 @@ previous example.
use Zend\Code\Generator\DocBlockGenerator;
use Zend\Code\Generator\FileGenerator;

$file = FileGenerator::fromArray(array(
'classes' => array($foo),
'docblock' => DocBlockGenerator::fromArray(array(
$file = FileGenerator::fromArray([
'classes' => [$foo],
'docblock' => DocBlockGenerator::fromArray([
'shortDescription' => 'Foo class file',
'longDescription' => null,
'tags' => array(
array(
'tags' => [
[
'name' => 'license',
'description' => 'New BSD',
),
),
)),
],
],
]),
'body' => 'define(\'APPLICATION_ENV\', \'testing\');',
));
]);
```

Calling `generate()` will generate the code -- but not write it to a file. You will need to capture
Expand Down Expand Up @@ -351,22 +351,22 @@ $generator = ClassGenerator::fromReflection(
);
$generator->addMethod(
'setBaz',
array('baz'),
['baz'],
MethodGenerator::FLAG_PUBLIC,
'$this->_baz = $baz;' . "\n" . 'return $this;',
DocBlockGenerator::fromArray(array(
DocBlockGenerator::fromArray([
'shortDescription' => 'Set the baz property',
'longDescription' => null,
'tags' => array(
new Tag\ParamTag(array(
'tags' => [
new Tag\ParamTag([
'paramName' => 'baz',
'datatype' => 'string'
)),
new Tag\ReturnTag(array(
]),
new Tag\ReturnTag([
'datatype' => 'string',
)),
),
))
]),
],
])
);
$code = $generator->generate();
```
4 changes: 2 additions & 2 deletions doc/book/generator/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ that should appear before generated content. Its *API* is as follows:
abstract class Zend\Code\Generator\AbstractGenerator
implements Zend\Code\Generator\GeneratorInterface
{
public function __construct(Array|Traversable $options = array())
public function __construct(Array|Traversable $options = [])
public function setOptions(Array $options)
public function setSourceContent($sourceContent)
public function getSourceContent()
Expand Down Expand Up @@ -361,7 +361,7 @@ $parameter->setDefaultValue(
new Zend\Code\Generator\ValueGenerator("null")
);
$parameter->setDefaultValue(
new Zend\Code\Generator\ValueGenerator("array('foo', 'bar')")
new Zend\Code\Generator\ValueGenerator("['foo', 'bar']")
);
```

Expand Down
10 changes: 10 additions & 0 deletions doc/book/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="container">
<div class="jumbotron">
<h1>zend-code</h1>

<p>Extensions to the PHP Reflection API, static code scanning, and code generation.</p>

<pre><code class="language-bash">$ composer require zendframework/zend-code</code></pre>
</div>
</div>

8 changes: 4 additions & 4 deletions doc/book/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (in_array($type, ['string', 'int', 'float', 'bool'])) {
$generator->setType($type);
```

## `Zend\Code\Reflection\ParameterReflection#getType()` changes
## `ParameterReflection::getType()` changes

PHP 7 introduced [`ReflectionParameter#getType()`](http://php.net/manual/en/reflectionparameter.gettype.php).

Expand All @@ -37,7 +37,7 @@ was renamed to `Zend\Code\Reflection\ParameterReflection#detectType()`.
If you relied on `Zend\Code\Reflection\ParameterReflection#getType()`, you can
simply replace the method calls in your code.

## DocBlock types ignored by `Zend\Code\Generator\ParameterGenerator::fromReflection()`
## DocBlock types ignored by `ParameterGenerator::fromReflection()`

As a direct consequence of the previous change, calls to
`Zend\Code\Generator\ParameterGenerator::fromReflection()` will not mirror the
Expand Down Expand Up @@ -116,13 +116,13 @@ In version 3.x, it produces `public function foo(\baz $bar) : \tab {}`.
In order to avoid migration problems, be sure to always pass fully qualified class
names to `Zend\Code\Generator\MethodGenerator` and `Zend\Code\Generator\ParameterGenerator`.

## `Zend\Code\Generator\ParameterGenerator::$simple` was removed
## `ParameterGenerator::$simple` was removed

If you extended `Zend\Code\Generator\ParameterGenerator`, be sure to check if you
are accessing the protected static variable `$simple`: it was removed, and you should
adapt your code by either copying it into your class or avoiding its usage.

## `Zend\Code\Generator\ParameterGenerator::$type` has changed
## `ParameterGenerator::$type` has changed

If you extended `Zend\Code\Generator\ParameterGenerator`, be sure to check if you
are accessing the protected variable `$type`: its type has changed.
Expand Down
9 changes: 0 additions & 9 deletions doc/bookdown.json

This file was deleted.

7 changes: 5 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ docs_dir: doc/book
site_dir: doc/html
pages:
- index.md
- { 'zend-code Generator Component': [{ Intro: generator/intro.md }, { Examples: generator/examples.md }, { Reference: generator/reference.md }] }
- { 'Migration from v2 to v3': migration.md }
- "Code Generation":
- Intro: generator/intro.md
- Examples: generator/examples.md
- Reference: generator/reference.md
- Migration: migration.md
site_name: zend-code
site_description: 'zend-code: Tools for reflecting, scanning, and generating PHP code'
repo_url: 'https://github.com/zendframework/zend-code'
Expand Down