Skip to content
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

Bump dev tools and CI workflows #89

Merged
merged 1 commit into from Mar 2, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/coding-standards.yml
Expand Up @@ -12,6 +12,7 @@ on:
jobs:
coding-standards:
name: "Coding Standards"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.2.0"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.4.1"
with:
composer-root-version: "1.4"
php-version: "8.1"
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yml
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
phpunit:
name: "PHPUnit"
uses: "doctrine/.github/.github/workflows/continuous-integration.yml@1.2.0"
uses: "doctrine/.github/.github/workflows/continuous-integration.yml@1.4.1"
with:
php-versions: '["7.1", "7.2", "7.3", "7.4", "8.0"]'
php-versions: '["7.1", "7.2", "7.3", "7.4", "8.0", "8.1"]'
composer-root-version: "1.4"
2 changes: 1 addition & 1 deletion .github/workflows/phpbench.yml
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"

steps:
- name: "Checkout"
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release-on-milestone-closed.yml
Expand Up @@ -8,9 +8,8 @@ on:
jobs:
release:
name: "Git tag, release & create merge-up PR"
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@1.2.0"
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@1.4.1"
secrets:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
ORGANIZATION_ADMIN_TOKEN: ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
static-analysis:
name: "Static Analysis"
uses: "doctrine/.github/.github/workflows/static-analysis.yml@1.2.0"
uses: "doctrine/.github/.github/workflows/static-analysis.yml@1.4.1"
with:
composer-root-version: "1.4"
php-version: "7.4"
php-version: "8.1"
17 changes: 11 additions & 6 deletions composer.json
Expand Up @@ -21,12 +21,12 @@
"require-dev": {
"ext-phar": "*",
"ext-pdo": "*",
"doctrine/coding-standard": "^8.0",
"phpbench/phpbench": "^0.13 || 1.0.0-alpha2",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"vimeo/psalm": "^4.11"
"doctrine/coding-standard": "^9",
"phpbench/phpbench": "^0.16 || ^1",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan-phpunit": "^1",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"vimeo/psalm": "^4.22"
},
"autoload": {
"psr-4": {
Expand All @@ -39,5 +39,10 @@
"DoctrineTest\\InstantiatorTest\\": "tests",
"DoctrineTest\\InstantiatorTestAsset\\": "tests"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
4 changes: 2 additions & 2 deletions phpbench.json
@@ -1,4 +1,4 @@
{
"bootstrap": "vendor/autoload.php",
"path": "tests/DoctrineTest/InstantiatorPerformance"
"runner.bootstrap": "vendor/autoload.php",
"runner.path": "tests/DoctrineTest/InstantiatorPerformance"
}
6 changes: 5 additions & 1 deletion phpcs.xml.dist
Expand Up @@ -9,6 +9,8 @@
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>

<config name="php_version" value="70100"/>

<file>src</file>
<file>tests</file>

Expand All @@ -27,7 +29,9 @@
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint">
<exclude-pattern>*/src/*</exclude-pattern>
<exclude-pattern>src/*</exclude-pattern>
<exclude-pattern>tests/DoctrineTest/InstantiatorTestAsset/SerializableArrayObjectAsset.php</exclude-pattern>
<exclude-pattern>tests/DoctrineTest/InstantiatorTestAsset/SimpleSerializableAsset.php</exclude-pattern>
</rule>

<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint">
Expand Down
8 changes: 7 additions & 1 deletion phpstan.neon.dist
Expand Up @@ -4,12 +4,18 @@ includes:

parameters:
level: max
phpVersion: 80103
paths:
- src
- tests

ignoreErrors:
# PHPStan is unable to infer the return type of unserialize() in this case.
-
message: '#Method Doctrine\\Instantiator\\Instantiator\:\:buildFactory\(\) should return callable\(\): T of object but returns Closure\(\): mixed\.#'
path: 'src/Doctrine/Instantiator/Instantiator.php'

# dynamic properties confuse static analysis
-
message: '#Access to an undefined property object::\$foo\.#'
path: '*/tests/DoctrineTest/InstantiatorTest/InstantiatorTest.php'
path: 'tests/DoctrineTest/InstantiatorTest/InstantiatorTest.php'
8 changes: 7 additions & 1 deletion phpunit.xml.dist
@@ -1,15 +1,21 @@
<?xml version="1.0"?>
<phpunit
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
convertDeprecationsToExceptions="true"
verbose="true"
stopOnFailure="false"
processIsolation="false"
backupGlobals="false"
>
<php>
<ini name="error_reporting" value="-1" />
</php>

<testsuite name="Doctrine\Instantiator tests">
<directory>./tests/DoctrineTest/InstantiatorTest</directory>
</testsuite>
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<psalm
errorLevel="7"
phpVersion="8.1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand Down
Expand Up @@ -28,8 +28,9 @@ public static function fromNonExistingClass(string $className): self
}

/**
* @template T of object
* @phpstan-param ReflectionClass<T> $reflectionClass
*
* @template T of object
*/
public static function fromAbstractClass(ReflectionClass $reflectionClass): self
{
Expand Down
Expand Up @@ -14,8 +14,9 @@
class UnexpectedValueException extends BaseUnexpectedValueException implements ExceptionInterface
{
/**
* @template T of object
* @phpstan-param ReflectionClass<T> $reflectionClass
*
* @template T of object
*/
public static function fromSerializationTriggeredException(
ReflectionClass $reflectionClass,
Expand All @@ -32,8 +33,9 @@ public static function fromSerializationTriggeredException(
}

/**
* @template T of object
* @phpstan-param ReflectionClass<T> $reflectionClass
*
* @template T of object
*/
public static function fromUncleanUnSerialization(
ReflectionClass $reflectionClass,
Expand Down
40 changes: 23 additions & 17 deletions src/Doctrine/Instantiator/Instantiator.php
Expand Up @@ -45,15 +45,14 @@ final class Instantiator implements InstantiatorInterface

/**
* @param string $className
* @phpstan-param class-string<T> $className
*
* @return object
* @phpstan-return T
*
* @throws ExceptionInterface
*
* @template T of object
* @phpstan-param class-string<T> $className
*
* @phpstan-return T
*/
public function instantiate($className)
{
Expand All @@ -78,12 +77,12 @@ public function instantiate($className)
/**
* Builds the requested object and caches it in static properties for performance
*
* @return object
*
* @template T of object
* @phpstan-param class-string<T> $className
*
* @return object
* @phpstan-return T
*
* @template T of object
*/
private function buildAndCacheFromFactory(string $className)
{
Expand All @@ -101,14 +100,15 @@ private function buildAndCacheFromFactory(string $className)
* Builds a callable capable of instantiating the given $className without
* invoking its constructor.
*
* @phpstan-param class-string<T> $className
*
* @phpstan-return callable(): T
*
* @throws InvalidArgumentException
* @throws UnexpectedValueException
* @throws ReflectionException
*
* @template T of object
* @phpstan-param class-string<T> $className
*
* @phpstan-return callable(): T
*/
private function buildFactory(string $className): callable
{
Expand All @@ -133,13 +133,14 @@ private function buildFactory(string $className): callable
}

/**
* @phpstan-param class-string<T> $className
*
* @phpstan-return ReflectionClass<T>
*
* @throws InvalidArgumentException
* @throws ReflectionException
*
* @template T of object
* @phpstan-param class-string<T> $className
*
* @phpstan-return ReflectionClass<T>
*/
private function getReflectionClass(string $className): ReflectionClass
{
Expand All @@ -157,10 +158,11 @@ private function getReflectionClass(string $className): ReflectionClass
}

/**
* @phpstan-param ReflectionClass<T> $reflectionClass
*
* @throws UnexpectedValueException
*
* @template T of object
* @phpstan-param ReflectionClass<T> $reflectionClass
*/
private function checkIfUnSerializationIsSupported(ReflectionClass $reflectionClass, string $serializedString): void
{
Expand Down Expand Up @@ -188,10 +190,11 @@ private function checkIfUnSerializationIsSupported(ReflectionClass $reflectionCl
}

/**
* @phpstan-param ReflectionClass<T> $reflectionClass
*
* @throws UnexpectedValueException
*
* @template T of object
* @phpstan-param ReflectionClass<T> $reflectionClass
*/
private function attemptInstantiationViaUnSerialization(ReflectionClass $reflectionClass, string $serializedString): void
{
Expand All @@ -203,8 +206,9 @@ private function attemptInstantiationViaUnSerialization(ReflectionClass $reflect
}

/**
* @template T of object
* @phpstan-param ReflectionClass<T> $reflectionClass
*
* @template T of object
*/
private function isInstantiableViaReflection(ReflectionClass $reflectionClass): bool
{
Expand All @@ -214,8 +218,9 @@ private function isInstantiableViaReflection(ReflectionClass $reflectionClass):
/**
* Verifies whether the given class is to be considered internal
*
* @template T of object
* @phpstan-param ReflectionClass<T> $reflectionClass
*
* @template T of object
*/
private function hasInternalAncestors(ReflectionClass $reflectionClass): bool
{
Expand All @@ -235,8 +240,9 @@ private function hasInternalAncestors(ReflectionClass $reflectionClass): bool
*
* Classes implementing `__clone` cannot be safely cloned, as that may cause side-effects.
*
* @template T of object
* @phpstan-param ReflectionClass<T> $reflectionClass
*
* @template T of object
*/
private function isSafeToClone(ReflectionClass $reflectionClass): bool
{
Expand Down
5 changes: 2 additions & 3 deletions src/Doctrine/Instantiator/InstantiatorInterface.php
Expand Up @@ -11,15 +11,14 @@ interface InstantiatorInterface
{
/**
* @param string $className
* @phpstan-param class-string<T> $className
*
* @return object
* @phpstan-return T
*
* @throws ExceptionInterface
*
* @template T of object
* @phpstan-param class-string<T> $className
*
* @phpstan-return T
*/
public function instantiate($className);
}
Expand Up @@ -15,7 +15,7 @@
*
* @BeforeMethods({"init"})
*/
class InstantiatorPerformanceEvent
class InstantiatorPerformanceBench
{
/** @var Instantiator */
private $instantiator;
Expand Down
10 changes: 6 additions & 4 deletions tests/DoctrineTest/InstantiatorTest/InstantiatorTest.php
Expand Up @@ -47,17 +47,19 @@ protected function setUp(): void
}

/**
* @dataProvider getInstantiableClasses
* @phpstan-param class-string $className
*
* @dataProvider getInstantiableClasses
*/
public function testCanInstantiate(string $className): void
{
self::assertInstanceOf($className, $this->instantiator->instantiate($className));
}

/**
* @dataProvider getInstantiableClasses
* @phpstan-param class-string $className
*
* @dataProvider getInstantiableClasses
*/
public function testInstantiatesSeparateInstances(string $className): void
{
Expand All @@ -76,8 +78,9 @@ public function testExceptionOnUnSerializationException(): void
}

/**
* @dataProvider getInvalidClassNames
* @phpstan-param class-string $invalidClassName
*
* @dataProvider getInvalidClassNames
*/
public function testInstantiationFromNonExistingClass(string $invalidClassName): void
{
Expand Down Expand Up @@ -110,7 +113,6 @@ public function testInstancesAreNotCloned(): void
* Provides a list of instantiable classes (existing)
*
* @return string[][]
*
* @phpstan-return list<array{class-string}>
*/
public function getInstantiableClasses(): array
Expand Down