Skip to content

Commit

Permalink
bug #5989 NoAliasFunctionsFixer - Correct mapping (weshooper)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

NoAliasFunctionsFixer -  Correct mapping

These were added recently, but are incorrectly mapping the function to the alias.

Commits
-------

0e9d477 Correct mapping in NoAliasFunctionsFixer
  • Loading branch information
SpacePossum committed Sep 9, 2021
2 parents 7443e4e + 0e9d477 commit 5e6bd99
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 136 deletions.
18 changes: 7 additions & 11 deletions src/Fixer/Alias/NoAliasFunctionsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ final class NoAliasFunctionsFixer extends AbstractFixer implements ConfigurableF
'@internal' => [
'diskfreespace' => 'disk_free_space',

'checkdnsrr' => 'dns_check_record',
'getmxrr' => 'dns_get_mx',
'dns_check_record' => 'checkdnsrr',
'dns_get_mx' => 'getmxrr',

'session_commit' => 'session_write_close',

Expand Down Expand Up @@ -83,14 +83,8 @@ final class NoAliasFunctionsFixer extends AbstractFixer implements ConfigurableF
'imap_scanmailbox' => 'imap_listscan',
],

'@snmp' => [
'snmpwalkoid' => 'snmprealwalk',
'snmp_set_oid_numeric_print' => 'snmp_set_oid_output_format',
],

'@ldap' => [
'ldap_close' => 'ldap_unbind',
'ldap_get_values' => 'ldap_get_values_len',
'ldap_modify' => 'ldap_mod_replace',
],

Expand Down Expand Up @@ -169,6 +163,7 @@ public function configure(array $configuration): void
parent::configure($configuration);

$this->aliases = [];

foreach ($this->configuration['sets'] as $set) {
if ('@all' === $set) {
$this->aliases = array_merge(...array_values(self::SETS));
Expand Down Expand Up @@ -264,6 +259,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
foreach ($tokens->findGivenKind(T_STRING) as $index => $token) {
// check mapping hit
$tokenContent = strtolower($token->getContent());

if (!isset($this->aliases[$tokenContent])) {
continue;
}
Expand Down Expand Up @@ -315,16 +311,16 @@ protected function createConfigurationDefinition(): FixerConfigurationResolverIn
'@pcntl' => 'PCNTL functions',
'@pg' => 'pg functions',
'@posix' => 'POSIX functions',
'@snmp' => 'SNMP functions',
'@snmp' => 'SNMP functions', // @TODO Remove on next major 4.0 as this set is now empty
'@sodium' => 'libsodium functions',
'@time' => 'time functions',
];

$list = '';
$list = "List of sets to fix. Defined sets are:\n\n";

foreach ($sets as $set => $description) {
$list .= sprintf("* `%s` (%s)\n", $set, $description);
}
$list = sprintf("List of sets to fix. Defined sets are:\n\n%s", $list);

return new FixerConfigurationResolver([
(new FixerOptionBuilder('sets', $list))
Expand Down

0 comments on commit 5e6bd99

Please sign in to comment.