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

Duplicate function not reported #3475

Closed
dktapps opened this issue Jun 15, 2020 · 4 comments
Closed

Duplicate function not reported #3475

dktapps opened this issue Jun 15, 2020 · 4 comments

Comments

@dktapps
Copy link
Contributor

dktapps commented Jun 15, 2020

Bug report

Code snippet that reproduces the problem

https://phpstan.org/r/7f1e131e-6dab-4a1f-b1f6-68eed9a683d4

Expected output

This code should report an error because lol() is declared twice.

@ondrejmirtes
Copy link
Member

Hi, I'd really appreciate if you tried to implement these things and not just report them, I know you're capable of it and it'd make my work easier :)

@dktapps
Copy link
Contributor Author

dktapps commented Jun 16, 2020

Sure. I just like to stick issues down first, because it usually takes me a lot longer to figure out where a fix needs to be made than it does to write an issue, and there's a good chance someone with more knowledge will beat me to it. Also, this way it doesn't matter if I forget about issues while I work because they've already been reported.

@ondrejmirtes
Copy link
Member

This one is pretty easy. Create a rule that registers to InClassNode, get $node->getOriginalNode() and cycle through all ->stmts. Save all constants, properties, methods to separate arrays and if you encounter a duplicate entry, report an error.

ondrejmirtes added a commit that referenced this issue Jun 20, 2020
phpstan/phpstan-src@5e2ba1a implemented DuplicateDeclarationRule, fixes #3475
ondrejmirtes added a commit that referenced this issue Jun 21, 2020
phpstan/phpstan-src@d8a0735 Fix non-abstract class contains abstract method with more than one-level parent class away
phpstan/phpstan-src@b21f537 Fix unknown properties for class extending DateInterval|DatePeriod and loaded with runtime reflection
phpstan/phpstan-src@b537b97 Only consider class-strings when resolving dependencies
phpstan/phpstan-src@4a9c159 Fix `__DIR__` in global constant
phpstan/phpstan-src@75e6115 Tip for Discovering Symbols on all "not found" messages
phpstan/phpstan-src@be72fc4 Fix test
phpstan/phpstan-src@a9834c9 Use dev-master of jetbrains/phpstorm-stubs
phpstan/phpstan-src@675e3a2 Align `APCuIterator` case with its implementation
phpstan/phpstan-src@56276db Fix array typehint without null in PHPDoc
phpstan/phpstan-src@781016e Cleanup
phpstan/phpstan-src@13d0f3d Don't use PhpStorm stubs for Ds\\ extension
phpstan/phpstan-src@9b5a48c Skip ext-ds test with static reflection
phpstan/phpstan-src@dfca54d Update phpstorm-stubs
phpstan/phpstan-src@0b855c7 Revert "Skip ext-ds test with static reflection"
phpstan/phpstan-src@d249aba Revert "Don't use PhpStorm stubs for Ds\\ extension"
phpstan/phpstan-src@0ad3e88 Don't skip ext-ds tests where possible
phpstan/phpstan-src@eb9294a Add test case to assert failure
phpstan/phpstan-src@4889a9d Add DOMDocument class to list of exclusions
phpstan/phpstan-src@0430852 Add required ext-dom extenstion
phpstan/phpstan-src@4b12d94 CS
phpstan/phpstan-src@00b0284 Exclude more classes
phpstan/phpstan-src@4cf0141 Look at `install-path` from `installed.json` available in Composer v2
phpstan/phpstan-src@d1990b8 Skip files from broken Composer installations
phpstan/phpstan-src@43ee94a Update phpstorm-stubs
phpstan/phpstan-src@09f0beb Native method reflection - look in stubs first, then into native runtime PHP reflection
phpstan/phpstan-src@20edb4f ResultCacheManager::process() - option not to save the cache
phpstan/phpstan-src@6767062 MutatingScope - remove forgotten var_dump
phpstan/phpstan-src@ac6c634 Refactoring
phpstan/phpstan-src@67dc203 Update actions/cache requirement to v2
phpstan/phpstan-src@60c53e0 Bump actions/checkout from v2.2.0 to v2.3.0
phpstan/phpstan-src@d240307 dbase-ext: DB-handle changed from int to resource
phpstan/phpstan-src@6bcb400 dbase_open|dbase_create can also return false
phpstan/phpstan-src@e6ba8a0 Single reflection file support
phpstan/phpstan-src@6425cdf functionMap: narrow possible return values of openssl_verify()
phpstan/phpstan-src@bf6921d Bump actions/checkout from v2.3.0 to v2.3.1
phpstan/phpstan-src@b9f62d6 Remove hack of yaml highlighting for neon files
phpstan/phpstan-src@0613451 Replicate behaviour from ThisVariableRule in DefinedVariableRule
phpstan/phpstan-src@14b17a8 Remove obsolete ThisVariableRule
phpstan/phpstan-src@1567d0f testFileAsserts - testing variable certainty support
phpstan/phpstan-src@7ea7ce4 Cleanup thanks to maybe certainty for variables in root scope
phpstan/phpstan-src@44f9d08 Override variable certainty in global scope with `@var`
phpstan/phpstan-src@261cf18 Fix
phpstan/phpstan-src@428c8e5 Support multiple doc comments above statement
phpstan/phpstan-src@acf070f Updated PhpStorm stubs
phpstan/phpstan-src@749f50b Loosen the requirements for the $function parameter of the register_shutdown_function function
phpstan/phpstan-src@5e2ba1a implemented DuplicateDeclarationRule, fixes #3475
phpstan/phpstan-src@9547231 added support for BitwiseNot operator
phpstan/phpstan-src@5f5de22 InvalidUnaryOperationRule: added support for BitwiseNot operator
phpstan/phpstan-src@24246f3 `treatPhpDocTypesAsCertain` is not necessary in BitwiseNot handling
phpstan/phpstan-src@f8a6cf1 Debugging message for ShouldNotHappenException in OptimizedDirectorySourceLocator
ondrejmirtes added a commit that referenced this issue Jun 24, 2020
phpstan/phpstan-src@eb9294a Add test case to assert failure
phpstan/phpstan-src@4889a9d Add DOMDocument class to list of exclusions
phpstan/phpstan-src@0430852 Add required ext-dom extenstion
phpstan/phpstan-src@4b12d94 CS
phpstan/phpstan-src@00b0284 Exclude more classes
phpstan/phpstan-src@4cf0141 Look at `install-path` from `installed.json` available in Composer v2
phpstan/phpstan-src@d1990b8 Skip files from broken Composer installations
phpstan/phpstan-src@43ee94a Update phpstorm-stubs
phpstan/phpstan-src@09f0beb Native method reflection - look in stubs first, then into native runtime PHP reflection
phpstan/phpstan-src@20edb4f ResultCacheManager::process() - option not to save the cache
phpstan/phpstan-src@6767062 MutatingScope - remove forgotten var_dump
phpstan/phpstan-src@ac6c634 Refactoring
phpstan/phpstan-src@67dc203 Update actions/cache requirement to v2
phpstan/phpstan-src@60c53e0 Bump actions/checkout from v2.2.0 to v2.3.0
phpstan/phpstan-src@d240307 dbase-ext: DB-handle changed from int to resource
phpstan/phpstan-src@6bcb400 dbase_open|dbase_create can also return false
phpstan/phpstan-src@e6ba8a0 Single reflection file support
phpstan/phpstan-src@6425cdf functionMap: narrow possible return values of openssl_verify()
phpstan/phpstan-src@bf6921d Bump actions/checkout from v2.3.0 to v2.3.1
phpstan/phpstan-src@b9f62d6 Remove hack of yaml highlighting for neon files
phpstan/phpstan-src@0613451 Replicate behaviour from ThisVariableRule in DefinedVariableRule
phpstan/phpstan-src@14b17a8 Remove obsolete ThisVariableRule
phpstan/phpstan-src@1567d0f testFileAsserts - testing variable certainty support
phpstan/phpstan-src@7ea7ce4 Cleanup thanks to maybe certainty for variables in root scope
phpstan/phpstan-src@44f9d08 Override variable certainty in global scope with `@var`
phpstan/phpstan-src@261cf18 Fix
phpstan/phpstan-src@428c8e5 Support multiple doc comments above statement
phpstan/phpstan-src@acf070f Updated PhpStorm stubs
phpstan/phpstan-src@749f50b Loosen the requirements for the $function parameter of the register_shutdown_function function
phpstan/phpstan-src@5e2ba1a implemented DuplicateDeclarationRule, fixes #3475
phpstan/phpstan-src@9547231 added support for BitwiseNot operator
phpstan/phpstan-src@5f5de22 InvalidUnaryOperationRule: added support for BitwiseNot operator
phpstan/phpstan-src@24246f3 `treatPhpDocTypesAsCertain` is not necessary in BitwiseNot handling
phpstan/phpstan-src@f8a6cf1 Debugging message for ShouldNotHappenException in OptimizedDirectorySourceLocator
phpstan/phpstan-src@c8923b5 functionMap: ZipArchive::open() returns true on success, int (error code) on failure
phpstan/phpstan-src@a59a83c Bump shivammathur/setup-php from 2.3.0 to 2.3.1
phpstan/phpstan-src@423ed91 mysqli_stmt_fetch() and mysqli_stmt::fetch() can return NULL
phpstan/phpstan-src@7546777 openssl_pkey_export() allows null for the passphrase
phpstan/phpstan-src@cdf5b85 Fix enchant_broker_list_dicts() return type
phpstan/phpstan-src@8390949 Subclasses of PDO are analysed using static reflection
phpstan/phpstan-src@af183ec correct return value for PHP internal functions on failure
phpstan/phpstan-src@47a76e3 Fix build
phpstan/phpstan-src@4cbb589 Use composer.json reading just to locate functions
phpstan/phpstan-src@73aede3 Fix return type & callback type hints for Redis::subscribe()
phpstan/phpstan-src@1cd97b4 More cleanup
phpstan/phpstan-src@e6dd87b Dive into a trait that starts on the same line as the one in the reflection
phpstan/phpstan-src@1c63a78 Revert "More cleanup"
phpstan/phpstan-src@37356d4 Revert "Use composer.json reading just to locate functions"
phpstan/phpstan-src@3902d73 Skip AutoloadSourceLocator for unprefixed dependencies shipped in the PHAR
phpstan/phpstan-src@2e61259 Attempt to load remaining classes after skipping them in ClassBlacklistSourceLocator if they're not in Composer paths
ondrejmirtes added a commit that referenced this issue Jul 1, 2020
phpstan/phpstan-src@6767062 MutatingScope - remove forgotten var_dump
phpstan/phpstan-src@ac6c634 Refactoring
phpstan/phpstan-src@67dc203 Update actions/cache requirement to v2
phpstan/phpstan-src@60c53e0 Bump actions/checkout from v2.2.0 to v2.3.0
phpstan/phpstan-src@d240307 dbase-ext: DB-handle changed from int to resource
phpstan/phpstan-src@6bcb400 dbase_open|dbase_create can also return false
phpstan/phpstan-src@e6ba8a0 Single reflection file support
phpstan/phpstan-src@6425cdf functionMap: narrow possible return values of openssl_verify()
phpstan/phpstan-src@bf6921d Bump actions/checkout from v2.3.0 to v2.3.1
phpstan/phpstan-src@b9f62d6 Remove hack of yaml highlighting for neon files
phpstan/phpstan-src@0613451 Replicate behaviour from ThisVariableRule in DefinedVariableRule
phpstan/phpstan-src@14b17a8 Remove obsolete ThisVariableRule
phpstan/phpstan-src@1567d0f testFileAsserts - testing variable certainty support
phpstan/phpstan-src@7ea7ce4 Cleanup thanks to maybe certainty for variables in root scope
phpstan/phpstan-src@44f9d08 Override variable certainty in global scope with `@var`
phpstan/phpstan-src@261cf18 Fix
phpstan/phpstan-src@428c8e5 Support multiple doc comments above statement
phpstan/phpstan-src@acf070f Updated PhpStorm stubs
phpstan/phpstan-src@749f50b Loosen the requirements for the $function parameter of the register_shutdown_function function
phpstan/phpstan-src@5e2ba1a implemented DuplicateDeclarationRule, fixes #3475
phpstan/phpstan-src@9547231 added support for BitwiseNot operator
phpstan/phpstan-src@5f5de22 InvalidUnaryOperationRule: added support for BitwiseNot operator
phpstan/phpstan-src@24246f3 `treatPhpDocTypesAsCertain` is not necessary in BitwiseNot handling
phpstan/phpstan-src@f8a6cf1 Debugging message for ShouldNotHappenException in OptimizedDirectorySourceLocator
phpstan/phpstan-src@c8923b5 functionMap: ZipArchive::open() returns true on success, int (error code) on failure
phpstan/phpstan-src@a59a83c Bump shivammathur/setup-php from 2.3.0 to 2.3.1
phpstan/phpstan-src@423ed91 mysqli_stmt_fetch() and mysqli_stmt::fetch() can return NULL
phpstan/phpstan-src@7546777 openssl_pkey_export() allows null for the passphrase
phpstan/phpstan-src@cdf5b85 Fix enchant_broker_list_dicts() return type
phpstan/phpstan-src@8390949 Subclasses of PDO are analysed using static reflection
phpstan/phpstan-src@af183ec correct return value for PHP internal functions on failure
phpstan/phpstan-src@47a76e3 Fix build
phpstan/phpstan-src@4cbb589 Use composer.json reading just to locate functions
phpstan/phpstan-src@73aede3 Fix return type & callback type hints for Redis::subscribe()
phpstan/phpstan-src@1cd97b4 More cleanup
phpstan/phpstan-src@e6dd87b Dive into a trait that starts on the same line as the one in the reflection
phpstan/phpstan-src@1c63a78 Revert "More cleanup"
phpstan/phpstan-src@37356d4 Revert "Use composer.json reading just to locate functions"
phpstan/phpstan-src@3902d73 Skip AutoloadSourceLocator for unprefixed dependencies shipped in the PHAR
phpstan/phpstan-src@2e61259 Attempt to load remaining classes after skipping them in ClassBlacklistSourceLocator if they're not in Composer paths
phpstan/phpstan-src@37e65a4 Update dealerdirect/phpcodesniffer-composer-installer requirement
phpstan/phpstan-src@6905d66 Check leading and trailing file whitespace and BOM
phpstan/phpstan-src@f61f3f9 Fix not-whitespace HTML
phpstan/phpstan-src@1a3911b Add Formatter for GitHub Actions
phpstan/phpstan-src@7d9bb8d Use github error-format in workflow
phpstan/phpstan-src@d1177d7 Handle generic errors as anotations
phpstan/phpstan-src@123ffab Handle warnings
phpstan/phpstan-src@6e7d5f6 Simplify config - TableErrorFormatter can be autowired
phpstan/phpstan-src@6fd85e3 Make GithubErrorFormatter the default when running in GitHub Actions
phpstan/phpstan-src@a21012d Fix handling unpacked argument with constant arrays
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants