| Conditions | 1 |
| Paths | 1 |
| Total Lines | 124 |
| Code Lines | 98 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 36 | protected function configure() |
||
| 37 | { |
||
| 38 | $this |
||
| 39 | ->setName(self::NAME) |
||
| 40 | ->setDescription('Will update a composer configuration file.') |
||
| 41 | // @codingStandardsIgnoreStart |
||
| 42 | ->setHelp(<<<DESC |
||
| 43 | - <info>keywords</info> will be appended to existing ones |
||
| 44 | - <info>other plain values</info> (package name, version, ...) will replace old ones if they are already present, else they will be added |
||
| 45 | - <info>nested values</info> (authors, autoload, script, ...) will replace old ones if they are already present, else they will be appended |
||
| 46 | DESC |
||
| 47 | ) |
||
| 48 | // @codingStandardsIgnoreEnd |
||
| 49 | ->addArgument( |
||
| 50 | self::ARGUMENT_CONFIGURATION_DEST_FOLDER, |
||
| 51 | InputArgument::OPTIONAL, |
||
| 52 | 'Existing onfiguration file path', |
||
| 53 | '.' |
||
| 54 | ) |
||
| 55 | ->addOption( |
||
| 56 | InputTransformer::KEY_PACKAGE_NAME, |
||
| 57 | null, |
||
| 58 | InputOption::VALUE_REQUIRED, |
||
| 59 | 'Name for the composer package' |
||
| 60 | ) |
||
| 61 | ->addOption( |
||
| 62 | InputTransformer::KEY_TYPE, |
||
| 63 | null, |
||
| 64 | InputOption::VALUE_REQUIRED, |
||
| 65 | 'Package type. Ex : "library" / "project"' |
||
| 66 | ) |
||
| 67 | ->addOption( |
||
| 68 | InputTransformer::KEY_LICENSE, |
||
| 69 | null, |
||
| 70 | InputOption::VALUE_REQUIRED, |
||
| 71 | 'Package license type' |
||
| 72 | ) |
||
| 73 | ->addOption( |
||
| 74 | InputTransformer::KEY_PACKAGE_VERSION, |
||
| 75 | null, |
||
| 76 | InputOption::VALUE_REQUIRED, |
||
| 77 | 'Package version number. Ex : "X.Y.Z"' |
||
| 78 | ) |
||
| 79 | ->addOption( |
||
| 80 | InputTransformer::KEY_DESCRIPTION, |
||
| 81 | null, |
||
| 82 | InputOption::VALUE_REQUIRED, |
||
| 83 | 'Package description' |
||
| 84 | ) |
||
| 85 | ->addOption( |
||
| 86 | InputTransformer::KEY_KEYWORD, |
||
| 87 | null, |
||
| 88 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
| 89 | 'Package keywords' |
||
| 90 | ) |
||
| 91 | ->addOption( |
||
| 92 | InputTransformer::KEY_AUTHOR, |
||
| 93 | null, |
||
| 94 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
| 95 | 'Package authors. Format "name[#email[#role]]' |
||
| 96 | ) |
||
| 97 | ->addOption( |
||
| 98 | InputTransformer::KEY_PROVIDED_PACKAGE, |
||
| 99 | null, |
||
| 100 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
| 101 | 'List of packages provided by this one. Ex : "package-name#version"' |
||
| 102 | ) |
||
| 103 | ->addOption( |
||
| 104 | InputTransformer::KEY_SUGGESTED_PACKAGE, |
||
| 105 | null, |
||
| 106 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
| 107 | 'List of packages suggested by this one. Ex : "package-name#description"' |
||
| 108 | ) |
||
| 109 | ->addOption( |
||
| 110 | InputTransformer::KEY_SUPPORT, |
||
| 111 | null, |
||
| 112 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
| 113 | 'List of package support urls. Ex : "type#url"' |
||
| 114 | ) |
||
| 115 | ->addOption( |
||
| 116 | InputTransformer::KEY_AUTOLOAD_PSR0, |
||
| 117 | null, |
||
| 118 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
| 119 | 'List of package PSR-0 autoload. Ex : "namespace#path"' |
||
| 120 | ) |
||
| 121 | ->addOption( |
||
| 122 | InputTransformer::KEY_AUTOLOAD_PSR4, |
||
| 123 | null, |
||
| 124 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
| 125 | 'List of package PSR-4 autoload. Ex : "namespace#path"' |
||
| 126 | ) |
||
| 127 | ->addOption( |
||
| 128 | InputTransformer::KEY_AUTOLOAD_DEV_PSR0, |
||
| 129 | null, |
||
| 130 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
| 131 | 'List of packages PSR-0 dev autoload. Ex : "namespace#path"' |
||
| 132 | ) |
||
| 133 | ->addOption( |
||
| 134 | InputTransformer::KEY_AUTOLOAD_DEV_PSR4, |
||
| 135 | null, |
||
| 136 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
| 137 | 'List of package PSR-4 dev autoload. Ex : "namespace#path"' |
||
| 138 | ) |
||
| 139 | ->addOption( |
||
| 140 | InputTransformer::KEY_REQUIRE, |
||
| 141 | null, |
||
| 142 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
| 143 | 'List of required packages. Ex "vendor/package-name#~x.y"' |
||
| 144 | ) |
||
| 145 | ->addOption( |
||
| 146 | InputTransformer::KEY_REQUIRE_DEV, |
||
| 147 | null, |
||
| 148 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
| 149 | 'List of required dev packages. Ex "vendor/package-name#~x.y"' |
||
| 150 | ) |
||
| 151 | ->addOption( |
||
| 152 | InputTransformer::KEY_SCRIPT, |
||
| 153 | null, |
||
| 154 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
| 155 | 'List of scripts for the package. Ex : "script-name#command"' |
||
| 156 | ) |
||
| 157 | ; |
||
| 158 | parent::configure(); |
||
| 159 | } |
||
| 160 | |||
| 186 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: