Skip to content

weak_vendors mode and phars #24853

@greg0ire

Description

@greg0ire
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.3.*

When introducing this mode, I overlooked the fact that file paths could look like this:

phar:///usr/local/bin/phpunit-5/phpunit/Util/Fileloader.php

In that kind of case, there is not always a way to tell if the deprecation was triggered inside or outside a vendor, so IMO I should add a special case just for phar paths in that method:

$inVendors = function ($path) {
/** @var string[] absolute paths to vendor directories */
static $vendors;
if (null === $vendors) {
foreach (get_declared_classes() as $class) {
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
$r = new \ReflectionClass($class);
$v = dirname(dirname($r->getFileName()));
if (file_exists($v.'/composer/installed.json')) {
$vendors[] = $v;
}
}
}
}
$path = realpath($path) ?: $path;
foreach ($vendors as $vendor) {
if (0 === strpos($path, $vendor) && false !== strpbrk(substr($path, strlen($vendor), 1), '/'.DIRECTORY_SEPARATOR)) {
return true;
}
}
return false;
};

Not sure how realpath behave with such paths, BTW

I wonder how / if I'm going to be able to test that though... any ideas?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy