Repository: laravel/framework
File: src/Illuminate/Container/Container.php (PHP)

Code before:

        return isset($this->resolved[$abstract]) ||
               isset($this->instances[$abstract]);
    }

    /**
     * Determine if a given type is shared.
     *
     * @param  string  $abstract
     * @return bool
     */
        public function isShared($abstract)
    {
        if (isset($this->instances[$abstract])) {
            return true;
        }

        if (isset($this->bindings[$abstract]['shared']) && $this->bindings[$abstract]['shared'] === true) {
            return true;
        }

        if (! class_exists($abstract)) {
            return false;
        }

        if ($scopedType = $this->getScopedTyped(new ReflectionClass($abstract)) === null) {
            return false;
        }

        if ($scopedType === 'scoped') {
            if (! in_array($abstract, $this->scopedInstances, true)) {
                $this->scopedInstances[] = $abstract;
            }
        }

        return true;
    }

    /**
     * Determine if a ReflectionClass has scoping attributes applied.
     *
     * @param  ReflectionClass<object>  $reflection
     * @return "singleton"|"scoped"|null
     */
    protected function getScopedTyped(ReflectionClass $reflection): ?string
    {
        if (! empty($reflection->getAttributes(Singleton::class))) {
            return 'singleton';
        }

        if (! empty($reflection->getAttributes(Scoped::class))) {

Review comment (refactor):
Doesn't the assignment need to be wrapped in parentheses?

```php
//  ( <------------------- added parentheses -------------------------> )
if (($scopedType = $this->getScopedTyped(new ReflectionClass($abstract))) === null) {
```

The `===` (comparison) operator has a higher precedence than the `=` (assignment) one. So it will be evaluated before the assignment.

Reference: https://www.php.net/manual/en/language.operators.precedence.php

The way it currently is, instead of the `$scopedType` variable being assigned `singleton`, `scoped` or `null`,  it will end up with a boolean from the comparison to `null`.


Code after:

        return isset($this->resolved[$abstract]) ||
               isset($this->instances[$abstract]);
    }

    /**
     * Determine if a given type is shared.
     *
     * @param  string  $abstract
     * @return bool
     */
    public function isShared($abstract)
    {
        if (isset($this->instances[$abstract])) {
            return true;
        }

        if (isset($this->bindings[$abstract]['shared']) && $this->bindings[$abstract]['shared'] === true) {
            return true;
        }

        if (! class_exists($abstract)) {
            return false;
        }

        if (($scopedType = $this->getScopedTyped(new ReflectionClass($abstract))) === null) {
            return false;
        }

        if ($scopedType === 'scoped') {
            if (! in_array($abstract, $this->scopedInstances, true)) {
                $this->scopedInstances[] = $abstract;
            }
        }

        return true;
    }

    /**
     * Determine if a ReflectionClass has scoping attributes applied.
     *
     * @param  ReflectionClass<object>  $reflection
     * @return "singleton"|"scoped"|null
     */
    protected function getScopedTyped(ReflectionClass $reflection): ?string
    {
        if (! empty($reflection->getAttributes(Singleton::class))) {
            return 'singleton';
        }

        if (! empty($reflection->getAttributes(Scoped::class))) {