36 Commits
1.2.1 ... 1.2.3

Author SHA1 Message Date
Alexander M. Turek
1034e5e71f Bump CI tooling and workflows and fix remaining PHP 8.1 issues (#58) 2022-05-31 20:46:25 +02:00
Andor
d5ae5d3a5b Fix PHP 8.1 deprecations for tentative return types (#57) 2022-05-31 15:51:40 +02:00
Grégoire Paris
02097bc0fe Merge pull request #55 from greg0ire/remove-references-to-master
Remove references to master
2021-02-05 23:46:02 +01:00
Grégoire Paris
381bfa425f Remove references to master
There isn't going to be a next minor or major. Only bugfixes might get
merged.
2021-02-05 19:55:53 +01:00
Grégoire Paris
d186376821 Merge pull request #54 from nicwortel/remove-composer-lock
Remove composer.lock from version control
2021-01-07 22:02:49 +01:00
Nic Wortel
04367f0db3 In the PHPUnit CI job, remove PHPStan and Doctrine Coding Standard
These dev tools are incompatible with PHP 8.
2021-01-07 21:54:47 +01:00
Nic Wortel
e44961f0af Remove composer.lock from version control
See https://github.com/orgs/doctrine/projects/7#card-50248076.
2021-01-07 21:44:22 +01:00
Grégoire Paris
970fe98e79 Merge pull request #53 from greg0ire/abandon-package
Abandon package
2020-11-02 22:01:43 +01:00
Grégoire Paris
6c3096dd9b Abandon package
Other Doctrine packages have migrated away from doctrine/reflection,
which means this library is no longer worth maintaining.
2020-10-29 23:48:40 +01:00
Grégoire Paris
26ba62bc4b Merge pull request #52 from greg0ire/migrate-tests-to-ga
Migrate from Travis to Github Actions
2020-10-27 23:40:38 +01:00
Grégoire Paris
4ac6925893 Migrate Static Analysis to Github Actions 2020-10-27 23:38:13 +01:00
Grégoire Paris
1e02418cf8 Migrate unit tests to Github Actions 2020-10-27 23:04:07 +01:00
Grégoire Paris
fa587178be Merge pull request #49 from alexpott/php8-compatibility
PHP 8 compatibility
2020-10-27 22:46:55 +01:00
Alex Pott
dc269e064a doctrine/coding-standard needs a PHP 8.0 compatible version 2020-10-27 21:35:12 +00:00
Alex Pott
a8d82251c6 Fix up things after merging 1.2.x 2020-10-27 21:27:25 +00:00
Alex Pott
f3ade869eb Ensure phpstan runs with locked dependencies 2020-10-27 22:05:39 +01:00
Alex Pott
06eec07aa3 Ignore compatibility files in phpstan 2020-10-27 22:05:39 +01:00
Alex Pott
2336d15b1a Update dist to use a more recent PHP 8.0 2020-10-27 22:04:16 +01:00
Alex Pott
a82bebf801 Initial commit 2020-10-27 22:04:16 +01:00
Grégoire Paris
e65c2eb6a8 Merge pull request #51 from doctrine/greg0ire-patch-1
Setup release workflow
2020-10-27 22:01:47 +01:00
Grégoire Paris
e3c48f5fbd Merge pull request #50 from greg0ire/migrate-cs-to-ga
Migrate cs to ga
2020-10-27 21:55:50 +01:00
Grégoire Paris
cac3bcb8fc Migrate to Github Actions for coding standard 2020-10-27 21:47:11 +01:00
Grégoire Paris
db4b566464 Setup release workflow 2020-10-27 21:45:16 +01:00
Grégoire Paris
486d0cbea5 Upgrade doctrine/coding-standard
It depends on a library that needs to be upgraded so that we can use
Composer 2
2020-10-27 21:40:39 +01:00
Claudio Zizza
cea2760c34 Merge pull request #48 from doctrine/default-branch-website-config
Move website config to default branch
2020-10-05 14:03:36 +02:00
Claudio Zizza
4f143d5384 Move website config to default branch
Adapts the website config to be compatible with the doctrine/doctrine-website#356 changes
2020-10-03 20:14:44 +02:00
Grégoire Paris
efdbb0f82a Merge pull request #44 from greg0ire/scrutinizer➡codecov
Use CodeCov instead of Scrutinizer
2020-06-20 15:00:11 +02:00
Grégoire Paris
edfb312da0 Use CodeCov instead of Scrutinizer 2020-06-20 14:12:43 +02:00
Grégoire Paris
344bc74ba8 Merge remote-tracking branch 'origin/1.1.x' into 1.2.x 2020-05-27 18:45:57 +02:00
Grégoire Paris
1b33070b49 Merge pull request #33 from DieterHolvoet/issue-32
Fix Trying to access array offset on value of type null
2020-04-26 13:02:52 +02:00
Dieter Holvoet
41a2f0f445 Add type check to prevent PHP 7.4 warnings
PHP 7.4 introduces a "Trying to access array offset on value of type ..." warning for accessing null/bool/int/float/resource (everything but array, string and object) as if it were an array. This commit fixes an instance where this warning is emitted.

Fixes #32.
2020-04-26 12:57:05 +02:00
Grégoire Paris
d11bac73db Merge pull request #40 from pgrimaud/master
Fix typo in lib/Doctrine/Common/Reflection/TypedNoDefaultReflectionProperty.php
2020-04-18 23:41:10 +02:00
Pierre Grimaud
1c7272c98a Fix typos 2020-04-18 23:34:26 +02:00
Grégoire Paris
8f7fdc01b3 Merge pull request #38 from greg0ire/validate-composer-json
Validate composer json
2020-03-30 18:19:46 +02:00
Grégoire Paris
79de2517ba Sort packages alphabetically 2020-03-24 09:21:01 +01:00
Grégoire Paris
827618c360 Validate composer files 2020-03-24 09:20:26 +01:00
37 changed files with 486 additions and 3783 deletions

View File

@@ -6,20 +6,20 @@
"versions": [
{
"name": "1.2",
"branchName": "master",
"slug": "latest",
"upcoming": true
},
{
"name": "1.1",
"branchName": "1.1.x",
"slug": "1.1",
"branchName": "1.2.x",
"slug": "1.2",
"current": true,
"aliases": [
"current",
"stable"
]
},
{
"name": "1.1",
"branchName": "1.1.x",
"slug": "1.1",
"maintained": false
},
{
"name": "1.0",
"branchName": "1.0",

1
.gitattributes vendored
View File

@@ -5,4 +5,3 @@
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/phpcs.xml.dist export-ignore
/composer.lock export-ignore

16
.github/workflows/coding-standards.yml vendored Normal file
View File

@@ -0,0 +1,16 @@
name: "Coding Standards"
on:
pull_request:
branches:
- "*.x"
push:
branches:
- "*.x"
jobs:
coding-standards:
uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.4.1"
with:
php-version: "8.1"
composer-root-version: "1.2"

View File

@@ -0,0 +1,17 @@
name: "Continuous Integration"
on:
pull_request:
branches:
- "*.x"
push:
branches:
- "*.x"
jobs:
phpunit:
name: "PHPUnit"
uses: "doctrine/.github/.github/workflows/continuous-integration.yml@1.4.1"
with:
php-versions: '["7.1", "7.2", "7.3", "7.4", "8.0", "8.1"]'
composer-root-version: "1.2"

View File

@@ -0,0 +1,15 @@
name: "Automatic Releases"
on:
milestone:
types:
- "closed"
jobs:
release:
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@1.4.1"
secrets:
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
ORGANIZATION_ADMIN_TOKEN: ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}
SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}

39
.github/workflows/static-analysis.yml vendored Normal file
View File

@@ -0,0 +1,39 @@
name: "Static Analysis"
on:
pull_request:
branches:
- "*.x"
push:
branches:
- "*.x"
jobs:
phpstan:
name: "PHPStan"
runs-on: "ubuntu-20.04"
env:
COMPOSER_ROOT_VERSION: "1.2"
strategy:
matrix:
php-version:
- "8.1"
steps:
- name: "Checkout code"
uses: "actions/checkout@v2"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "highest"
- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan analyse"

2
.gitignore vendored
View File

@@ -1,4 +1,6 @@
/vendor/
/composer.lock
/phpunit.xml
/phpcs.xml
/.phpcs-cache
/.phpunit.result.cache

View File

@@ -1,29 +0,0 @@
build:
nodes:
analysis:
environment:
php:
version: 7.1
cache:
disabled: false
directories:
- ~/.composer/cache
project_setup:
override: true
tests:
override:
- php-scrutinizer-run
- phpcs-run
dependencies:
override:
- COMPOSER_ROOT_VERSION=1.2 composer install -noa
tools:
external_code_coverage:
timeout: 600
build_failure_conditions:
- 'elements.rating(<= C).new.exists' # No new classes/methods with a rating of C or worse allowed
- 'issues.label("coding-style").new.exists' # No new coding style issues allowed
- 'issues.severity(>= MAJOR).new.exists' # New issues of major or higher severity
- 'project.metric_change("scrutinizer.test_coverage", < 0)' # Code Coverage decreased from previous inspection

View File

@@ -1,52 +0,0 @@
dist: trusty
sudo: false
language: php
env:
global:
- COMPOSER_ROOT_VERSION=1.2
cache:
directories:
- $HOME/.composer/cache
php:
- 7.1
- 7.2
- 7.3
- 7.4
- nightly
before_install:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
install:
- rm composer.lock
- travis_retry composer update -n --prefer-dist
script: ./vendor/bin/phpunit
jobs:
allow_failures:
- php: nightly
include:
- stage: Coverage
before_script:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
script:
- ./vendor/bin/phpunit --coverage-clover clover.xml
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover clover.xml
- stage: Coding standard
install:
- travis_retry composer install -n --prefer-dist
script:
- ./vendor/bin/phpcs
- stage: Lint
php: 7.4
script: vendor/bin/phpstan analyse

View File

@@ -1,8 +1,11 @@
⚠ This package is abandoned, consider migrating to alternatives, such as
`roave/better-reflection`. Features that are still useful to Doctrine have been
moved to `doctrine/persistence`
# Doctrine Reflection
[![Build Status](https://travis-ci.org/doctrine/reflection.svg)](https://travis-ci.org/doctrine/reflection)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/doctrine/reflection/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/doctrine/reflection/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/doctrine/reflection/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/doctrine/reflection/?branch=master)
[![Code Coverage](https://codecov.io/gh/doctrine/dbal/branch/reflection/graph/badge.svg)](https://codecov.io/gh/doctrine/reflection/branch/1.2.x)
The Doctrine Reflection project is a simple library used by the various Doctrine projects which adds some additional functionality on top of the reflection functionality that comes with PHP. It allows you to get the reflection information about classes, methods and properties statically.

View File

@@ -17,16 +17,16 @@
{"name": "Marco Pivetta", "email": "ocramius@gmail.com"}
],
"require": {
"php": "^7.1",
"php": "^7.1 || ^8.0",
"ext-tokenizer": "*",
"doctrine/annotations": "^1.0"
},
"require-dev": {
"phpstan/phpstan": "^0.11.0",
"phpstan/phpstan-phpunit": "^0.11.0",
"phpunit/phpunit": "^7.0",
"doctrine/coding-standard": "^5.0",
"doctrine/common": "^2.10"
"doctrine/coding-standard": "^9",
"doctrine/common": "^3.3",
"phpstan/phpstan": "^1.4.10",
"phpstan/phpstan-phpunit": "^1",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5"
},
"conflict": {
"doctrine/common": "<2.9"
@@ -42,9 +42,11 @@
"Doctrine\\Tests_PHP74\\": "tests/Doctrine/Tests_PHP74"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
}
}
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
},
"sort-packages": true
},
"abandoned": "roave/better-reflection"
}

3593
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,24 @@
<?php
namespace Doctrine\Common\Reflection\Compatibility\Php7;
use ReflectionException;
trait ReflectionClass
{
/**
* {@inheritDoc}
*/
public function getConstants()
{
throw new ReflectionException('Method not implemented');
}
/**
* {@inheritDoc}
*/
public function newInstance($args)
{
throw new ReflectionException('Method not implemented');
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace Doctrine\Common\Reflection\Compatibility\Php7;
use ReflectionException;
trait ReflectionMethod
{
/**
* {@inheritDoc}
*/
public function invoke($object, $parameter = null)
{
throw new ReflectionException('Method not implemented');
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Doctrine\Common\Reflection\Compatibility\Php8;
use ReflectionException;
use ReturnTypeWillChange;
trait ReflectionClass
{
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getConstants(?int $filter = null)
{
throw new ReflectionException('Method not implemented');
}
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function newInstance(mixed ...$args)
{
throw new ReflectionException('Method not implemented');
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Doctrine\Common\Reflection\Compatibility\Php8;
use ReflectionException;
use ReturnTypeWillChange;
trait ReflectionMethod
{
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function invoke(?object $object, mixed ...$args)
{
throw new ReflectionException('Method not implemented');
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Doctrine\Common\Reflection\Compatibility;
use function class_alias;
use const PHP_VERSION_ID;
if (PHP_VERSION_ID >= 80000) {
class_alias('Doctrine\Common\Reflection\Compatibility\Php8\ReflectionClass', 'Doctrine\Common\Reflection\Compatibility\ReflectionClass');
} else {
class_alias('Doctrine\Common\Reflection\Compatibility\Php7\ReflectionClass', 'Doctrine\Common\Reflection\Compatibility\ReflectionClass');
}
if (false) {
trait ReflectionClass
{
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Doctrine\Common\Reflection\Compatibility;
use function class_alias;
use const PHP_VERSION_ID;
if (PHP_VERSION_ID >= 80000) {
class_alias('Doctrine\Common\Reflection\Compatibility\Php8\ReflectionMethod', 'Doctrine\Common\Reflection\Compatibility\ReflectionMethod');
} else {
class_alias('Doctrine\Common\Reflection\Compatibility\Php7\ReflectionMethod', 'Doctrine\Common\Reflection\Compatibility\ReflectionMethod');
}
if (false) {
trait ReflectionMethod
{
}
}

View File

@@ -2,13 +2,14 @@
namespace Doctrine\Common\Reflection;
use const DIRECTORY_SEPARATOR;
use function is_file;
use function str_replace;
use function strpos;
use function strrpos;
use function substr;
use const DIRECTORY_SEPARATOR;
/**
* Finds a class in a PSR-0 structure.
*/

View File

@@ -4,6 +4,7 @@ namespace Doctrine\Common\Reflection;
use Doctrine\Common\Proxy\Proxy;
use ReflectionProperty;
use ReturnTypeWillChange;
/**
* PHP Runtime Reflection Public Property - special overrides for public properties.
@@ -17,6 +18,7 @@ class RuntimePublicReflectionProperty extends ReflectionProperty
* This is to avoid calling `__get` on the provided $object if it
* is a {@see \Doctrine\Common\Proxy\Proxy}.
*/
#[ReturnTypeWillChange]
public function getValue($object = null)
{
$name = $this->getName();
@@ -41,6 +43,7 @@ class RuntimePublicReflectionProperty extends ReflectionProperty
*
* @link https://bugs.php.net/bug.php?id=63463
*/
#[ReturnTypeWillChange]
public function setValue($object, $value = null)
{
if (! ($object instanceof Proxy && ! $object->__isInitialized())) {

View File

@@ -2,11 +2,15 @@
namespace Doctrine\Common\Reflection;
use Doctrine\Common\Reflection\Compatibility\ReflectionClass as CompatibilityReflectionClass;
use ReflectionClass;
use ReflectionException;
use ReturnTypeWillChange;
class StaticReflectionClass extends ReflectionClass
{
use CompatibilityReflectionClass;
/**
* The static reflection parser object.
*
@@ -22,6 +26,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getName()
{
return $this->staticReflectionParser->getClassName();
@@ -30,6 +35,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getDocComment()
{
return $this->staticReflectionParser->getDocComment();
@@ -38,6 +44,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getNamespaceName()
{
return $this->staticReflectionParser->getNamespaceName();
@@ -54,6 +61,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getMethod($name)
{
return $this->staticReflectionParser->getReflectionMethod($name);
@@ -62,6 +70,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getProperty($name)
{
return $this->staticReflectionParser->getReflectionProperty($name);
@@ -78,6 +87,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getConstant($name)
{
throw new ReflectionException('Method not implemented');
@@ -86,14 +96,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
public function getConstants()
{
throw new ReflectionException('Method not implemented');
}
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getConstructor()
{
throw new ReflectionException('Method not implemented');
@@ -102,6 +105,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getDefaultProperties()
{
throw new ReflectionException('Method not implemented');
@@ -110,6 +114,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getEndLine()
{
throw new ReflectionException('Method not implemented');
@@ -118,6 +123,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getExtension()
{
throw new ReflectionException('Method not implemented');
@@ -126,6 +132,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getExtensionName()
{
throw new ReflectionException('Method not implemented');
@@ -134,6 +141,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getFileName()
{
throw new ReflectionException('Method not implemented');
@@ -142,6 +150,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getInterfaceNames()
{
throw new ReflectionException('Method not implemented');
@@ -150,6 +159,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getInterfaces()
{
throw new ReflectionException('Method not implemented');
@@ -158,6 +168,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getMethods($filter = null)
{
throw new ReflectionException('Method not implemented');
@@ -166,6 +177,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getModifiers()
{
throw new ReflectionException('Method not implemented');
@@ -174,6 +186,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getParentClass()
{
throw new ReflectionException('Method not implemented');
@@ -182,6 +195,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getProperties($filter = null)
{
throw new ReflectionException('Method not implemented');
@@ -190,6 +204,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getShortName()
{
throw new ReflectionException('Method not implemented');
@@ -198,6 +213,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getStartLine()
{
throw new ReflectionException('Method not implemented');
@@ -206,6 +222,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getStaticProperties()
{
throw new ReflectionException('Method not implemented');
@@ -214,6 +231,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getStaticPropertyValue($name, $default = '')
{
throw new ReflectionException('Method not implemented');
@@ -222,6 +240,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getTraitAliases()
{
throw new ReflectionException('Method not implemented');
@@ -230,6 +249,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getTraitNames()
{
throw new ReflectionException('Method not implemented');
@@ -238,6 +258,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getTraits()
{
throw new ReflectionException('Method not implemented');
@@ -246,6 +267,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function hasConstant($name)
{
throw new ReflectionException('Method not implemented');
@@ -254,6 +276,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function hasMethod($name)
{
throw new ReflectionException('Method not implemented');
@@ -262,6 +285,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function hasProperty($name)
{
throw new ReflectionException('Method not implemented');
@@ -270,6 +294,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function implementsInterface($interface)
{
throw new ReflectionException('Method not implemented');
@@ -278,6 +303,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function inNamespace()
{
throw new ReflectionException('Method not implemented');
@@ -286,6 +312,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isAbstract()
{
throw new ReflectionException('Method not implemented');
@@ -294,6 +321,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isCloneable()
{
throw new ReflectionException('Method not implemented');
@@ -302,6 +330,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isFinal()
{
throw new ReflectionException('Method not implemented');
@@ -310,6 +339,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isInstance($object)
{
throw new ReflectionException('Method not implemented');
@@ -318,6 +348,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isInstantiable()
{
throw new ReflectionException('Method not implemented');
@@ -326,6 +357,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isInterface()
{
throw new ReflectionException('Method not implemented');
@@ -334,6 +366,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isInternal()
{
throw new ReflectionException('Method not implemented');
@@ -342,6 +375,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isIterateable()
{
throw new ReflectionException('Method not implemented');
@@ -350,6 +384,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isSubclassOf($class)
{
throw new ReflectionException('Method not implemented');
@@ -358,6 +393,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isTrait()
{
throw new ReflectionException('Method not implemented');
@@ -366,6 +402,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isUserDefined()
{
throw new ReflectionException('Method not implemented');
@@ -374,14 +411,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
public function newInstance($args)
{
throw new ReflectionException('Method not implemented');
}
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function newInstanceArgs(array $args = [])
{
throw new ReflectionException('Method not implemented');
@@ -390,6 +420,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function newInstanceWithoutConstructor()
{
throw new ReflectionException('Method not implemented');
@@ -398,6 +429,7 @@ class StaticReflectionClass extends ReflectionClass
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function setStaticPropertyValue($name, $value)
{
throw new ReflectionException('Method not implemented');

View File

@@ -2,11 +2,15 @@
namespace Doctrine\Common\Reflection;
use Doctrine\Common\Reflection\Compatibility\ReflectionMethod as CompatibilityReflectionMethod;
use ReflectionException;
use ReflectionMethod;
use ReturnTypeWillChange;
class StaticReflectionMethod extends ReflectionMethod
{
use CompatibilityReflectionMethod;
/**
* The PSR-0 parser object.
*
@@ -33,6 +37,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getName()
{
return $this->methodName;
@@ -49,6 +54,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getDeclaringClass()
{
return $this->getStaticReflectionParser()->getReflectionClass();
@@ -57,6 +63,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getNamespaceName()
{
return $this->getStaticReflectionParser()->getNamespaceName();
@@ -65,6 +72,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getDocComment()
{
return $this->getStaticReflectionParser()->getDocComment('method', $this->methodName);
@@ -89,6 +97,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getClosure($object = null)
{
throw new ReflectionException('Method not implemented');
@@ -97,6 +106,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getModifiers()
{
throw new ReflectionException('Method not implemented');
@@ -105,6 +115,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getPrototype()
{
throw new ReflectionException('Method not implemented');
@@ -113,14 +124,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
public function invoke($object, $parameter = null)
{
throw new ReflectionException('Method not implemented');
}
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function invokeArgs($object, array $args)
{
throw new ReflectionException('Method not implemented');
@@ -129,6 +133,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isAbstract()
{
throw new ReflectionException('Method not implemented');
@@ -137,6 +142,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isConstructor()
{
throw new ReflectionException('Method not implemented');
@@ -145,6 +151,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isDestructor()
{
throw new ReflectionException('Method not implemented');
@@ -153,6 +160,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isFinal()
{
throw new ReflectionException('Method not implemented');
@@ -161,6 +169,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isPrivate()
{
throw new ReflectionException('Method not implemented');
@@ -169,6 +178,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isProtected()
{
throw new ReflectionException('Method not implemented');
@@ -177,6 +187,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isPublic()
{
throw new ReflectionException('Method not implemented');
@@ -185,6 +196,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isStatic()
{
throw new ReflectionException('Method not implemented');
@@ -193,6 +205,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function setAccessible($accessible)
{
throw new ReflectionException('Method not implemented');
@@ -209,6 +222,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getClosureThis()
{
throw new ReflectionException('Method not implemented');
@@ -217,6 +231,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getEndLine()
{
throw new ReflectionException('Method not implemented');
@@ -225,6 +240,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getExtension()
{
throw new ReflectionException('Method not implemented');
@@ -233,6 +249,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getExtensionName()
{
throw new ReflectionException('Method not implemented');
@@ -241,6 +258,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getFileName()
{
throw new ReflectionException('Method not implemented');
@@ -249,6 +267,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getNumberOfParameters()
{
throw new ReflectionException('Method not implemented');
@@ -257,6 +276,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getNumberOfRequiredParameters()
{
throw new ReflectionException('Method not implemented');
@@ -265,6 +285,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getParameters()
{
throw new ReflectionException('Method not implemented');
@@ -273,6 +294,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getShortName()
{
throw new ReflectionException('Method not implemented');
@@ -281,6 +303,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getStartLine()
{
throw new ReflectionException('Method not implemented');
@@ -289,6 +312,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getStaticVariables()
{
throw new ReflectionException('Method not implemented');
@@ -297,6 +321,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function inNamespace()
{
throw new ReflectionException('Method not implemented');
@@ -305,6 +330,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isClosure()
{
throw new ReflectionException('Method not implemented');
@@ -313,6 +339,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isDeprecated()
{
throw new ReflectionException('Method not implemented');
@@ -321,6 +348,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isInternal()
{
throw new ReflectionException('Method not implemented');
@@ -329,6 +357,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isUserDefined()
{
throw new ReflectionException('Method not implemented');
@@ -337,6 +366,7 @@ class StaticReflectionMethod extends ReflectionMethod
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function returnsReference()
{
throw new ReflectionException('Method not implemented');

View File

@@ -4,6 +4,18 @@ namespace Doctrine\Common\Reflection;
use Doctrine\Common\Annotations\TokenParser;
use ReflectionException;
use function array_merge;
use function file_get_contents;
use function is_array;
use function ltrim;
use function preg_match;
use function sprintf;
use function strpos;
use function strrpos;
use function strtolower;
use function substr;
use const T_CLASS;
use const T_DOC_COMMENT;
use const T_EXTENDS;
@@ -17,18 +29,11 @@ use const T_STRING;
use const T_USE;
use const T_VAR;
use const T_VARIABLE;
use function array_merge;
use function file_get_contents;
use function ltrim;
use function preg_match;
use function sprintf;
use function strpos;
use function strrpos;
use function strtolower;
use function substr;
/**
* Parses a file for namespaces/use/class declarations.
*
* @phpstan-consistent-constructor
*/
class StaticReflectionParser implements ReflectionProviderInterface
{
@@ -102,7 +107,7 @@ class StaticReflectionParser implements ReflectionProviderInterface
/**
* The parent PSR-0 Parser.
*
* @var \Doctrine\Common\Reflection\StaticReflectionParser
* @var StaticReflectionParser
*/
protected $parentStaticReflectionParser;
@@ -140,6 +145,7 @@ class StaticReflectionParser implements ReflectionProviderInterface
if ($this->parsed || ! $fileName) {
return;
}
$this->parsed = true;
$contents = file_get_contents($fileName);
if ($this->classAnnotationOptimize) {
@@ -149,9 +155,10 @@ class StaticReflectionParser implements ReflectionProviderInterface
$contents = $matches[0];
}
}
$tokenParser = new TokenParser($contents);
$docComment = '';
$last_token = false;
$lastToken = false;
while ($token = $tokenParser->next(false)) {
switch ($token[0]) {
@@ -162,10 +169,11 @@ class StaticReflectionParser implements ReflectionProviderInterface
$docComment = $token[1];
break;
case T_CLASS:
if ($last_token !== T_PAAMAYIM_NEKUDOTAYIM && $last_token !== T_NEW) {
if ($lastToken !== T_PAAMAYIM_NEKUDOTAYIM && $lastToken !== T_NEW) {
$this->docComment['class'] = $docComment;
$docComment = '';
}
break;
case T_VAR:
case T_PRIVATE:
@@ -177,6 +185,7 @@ class StaticReflectionParser implements ReflectionProviderInterface
$this->docComment['property'][$propertyName] = $docComment;
continue 2;
}
if ($token[0] !== T_FUNCTION) {
// For example, it can be T_FINAL.
continue 2;
@@ -189,6 +198,11 @@ class StaticReflectionParser implements ReflectionProviderInterface
while (($token = $tokenParser->next()) && $token[0] !== T_STRING) {
continue;
}
if ($token === null) {
break;
}
$methodName = $token[1];
$this->docComment['method'][$methodName] = $docComment;
$docComment = '';
@@ -207,6 +221,7 @@ class StaticReflectionParser implements ReflectionProviderInterface
$prefix = strtolower($this->parentClassName);
$postfix = '';
}
foreach ($this->useStatements as $alias => $use) {
if ($alias !== $prefix) {
continue;
@@ -216,13 +231,15 @@ class StaticReflectionParser implements ReflectionProviderInterface
$fullySpecified = true;
}
}
if (! $fullySpecified) {
$this->parentClassName = '\\' . $this->namespace . '\\' . $this->parentClassName;
}
break;
}
$last_token = $token[0];
$lastToken = is_array($token) ? $token[0] : false;
}
}
@@ -321,9 +338,11 @@ class StaticReflectionParser implements ReflectionProviderInterface
if (isset($this->docComment[$type][$name])) {
return $this;
}
if (! empty($this->parentClassName)) {
return $this->getParentStaticReflectionParser()->getStaticReflectionParserForDeclaringClass($type, $name);
}
throw new ReflectionException('Invalid ' . $type . ' "' . $name . '"');
}
}

View File

@@ -4,6 +4,7 @@ namespace Doctrine\Common\Reflection;
use ReflectionException;
use ReflectionProperty;
use ReturnTypeWillChange;
class StaticReflectionProperty extends ReflectionProperty
{
@@ -33,6 +34,7 @@ class StaticReflectionProperty extends ReflectionProperty
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getName()
{
return $this->propertyName;
@@ -49,6 +51,7 @@ class StaticReflectionProperty extends ReflectionProperty
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getDeclaringClass()
{
return $this->getStaticReflectionParser()->getReflectionClass();
@@ -57,6 +60,7 @@ class StaticReflectionProperty extends ReflectionProperty
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getDocComment()
{
return $this->getStaticReflectionParser()->getDocComment('property', $this->propertyName);
@@ -81,6 +85,7 @@ class StaticReflectionProperty extends ReflectionProperty
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getModifiers()
{
throw new ReflectionException('Method not implemented');
@@ -89,6 +94,7 @@ class StaticReflectionProperty extends ReflectionProperty
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function getValue($object = null)
{
throw new ReflectionException('Method not implemented');
@@ -97,6 +103,7 @@ class StaticReflectionProperty extends ReflectionProperty
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isDefault()
{
throw new ReflectionException('Method not implemented');
@@ -105,6 +112,7 @@ class StaticReflectionProperty extends ReflectionProperty
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isPrivate()
{
throw new ReflectionException('Method not implemented');
@@ -113,6 +121,7 @@ class StaticReflectionProperty extends ReflectionProperty
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isProtected()
{
throw new ReflectionException('Method not implemented');
@@ -121,6 +130,7 @@ class StaticReflectionProperty extends ReflectionProperty
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isPublic()
{
throw new ReflectionException('Method not implemented');
@@ -129,6 +139,7 @@ class StaticReflectionProperty extends ReflectionProperty
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function isStatic()
{
throw new ReflectionException('Method not implemented');
@@ -137,6 +148,7 @@ class StaticReflectionProperty extends ReflectionProperty
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function setAccessible($accessible)
{
throw new ReflectionException('Method not implemented');
@@ -145,6 +157,7 @@ class StaticReflectionProperty extends ReflectionProperty
/**
* {@inheritDoc}
*/
#[ReturnTypeWillChange]
public function setValue($object, $value = null)
{
throw new ReflectionException('Method not implemented');

View File

@@ -3,6 +3,7 @@
namespace Doctrine\Common\Reflection;
use ReflectionProperty;
use ReturnTypeWillChange;
/**
* PHP Typed No Default Reflection Property - special override for typed properties without a default value.
@@ -13,9 +14,10 @@ class TypedNoDefaultReflectionProperty extends ReflectionProperty
* {@inheritDoc}
*
* Checks that a typed property is initialized before accessing its value.
* This is neccessary to avoid PHP error "Error: Typed property must not be accessed before initialization".
* This is necessary to avoid PHP error "Error: Typed property must not be accessed before initialization".
* Should be used only for reflecting typed properties without a default value.
*/
#[ReturnTypeWillChange]
public function getValue($object = null)
{
return $object !== null && $this->isInitialized($object) ? parent::getValue($object) : null;
@@ -29,6 +31,7 @@ class TypedNoDefaultReflectionProperty extends ReflectionProperty
*
* @link https://github.com/doctrine/orm/issues/7999
*/
#[ReturnTypeWillChange]
public function setValue($object, $value = null)
{
if ($value === null && $this->hasType() && ! $this->getType()->allowsNull()) {

View File

@@ -7,13 +7,17 @@
<arg name="colors"/>
<!-- Ignore warnings and show progress of the run -->
<arg value="np"/>
<arg value="nps"/>
<config name="php_version" value="70100"/>
<file>lib</file>
<file>tests</file>
<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"/>
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint"/>
</rule>
@@ -26,8 +30,20 @@
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
<rule ref="Squiz.NamingConventions.ValidVariableName.NotCamelCaps">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming">
<exclude-pattern>lib/Doctrine/Common/Reflection/ClassFinderInterface.php</exclude-pattern>
<exclude-pattern>lib/Doctrine/Common/Reflection/ReflectionProviderInterface.php</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint">
<exclude-pattern>tests/*</exclude-pattern>
</rule>
</ruleset>

View File

@@ -1,11 +1,9 @@
parameters:
level: 3
paths:
- %rootDir%/../../../lib
- %rootDir%/../../../tests
ignoreErrors:
- '#Doctrine\\Common\\Reflection\\StaticReflection[a-zA-Z0-9_]+::__construct\(\) does not call parent constructor from Reflection[a-zA-Z0-9_]+#'
- lib
- tests
phpVersion: 80106
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon

View File

@@ -4,43 +4,45 @@ namespace Doctrine\Tests\Common\Reflection;
use Doctrine\Common\Reflection\Psr0FindFile;
use PHPUnit\Framework\TestCase;
use const DIRECTORY_SEPARATOR;
use function sprintf;
use function strlen;
use function substr;
use const DIRECTORY_SEPARATOR;
class Psr0FindFileTest extends TestCase
{
/** @var Psr0FindFile */
private $psr0FindFile;
public function testFindFile() : void
public function testFindFile(): void
{
$file = $this->psr0FindFile->findFile(NoParent::class);
self::assertSame(sprintf('%s%sNoParent.php', __DIR__, DIRECTORY_SEPARATOR), $file);
}
public function testFindFileNotFound() : void
public function testFindFileNotFound(): void
{
self::assertNull($this->psr0FindFile->findFile('DoesNotExist'));
}
public function testFindFileWithLeadingNamespaceSeparator() : void
public function testFindFileWithLeadingNamespaceSeparator(): void
{
$file = $this->psr0FindFile->findFile('\Doctrine\Tests\Common\Reflection\NoParent');
self::assertSame(sprintf('%s%sNoParent.php', __DIR__, DIRECTORY_SEPARATOR), $file);
}
public function testFindFileFromPearLikeClassName() : void
public function testFindFileFromPearLikeClassName(): void
{
$file = $this->psr0FindFile->findFile('Doctrine_Tests_Common_Reflection_NoParent');
self::assertSame(sprintf('%s%sNoParent.php', __DIR__, DIRECTORY_SEPARATOR), $file);
}
protected function setUp() : void
protected function setUp(): void
{
$testsRoot = substr(__DIR__, 0, -strlen(__NAMESPACE__) - 1);

View File

@@ -2,15 +2,17 @@
namespace Doctrine\Tests\Common\Reflection;
use BadMethodCallException;
use Closure;
use Doctrine\Common\Proxy\Proxy;
use Doctrine\Common\Reflection\RuntimePublicReflectionProperty;
use PHPUnit\Framework\TestCase;
use function call_user_func;
class RuntimePublicReflectionPropertyTest extends TestCase
{
public function testGetValue() : void
public function testGetValue(): void
{
$object = new RuntimePublicReflectionPropertyTestClass();
@@ -23,7 +25,7 @@ class RuntimePublicReflectionPropertyTest extends TestCase
self::assertNull($reflProperty->getValue($object));
}
public function testSetValue() : void
public function testSetValue(): void
{
$object = new RuntimePublicReflectionPropertyTestClass();
@@ -36,7 +38,7 @@ class RuntimePublicReflectionPropertyTest extends TestCase
self::assertSame('changedValue', $reflProperty->getValue($object));
}
public function testGetValueOnProxyPublicProperty() : void
public function testGetValueOnProxyPublicProperty(): void
{
$getCheckMock = $this->getMockBuilder('stdClass')->setMethods(['callGet'])->getMock();
$getCheckMock->expects($this->never())->method('callGet');
@@ -57,7 +59,7 @@ class RuntimePublicReflectionPropertyTest extends TestCase
self::assertNull($reflProperty->getValue($mockProxy));
}
public function testSetValueOnProxyPublicProperty() : void
public function testSetValueOnProxyPublicProperty(): void
{
$setCheckMock = $this->getMockBuilder('stdClass')->setMethods(['neverCallSet'])->getMock();
$setCheckMock->expects($this->never())->method('neverCallSet');
@@ -130,6 +132,7 @@ class RuntimePublicReflectionPropertyTestProxyMock implements Proxy
*/
public function __getLazyProperties()
{
throw new BadMethodCallException('Not implemented.');
}
/**
@@ -210,6 +213,7 @@ class RuntimePublicReflectionPropertyTestProxyMock implements Proxy
*/
public function __getCloner()
{
throw new BadMethodCallException('Not implemented.');
}
}

View File

@@ -6,8 +6,8 @@ use Doctrine\Common\Reflection\StaticReflectionClass;
use Doctrine\Common\Reflection\StaticReflectionMethod;
use Doctrine\Common\Reflection\StaticReflectionParser;
use Doctrine\Common\Reflection\StaticReflectionProperty;
use PHPStan\Testing\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use ReflectionException;
class StaticReflectionClassTest extends TestCase
@@ -18,7 +18,7 @@ class StaticReflectionClassTest extends TestCase
/** @var StaticReflectionClass */
private $staticReflectionClass;
public function testGetName() : void
public function testGetName(): void
{
$this->staticReflectionParser->expects($this->once())
->method('getClassName')
@@ -27,7 +27,7 @@ class StaticReflectionClassTest extends TestCase
self::assertSame('ClassName', $this->staticReflectionClass->getName());
}
public function testGetDocComment() : void
public function testGetDocComment(): void
{
$this->staticReflectionParser->expects($this->once())
->method('getDocComment')
@@ -36,7 +36,7 @@ class StaticReflectionClassTest extends TestCase
self::assertSame('test doc comment', $this->staticReflectionClass->getDocComment());
}
public function testGetNamespaceName() : void
public function testGetNamespaceName(): void
{
$this->staticReflectionParser->expects($this->once())
->method('getNamespaceName')
@@ -45,7 +45,7 @@ class StaticReflectionClassTest extends TestCase
self::assertSame('Namespace', $this->staticReflectionClass->getNamespaceName());
}
public function testGetUseStatements() : void
public function testGetUseStatements(): void
{
$this->staticReflectionParser->expects($this->once())
->method('getUseStatements')
@@ -54,7 +54,7 @@ class StaticReflectionClassTest extends TestCase
self::assertSame(['ClassName'], $this->staticReflectionClass->getUseStatements());
}
public function testGetMethod() : void
public function testGetMethod(): void
{
$staticReflectionMethod = $this->createPartialMock(StaticReflectionMethod::class, []);
@@ -66,7 +66,7 @@ class StaticReflectionClassTest extends TestCase
self::assertSame($staticReflectionMethod, $this->staticReflectionClass->getMethod('method'));
}
public function testGetProperty() : void
public function testGetProperty(): void
{
$staticReflectionProperty = $this->createMock(StaticReflectionProperty::class);
@@ -83,7 +83,7 @@ class StaticReflectionClassTest extends TestCase
*
* @dataProvider getNotImplementedMethods
*/
public function testNotImplemented(string $method, array $args) : void
public function testNotImplemented(string $method, array $args): void
{
$this->expectException(ReflectionException::class);
$this->expectExceptionMessage('Method not implemented');
@@ -94,7 +94,7 @@ class StaticReflectionClassTest extends TestCase
/**
* @return mixed[]
*/
public function getNotImplementedMethods() : array
public function getNotImplementedMethods(): array
{
return [
['export', ['Test', 'Test', true]],
@@ -143,7 +143,7 @@ class StaticReflectionClassTest extends TestCase
];
}
protected function setUp() : void
protected function setUp(): void
{
$this->staticReflectionParser = $this->createMock(StaticReflectionParser::class);

View File

@@ -5,8 +5,8 @@ namespace Doctrine\Tests\Common\Reflection;
use Doctrine\Common\Reflection\StaticReflectionClass;
use Doctrine\Common\Reflection\StaticReflectionMethod;
use Doctrine\Common\Reflection\StaticReflectionParser;
use PHPStan\Testing\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use ReflectionException;
class StaticReflectionMethodTest extends TestCase
@@ -20,12 +20,12 @@ class StaticReflectionMethodTest extends TestCase
/** @var StaticReflectionMethod */
private $staticReflectionMethod;
public function testGetName() : void
public function testGetName(): void
{
self::assertSame($this->methodName, $this->staticReflectionMethod->getName());
}
public function testGetDeclaringClass() : void
public function testGetDeclaringClass(): void
{
$staticReflectionClass = $this->createPartialMock(StaticReflectionClass::class, []);
@@ -36,7 +36,7 @@ class StaticReflectionMethodTest extends TestCase
self::assertSame($staticReflectionClass, $this->staticReflectionMethod->getDeclaringClass());
}
public function testGetNamespaceName() : void
public function testGetNamespaceName(): void
{
$this->staticReflectionParser->expects($this->once())
->method('getNamespaceName')
@@ -45,7 +45,7 @@ class StaticReflectionMethodTest extends TestCase
self::assertSame('test', $this->staticReflectionMethod->getNamespaceName());
}
public function testGetDocComment() : void
public function testGetDocComment(): void
{
$staticReflectionClass = $this->createPartialMock(StaticReflectionClass::class, []);
@@ -57,7 +57,7 @@ class StaticReflectionMethodTest extends TestCase
self::assertSame('test doc comment', $this->staticReflectionMethod->getDocComment());
}
public function testGetUseStatements() : void
public function testGetUseStatements(): void
{
$staticReflectionClass = $this->createPartialMock(StaticReflectionClass::class, []);
@@ -73,7 +73,7 @@ class StaticReflectionMethodTest extends TestCase
*
* @dataProvider getNotImplementedMethods
*/
public function testNotImplemented(string $method, array $args) : void
public function testNotImplemented(string $method, array $args): void
{
$this->expectException(ReflectionException::class);
$this->expectExceptionMessage('Method not implemented');
@@ -84,7 +84,7 @@ class StaticReflectionMethodTest extends TestCase
/**
* @return mixed[]
*/
public function getNotImplementedMethods() : array
public function getNotImplementedMethods(): array
{
return [
['export', ['Test', 'Test', true]],
@@ -123,7 +123,7 @@ class StaticReflectionMethodTest extends TestCase
];
}
protected function setUp() : void
protected function setUp(): void
{
$this->staticReflectionParser = $this->createMock(StaticReflectionParser::class);
$this->methodName = 'methodName';

View File

@@ -7,6 +7,7 @@ use Doctrine\Common\Reflection\StaticReflectionParser;
use Doctrine\Tests\Common\Reflection\Dummies\NoParent as NoParentDummy;
use Doctrine\Tests\DoctrineTestCase;
use ReflectionException;
use function strlen;
use function substr;

View File

@@ -5,8 +5,8 @@ namespace Doctrine\Tests\Common\Reflection;
use Doctrine\Common\Reflection\StaticReflectionClass;
use Doctrine\Common\Reflection\StaticReflectionParser;
use Doctrine\Common\Reflection\StaticReflectionProperty;
use PHPStan\Testing\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use ReflectionException;
class StaticReflectionPropertyTest extends TestCase
@@ -20,12 +20,12 @@ class StaticReflectionPropertyTest extends TestCase
/** @var StaticReflectionProperty */
private $staticReflectionProperty;
public function testGetName() : void
public function testGetName(): void
{
self::assertSame($this->propertyName, $this->staticReflectionProperty->getName());
}
public function testGetDeclaringClass() : void
public function testGetDeclaringClass(): void
{
$staticReflectionClass = $this->createPartialMock(StaticReflectionClass::class, []);
@@ -36,7 +36,7 @@ class StaticReflectionPropertyTest extends TestCase
self::assertSame($staticReflectionClass, $this->staticReflectionProperty->getDeclaringClass());
}
public function testGetDocComment() : void
public function testGetDocComment(): void
{
$staticReflectionClass = $this->createPartialMock(StaticReflectionClass::class, []);
@@ -48,7 +48,7 @@ class StaticReflectionPropertyTest extends TestCase
self::assertSame('test doc comment', $this->staticReflectionProperty->getDocComment());
}
public function testGetUseStatements() : void
public function testGetUseStatements(): void
{
$staticReflectionClass = $this->createPartialMock(StaticReflectionClass::class, []);
@@ -64,7 +64,7 @@ class StaticReflectionPropertyTest extends TestCase
*
* @dataProvider getNotImplementedMethods
*/
public function testNotImplemented(string $method, array $args) : void
public function testNotImplemented(string $method, array $args): void
{
$this->expectException(ReflectionException::class);
$this->expectExceptionMessage('Method not implemented');
@@ -75,7 +75,7 @@ class StaticReflectionPropertyTest extends TestCase
/**
* @return mixed[]
*/
public function getNotImplementedMethods() : array
public function getNotImplementedMethods(): array
{
return [
['export', ['Test', 'Test', true]],
@@ -92,7 +92,7 @@ class StaticReflectionPropertyTest extends TestCase
];
}
protected function setUp() : void
protected function setUp(): void
{
$this->staticReflectionParser = $this->createMock(StaticReflectionParser::class);
$this->propertyName = 'propertyName';

View File

@@ -2,8 +2,6 @@
namespace Doctrine\Tests;
use const E_ALL;
use const E_STRICT;
use function error_reporting;
use function is_file;
use function is_readable;
@@ -11,6 +9,9 @@ use function spl_autoload_register;
use function strpos;
use function strtr;
use const E_ALL;
use const E_STRICT;
error_reporting(E_ALL | E_STRICT);
// register silently failing autoloader

View File

@@ -0,0 +1,13 @@
<?php
namespace Doctrine\Tests_PHP74\Common\Reflection\Dummies;
trait TokenParserAnonymousFunctionTestClass
{
protected function method()
{
return static function ($value) {
return $value;
};
}
}

View File

@@ -0,0 +1,25 @@
<?php
namespace Doctrine\Tests_PHP74\Common\Reflection;
use Doctrine\Common\Reflection\Psr0FindFile;
use Doctrine\Common\Reflection\StaticReflectionParser;
use Doctrine\Tests_PHP74\Common\Reflection\Dummies\TokenParserAnonymousFunctionTestClass;
use PHPUnit\Framework\TestCase;
use function strlen;
use function substr;
class TokenParserAnonymousFunctionTest extends TestCase
{
public function testGetValue(): void
{
$testsRoot = substr(__DIR__, 0, -strlen(__NAMESPACE__) - 1);
$paths = [
'Doctrine\\Tests_PHP74' => [$testsRoot],
];
$staticReflectionParser = new StaticReflectionParser(TokenParserAnonymousFunctionTestClass::class, new Psr0FindFile($paths));
self::assertEquals('', $staticReflectionParser->getDocComment());
}
}

View File

@@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase;
class TypedNoDefaultReflectionPropertyTest extends TestCase
{
public function testGetValue() : void
public function testGetValue(): void
{
$object = new TypedNoDefaultReflectionPropertyTestClass();
@@ -24,7 +24,7 @@ class TypedNoDefaultReflectionPropertyTest extends TestCase
self::assertNull($reflProperty->getValue($object));
}
public function testSetValueNull() : void
public function testSetValueNull(): void
{
$reflection = new TypedNoDefaultReflectionProperty(TypedFoo::class, 'id');
$reflection->setAccessible(true);
@@ -40,7 +40,7 @@ class TypedNoDefaultReflectionPropertyTest extends TestCase
self::assertFalse($reflection->isInitialized($object));
}
public function testSetValueNullOnNullableProperty() : void
public function testSetValueNullOnNullableProperty(): void
{
$reflection = new TypedNoDefaultReflectionProperty(TypedNullableFoo::class, 'value');
$reflection->setAccessible(true);