Skip to content

Call to undefined method App\Console\Kernel::bootstrap() #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
@@ -1,2 +1,3 @@
/vendor/
/composer.lock
/.idea
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 7.0
- 7.1
- 7.2

Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# phpstan-laravel
Laravel plugins for [PHPStan](https://github.com/phpstan/phpstan)

[![Build Status](https://img.shields.io/travis/Weebly/phpstan-laravel/master.svg?style=flat-square)](https://travis-ci.org/Weebly/phpstan-laravel)
# phpstan-lumen
Lumen plugins for [PHPStan](https://github.com/phpstan/phpstan)

## Usage

To use this extension, require it in [Composer](https://getcomposer.org/):

```
composer require --dev weebly/phpstan-laravel
composer require --dev webparking/phpstan-lumen
```

And include extension.neon in your project's PHPStan config:

```
includes:
- vendor/weebly/phpstan-laravel/extension.neon
- vendor/webparking/phpstan-lumen/extension.neon
```
2 changes: 0 additions & 2 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
define('LARAVEL_START', microtime(true));

$app = require_once __DIR__ . '/../../../bootstrap/app.php';

$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
21 changes: 10 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
{
"name": "weebly/phpstan-laravel",
"name": "webparking2/phpstan-lumen",
"license": "BSD-2-Clause",
"description": "Laravel plugins for PHPStan",
"description": "Lumen plugins for PHPStan",
"type": "library",
"authors": [
{
"name": "Chris Leppanen",
"email": "chris.leppanen@weebly.com"
},
{
"name": "Jeroen van Oort",
"email": "jeroen.vanoort@webparking.nl"
}
],
"require": {
"laravel/framework": "5.5.* || 5.6.*",
"phpstan/phpstan": "^0.9"
"laravel/lumen-framework": "5.5.* || 5.6.* || 5.7.*",
"phpstan/phpstan": "0.10.1"
},
"require-dev": {
"phpunit/phpunit": "^6.5.2"
},
"autoload": {
"psr-4": {
"Weebly\\PHPStan\\Laravel\\": "src/"
"Webparking\\PHPStan\\Lumen\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\Weebly\\PHPStan\\Laravel\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"Tests\\Webparking\\PHPStan\\Lumen\\": "tests/"
}
}
}
14 changes: 7 additions & 7 deletions extension.neon
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
services:
-
class: Weebly\PHPStan\Laravel\MethodReflectionFactory
class: Webparking\PHPStan\Lumen\MethodReflectionFactory
-
class: Weebly\PHPStan\Laravel\BuilderMethodExtension
class: Webparking\PHPStan\Lumen\BuilderMethodExtension
tags:
- phpstan.broker.methodsClassReflectionExtension
-
class: Weebly\PHPStan\Laravel\FacadeMethodExtension
class: Webparking\PHPStan\Lumen\FacadeMethodExtension
tags:
- phpstan.broker.methodsClassReflectionExtension
-
class: Weebly\PHPStan\Laravel\MacroMethodExtension
class: Webparking\PHPStan\Lumen\MacroMethodExtension
tags:
- phpstan.broker.methodsClassReflectionExtension
-
class: Weebly\PHPStan\Laravel\HelpersReturnTypeExtension
class: Webparking\PHPStan\Lumen\HelpersReturnTypeExtension
tags:
- phpstan.broker.dynamicFunctionReturnTypeExtension

- class: Weebly\PHPStan\Laravel\Utils\AnnotationsHelper
- class: Webparking\PHPStan\Lumen\Utils\AnnotationsHelper

parameters:
bootstrap: %rootDir%/../../weebly/phpstan-laravel/bootstrap.php
bootstrap: %rootDir%/../../webparking/phpstan-lumen/bootstrap.php
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</filter>

<testsuites>
<testsuite name="weebly/phpstan-laravel">
<testsuite name="webparking/phpstan-lumen">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
Expand Down
10 changes: 5 additions & 5 deletions src/BuilderMethodExtension.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Weebly\PHPStan\Laravel;
namespace Webparking\PHPStan\Lumen;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
Expand All @@ -10,7 +10,7 @@
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\MethodsClassReflectionExtension;
use PHPStan\Reflection\MethodReflection;
use Weebly\PHPStan\Laravel\Utils\AnnotationsHelper;
use Webparking\PHPStan\Lumen\Utils\AnnotationsHelper;

final class BuilderMethodExtension implements MethodsClassReflectionExtension, BrokerAwareExtension
{
Expand All @@ -25,7 +25,7 @@ final class BuilderMethodExtension implements MethodsClassReflectionExtension, B
private $methods = [];

/**
* @var \Weebly\PHPStan\Laravel\MethodReflectionFactory
* @var \Webparking\PHPStan\Lumen\MethodReflectionFactory
*/
private $methodReflectionFactory;

Expand All @@ -37,7 +37,7 @@ final class BuilderMethodExtension implements MethodsClassReflectionExtension, B
/**
* BuilderMethodExtension constructor.
*
* @param \Weebly\PHPStan\Laravel\MethodReflectionFactory $methodReflectionFactory
* @param \Webparking\PHPStan\Lumen\MethodReflectionFactory $methodReflectionFactory
* @param AnnotationsHelper $annotationsHelper
*/
public function __construct(MethodReflectionFactory $methodReflectionFactory, AnnotationsHelper $annotationsHelper)
Expand All @@ -49,7 +49,7 @@ public function __construct(MethodReflectionFactory $methodReflectionFactory, An
/**
* @inheritdoc
*/
public function setBroker(Broker $broker)
public function setBroker(Broker $broker): void
{
$this->broker = $broker;
}
Expand Down
10 changes: 5 additions & 5 deletions src/FacadeMethodExtension.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Weebly\PHPStan\Laravel;
namespace Webparking\PHPStan\Lumen;

use Illuminate\Auth\AuthManager;
use Illuminate\Broadcasting\BroadcastManager;
Expand All @@ -10,7 +10,7 @@
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\MethodsClassReflectionExtension;
use PHPStan\Reflection\MethodReflection;
use Weebly\PHPStan\Laravel\Utils\AnnotationsHelper;
use Webparking\PHPStan\Lumen\Utils\AnnotationsHelper;
use PHPStan\Broker\ClassNotFoundException;

final class FacadeMethodExtension implements MethodsClassReflectionExtension, BrokerAwareExtension
Expand All @@ -34,7 +34,7 @@ final class FacadeMethodExtension implements MethodsClassReflectionExtension, Br
private $methods = [];

/**
* @var \Weebly\PHPStan\Laravel\MethodReflectionFactory
* @var \Webparking\PHPStan\Lumen\MethodReflectionFactory
*/
private $methodReflectionFactory;

Expand All @@ -46,7 +46,7 @@ final class FacadeMethodExtension implements MethodsClassReflectionExtension, Br
/**
* FacadeMethodExtension constructor.
*
* @param \Weebly\PHPStan\Laravel\MethodReflectionFactory $methodReflectionFactory
* @param \Webparking\PHPStan\Lumen\MethodReflectionFactory $methodReflectionFactory
* @param AnnotationsHelper $annotationsHelper
*/
public function __construct(MethodReflectionFactory $methodReflectionFactory, AnnotationsHelper $annotationsHelper)
Expand All @@ -58,7 +58,7 @@ public function __construct(MethodReflectionFactory $methodReflectionFactory, An
/**
* @inheritdoc
*/
public function setBroker(Broker $broker)
public function setBroker(Broker $broker): void
{
$this->broker = $broker;
}
Expand Down
6 changes: 3 additions & 3 deletions src/HelpersReturnTypeExtension.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Weebly\PHPStan\Laravel;
namespace Webparking\PHPStan\Lumen;

use PhpParser\Node\Expr\ClassConstFetch;
use PhpParser\Node\Expr\FuncCall;
Expand Down Expand Up @@ -42,7 +42,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
switch ($functionReflection->getName()) {
case 'app':
if (empty($functionCall->args) || $scope->getType($functionCall->args[0]->value) instanceof NullType) {
return new ObjectType(\Illuminate\Foundation\Application::class);
return new ObjectType(\Laravel\Lumen\Application::class);
}

$arg1 = $functionCall->args[0];
Expand All @@ -58,7 +58,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
return new MixedType();
case 'redirect':
if (empty($functionCall->args)) {
return new ObjectType(\Illuminate\Routing\Redirector::class);
return new ObjectType(\Laravel\Lumen\Http\Redirector::class);
}

return new ObjectType(\Illuminate\Http\RedirectResponse::class);
Expand Down
5 changes: 3 additions & 2 deletions src/MacroMethodExtension.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Weebly\PHPStan\Laravel;
namespace Webparking\PHPStan\Lumen;

use Illuminate\Support\Traits\Macroable;
use PHPStan\Broker\Broker;
Expand Down Expand Up @@ -50,7 +50,7 @@ public function __construct(PhpMethodReflectionFactory $methodReflectionFactory,
/**
* @inheritdoc
*/
public function setBroker(Broker $broker)
public function setBroker(Broker $broker): void
{
$this->broker = $broker;
}
Expand Down Expand Up @@ -106,6 +106,7 @@ private function createMethod(ClassReflection $classReflection, \ReflectionFunct
$resolvedPhpDoc = $this->fileTypeMapper->getResolvedPhpDoc(
$functionReflection->getFileName(),
null,
null,
$functionReflection->getDocComment()
);

Expand Down
18 changes: 16 additions & 2 deletions src/MethodReflectionFactory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Weebly\PHPStan\Laravel;
namespace Webparking\PHPStan\Lumen;

use PHPStan\Broker\Broker;
use PHPStan\PhpDoc\PhpDocBlock;
Expand Down Expand Up @@ -48,6 +48,10 @@ public function create(ClassReflection $classReflection, \ReflectionMethod $meth
{
$phpDocParameterTypes = [];
$phpDocReturnType = null;
$phpDocThrowType = null;
$phpDocIsDeprecated = false;
$phpDocIsInternal = false;
$phpDocIsFinal = false;
if ($methodReflection->getDocComment() !== false) {
$phpDocBlock = PhpDocBlock::resolvePhpDocBlockForMethod(
Broker::getInstance(),
Expand All @@ -60,12 +64,17 @@ public function create(ClassReflection $classReflection, \ReflectionMethod $meth
$resolvedPhpDoc = $this->fileTypeMapper->getResolvedPhpDoc(
$phpDocBlock->getFile(),
$phpDocBlock->getClass(),
null,
$phpDocBlock->getDocComment()
);
$phpDocParameterTypes = array_map(function (ParamTag $tag): Type {
return $tag->getType();
}, $resolvedPhpDoc->getParamTags());
$phpDocReturnType = $resolvedPhpDoc->getReturnTag() !== null ? $resolvedPhpDoc->getReturnTag()->getType() : null;
$phpDocThrowType = $resolvedPhpDoc->getThrowsTag() !== null ? $resolvedPhpDoc->getThrowsTag()->getType() : null;
$phpDocIsDeprecated = $resolvedPhpDoc->isDeprecated();
$phpDocIsInternal = $resolvedPhpDoc->isInternal();
$phpDocIsFinal = $resolvedPhpDoc->isFinal();
}

if ($methodWrapper) {
Expand All @@ -74,9 +83,14 @@ public function create(ClassReflection $classReflection, \ReflectionMethod $meth

return $this->methodReflectionFactory->create(
$classReflection,
null,
$methodReflection,
$phpDocParameterTypes,
$phpDocReturnType
$phpDocReturnType,
$phpDocThrowType,
$phpDocIsDeprecated,
$phpDocIsInternal,
$phpDocIsFinal
);
}
}
2 changes: 1 addition & 1 deletion src/ReflectionMethodAlwaysStatic.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Weebly\PHPStan\Laravel;
namespace Webparking\PHPStan\Lumen;

final class ReflectionMethodAlwaysStatic extends \ReflectionMethod
{
Expand Down
2 changes: 1 addition & 1 deletion src/ReflectionMethodFunctionProxy.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types = 1);

namespace Weebly\PHPStan\Laravel;
namespace Webparking\PHPStan\Lumen;

final class ReflectionMethodFunctionProxy extends \ReflectionMethod
{
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/AnnotationsHelper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Weebly\PHPStan\Laravel\Utils;
namespace Webparking\PHPStan\Lumen\Utils;

use PHPStan\Reflection\ClassReflection;

Expand Down
10 changes: 5 additions & 5 deletions tests/BuilderMethodExtensionTest.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?php declare(strict_types = 1);

namespace Tests\Weebly\PHPStan\Laravel;
namespace Tests\Webparking\PHPStan\Lumen;

use PHPStan\Testing\TestCase;
use PHPStan\Broker\Broker;
use Weebly\PHPStan\Laravel\MethodReflectionFactory;
use Webparking\PHPStan\Lumen\MethodReflectionFactory;
use PHPUnit\Framework\MockObject\MockObject;
use PHPStan\Reflection\Php\PhpMethodReflectionFactory;
use PHPStan\Reflection\Php\PhpMethodReflection;
use PHPStan\Type\FileTypeMapper;
use Illuminate\Database\Eloquent\Model;
use Weebly\PHPStan\Laravel\BuilderMethodExtension;
use Webparking\PHPStan\Lumen\BuilderMethodExtension;
use stdClass;
use Illuminate\Database\Eloquent\Builder;
use Weebly\PHPStan\Laravel\Utils\AnnotationsHelper;
use Webparking\PHPStan\Lumen\Utils\AnnotationsHelper;
use PHPStan\Broker\ClassNotFoundException;

/**
* @package Tests\Weebly\PHPStan\Laravel
* @package Tests\Webparking\PHPStan\Lumen
*/
class BuilderMethodExtensionTest extends TestCase
{
Expand Down
Loading