Skip to content

Commit

Permalink
Initial commit of fork
Browse files Browse the repository at this point in the history
  • Loading branch information
sidz committed Jan 28, 2024
1 parent 15aa983 commit 45eb613
Show file tree
Hide file tree
Showing 24 changed files with 81 additions and 79 deletions.
38 changes: 21 additions & 17 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
MIT License
The MIT License
---------------

Copyright (c) 2022 Andrew Riddlestone
Copyright (c) 2023 Oleg Zhulnev (https://github.com/sidz)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ PHPStan extensions to help test CakePHP 2 projects with PHPStan

Installation is best done through composer:
```shell
composer require --dev ariddlestone/phpstan-cakephp2
composer require --dev sidz/phpstan-cakephp2
```

You will need to make sure the extension is included in your phpstan config:
```yaml
# phpstan.neon
includes:
- vendor/ariddlestone/phpstan-cakephp2/extension.neon
- vendor/sidz/phpstan-cakephp2/extension.neon
```
If you have behavior classes in odd locations (perhaps in a vendor directory) you will need to add those locations to
Expand Down
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "ariddlestone/phpstan-cakephp2",
"name": "sidz/phpstan-cakephp2",
"description": "An extension to help test CakePHP 2 projects with PHPStan",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Andrew Riddlestone",
"email": "andrew.riddlestone@gmail.com"
"name": "Oleg Zhulnev",
"email": "plbsid@gmail.com"
}
],
"require": {
Expand All @@ -21,12 +21,12 @@
},
"autoload": {
"psr-4": {
"ARiddlestone\\PHPStanCakePHP2\\": "src/"
"PHPStanCakePHP2\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"ARiddlestone\\PHPStanCakePHP2\\Test\\": "tests/"
"PHPStanCakePHP2\\Test\\": "tests/"
},
"classmap": [
"tests/Feature/classes",
Expand All @@ -42,7 +42,6 @@
]
},
"scripts": {
"extract-phpstan": "phar extract -f vendor/phpstan/phpstan/phpstan.phar phpstan",
"phpinsights": "phpinsights analyse --no-interaction --ansi --config-path=phpinsights.php --summary src",
"phpinsights-github": "phpinsights analyse --no-interaction --ansi --config-path=phpinsights.php --format=github-action src",
"phpstan": "phpstan",
Expand Down
14 changes: 7 additions & 7 deletions extension.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ parameters:
stubFiles:
- stubs/Utility.php
services:
- class: ARiddlestone\PHPStanCakePHP2\ClassComponentsExtension
- class: PHPStanCakePHP2\ClassComponentsExtension
tags:
- phpstan.broker.propertiesClassReflectionExtension
- class: ARiddlestone\PHPStanCakePHP2\ClassModelsExtension
- class: PHPStanCakePHP2\ClassModelsExtension
tags:
- phpstan.broker.propertiesClassReflectionExtension
- class: ARiddlestone\PHPStanCakePHP2\ClassRegistryInitExtension
- class: PHPStanCakePHP2\ClassRegistryInitExtension
tags:
- phpstan.broker.dynamicStaticMethodReturnTypeExtension
- class: ARiddlestone\PHPStanCakePHP2\ClassTasksExtension
- class: PHPStanCakePHP2\ClassTasksExtension
tags:
- phpstan.broker.propertiesClassReflectionExtension
- class: ARiddlestone\PHPStanCakePHP2\ModelBehaviorsExtension
- class: PHPStanCakePHP2\ModelBehaviorsExtension
arguments:
behaviorPaths: %ModelBehaviorsExtension.behaviorPaths%
tags:
- phpstan.broker.methodsClassReflectionExtension
- class: ARiddlestone\PHPStanCakePHP2\Service\SchemaService
- class: PHPStanCakePHP2\Service\SchemaService
arguments:
schemaPaths: %SchemaService.schemaPaths%
- class: ARiddlestone\PHPStanCakePHP2\LoadComponentOnFlyMethodReturnTypeExtension
- class: PHPStanCakePHP2\LoadComponentOnFlyMethodReturnTypeExtension
tags:
- phpstan.broker.dynamicMethodReturnTypeExtension
parametersSchema:
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
Expand Down
2 changes: 1 addition & 1 deletion src/ClassComponentsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace ARiddlestone\PHPStanCakePHP2;
namespace PHPStanCakePHP2;

final class ClassComponentsExtension extends ClassPropertiesExtension
{
Expand Down
2 changes: 1 addition & 1 deletion src/ClassModelsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace ARiddlestone\PHPStanCakePHP2;
namespace PHPStanCakePHP2;

/**
* Adds {@link Model}s as properties to {@link Shell}s.
Expand Down
5 changes: 2 additions & 3 deletions src/ClassPropertiesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

declare(strict_types=1);

namespace ARiddlestone\PHPStanCakePHP2;
namespace PHPStanCakePHP2;

use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\PropertiesClassReflectionExtension;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Reflection\ReflectionProvider;

abstract class ClassPropertiesExtension implements
PropertiesClassReflectionExtension
abstract class ClassPropertiesExtension implements PropertiesClassReflectionExtension
{
private ReflectionProvider $reflectionProvider;

Expand Down
2 changes: 1 addition & 1 deletion src/ClassReflectionFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace ARiddlestone\PHPStanCakePHP2;
namespace PHPStanCakePHP2;

use Exception;
use PHPStan\Reflection\ClassReflection;
Expand Down
6 changes: 4 additions & 2 deletions src/ClassRegistryInitExtension.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

namespace ARiddlestone\PHPStanCakePHP2;
declare(strict_types=1);

use ARiddlestone\PHPStanCakePHP2\Service\SchemaService;
namespace PHPStanCakePHP2;

use PHPStanCakePHP2\Service\SchemaService;
use Inflector;
use PhpParser\ConstExprEvaluator;
use PhpParser\Node\Expr\StaticCall;
Expand Down
2 changes: 1 addition & 1 deletion src/ClassTasksExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace ARiddlestone\PHPStanCakePHP2;
namespace PHPStanCakePHP2;

/**
* Adds {@link Model}s as properties to {@link Shell}s.
Expand Down
2 changes: 1 addition & 1 deletion src/LoadComponentOnFlyMethodReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace ARiddlestone\PHPStanCakePHP2;
namespace PHPStanCakePHP2;

use Component;
use PhpParser\Node\Expr\MethodCall;
Expand Down
7 changes: 2 additions & 5 deletions src/ModelBehaviorMethodExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace ARiddlestone\PHPStanCakePHP2;
namespace PHPStanCakePHP2;

use PHPStan\BetterReflection\Reflection\Adapter\ReflectionMethod;
use PHPStan\Reflection\ClassReflection;
Expand All @@ -14,10 +14,7 @@

final class ModelBehaviorMethodExtractor
{
/**
* @var ClassReflection
*/
private $classReflection;
private ClassReflection $classReflection;

public function __construct(ClassReflection $classReflection)
{
Expand Down
7 changes: 2 additions & 5 deletions src/ModelBehaviorMethodWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace ARiddlestone\PHPStanCakePHP2;
namespace PHPStanCakePHP2;

use PHPStan\Reflection\ClassMemberReflection;
use PHPStan\Reflection\ClassReflection;
Expand All @@ -18,10 +18,7 @@
*/
final class ModelBehaviorMethodWrapper implements MethodReflection
{
/**
* @var MethodReflection
*/
private $wrappedMethod;
private MethodReflection $wrappedMethod;

public function __construct(MethodReflection $wrappedMethod)
{
Expand Down
14 changes: 6 additions & 8 deletions src/ModelBehaviorsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace ARiddlestone\PHPStanCakePHP2;
namespace PHPStanCakePHP2;

use Exception;
use PHPStan\Reflection\ClassReflection;
Expand All @@ -15,20 +15,17 @@
*/
final class ModelBehaviorsExtension implements MethodsClassReflectionExtension
{
/**
* @var ReflectionProvider
*/
private $reflectionProvider;
private ReflectionProvider $reflectionProvider;

/**
* @var array<string>
*/
private $behaviorPaths;
private array $behaviorPaths;

/**
* @var array<MethodReflection>|null
*/
private $behaviorMethods = null;
private ?array $behaviorMethods = null;

/**
* @param array<string> $behaviorPaths
Expand All @@ -54,7 +51,8 @@ public function hasMethod(
array_map(
[$this, 'getMethodReflectionName'],
$this->getBehaviorMethods()
)
),
true
);
}

Expand Down
14 changes: 4 additions & 10 deletions src/PublicReadOnlyPropertyReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace ARiddlestone\PHPStanCakePHP2;
namespace PHPStanCakePHP2;

use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\PropertyReflection;
Expand All @@ -12,15 +12,9 @@

final class PublicReadOnlyPropertyReflection implements PropertyReflection
{
/**
* @var string
*/
private $name;

/**
* @var ClassReflection
*/
private $declaringClass;
private string $name;

private ClassReflection $declaringClass;

public function __construct(string $name, ClassReflection $declaringClass)
{
Expand Down
6 changes: 4 additions & 2 deletions src/Service/SchemaService.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

namespace ARiddlestone\PHPStanCakePHP2\Service;
declare(strict_types=1);

use ARiddlestone\PHPStanCakePHP2\ClassReflectionFinder;
namespace PHPStanCakePHP2\Service;

use PHPStanCakePHP2\ClassReflectionFinder;
use Exception;
use PHPStan\BetterReflection\Reflection\Adapter\ReflectionProperty;
use PHPStan\Reflection\ReflectionProvider;
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion tests/Feature/ClassRegistryInitTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace ARiddlestone\PHPStanCakePHP2\Test\Feature;
declare(strict_types=1);

namespace PHPStanCakePHP2\Test\Feature;

use PHPStan\Testing\TypeInferenceTestCase;

Expand Down
4 changes: 3 additions & 1 deletion tests/Feature/ComponentExtensionsTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace ARiddlestone\PHPStanCakePHP2\Test\Feature;
declare(strict_types=1);

namespace PHPStanCakePHP2\Test\Feature;

use PHPStan\Testing\TypeInferenceTestCase;

Expand Down
4 changes: 3 additions & 1 deletion tests/Feature/ControllerExtensionsTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace ARiddlestone\PHPStanCakePHP2\Test\Feature;
declare(strict_types=1);

namespace PHPStanCakePHP2\Test\Feature;

use PHPStan\Testing\TypeInferenceTestCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace ARiddlestone\PHPStanCakePHP2\Test\Feature;
namespace PHPStanCakePHP2\Test\Feature;

use PHPStan\Testing\TypeInferenceTestCase;

Expand Down
4 changes: 3 additions & 1 deletion tests/Feature/ModelExtensionsTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace ARiddlestone\PHPStanCakePHP2\Test\Feature;
declare(strict_types=1);

namespace PHPStanCakePHP2\Test\Feature;

use PHPStan\Testing\TypeInferenceTestCase;

Expand Down
Loading

0 comments on commit 45eb613

Please sign in to comment.