8000 WIP [Meta] Add PHPStan to build process by dkarlovi · Pull Request #25536 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

WIP [Meta] Add PHPStan to build process #25536

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

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[Meta] PHPStan, undo changes to Debug component
  • Loading branch information
dkarlovi committed Dec 19, 2017
commit dbdf9de3d7b89866a54fc83e3301a49fc423ed97
13 changes: 10 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ parameters:
- src/Symfony/Component/Form/Tests/SimpleFormTest.php
- src/Symfony/Component/Process/Tests/NonStopableProcess.php
ignoreErrors:
##
## False positive
##
# incorrect, no params is valid
- '#Function get_defined_functions invoked with 0 parameters, 1 required.#'

##
## By design
##
- '#__construct\(\) does not call parent constructor from .+#'
- '#Function xdebug_[^\s]* not found.#'

# not errors, actually expected to fail
- '#Class Symfony\\Bundle\\FrameworkBundle\\Tests\\DependencyInjection\\Compiler\\NotFound not found.#'
- '#Class Symfony\\Component\\DependencyInjection\\Tests\\Compiler\\NotExist not found.#'
Expand All @@ -30,12 +38,11 @@ parameters:
- src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php

##
## By Symfony design
## By design
##
# broken require-dev: https://github.com/symfony/symfony/pull/25536/files#r157591181
- src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php


##
## Temporary
##
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private function getClassCandidates(string $class): array
}
}

if ($function[0] instanceof ComposerClassLoader) {
if ($function[0] instanceof ComposerClassLoader || is_subclass_of($function[0], '\Symfony\Component\ClassLoader\ClassLoader')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be is_subclass_of($function[0], ClassLoader::class), no ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or be just reverted as the previous code was just fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code refers to a non-existent class?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already discussed, see #25536 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's try this: there exists a (common) situation where this code refers to a non-existent class, that's the reason PHPStan found it and complained about it.

There exists a situation where this class exists. They both exists. The new code is valid in both cases, existing code is not.

Copy link
Member
@nicolas-grekas nicolas-grekas Dec 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on what? how do you define "valid"?
on my side it's: it works as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. 👍

foreach ($function[0]->getPrefixes() as $prefix => $paths) {
foreach ($paths as $path) {
$classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function handleError(array $error, FatalErrorException $exception)
}

$candidates = array();
foreach (get_defined_functions(false) as $type => $definedFunctionNames) {
foreach (get_defined_functions() as $type => $definedFunctionNames) {
foreach ($definedFunctionNames as $definedFunctionName) {
if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) {
$definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1);
Expand Down
0