liberu-genealogy / php-gedcom

Gedcom reading and writing for PHP 8.3
https://www.liberu.co.uk
MIT License
74 stars 40 forks source link

Sweep: psr4 #45

Closed curtisdelicata closed 1 month ago

curtisdelicata commented 1 month ago

Details

src\Gedcom\Record\Indi.php does not comply with psr-4 autoloading standard.

sweep-ai[bot] commented 1 month ago

🚀 Here's the PR! #46

💎 Sweep Pro: You have unlimited Sweep issues

Actions

Step 1: 🔎 Searching

(Click to expand) Here are the code search results. I'm now analyzing these search results to write the PR. https://github.com/liberu-genealogy/php-gedcom/blob/876cf0f07f8bfd85a8437de95f1d573cb8e22a0d/src/Gedcom/Record/Indi.php#L1-L20 https://github.com/liberu-genealogy/php-gedcom/blob/876cf0f07f8bfd85a8437de95f1d573cb8e22a0d/composer.json#L1-L29 https://github.com/liberu-genealogy/php-gedcom/blob/876cf0f07f8bfd85a8437de95f1d573cb8e22a0d/src/Record/Indi.php#L1-L812 https://github.com/liberu-genealogy/php-gedcom/blob/876cf0f07f8bfd85a8437de95f1d573cb8e22a0d/src/Parser/Indi.php#L1-L192 https://github.com/liberu-genealogy/php-gedcom/blob/876cf0f07f8bfd85a8437de95f1d573cb8e22a0d/src/Gedcom.php#L1-L256

Step 2: ⌨️ Coding

We decided to make the following renames to help you solve the GitHub issue: Rename src/Gedcom/Record/Indi.php to src/Record/Indi.php

I'm going to follow the following steps to help you solve the GitHub issue:

  1. Update the namespace declaration in src/Record/Indi.php to comply with PSR-4 autoloading standard.
  2. Update any references to the Gedcom\Record\Indi class in other files to use the new namespace.
  3. Update the autoload configuration in composer.json to map the Record namespace to the src/Record/ directory.

Here are the changes we decided to make. I'm done making edits and now I'm just validating the changes using a linter to catch any mistakes like syntax errors or undefined variables:

src/Record/Indi.php

Update the namespace declaration to match the file path according to PSR-4 autoloading standards.
--- 
+++ 
@@ -1,6 +1,6 @@
 <?php

-namespace Gedcom\Record;
+namespace Record;

 class Indi
 {

src/Parser/Indi.php

Update references to the `Gedcom\Record\Indi` class to use the new namespace.
--- 
+++ 
@@ -1,2 +1,2 @@
-        $indi = new \Gedcom\Record\Indi();
+        $indi = new \Record\Indi();
         $indi->setId($identifier);

src/Gedcom.php

Update references to the `Gedcom\Record\Indi` class in docblocks and method signatures.
--- 
+++ 
@@ -1,6 +1,6 @@
     /**
      * Stores all the individuals contained within the GEDCOM file.
      *
-     * @var \Gedcom\Record\Indi[]
+     * @var \Record\Indi[]
      */
     protected $indi = [];

composer.json

Update the `autoload` configuration to map the `Record` namespace to the `src/Record/` directory.
--- 
+++ 
@@ -1,5 +1,6 @@
     "autoload": {
         "psr-4": {
-            "Gedcom\\": "src/"
+            "Gedcom\\": "src/",
+            "Record\\": "src/Record/"
         }
     },

Step 3: 🔄️ Validating

Your changes have been successfully made to the branch sweep/psr4_ecc88. I have validated these changes using a syntax checker and a linter.


[!TIP] To recreate the pull request, edit the issue title or description.

This is an automated message generated by Sweep AI.