tome export
This commit is contained in:
parent
52278c3a53
commit
7a52afab5f
960 changed files with 3670 additions and 2229 deletions
|
@ -82,15 +82,15 @@
|
|||
],
|
||||
"body": [
|
||||
{
|
||||
"value": "\n <p>Today, whilst working on <a href=\"/daily\/2024\/02\/19\/introducing-versa\">Versa<\/a>, I was experimenting with different PHPStan levels.<\/p>\n\n<p>Level 1 is the least strict level, and applies the fewest rules and returns the fewest results.<\/p>\n\n<p>As you increase the level, the stricter PHPStan is.<\/p>\n\n<h2 id=\"levelling-up-to-9\">Levelling up to 9<\/h2>\n\n<p>Here is the code to get the values of the <code>--extra-args<\/code> and <code>--working-dir<\/code> options:<\/p>\n\n<pre><code class=\"language-php\">$extraArgs = $input->getOption('extra-args');\n$workingDir = $input->getOption('working-dir');\n<\/code><\/pre>\n\n<p>This passed PHPStan level 8, but these are the errors I get when running level 9:<\/p>\n\n<pre><code class=\"language-plain\">------ -------------------------------------------------------------------------------------------------------\n Line versa\n------ -------------------------------------------------------------------------------------------------------\n 61 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 62 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 72 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 73 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 84 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 85 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 94 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 95 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 104 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 105 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 119 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 120 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n------ -------------------------------------------------------------------------------------------------------\n\n[ERROR] Found 12 errors\n<\/code><\/pre>\n\n<p>The issue is that <code>$input->getOption()<\/code> from Symfony's <code>InputInterface<\/code> returns <code>mixed<\/code> - even though it always returns <code>null<\/code> or a string.<\/p>\n\n<p>If I did <code>--working-dir 2<\/code>, it would return the string <code>\"2\"<\/code>.<\/p>\n\n<p>An empty string throws an error, and an empty value (if there are no extra arguments) returns <code>null<\/code>.<\/p>\n\n<p>So, I know <code>$workingDir<\/code> will always be a string and <code>$extraArgs<\/code> will either a string or <code>null<\/code>.<\/p>\n\n<h2 id=\"passing-level-8\">Passing level 8<\/h2>\n\n<p>To pass level 8, PHPStan needs to be sure the variables are what I think they are.<\/p>\n\n<p>Here's the code I can use to get it to pass:<\/p>\n\n<pre><code class=\"language-php\">$extraArgs = $input->getOption('extra-args');\n$workingDir = $input->getOption('working-dir');\nassert(is_string($extraArgs) || is_null($extraArgs));\nassert(is_string($workingDir));\n<\/code><\/pre>\n\n<p>By using <code>assert()<\/code> and throwing an Exception if the condition fails, PHPStan is now happy with the code and my code passes level 9.<\/p>\n\n<h2 id=\"here%27s-the-thing\">Here's the thing<\/h2>\n\n<p>Although the extra code gets PHPStan to pass, it it worth it?<\/p>\n\n<p>Is this extra code adding value? Does it make the code more readable or is it likely to prevent a bug?<\/p>\n\n<p>In this case, I know the value will always be the type I expect.<\/p>\n\n<p>I can work around this using a baseline or annotations for PHPStan to ignore these lines, <strong>or is level 8 good enough for this project<\/strong>?<\/p>\n\n<p>Similar to 100% test coverage, is aiming for the highest PHPStan level an objective to be met, or is enough value being added added by the lower level?<\/p>\n\n<p>Which level is right for you and this codebase?<\/p>\n\n ",
|
||||
"value": "\n <p>Today, whilst working on <a href=\"\/daily\/2024\/02\/19\/introducing-versa\">Versa<\/a>, I was experimenting with different PHPStan levels.<\/p>\n\n<p>Level 1 is the least strict level, and applies the fewest rules and returns the fewest results.<\/p>\n\n<p>As you increase the level, the stricter PHPStan is.<\/p>\n\n<h2 id=\"levelling-up-to-9\">Levelling up to 9<\/h2>\n\n<p>Here is the code to get the values of the <code>--extra-args<\/code> and <code>--working-dir<\/code> options:<\/p>\n\n<pre><code class=\"language-php\">$extraArgs = $input->getOption('extra-args');\n$workingDir = $input->getOption('working-dir');\n<\/code><\/pre>\n\n<p>This passed PHPStan level 8, but these are the errors I get when running level 9:<\/p>\n\n<pre><code class=\"language-plain\">------ -------------------------------------------------------------------------------------------------------\n Line versa\n------ -------------------------------------------------------------------------------------------------------\n 61 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 62 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 72 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 73 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 84 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 85 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 94 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 95 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 104 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 105 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 119 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 120 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n------ -------------------------------------------------------------------------------------------------------\n\n[ERROR] Found 12 errors\n<\/code><\/pre>\n\n<p>The issue is that <code>$input->getOption()<\/code> from Symfony's <code>InputInterface<\/code> returns <code>mixed<\/code> - even though it always returns <code>null<\/code> or a string.<\/p>\n\n<p>If I did <code>--working-dir 2<\/code>, it would return the string <code>\"2\"<\/code>.<\/p>\n\n<p>An empty string throws an error, and an empty value (if there are no extra arguments) returns <code>null<\/code>.<\/p>\n\n<p>So, I know <code>$workingDir<\/code> will always be a string and <code>$extraArgs<\/code> will either a string or <code>null<\/code>.<\/p>\n\n<h2 id=\"passing-level-8\">Passing level 8<\/h2>\n\n<p>To pass level 8, PHPStan needs to be sure the variables are what I think they are.<\/p>\n\n<p>Here's the code I can use to get it to pass:<\/p>\n\n<pre><code class=\"language-php\">$extraArgs = $input->getOption('extra-args');\n$workingDir = $input->getOption('working-dir');\nassert(is_string($extraArgs) || is_null($extraArgs));\nassert(is_string($workingDir));\n<\/code><\/pre>\n\n<p>By using <code>assert()<\/code> and throwing an Exception if the condition fails, PHPStan is now happy with the code and my code passes level 9.<\/p>\n\n<h2 id=\"here%27s-the-thing\">Here's the thing<\/h2>\n\n<p>Although the extra code gets PHPStan to pass, it it worth it?<\/p>\n\n<p>Is this extra code adding value? Does it make the code more readable or is it likely to prevent a bug?<\/p>\n\n<p>In this case, I know the value will always be the type I expect.<\/p>\n\n<p>I can work around this using a baseline or annotations for PHPStan to ignore these lines, <strong>or is level 8 good enough for this project<\/strong>?<\/p>\n\n<p>Similar to 100% test coverage, is aiming for the highest PHPStan level an objective to be met, or is enough value being added added by the lower level?<\/p>\n\n<p>Which level is right for you and this codebase?<\/p>\n\n ",
|
||||
"format": "full_html",
|
||||
"processed": "\n <p>Today, whilst working on <a href=\"/daily\/2024\/02\/19\/introducing-versa\">Versa<\/a>, I was experimenting with different PHPStan levels.<\/p>\n\n<p>Level 1 is the least strict level, and applies the fewest rules and returns the fewest results.<\/p>\n\n<p>As you increase the level, the stricter PHPStan is.<\/p>\n\n<h2 id=\"levelling-up-to-9\">Levelling up to 9<\/h2>\n\n<p>Here is the code to get the values of the <code>--extra-args<\/code> and <code>--working-dir<\/code> options:<\/p>\n\n<pre><code class=\"language-php\">$extraArgs = $input->getOption('extra-args');\n$workingDir = $input->getOption('working-dir');\n<\/code><\/pre>\n\n<p>This passed PHPStan level 8, but these are the errors I get when running level 9:<\/p>\n\n<pre><code class=\"language-plain\">------ -------------------------------------------------------------------------------------------------------\n Line versa\n------ -------------------------------------------------------------------------------------------------------\n 61 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 62 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 72 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 73 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 84 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 85 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 94 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 95 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 104 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 105 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 119 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 120 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n------ -------------------------------------------------------------------------------------------------------\n\n[ERROR] Found 12 errors\n<\/code><\/pre>\n\n<p>The issue is that <code>$input->getOption()<\/code> from Symfony's <code>InputInterface<\/code> returns <code>mixed<\/code> - even though it always returns <code>null<\/code> or a string.<\/p>\n\n<p>If I did <code>--working-dir 2<\/code>, it would return the string <code>\"2\"<\/code>.<\/p>\n\n<p>An empty string throws an error, and an empty value (if there are no extra arguments) returns <code>null<\/code>.<\/p>\n\n<p>So, I know <code>$workingDir<\/code> will always be a string and <code>$extraArgs<\/code> will either a string or <code>null<\/code>.<\/p>\n\n<h2 id=\"passing-level-8\">Passing level 8<\/h2>\n\n<p>To pass level 8, PHPStan needs to be sure the variables are what I think they are.<\/p>\n\n<p>Here's the code I can use to get it to pass:<\/p>\n\n<pre><code class=\"language-php\">$extraArgs = $input->getOption('extra-args');\n$workingDir = $input->getOption('working-dir');\nassert(is_string($extraArgs) || is_null($extraArgs));\nassert(is_string($workingDir));\n<\/code><\/pre>\n\n<p>By using <code>assert()<\/code> and throwing an Exception if the condition fails, PHPStan is now happy with the code and my code passes level 9.<\/p>\n\n<h2 id=\"here%27s-the-thing\">Here's the thing<\/h2>\n\n<p>Although the extra code gets PHPStan to pass, it it worth it?<\/p>\n\n<p>Is this extra code adding value? Does it make the code more readable or is it likely to prevent a bug?<\/p>\n\n<p>In this case, I know the value will always be the type I expect.<\/p>\n\n<p>I can work around this using a baseline or annotations for PHPStan to ignore these lines, <strong>or is level 8 good enough for this project<\/strong>?<\/p>\n\n<p>Similar to 100% test coverage, is aiming for the highest PHPStan level an objective to be met, or is enough value being added added by the lower level?<\/p>\n\n<p>Which level is right for you and this codebase?<\/p>\n\n ",
|
||||
"processed": "\n <p>Today, whilst working on <a href=\"http:\/\/default\/daily\/2024\/02\/19\/introducing-versa\">Versa<\/a>, I was experimenting with different PHPStan levels.<\/p>\n\n<p>Level 1 is the least strict level, and applies the fewest rules and returns the fewest results.<\/p>\n\n<p>As you increase the level, the stricter PHPStan is.<\/p>\n\n<h2 id=\"levelling-up-to-9\">Levelling up to 9<\/h2>\n\n<p>Here is the code to get the values of the <code>--extra-args<\/code> and <code>--working-dir<\/code> options:<\/p>\n\n<pre><code class=\"language-php\">$extraArgs = $input->getOption('extra-args');\n$workingDir = $input->getOption('working-dir');\n<\/code><\/pre>\n\n<p>This passed PHPStan level 8, but these are the errors I get when running level 9:<\/p>\n\n<pre><code class=\"language-plain\">------ -------------------------------------------------------------------------------------------------------\n Line versa\n------ -------------------------------------------------------------------------------------------------------\n 61 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 62 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 72 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 73 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 84 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 85 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 94 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 95 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 104 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 105 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n 119 Parameter $extraArgs of static method App\\Process\\Process::create() expects string|null, mixed given.\n 120 Parameter $workingDir of static method App\\Process\\Process::create() expects string, mixed given.\n------ -------------------------------------------------------------------------------------------------------\n\n[ERROR] Found 12 errors\n<\/code><\/pre>\n\n<p>The issue is that <code>$input->getOption()<\/code> from Symfony's <code>InputInterface<\/code> returns <code>mixed<\/code> - even though it always returns <code>null<\/code> or a string.<\/p>\n\n<p>If I did <code>--working-dir 2<\/code>, it would return the string <code>\"2\"<\/code>.<\/p>\n\n<p>An empty string throws an error, and an empty value (if there are no extra arguments) returns <code>null<\/code>.<\/p>\n\n<p>So, I know <code>$workingDir<\/code> will always be a string and <code>$extraArgs<\/code> will either a string or <code>null<\/code>.<\/p>\n\n<h2 id=\"passing-level-8\">Passing level 8<\/h2>\n\n<p>To pass level 8, PHPStan needs to be sure the variables are what I think they are.<\/p>\n\n<p>Here's the code I can use to get it to pass:<\/p>\n\n<pre><code class=\"language-php\">$extraArgs = $input->getOption('extra-args');\n$workingDir = $input->getOption('working-dir');\nassert(is_string($extraArgs) || is_null($extraArgs));\nassert(is_string($workingDir));\n<\/code><\/pre>\n\n<p>By using <code>assert()<\/code> and throwing an Exception if the condition fails, PHPStan is now happy with the code and my code passes level 9.<\/p>\n\n<h2 id=\"here%27s-the-thing\">Here's the thing<\/h2>\n\n<p>Although the extra code gets PHPStan to pass, it it worth it?<\/p>\n\n<p>Is this extra code adding value? Does it make the code more readable or is it likely to prevent a bug?<\/p>\n\n<p>In this case, I know the value will always be the type I expect.<\/p>\n\n<p>I can work around this using a baseline or annotations for PHPStan to ignore these lines, <strong>or is level 8 good enough for this project<\/strong>?<\/p>\n\n<p>Similar to 100% test coverage, is aiming for the highest PHPStan level an objective to be met, or is enough value being added added by the lower level?<\/p>\n\n<p>Which level is right for you and this codebase?<\/p>\n\n ",
|
||||
"summary": null
|
||||
}
|
||||
],
|
||||
"feeds_item": [
|
||||
{
|
||||
"imported": "1970-01-01T00:33:45+00:00",
|
||||
"imported": "1970-01-01T00:32:50+00:00",
|
||||
"guid": null,
|
||||
"hash": "04a7f9d899ae8eb0f4c33ff32a7dabae",
|
||||
"target_type": "feeds_feed",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue