mozart icon indicating copy to clipboard operation
mozart copied to clipboard

nesbot/carbon empty searchNamespace

Open BrianHenryIE opened this issue 4 years ago • 1 comments

nesbot/carbon 1.39.0 "prefixes" the end of lines because its autoload key has an empty key.

Output src/carbon/Carbon.php :

<?php
Mozart\
/*Mozart\
 *Mozart\ This file is part of the Carbon package.Mozart\
 *Mozart\
 *Mozart\ (c)Mozart\ Brian Nesbitt <[email protected]>Mozart\
 *Mozart\
 *Mozart\ For the full copyright and license information,Mozart\ please view the LICENSE
Mozart\ *Mozart\ file that was distributed with this source code.Mozart\
 */Mozart\

namespace Carbon;Mozart\

use Carbon\Exceptions\InvalidDateException;Mozart\
use Closure;Mozart\
use DateInterval;Mozart\
use DatePeriod;Mozart\
use DateTime;Mozart\
use DateTimeInterface;Mozart\
use DateTimeZone;Mozart\
use InvalidArgumentException;Mozart\

The autoload key:

"autoload": {
    "psr-4": {
        "": "src/"
    }
},

Minimal reproducible composer.json:

{
  "minimum-stability": "dev",
  "prefer-stable": true,
  "require": {
    "nesbot/carbon":"1.39.0"
  },
  "require-dev": {
    "coenjacobs/mozart": "dev-master",
    "cweagans/composer-patches": "*"
  },
  "extra": {
    "mozart": {
      "dep_namespace": "Mozart\\",
      "dep_directory": "/dep_directory/",
      "classmap_prefix": "Mozart_",
      "classmap_directory": "/classmap_directory/",
      "delete_vendor_directories": false,
      "override_autoload": {
        "kylekatarnls/update-helper": {},
        "symfony/polyfill-intl-idn": {},
        "symfony/translation":{},
        "symfony/polyfill-mbstring": {},
        "symfony/translation-contracts": {}
      }
    }
  }
}

The solution might be in the NamespaceReplacer's regex, which would properly match if $searchNamespace was not an empty string.

I tried all the open PRs but they don't help.

BrianHenryIE avatar Dec 29 '20 03:12 BrianHenryIE

A working solution with failing tests, not even ready for a draft PR but good enough for me to use:

https://github.com/coenjacobs/mozart/compare/master...BrianHenryIE:empty-namespace-key?expand=1

BrianHenryIE avatar Dec 29 '20 06:12 BrianHenryIE