mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 14:54:04 +00:00
minor improvements for phpstan
This commit is contained in:
parent
62d19c5f5d
commit
f941df3a82
4 changed files with 18 additions and 9 deletions
|
|
@ -15,11 +15,16 @@ class CrossDomainRedirect implements Feature
|
|||
RedirectResponse::macro('domain', function (string $domain) {
|
||||
/** @var RedirectResponse $this */
|
||||
|
||||
// Replace first occurrence of the hostname fragment with $domain
|
||||
$url = $this->getTargetUrl();
|
||||
|
||||
/**
|
||||
* The original hostname in the redirect response.
|
||||
*
|
||||
* @var string $hostname
|
||||
*/
|
||||
$hostname = parse_url($url, PHP_URL_HOST);
|
||||
$position = strpos($url, $hostname);
|
||||
$this->setTargetUrl(substr_replace($url, $domain, $position, strlen($hostname)));
|
||||
|
||||
$this->setTargetUrl((string) str($url)->replace($hostname, $domain));
|
||||
|
||||
return $this;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ class Tenancy
|
|||
$tenants = is_string($tenants) ? [$tenants] : $tenants;
|
||||
|
||||
// Use all tenants if $tenants is falsey
|
||||
$tenants = $tenants ?: $this->model()->cursor();
|
||||
$tenants = $tenants ?: $this->model()->cursor(); // todo0 phpstan thinks this isn't needed, but tests fail without it
|
||||
|
||||
$originalTenant = $this->tenant;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,11 +58,15 @@ if (! function_exists('global_cache')) {
|
|||
if (! function_exists('tenant_route')) {
|
||||
function tenant_route(string $domain, string $route, array $parameters = [], bool $absolute = true): string
|
||||
{
|
||||
// replace the first occurrence of the hostname fragment with $domain
|
||||
$url = route($route, $parameters, $absolute);
|
||||
$hostname = parse_url($url, PHP_URL_HOST);
|
||||
$position = strpos($url, $hostname);
|
||||
|
||||
return substr_replace($url, $domain, $position, strlen($hostname));
|
||||
/**
|
||||
* The original hostname in the generated route.
|
||||
*
|
||||
* @var string $hostname
|
||||
*/
|
||||
$hostname = parse_url($url, PHP_URL_HOST);
|
||||
|
||||
return (string) str($url)->replace($hostname, $domain);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
|||
'--realpath' => true,
|
||||
'--force' => true,
|
||||
],
|
||||
'tenancy.bootstrappers.redis' => \Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper::class,
|
||||
'tenancy.bootstrappers.redis' => \Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper::class, // todo0 change this to []? two tests in TenantDatabaseManagerTest are failing with that
|
||||
'queue.connections.central' => [
|
||||
'driver' => 'sync',
|
||||
'central' => true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue