Skip to content
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ script:
- composer validate
- ./vendor/bin/phing security:check
- ./vendor/bin/phing sniff
- ./vendor/bin/phing static-analysis
- if [[ $TEST_COVERAGE == 'true' ]]; then ./vendor/bin/phing unit-with-coverage ; fi
- if [[ $TEST_COVERAGE != 'true' ]]; then ./vendor/bin/phing unit ; fi

after_script:
- if [[ $TEST_COVERAGE == 'true' ]]; then ./vendor/bin/coveralls -v ; fi

8 changes: 8 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,12 @@
<arg value="clover.xml"/>
</exec>
</target>

<target name="static-analysis">
<exec executable="./vendor/bin/phpstan"
passthru="true"
checkreturn="true">
<arg value="analyse"/>
</exec>
</target>
</project>
4 changes: 4 additions & 0 deletions captainhook.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"pre-push": {
"enabled": false,
"actions": [
{
"action": "./vendor/bin/phing static-analysis",
"options": []
},
{
"action": "./vendor/bin/phing security:check",
"options": []
Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"mikey179/vfsstream": "^1.6",
"nikic/php-parser": "^4.3",
"phing/phing": "^2.16",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan-phpunit": "^0.12.8",
"phpunit/phpunit": "^8.5.3",
"squizlabs/php_codesniffer": "^3.4"
},
Expand Down
103 changes: 102 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
parameters:
level: 7
inferPrivatePropertyTypeFromConstructor: true
fileExtensions:
- php
paths:
- src/bitExpert
- tests/bitExpert
ignoreErrors:
-
message: '~Call to an undefined method ReflectionType::getName~'
path: src/bitExpert/PHPStan/Magento/Autoload/ProxyAutoloader.php
-
message: '~Parameter #1 \$argument of class ReflectionClass constructor expects~'
path: src/bitExpert/PHPStan/Magento/Autoload/ProxyAutoloader.php
-
message: '~Class Magento\\Framework\\DataObject not found~'
path: src/bitExpert/PHPStan/Magento/Reflection/Framework/DataObjectMagicMethodReflectionExtension.php
4 changes: 2 additions & 2 deletions src/bitExpert/PHPStan/Magento/Autoload/FactoryAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public function autoload(string $class): void
/**
* Generate the factory file content as Magento would.
*
* @param $class
* @param string $class
* @return string
*/
protected function getFileContents($class): string
protected function getFileContents(string $class): string
{
$namespace = explode('\\', ltrim($class, '\\'));
$factoryClassname = array_pop($namespace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MagicMethodReflection implements MethodReflection
*/
private $declaringClass;
/**
* @var array
* @var ParametersAcceptor[]
*/
private $variants;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function setUp(): void
/**
* @test
*/
public function nullReturnedWhenLookingUpNonExistentFileInCache()
public function nullReturnedWhenLookingUpNonExistentFileInCache(): void
{
$absFilename = $this->storage->load('test.txt', '');

Expand All @@ -47,7 +47,7 @@ public function nullReturnedWhenLookingUpNonExistentFileInCache()
/**
* @test
*/
public function absoluteFilenameReturnedWhenLookingUpExistentFileInCache()
public function absoluteFilenameReturnedWhenLookingUpExistentFileInCache(): void
{
vfsStream::create(
['4b' => ['6f' => ['4b6fcb2d521ef0fd442a5301e7932d16cc9f375a.php' => 'Lorem ipsum']]],
Expand All @@ -62,7 +62,7 @@ public function absoluteFilenameReturnedWhenLookingUpExistentFileInCache()
/**
* @test
*/
public function addingFileToCacheSucceeds()
public function addingFileToCacheSucceeds(): void
{
$this->storage->save('test.txt', '', 'Lorem ipsum');
$absFilename = $this->storage->load('test.txt', '');
Expand All @@ -73,7 +73,7 @@ public function addingFileToCacheSucceeds()
/**
* @test
*/
public function addingFileToCacheFails()
public function addingFileToCacheFails(): void
{
$this->expectException(InvalidArgumentException::class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function setUp(): void
/**
* @test
*/
public function autoloaderIgnoresClassesWithoutFactoryPostfix()
public function autoloaderIgnoresClassesWithoutFactoryPostfix(): void
{
$this->storage->expects($this->never())
->method('load');
Expand All @@ -47,7 +47,7 @@ public function autoloaderIgnoresClassesWithoutFactoryPostfix()
/**
* @test
*/
public function autoloaderUsesCachedFileWhenFound()
public function autoloaderUsesCachedFileWhenFound(): void
{
$this->storage->expects($this->once())
->method('load')
Expand All @@ -61,7 +61,7 @@ public function autoloaderUsesCachedFileWhenFound()
/**
* @test
*/
public function autoloaderGeneratesCacheFileWhenNotFoundInCache()
public function autoloaderGeneratesCacheFileWhenNotFoundInCache(): void
{
$this->storage->expects($this->atMost(2))
->method('load')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function setUp(): void
/**
* @test
*/
public function autoloaderIgnoresClassesWithoutProxyPostfix()
public function autoloaderIgnoresClassesWithoutProxyPostfix(): void
{
$this->storage->expects($this->never())
->method('load');
Expand All @@ -47,7 +47,7 @@ public function autoloaderIgnoresClassesWithoutProxyPostfix()
/**
* @test
*/
public function autoloaderUsesCachedFileWhenFound()
public function autoloaderUsesCachedFileWhenFound(): void
{
$this->storage->expects($this->once())
->method('load')
Expand All @@ -61,7 +61,7 @@ public function autoloaderUsesCachedFileWhenFound()
/**
* @test
*/
public function autoloaderGeneratesCacheFileWhenNotFoundInCache()
public function autoloaderGeneratesCacheFileWhenNotFoundInCache(): void
{
// little hack: the proxy autoloader will use Reflection to look for a class without the \Proxy prefix,
// to avoid having another stub class file, we define an class alias here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
declare(strict_types=1);

namespace PHPStan\Magento\Type;
namespace bitExpert\PHPStan\Magento\Type;

use bitExpert\PHPStan\Magento\Type\ObjectManagerDynamicReturnTypeExtension;
use PhpParser\Node\Expr\MethodCall;
Expand Down