Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nette/di #2597

Merged
merged 5 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions build/PHPStan/Build/ServiceLocatorDynamicReturnTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\ParametersAcceptorSelector;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeCombinator;

Expand Down Expand Up @@ -34,10 +33,14 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method

$returnType = ParametersAcceptorSelector::selectFromArgs($scope, $methodCall->getArgs(), $methodReflection->getVariants())->getReturnType();

if ($methodReflection->getName() === 'getByType' && count($methodCall->getArgs()) >= 2) {
$argType = $scope->getType($methodCall->getArgs()[1]->value);
if ($argType->isTrue()->yes()) {
$returnType = TypeCombinator::addNull($returnType);
if ($methodReflection->getName() === 'getByType') {
if (count($methodCall->getArgs()) < 2) {
$returnType = TypeCombinator::removeNull($returnType);
} else {
$argType = $scope->getType($methodCall->getArgs()[1]->value);
if ($argType->isTrue()->yes()) {
$returnType = TypeCombinator::removeNull($returnType);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/build/scoper.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function (string $filePath, string $prefix, string $content): string {
return str_replace('|Nette\\\\DI\\\\Statement', sprintf('|\\\\%s\\\\Nette\\\\DI\\\\Statement', $prefix), $content);
},
function (string $filePath, string $prefix, string $content): string {
if ($filePath !== 'vendor/nette/di/src/DI/Config/DefinitionSchema.php') {
if ($filePath !== 'vendor/nette/di/src/DI/Extensions/DefinitionSchema.php') {
return $content;
}
$content = str_replace(
Expand Down
35 changes: 16 additions & 19 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions src/DependencyInjection/Configurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
namespace PHPStan\DependencyInjection;

use Nette\DI\Config\Loader;
use Nette\DI\Container as OriginalNetteContainer;
use Nette\DI\ContainerLoader;
use PHPStan\File\FileReader;
use function array_keys;
use function error_reporting;
use function restore_error_handler;
use function set_error_handler;
use function sha1;
use const E_USER_DEPRECATED;
use const PHP_RELEASE_VERSION;
use const PHP_VERSION_ID;

Expand Down Expand Up @@ -60,6 +65,26 @@ public function loadContainer(): string
);
}

public function createContainer(bool $initialize = true): OriginalNetteContainer
{
set_error_handler(static function (int $errno): bool {
if ((error_reporting() & $errno) === 0) {
// silence @ operator
return true;
}

return $errno === E_USER_DEPRECATED;
});

try {
$container = parent::createContainer($initialize);
} finally {
restore_error_handler();
}

return $container;
}

/**
* @return string[]
*/
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/ContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace PHPStan\DependencyInjection;

use Nette\Bootstrap\Extensions\PhpExtension;
use Nette\DI\Config\Adapters\PhpAdapter;
use Nette\DI\Definitions\Statement;
use Nette\DI\Extensions\ExtensionsExtension;
use Nette\DI\Extensions\PhpExtension;
use Nette\DI\Helpers;
use Nette\Schema\Context as SchemaContext;
use Nette\Schema\Elements\AnyOf;
Expand Down