From 916428bd375edbd3ae4eb07ea75ef7dcb7298ef8 Mon Sep 17 00:00:00 2001 From: "marc.wuerth" Date: Thu, 1 Jun 2023 14:09:38 +0200 Subject: [PATCH] Only add PHP opening tag when the following rule of thumb are met Add PHP opening tags when all requirements are met: - Tne [mandatory class namespace](https://www.php-fig.org/psr/psr-1/#3-namespace-and-class-names) is defined or no class or interface respectively is defined - All necessary classes & functions are imported - All necessary variables & constants are defined - All necessary structures are visible or hinted at with a comment - All statements and/or structures are related to each other - Or the PHP opening tag is essential to the code example Do not add PHP opening tags when: - Only one or many unrelated statements are shown - Only one or many unrelated functions are shown - Only one or many unrelated methods are shown - Only one or many unrelated classes or interfaces respectively are shown - Only one or many unrelated other structures, such as an if-clause or match expression, are shown --- spec.md | 52 ---------------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/spec.md b/spec.md index 6fac42e..128426d 100644 --- a/spec.md +++ b/spec.md @@ -234,8 +234,6 @@ When using compound namespaces, there MUST NOT be more than two sub-namespaces w That is, the following is allowed: ```php -bar($arg1); Foo::bar($arg2, $arg3); @@ -721,8 +713,6 @@ array) does not constitute splitting the argument list itself. The following examples show correct argument usage. ```php -bar( $longArgument, $longerArgument, @@ -731,8 +721,6 @@ $foo->bar( ``` ```php - 'First case', 1, 2, 3 => multipleCases(), @@ -896,8 +874,6 @@ A `while` statement looks like the following. Note the placement of parentheses, spaces, and braces. ```php - $value) { // foreach body } @@ -997,8 +961,6 @@ A `try-catch-finally` block looks like the following. Note the placement of parentheses, spaces, and braces. ```php -bar( $arg1, function ($arg2) use ($var1) { @@ -1221,8 +1177,6 @@ Anonymous Classes MUST follow the same guidelines and principles as closures in the above section. ```php -