Skip to content

Commit

Permalink
Merge bb56651 into 85290e8
Browse files Browse the repository at this point in the history
  • Loading branch information
siad007 committed Dec 28, 2018
2 parents 85290e8 + bb56651 commit 47a4eed
Show file tree
Hide file tree
Showing 35 changed files with 246 additions and 152 deletions.
5 changes: 3 additions & 2 deletions .gitattributes
Expand Up @@ -3,11 +3,12 @@
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
.coveralls.yml export-ignore
apigen.yml export-ignore
CHANGELOG.md export-ignore
easy-coding-standard.neon export-ignore
CODE_OF_CUNDUCT.md export-ignore
easy-coding-standard.yml export-ignore
generate-api.sh export-ignore
phpstan.neon export-ignore
phpunit.xml export-ignore
28 changes: 21 additions & 7 deletions .travis.yml
Expand Up @@ -2,7 +2,23 @@ language: php

sudo: false

php: 7.1
php:
- 7.1
- 7.2
- 7.1snapshot
- 7.2snapshot
- master

matrix:
fast_finish: true
allow_failures:
- php: 7.1snapshot
- php: 7.2snapshot
- php: master

cache:
directories:
- $HOME/.composer/cache

env:
global:
Expand All @@ -12,16 +28,14 @@ env:
- secure: jJuaecVvLaHk9/kQabIcCn3pZ5KaqC5VZQUnvU5UWzAJmUxoDBVCAkdAz1/F3VyWhBtiiYiTo2D+DFsIXiNYXRNMIHp5AE+tz4XgSiZUhqV81BvRtCgJSJIBsiyVmbKE5WAoHt/ovMKZY7StVVejmK3OfsbXOf1ewhpWsmNTI30=

before_install:
# Prevents global install of dev dependecies failing (due to Roave\BetterReflection:@dev)
- composer global config minimum-stability dev
- composer global config prefer-stable true

install:
# install composer dependencies
- composer install
# Create composer global installs
- composer create-project apigen/apigen:dev-master temp/apigen-project
- composer global require apigen/apigen:dev-master
- CWD="$(pwd)" && mkdir -p ~/temp/apigen-project && cp -r . ~/temp/apigen-project && cd ~/temp/apigen-project/ && composer install && cd $CWD
- composer global require apigen/apigen

script:
# run tests
Expand All @@ -36,7 +50,7 @@ script:
- composer phpstan

# Global install checks
- temp/apigen-project/bin/apigen generate -h
- ~/temp/apigen-project/bin/apigen generate -h
# disable for now, due to commit lock on opened PR
# https://github.com/ApiGen/ApiGen/commit/891bdf8c8090ee72028943bb9d06d1accda27daf
# https://github.com/Roave/BetterReflection/pull/312
Expand Down Expand Up @@ -74,4 +88,4 @@ after_script:
# do not send emails
notifications:
email: never
email: false
5 changes: 3 additions & 2 deletions apigen.yml
@@ -1,4 +1,5 @@
parameters:
title: "ApiGen It-self"
visibilityLevels: [public, protected]
baseUrl: http://apigen.org
visibility_levels: [public, protected]
base_url: http://apigen.org
theme_directory: packages/ThemeDefault/src
2 changes: 2 additions & 0 deletions bin/apigen
Expand Up @@ -7,6 +7,8 @@ use Symfony\Component\Console\Application;
// Performance boost
gc_disable();

ini_set('memory_limit', "-1");

require_once __DIR__.'/bootstrap.php';

$container = (new ContainerFactory())->create();
Expand Down
22 changes: 11 additions & 11 deletions composer.json
Expand Up @@ -11,29 +11,29 @@
"bin": ["bin/apigen"],
"require": {
"php": "^7.1",
"roave/better-reflection": "dev-master#c87d856",
"roave/better-reflection": "^3.2",
"kukulich/fshl": "^2.1",

"latte/latte": "^2.4",
"nette/utils": "^2.4",
"nette/finder": "^2.4",
"nette/neon": "^2.4",

"symfony/config": "^3.3",
"symfony/console": "^3.3",
"symfony/finder": "^3.3",
"symfony/dependency-injection": "^3.3",
"symfony/http-kernel": "^3.3",
"symfony/yaml": "^3.3",
"symplify/package-builder": "^2.2",
"symfony/config": "^3.4",
"symfony/console": "^3.4",
"symfony/finder": "^3.4",
"symfony/dependency-injection": "^3.4",
"symfony/http-kernel": "^3.4",
"symfony/yaml": "^3.4",
"symplify/package-builder": "^5.2",
"psr/container": "^1.0",
"zendframework/zend-code": "^3.1"
},
"require-dev": {
"tracy/tracy": "^2.4",
"phpunit/phpunit": "^6.0",
"phpstan/phpstan": "^0.8",
"symplify/easy-coding-standard": "2.3.1"
"phpunit/phpunit": "^7.5",
"phpstan/phpstan": "^0.10",
"symplify/easy-coding-standard": "5.2.*"
},
"autoload": {
"psr-4": {
Expand Down
28 changes: 14 additions & 14 deletions easy-coding-standard.neon → easy-coding-standard.yml
@@ -1,18 +1,18 @@
includes:
- vendor/symplify/easy-coding-standard/config/php70-checkers.neon
- vendor/symplify/easy-coding-standard/config/php71-checkers.neon
- vendor/symplify/easy-coding-standard/config/symfony-checkers.neon
- vendor/symplify/easy-coding-standard/config/symplify-checkers.neon
- vendor/symplify/easy-coding-standard/config/common.neon
- vendor/symplify/easy-coding-standard/config/spaces.neon

checkers:
imports:
- { resource: '%vendor_dir%/symplify/easy-coding-standard/config/php70.yml' }
- { resource: '%vendor_dir%/symplify/easy-coding-standard/config/php71.yml' }
- { resource: '%vendor_dir%/symplify/easy-coding-standard/config/symfony.yml' }
- { resource: '%vendor_dir%/symplify/easy-coding-standard/config/symplify.yml' }
- { resource: '%vendor_dir%/symplify/easy-coding-standard/config/common.yml' }
- { resource: '%vendor_dir%/symplify/easy-coding-standard/config/common/spaces.yml' }

services:
# PSR2
PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff:
absoluteLineLimit: 120

# Code Structures
- SlevomatCodingStandard\Sniffs\ControlStructures\AssignmentInConditionSniff
SlevomatCodingStandard\Sniffs\ControlStructures\AssignmentInConditionSniff: ~

# Namespaces
SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff:
Expand All @@ -21,8 +21,8 @@ checkers:
# Strict and Scalar types
SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff:
usefulAnnotations:
- @dataProvider
- @deprecated
- '@dataProvider'
- '@deprecated'
enableEachParameterAndReturnInspection: true

parameters:
Expand Down Expand Up @@ -80,11 +80,11 @@ parameters:
- packages/Reflection/src/Reflection/Function_/FunctionParameterReflection.php
- packages/Reflection/src/Reflection/Interface_/InterfaceConstantReflection.php
- packages/Reflection/src/Contract/Reflection/AbstractMethodReflectionInterface.php
- *packages/Reflection/src/Contract/Reflection/*/*ReflectionInterface.php
- '*packages/Reflection/src/Contract/Reflection/*/*ReflectionInterface.php'

Symplify\CodingStandard\Sniffs\Debug\CommentedOutCodeSniff:
# todos, remove after they are fixed
- *packages/Annotation/src/AnnotationSubscriber/*Subscriber.php
- '*packages/Annotation/src/AnnotationSubscriber/*Subscriber.php'
- packages/Reflection/tests/Reflection/Method/MethodReflection/ParameterWithConstantDefalutValueTest.php
- packages/Reflection/tests/Reflection/Function_/FunctionParameterReflection/ConstantDefaultValueTest.php
- packages/Reflection/src/Reflection/Interface_/InterfaceConstantReflection.php
Expand Down
25 changes: 25 additions & 0 deletions packages/BetterReflection/src/Reflector/CacheClassReflector.php
@@ -0,0 +1,25 @@
<?php declare(strict_types=1);

namespace ApiGen\BetterReflection\Reflector;

use Roave\BetterReflection\Reflection\Reflection;
use Roave\BetterReflection\Reflector\ClassReflector;

class CacheClassReflector extends ClassReflector
{
private $reflectCache = [];

/**
* @inheritDoc
*/
public function reflect(string $className): Reflection
{
if (isset($this->reflectCache[$className])) {
return $this->reflectCache[$className];
}
$class = parent::reflect($className);
$this->reflectCache[$className] = $class;

return $class;
}
}
1 change: 1 addition & 0 deletions packages/BetterReflection/src/config/services.yml
Expand Up @@ -4,6 +4,7 @@ services:

ApiGen\BetterReflection\:
resource: '..'
exclude: '../{Reflector}'

# cached AST Locator
Roave\BetterReflection\SourceLocator\Ast\PhpParserLocator: ~
Expand Down
Expand Up @@ -38,7 +38,7 @@ public function provide(): array
private function unsetSymfonyDefaultParameters(array $containerParameters): array
{
foreach ($containerParameters as $name => $value) {
if (Strings::startsWith($name, 'kernel')) {
if (Strings::startsWith($name, 'kernel') || Strings::startsWith($name, 'container')) {
unset($containerParameters[$name]);
}
}
Expand Down
6 changes: 4 additions & 2 deletions packages/Reflection/src/Parser/Parser.php
Expand Up @@ -2,6 +2,7 @@

namespace ApiGen\Reflection\Parser;

use ApiGen\BetterReflection\Reflector\CacheClassReflector;
use ApiGen\BetterReflection\SourceLocator\SourceLocatorsFactory;
use ApiGen\Element\Cache\ReflectionWarmUpper;
use ApiGen\Reflection\Contract\Reflection\Class_\ClassReflectionInterface;
Expand All @@ -10,6 +11,7 @@
use ApiGen\Reflection\Contract\Reflection\Trait_\TraitReflectionInterface;
use ApiGen\Reflection\ReflectionStorage;
use ApiGen\Reflection\TransformerCollector;
use PhpParser\Error;
use Roave\BetterReflection\Reflector\ClassReflector;
use Roave\BetterReflection\Reflector\FunctionReflector;
use Roave\BetterReflection\SourceLocator\Type\SourceLocator;
Expand Down Expand Up @@ -186,14 +188,14 @@ private function resolveParentTraits(array $reflections): array

private function parseClassElements(SourceLocator $sourceLocator): void
{
$classReflector = new ClassReflector($sourceLocator);
$classReflector = new CacheClassReflector($sourceLocator);
$classInterfaceAndTraitReflections = $this->transformBetterClassInterfaceAndTraitReflections($classReflector);
$this->separateClassInterfaceAndTraitReflections($classInterfaceAndTraitReflections);
}

private function parseFunctions(SourceLocator $sourceLocator): void
{
$functionReflector = new FunctionReflector($sourceLocator, new ClassReflector($sourceLocator));
$functionReflector = new FunctionReflector($sourceLocator, new CacheClassReflector($sourceLocator));
$functionReflections = $this->transformBetterFunctionReflections($functionReflector);
$this->reflectionStorage->setFunctionReflections($functionReflections);
}
Expand Down
17 changes: 15 additions & 2 deletions packages/Reflection/src/Reflection/AbstractParameterReflection.php
Expand Up @@ -14,7 +14,8 @@
use phpDocumentor\Reflection\DocBlock\Tags\Param;
use Roave\BetterReflection\Reflection\ReflectionParameter;

abstract class AbstractParameterReflection implements AbstractParameterReflectionInterface, TransformerCollectorAwareInterface
abstract class AbstractParameterReflection implements AbstractParameterReflectionInterface,
TransformerCollectorAwareInterface
{
/**
* @var ReflectionParameter
Expand All @@ -26,11 +27,18 @@ abstract class AbstractParameterReflection implements AbstractParameterReflectio
*/
protected $transformerCollector;

/**
* AbstractParameterReflection constructor.
* @param ReflectionParameter $betterParameterReflection
*/
public function __construct(ReflectionParameter $betterParameterReflection)
{
$this->betterParameterReflection = $betterParameterReflection;
}

/**
* @return string
*/
public function getTypeHint(): string
{
$types = (string) $this->betterParameterReflection->getType();
Expand All @@ -47,6 +55,9 @@ public function getTypeHint(): string
return '';
}

/**
* @return bool
*/
public function isDefaultValueAvailable(): bool
{
return $this->betterParameterReflection->isDefaultValueAvailable();
Expand Down Expand Up @@ -117,7 +128,7 @@ private function getAnnotation(): ?Param
}

/**
* @return ClassMethodReflectionInterface|FunctionReflectionInterface|TraitMethodReflectionInterface
* @return ClassMethodReflectionInterface|FunctionReflectionInterface|TraitMethodReflectionInterface|null
*/
private function getDeclaringReflection()
{
Expand All @@ -128,5 +139,7 @@ private function getDeclaringReflection()
if ($this instanceof MethodParameterReflectionInterface) {
return $this->getDeclaringMethod();
}

return null;
}
}
10 changes: 5 additions & 5 deletions packages/Reflection/src/Reflection/Class_/ClassReflection.php
Expand Up @@ -13,8 +13,8 @@
use ApiGen\Reflection\Contract\Reflection\Trait_\TraitMethodReflectionInterface;
use ApiGen\Reflection\Contract\Reflection\Trait_\TraitReflectionInterface;
use ApiGen\Reflection\Contract\TransformerCollectorAwareInterface;
use ApiGen\Reflection\Reflection\Exception\NotFoundException;
use ApiGen\Reflection\TransformerCollector;
use InvalidArgumentException;
use phpDocumentor\Reflection\DocBlock;
use Roave\BetterReflection\Reflection\ReflectionClass;

Expand Down Expand Up @@ -190,7 +190,7 @@ public function getOwnInterfaces(): array
public function getMethod(string $name): ClassMethodReflectionInterface
{
if (! isset($this->getMethods()[$name])) {
throw new InvalidArgumentException(sprintf(
throw new NotFoundException(sprintf(
'Method "%s" does not exist in "%s" class.',
$name,
$this->getName()
Expand Down Expand Up @@ -255,7 +255,7 @@ public function getConstant(string $name): ClassConstantReflectionInterface
return $this->getConstants()[$name];
}

throw new InvalidArgumentException(sprintf(
throw new NotFoundException(sprintf(
'Constant %s does not exist in class %s',
$name,
$this->getName()
Expand All @@ -265,7 +265,7 @@ public function getConstant(string $name): ClassConstantReflectionInterface
public function getOwnConstant(string $name): ClassConstantReflectionInterface
{
if (! isset($this->getOwnConstants()[$name])) {
throw new InvalidArgumentException(sprintf(
throw new NotFoundException(sprintf(
'Constant %s does not exist in class %s',
$name,
$this->getName()
Expand Down Expand Up @@ -324,7 +324,7 @@ public function getInheritedProperties(): array
public function getProperty(string $name): ClassPropertyReflectionInterface
{
if (! isset($this->getProperties()[$name])) {
throw new InvalidArgumentException(sprintf(
throw new NotFoundException(sprintf(
'Property %s does not exist in class %s',
$name,
$this->getName()
Expand Down
@@ -0,0 +1,7 @@
<?php

namespace ApiGen\Reflection\Reflection\Exception;

class NotFoundException extends \InvalidArgumentException
{
}

0 comments on commit 47a4eed

Please sign in to comment.