From a15a5837d574924f9c0fdfd7b16e2618514acc37 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sat, 14 Nov 2026 11:51:32 -0800 Subject: [PATCH 1/3] Build/Test Tools: Add an opt-in PHPStan rule for methods that change state without `@phpstan-impure`. PHPStan decides whether a call has side effects from the method's signature alone. A method that returns a value and has no purity tag only "maybe" has side effects, so after a call to it PHPStan keeps whatever it had narrowed about the object's properties. When such a method changes those properties, callers get always-true or always-false comparisons that are wrong. `MissingImpureTagRule` reports these methods: non-void ones with no purity tag that write to properties of `$this`, to static properties, or to globals. It can also report methods that change state only through another impure method of the class. It is not enabled by default, because across `src/` it finds about 750 methods, most of which never mislead a caller. `tests/phpstan/missing-impure-tag-rule.neon` enables it for an audit. Co-Authored-By: Claude Opus 5.5 (medium effort) Claude-Code-Session-Id: dfb24569-a61a-4404-8588-60a387d2cccb --- tests/phpstan/MissingImpureTagRule.php | 351 +++++++++++++++++++++ tests/phpstan/base.neon | 1 + tests/phpstan/missing-impure-tag-rule.neon | 20 ++ 3 files changed, 372 insertions(+) create mode 100644 tests/phpstan/MissingImpureTagRule.php create mode 100644 tests/phpstan/missing-impure-tag-rule.neon diff --git a/tests/phpstan/MissingImpureTagRule.php b/tests/phpstan/MissingImpureTagRule.php new file mode 100644 index 0000000000000..e975171fa5d58 --- /dev/null +++ b/tests/phpstan/MissingImpureTagRule.php @@ -0,0 +1,351 @@ +…` properties that + * the caller established before the call. So a method that returns a value and + * also changes `$this->state` leaves its callers with a stale narrowed type for + * that state, and comparisons against it are then reported as always true or + * always false. + * + * This rule finds such methods by looking for writes in the method body to + * properties of `$this`, to static properties of the class, or to global + * variables, in methods whose side effects PHPStan only considers "maybe". + * + * @package WordPress + */ + +declare(strict_types=1); + +namespace WordPress\PHPStan; + +use PhpParser\Node; +use PhpParser\Node\Expr; +use PhpParser\Node\Name; +use PhpParser\Node\Stmt; +use PHPStan\Analyser\Scope; +use PHPStan\Node\InClassMethodNode; +use PHPStan\Rules\IdentifierRuleError; +use PHPStan\Rules\Rule; +use PHPStan\Rules\RuleErrorBuilder; +use PHPStan\ShouldNotHappenException; +use PHPStan\Type\StaticType; + +/** + * Reports non-void methods which write object, class, or global state but are + * not marked `@phpstan-impure`. + * + * @implements Rule + */ +class MissingImpureTagRule implements Rule { + + /** + * Whether to also report a method that calls a method of `$this` which + * PHPStan already considers to have side effects (one that is `void`, + * `@phpstan-impure`, or returns `$this`). + * + * @var bool + */ + private bool $reportTransitive; + + /** + * Constructor. + * + * @param bool $report_transitive Whether to report writes made via calls to impure methods of `$this`. + */ + public function __construct( bool $report_transitive = false ) { + $this->reportTransitive = $report_transitive; + } + + /** + * Returns the node type this rule processes. + * + * @return string + */ + public function getNodeType(): string { + return InClassMethodNode::class; + } + + /** + * Processes a class method node. + * + * @param InClassMethodNode $node Class method node. + * @param Scope $scope Analysis scope. + * @return list + * @throws ShouldNotHappenException + */ + public function processNode( Node $node, Scope $scope ): array { + $class_method = $node->getOriginalNode(); + if ( null === $class_method->stmts || '__construct' === $class_method->name->toLowerString() ) { + return array(); + } + + $class_reflection = $node->getClassReflection(); + $method_name = $class_method->name->toString(); + if ( ! $class_reflection->hasNativeMethod( $method_name ) ) { + return array(); + } + + /* + * Use the reflection that call sites see, so that everything PHPStan already + * accounts for is skipped: a void return type, `@phpstan-pure`/`@phpstan-impure` + * (and their `@psalm-`/`@pure` variants), the class-level + * `@phpstan-all-methods-pure`/`-impure` tags, tags inherited from a parent, and + * methods returning `$this`. + */ + $method_reflection = $class_reflection->getNativeMethod( $method_name ); + if ( ! $method_reflection->hasSideEffects()->maybe() ) { + return array(); + } + + // A fluent method returning `static` is also treated as having side effects here. + $return_type = $node->getMethodReflection()->getReturnType(); + if ( ! $class_method->isStatic() && $return_type instanceof StaticType ) { + return array(); + } + + $write = $this->findWrite( $class_method->stmts, $class_reflection->getName(), $method_reflection->getDeclaringClass()->getName() ); + if ( null === $write && $this->reportTransitive ) { + $write = $this->findImpureThisCall( $class_method->stmts, $class_reflection ); + } + if ( null === $write ) { + return array(); + } + + return array( + RuleErrorBuilder::message( + sprintf( + 'Method %s::%s() modifies %s but is not marked @phpstan-impure.', + $class_reflection->getDisplayName(), + $method_name, + $write['description'] + ) + ) + ->identifier( 'wordpress.missingImpureTag' ) + ->line( $write['line'] ) + ->tip( 'Without @phpstan-impure, callers keep narrowed types of this state across the call.' ) + ->build(), + ); + } + + /** + * Finds the first statement in a method body that writes state. + * + * Nested closures, arrow functions, and classes are not descended into, since + * they do not run as part of the call. + * + * @param Stmt[] $stmts Method body. + * @param string $class_name Name of the class being analysed. + * @param string $declaring_class Name of the class declaring the method. + * @return array{description: string, line: int}|null The written state and its line, or null if none. + */ + private function findWrite( array $stmts, string $class_name, string $declaring_class ): ?array { + $global_names = array(); + $found = null; + + $this->walk( + $stmts, + function ( Node $node ) use ( &$global_names, &$found, $class_name, $declaring_class ): bool { + if ( $node instanceof Stmt\Global_ ) { + foreach ( $node->vars as $var ) { + if ( $var instanceof Expr\Variable && is_string( $var->name ) ) { + $global_names[ $var->name ] = true; + } + } + return false; + } + + $targets = array(); + if ( + $node instanceof Expr\Assign + || $node instanceof Expr\AssignOp + || $node instanceof Expr\AssignRef + ) { + $targets = $this->expandDestructuring( $node->var ); + } elseif ( + $node instanceof Expr\PreInc + || $node instanceof Expr\PostInc + || $node instanceof Expr\PreDec + || $node instanceof Expr\PostDec + ) { + $targets = array( $node->var ); + } elseif ( $node instanceof Stmt\Unset_ ) { + $targets = $node->vars; + } + + foreach ( $targets as $target ) { + $description = $this->describeTarget( $target, $global_names, $class_name, $declaring_class ); + if ( null !== $description ) { + $found = array( + 'description' => $description, + 'line' => $node->getStartLine(), + ); + return true; + } + } + return false; + } + ); + + return $found; + } + + /** + * Finds the first call to a method of `$this` which PHPStan already considers + * to have side effects. + * + * @param Stmt[] $stmts Method body. + * @param \PHPStan\Reflection\ClassReflection $class_reflection Class being analysed. + * @return array{description: string, line: int}|null The call and its line, or null if none. + */ + private function findImpureThisCall( array $stmts, \PHPStan\Reflection\ClassReflection $class_reflection ): ?array { + $found = null; + + $this->walk( + $stmts, + function ( Node $node ) use ( &$found, $class_reflection ): bool { + if ( + ! ( $node instanceof Expr\MethodCall || $node instanceof Expr\StaticCall ) + || ! $node->name instanceof Node\Identifier + ) { + return false; + } + + if ( $node instanceof Expr\MethodCall ) { + if ( ! $node->var instanceof Expr\Variable || 'this' !== $node->var->name ) { + return false; + } + } elseif ( ! $node->class instanceof Name || ! in_array( $node->class->toLowerString(), array( 'self', 'static', 'parent' ), true ) ) { + return false; + } + + $callee = $node->name->toString(); + if ( ! $class_reflection->hasNativeMethod( $callee ) ) { + return false; + } + if ( ! $class_reflection->getNativeMethod( $callee )->hasSideEffects()->yes() ) { + return false; + } + + $found = array( + 'description' => sprintf( 'state via %s()', $callee ), + 'line' => $node->getStartLine(), + ); + return true; + } + ); + + return $found; + } + + /** + * Walks statements depth-first in source order, without descending into + * nested function-likes or classes. + * + * @param Node[] $nodes Nodes to walk. + * @param callable(Node): bool $callback Visitor; returning true stops the walk. + * @return bool Whether the walk was stopped. + */ + private function walk( array $nodes, callable $callback ): bool { + foreach ( $nodes as $node ) { + if ( ! $node instanceof Node ) { + continue; + } + if ( $callback( $node ) ) { + return true; + } + if ( + $node instanceof Expr\Closure + || $node instanceof Expr\ArrowFunction + || $node instanceof Stmt\Function_ + || $node instanceof Stmt\ClassLike + ) { + continue; + } + foreach ( $node->getSubNodeNames() as $name ) { + $sub = $node->$name; + if ( $sub instanceof Node ) { + $sub = array( $sub ); + } + if ( is_array( $sub ) && $this->walk( $sub, $callback ) ) { + return true; + } + } + } + return false; + } + + /** + * Expands a `list()`/`[]` destructuring target into the expressions it assigns. + * + * @param Expr $target Assignment target. + * @return Expr[] Assigned expressions. + */ + private function expandDestructuring( Expr $target ): array { + if ( ! $target instanceof Expr\List_ && ! $target instanceof Expr\Array_ ) { + return array( $target ); + } + + $targets = array(); + foreach ( $target->items as $item ) { + if ( null !== $item ) { + $targets = array_merge( $targets, $this->expandDestructuring( $item->value ) ); + } + } + return $targets; + } + + /** + * Describes the state an assignment target writes, if it is not local. + * + * @param Expr $target Assignment target. + * @param array $global_names Variables imported with `global`. + * @param string $class_name Name of the class being analysed. + * @param string $declaring_class Name of the class declaring the method. + * @return string|null Description of the written state, or null for a local variable. + */ + private function describeTarget( Expr $target, array $global_names, string $class_name, string $declaring_class ): ?string { + $root = $target; + while ( + $root instanceof Expr\ArrayDimFetch + || $root instanceof Expr\PropertyFetch + || $root instanceof Expr\NullsafePropertyFetch + ) { + $root = $root->var; + } + + if ( $root instanceof Expr\StaticPropertyFetch ) { + if ( $root->class instanceof Name ) { + $class = $root->class->toLowerString(); + if ( + in_array( $class, array( 'self', 'static', 'parent' ), true ) + || strtolower( $root->class->toString() ) === strtolower( $class_name ) + || strtolower( $root->class->toString() ) === strtolower( $declaring_class ) + ) { + return 'class state'; + } + } + return 'static state of another class'; + } + + if ( ! $root instanceof Expr\Variable || ! is_string( $root->name ) ) { + return null; + } + + if ( 'this' === $root->name ) { + // Assigning to `$this` itself is impossible; only its properties count. + return $root === $target ? null : 'object state'; + } + if ( 'GLOBALS' === $root->name ) { + return 'global state'; + } + if ( isset( $global_names[ $root->name ] ) ) { + return sprintf( 'global $%s', $root->name ); + } + return null; + } +} diff --git a/tests/phpstan/base.neon b/tests/phpstan/base.neon index 1c102ca47e7da..e5e14d984fe79 100644 --- a/tests/phpstan/base.neon +++ b/tests/phpstan/base.neon @@ -305,6 +305,7 @@ parameters: - ApplyFiltersDynamicFunctionReturnTypeExtension.php - HookDocumentationRule.php - HookParamCountRule.php + - MissingImpureTagRule.php bootstrapFiles: - bootstrap.php scanFiles: diff --git a/tests/phpstan/missing-impure-tag-rule.neon b/tests/phpstan/missing-impure-tag-rule.neon new file mode 100644 index 0000000000000..3de6a227400b0 --- /dev/null +++ b/tests/phpstan/missing-impure-tag-rule.neon @@ -0,0 +1,20 @@ +# Opt-in audit for methods that write object, class, or global state without being marked +# `@phpstan-impure`. It is not part of the default configuration, because most of the +# methods it finds never mislead a caller. Run it with a local config that includes both +# this file and `phpstan.neon.dist`. +# +# Set `missingImpureTagRuleTransitive: true` to also report methods that change state +# only by calling another method of the class that PHPStan already treats as impure. +services: + - + class: WordPress\PHPStan\MissingImpureTagRule + arguments: + report_transitive: %missingImpureTagRuleTransitive% + tags: + - phpstan.rules.rule + +parametersSchema: + missingImpureTagRuleTransitive: bool() + +parameters: + missingImpureTagRuleTransitive: false From e1814b3be04e7f99fabd4205d3d88d5c9570ad0f Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sat, 14 Nov 2026 12:15:27 -0800 Subject: [PATCH 2/3] Code Quality: Mark methods that change state as `@phpstan-impure`. This adds `@phpstan-impure` to the 747 methods that `MissingImpureTagRule` reports: non-void methods with no purity tag that write to properties of `$this`, to static properties, or to globals. The tags tell PHPStan to forget what it has narrowed about an object after calling one of these methods. At the configured level, this changes two results: * An access to the undefined `WP_Upgrader_Skin::$api` property in `Theme_Upgrader::install()` is now reported a third time, because `$this->skin` is no longer known to be the skin it was narrowed to. * One of the two `$last_error` checks in `WP_HTML_Processor::step()` is no longer reported as always false, now that the `step_*()` methods are impure. The one after the direct `bookmark_token()` call remains, since a catch block sees the scope from before the call's side effects. Co-Authored-By: Claude Opus 5.5 (medium effort) Claude-Code-Session-Id: dfb24569-a61a-4404-8588-60a387d2cccb --- phpstan.neon.dist | 9 +-- .../class-automatic-upgrader-skin.php | 4 ++ .../class-bulk-plugin-upgrader-skin.php | 2 + .../class-bulk-theme-upgrader-skin.php | 2 + .../includes/class-bulk-upgrader-skin.php | 8 +++ src/wp-admin/includes/class-core-upgrader.php | 2 + .../includes/class-custom-background.php | 4 ++ .../includes/class-custom-image-header.php | 6 ++ .../includes/class-language-pack-upgrader.php | 4 ++ .../includes/class-plugin-installer-skin.php | 4 ++ .../includes/class-plugin-upgrader-skin.php | 2 + .../includes/class-plugin-upgrader.php | 8 +++ .../includes/class-theme-installer-skin.php | 4 ++ .../includes/class-theme-upgrader.php | 10 ++++ .../class-walker-nav-menu-checklist.php | 2 + .../includes/class-walker-nav-menu-edit.php | 2 + ...ss-wp-application-passwords-list-table.php | 2 + .../includes/class-wp-automatic-updater.php | 4 ++ .../includes/class-wp-comments-list-table.php | 8 +++ .../includes/class-wp-filesystem-base.php | 6 ++ .../includes/class-wp-filesystem-ftpext.php | 2 + .../includes/class-wp-filesystem-ssh2.php | 2 + src/wp-admin/includes/class-wp-importer.php | 2 + .../includes/class-wp-links-list-table.php | 2 + src/wp-admin/includes/class-wp-list-table.php | 10 ++++ .../includes/class-wp-media-list-table.php | 4 ++ .../includes/class-wp-ms-sites-list-table.php | 2 + .../class-wp-ms-themes-list-table.php | 4 ++ .../includes/class-wp-ms-users-list-table.php | 2 + .../class-wp-plugin-install-list-table.php | 2 + .../includes/class-wp-plugins-list-table.php | 4 ++ .../includes/class-wp-posts-list-table.php | 12 ++++ .../class-wp-privacy-policy-content.php | 4 ++ .../class-wp-privacy-requests-table.php | 2 + src/wp-admin/includes/class-wp-screen.php | 34 +++++++++++ .../includes/class-wp-site-health.php | 12 ++++ src/wp-admin/includes/class-wp-site-icon.php | 4 ++ .../includes/class-wp-terms-list-table.php | 4 ++ .../class-wp-theme-install-list-table.php | 2 + .../includes/class-wp-themes-list-table.php | 2 + .../includes/class-wp-upgrader-skin.php | 8 +++ src/wp-admin/includes/class-wp-upgrader.php | 6 ++ .../includes/class-wp-users-list-table.php | 2 + .../twentyfourteen/inc/featured-content.php | 2 + .../themes/twentyfourteen/inc/widgets.php | 2 + .../class-wp-abilities-registry.php | 6 ++ .../class-wp-ability-categories-registry.php | 6 ++ .../abilities/class-wp-abilities-content.php | 4 ++ .../ai-client/class-wp-ai-client-builder.php | 2 + src/wp-includes/block-template.php | 2 + src/wp-includes/class-walker-comment.php | 6 ++ src/wp-includes/class-wp-admin-bar.php | 8 +++ src/wp-includes/class-wp-ajax-response.php | 2 + .../class-wp-block-bindings-registry.php | 6 ++ src/wp-includes/class-wp-block-list.php | 2 + .../class-wp-block-metadata-registry.php | 6 ++ src/wp-includes/class-wp-block-parser.php | 10 ++++ ...s-wp-block-pattern-categories-registry.php | 6 ++ .../class-wp-block-patterns-registry.php | 6 ++ src/wp-includes/class-wp-block-processor.php | 4 ++ .../class-wp-block-styles-registry.php | 6 ++ src/wp-includes/class-wp-block-supports.php | 2 + .../class-wp-block-templates-registry.php | 6 ++ .../class-wp-block-type-registry.php | 6 ++ src/wp-includes/class-wp-block-type.php | 6 ++ src/wp-includes/class-wp-block.php | 12 ++++ src/wp-includes/class-wp-comment-query.php | 10 ++++ src/wp-includes/class-wp-comment.php | 2 + .../class-wp-connector-registry.php | 4 ++ .../class-wp-customize-control.php | 4 ++ .../class-wp-customize-manager.php | 56 ++++++++++++++++++ .../class-wp-customize-nav-menus.php | 4 ++ .../class-wp-customize-setting.php | 12 ++++ .../class-wp-customize-widgets.php | 22 +++++++ src/wp-includes/class-wp-dependencies.php | 16 +++++ src/wp-includes/class-wp-dependency.php | 4 ++ src/wp-includes/class-wp-duotone.php | 10 ++++ src/wp-includes/class-wp-editor.php | 16 +++++ src/wp-includes/class-wp-embed.php | 12 ++++ .../class-wp-entity-actions-registry.php | 12 ++++ .../class-wp-entity-fields-registry.php | 14 +++++ src/wp-includes/class-wp-hook.php | 14 +++++ src/wp-includes/class-wp-http-curl.php | 6 ++ src/wp-includes/class-wp-http-response.php | 8 +++ .../class-wp-icon-collections-registry.php | 6 ++ src/wp-includes/class-wp-icons-registry.php | 12 ++++ src/wp-includes/class-wp-image-editor-gd.php | 14 +++++ .../class-wp-image-editor-imagick.php | 6 ++ src/wp-includes/class-wp-image-editor.php | 6 ++ src/wp-includes/class-wp-list-util.php | 6 ++ src/wp-includes/class-wp-locale-switcher.php | 6 ++ src/wp-includes/class-wp-locale.php | 4 ++ src/wp-includes/class-wp-meta-query.php | 6 ++ .../class-wp-metadata-lazyloader.php | 4 ++ src/wp-includes/class-wp-network-query.php | 10 ++++ src/wp-includes/class-wp-network.php | 8 +++ src/wp-includes/class-wp-object-cache.php | 22 +++++++ src/wp-includes/class-wp-oembed.php | 4 ++ src/wp-includes/class-wp-phpmailer.php | 2 + .../class-wp-plugin-dependencies.php | 16 +++++ src/wp-includes/class-wp-post-type.php | 18 ++++++ src/wp-includes/class-wp-query.php | 40 +++++++++++++ src/wp-includes/class-wp-recovery-mode.php | 4 ++ src/wp-includes/class-wp-rewrite.php | 36 ++++++++++++ src/wp-includes/class-wp-role.php | 4 ++ src/wp-includes/class-wp-roles.php | 12 ++++ src/wp-includes/class-wp-script-modules.php | 22 +++++++ src/wp-includes/class-wp-scripts.php | 10 ++++ src/wp-includes/class-wp-site-query.php | 10 ++++ src/wp-includes/class-wp-site.php | 2 + .../class-wp-speculation-rules.php | 2 + src/wp-includes/class-wp-styles.php | 6 ++ src/wp-includes/class-wp-tax-query.php | 6 ++ src/wp-includes/class-wp-taxonomy.php | 8 +++ src/wp-includes/class-wp-term-query.php | 6 ++ .../class-wp-textdomain-registry.php | 4 ++ .../class-wp-theme-json-resolver.php | 20 +++++++ src/wp-includes/class-wp-theme-json.php | 4 ++ src/wp-includes/class-wp-theme.php | 14 +++++ src/wp-includes/class-wp-user-query.php | 10 ++++ src/wp-includes/class-wp-user.php | 24 ++++++++ src/wp-includes/class-wp-view-config-data.php | 4 ++ src/wp-includes/class-wp-walker.php | 4 ++ src/wp-includes/class-wp-widget-factory.php | 6 ++ src/wp-includes/class-wp-widget.php | 4 ++ src/wp-includes/class-wp-xmlrpc-server.php | 18 ++++++ src/wp-includes/class-wp.php | 12 ++++ src/wp-includes/class-wpdb.php | 58 +++++++++++++++++++ ...class-wp-customize-code-editor-control.php | 2 + .../class-wp-customize-color-control.php | 2 + ...ass-wp-customize-cropped-image-control.php | 2 + .../class-wp-customize-custom-css-setting.php | 2 + ...lass-wp-customize-header-image-control.php | 2 + ...lass-wp-customize-header-image-setting.php | 2 + .../class-wp-customize-media-control.php | 2 + ...ass-wp-customize-nav-menu-item-setting.php | 10 ++++ ...wp-customize-nav-menu-location-control.php | 2 + .../class-wp-customize-nav-menu-setting.php | 6 ++ .../class-wp-customize-selective-refresh.php | 8 +++ .../class-wp-customize-theme-control.php | 2 + .../class-wp-customize-upload-control.php | 2 + ...class-wp-widget-area-customize-control.php | 2 + ...class-wp-widget-form-customize-control.php | 2 + .../fonts/class-wp-font-collection.php | 2 + .../fonts/class-wp-font-library.php | 6 ++ ...ass-wp-html-active-formatting-elements.php | 2 + .../html-api/class-wp-html-processor.php | 48 +++++++++++++++ .../html-api/class-wp-html-tag-processor.php | 34 +++++++++++ ...interactivity-api-directives-processor.php | 6 ++ .../class-wp-interactivity-api.php | 20 +++++++ src/wp-includes/kses.php | 4 ++ .../l10n/class-wp-translation-controller.php | 10 ++++ .../l10n/class-wp-translation-file-mo.php | 6 ++ .../l10n/class-wp-translation-file-php.php | 2 + .../l10n/class-wp-translation-file.php | 4 ++ .../rest-api/class-wp-rest-request.php | 34 +++++++++++ .../rest-api/class-wp-rest-response.php | 10 ++++ .../rest-api/class-wp-rest-server.php | 14 +++++ ...-rest-application-passwords-controller.php | 2 + .../class-wp-rest-attachments-controller.php | 2 + .../class-wp-rest-autosaves-controller.php | 2 + ...ass-wp-rest-block-directory-controller.php | 2 + ...st-block-pattern-categories-controller.php | 2 + ...lass-wp-rest-block-patterns-controller.php | 4 ++ ...lass-wp-rest-block-renderer-controller.php | 6 ++ .../class-wp-rest-block-types-controller.php | 2 + .../class-wp-rest-blocks-controller.php | 2 + .../class-wp-rest-comments-controller.php | 8 +++ ...lass-wp-rest-entity-actions-controller.php | 2 + ...class-wp-rest-entity-fields-controller.php | 2 + ...ss-wp-rest-font-collections-controller.php | 2 + .../class-wp-rest-font-faces-controller.php | 2 + ...class-wp-rest-font-families-controller.php | 2 + ...class-wp-rest-global-styles-controller.php | 2 + ...est-global-styles-revisions-controller.php | 2 + ...ss-wp-rest-icon-collections-controller.php | 2 + .../class-wp-rest-icons-controller.php | 2 + .../class-wp-rest-menu-items-controller.php | 2 + ...lass-wp-rest-menu-locations-controller.php | 2 + .../class-wp-rest-menus-controller.php | 2 + ...wp-rest-navigation-fallback-controller.php | 2 + ...s-wp-rest-pattern-directory-controller.php | 2 + .../class-wp-rest-plugins-controller.php | 2 + ...class-wp-rest-post-statuses-controller.php | 2 + .../class-wp-rest-post-types-controller.php | 2 + .../class-wp-rest-posts-controller.php | 4 ++ .../class-wp-rest-revisions-controller.php | 4 ++ .../class-wp-rest-search-controller.php | 2 + .../class-wp-rest-settings-controller.php | 2 + .../class-wp-rest-sidebars-controller.php | 4 ++ .../class-wp-rest-site-health-controller.php | 2 + .../class-wp-rest-taxonomies-controller.php | 2 + ...-wp-rest-template-autosaves-controller.php | 2 + ...-wp-rest-template-revisions-controller.php | 2 + .../class-wp-rest-templates-controller.php | 2 + .../class-wp-rest-terms-controller.php | 2 + .../class-wp-rest-themes-controller.php | 2 + .../class-wp-rest-url-details-controller.php | 2 + .../class-wp-rest-users-controller.php | 2 + .../class-wp-rest-view-config-controller.php | 2 + .../class-wp-rest-widget-types-controller.php | 2 + .../class-wp-rest-widgets-controller.php | 4 ++ .../secrets/class-wp-secrets-key-manager.php | 6 ++ .../sitemaps/class-wp-sitemaps-registry.php | 2 + ...class-wp-style-engine-css-declarations.php | 4 ++ .../class-wp-style-engine-css-rule.php | 6 ++ .../class-wp-style-engine-css-rules-store.php | 10 ++++ .../class-wp-style-engine-processor.php | 6 ++ .../widgets/class-wp-widget-calendar.php | 2 + .../widgets/class-wp-widget-custom-html.php | 4 ++ .../widgets/class-wp-widget-media.php | 8 +++ .../widgets/class-wp-widget-text.php | 4 ++ tests/phpstan/GlobalDocBlockVisitor.php | 4 ++ tests/phpstan/HashNotationVisitor.php | 16 +++++ tests/phpstan/HookDocBlock.php | 2 + tests/phpstan/HookDocsVisitor.php | 6 ++ .../phpstan/baselines/property.notFound.neon | 2 +- 217 files changed, 1500 insertions(+), 5 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index cbaa19f3e8db1..915053d9d6e00 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -192,10 +192,11 @@ parameters: path: src/wp-includes/html-api/class-wp-html-processor.php - # The early return at the start of step() narrows $last_error to null, and PHPStan does not see that - # bookmark_token() sets it to ERROR_EXCEEDED_MAX_BOOKMARKS before throwing, whether it is called directly - # in step() or via insert_virtual_node() in a step_*() method. So it reports that the checks in both catch - # blocks of step() can never match, when in fact they do whenever bookmarks run out. + # bookmark_token() sets it to ERROR_EXCEEDED_MAX_BOOKMARKS before throwing. A catch block sees the scope + # from where the exception was thrown, which is before the call's side effects apply, so marking + # bookmark_token() as `@phpstan-impure` does not help. So PHPStan reports that the check in the catch + # block after the direct call in step() can never match, when in fact it does whenever bookmarks run out. message: '#^Strict comparison using \=\=\= between ''exceeded\-max…'' and null will always evaluate to false\.$#' identifier: identical.alwaysFalse - count: 2 + count: 1 path: src/wp-includes/html-api/class-wp-html-processor.php diff --git a/src/wp-admin/includes/class-automatic-upgrader-skin.php b/src/wp-admin/includes/class-automatic-upgrader-skin.php index 4fee6205fc463..b030a1097a7df 100644 --- a/src/wp-admin/includes/class-automatic-upgrader-skin.php +++ b/src/wp-admin/includes/class-automatic-upgrader-skin.php @@ -36,6 +36,8 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin { * for being writable. Default empty. * @param bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false. * @return bool True on success, false on failure. + * + * @phpstan-impure */ public function request_filesystem_credentials( $error = false, $context = '', $allow_relaxed_file_ownership = false ) { if ( $context ) { @@ -70,6 +72,8 @@ public function get_upgrade_messages() { * * @param string|array|WP_Error $feedback Message data. * @param mixed ...$args Optional text replacements. + * + * @phpstan-impure */ public function feedback( $feedback, ...$args ) { if ( is_wp_error( $feedback ) ) { diff --git a/src/wp-admin/includes/class-bulk-plugin-upgrader-skin.php b/src/wp-admin/includes/class-bulk-plugin-upgrader-skin.php index bb62928fa6c2e..c8664e10e5f27 100644 --- a/src/wp-admin/includes/class-bulk-plugin-upgrader-skin.php +++ b/src/wp-admin/includes/class-bulk-plugin-upgrader-skin.php @@ -32,6 +32,8 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin { * Sets up the strings used in the update process. * * @since 3.0.0 + * + * @phpstan-impure */ public function add_strings() { parent::add_strings(); diff --git a/src/wp-admin/includes/class-bulk-theme-upgrader-skin.php b/src/wp-admin/includes/class-bulk-theme-upgrader-skin.php index f2b9b95025d3c..bd00d93554a3b 100644 --- a/src/wp-admin/includes/class-bulk-theme-upgrader-skin.php +++ b/src/wp-admin/includes/class-bulk-theme-upgrader-skin.php @@ -33,6 +33,8 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin { * Sets up the strings used in the update process. * * @since 3.0.0 + * + * @phpstan-impure */ public function add_strings() { parent::add_strings(); diff --git a/src/wp-admin/includes/class-bulk-upgrader-skin.php b/src/wp-admin/includes/class-bulk-upgrader-skin.php index d81eba885ddcd..b229ab10daee4 100644 --- a/src/wp-admin/includes/class-bulk-upgrader-skin.php +++ b/src/wp-admin/includes/class-bulk-upgrader-skin.php @@ -56,6 +56,8 @@ public function __construct( $args = array() ) { * Sets up the strings used in the update process. * * @since 3.0.0 + * + * @phpstan-impure */ public function add_strings() { $this->upgrader->strings['skin_upgrade_start'] = __( 'The update process is starting. This process may take a while on some hosts, so please be patient.' ); @@ -124,6 +126,8 @@ public function footer() { * @since 5.9.0 Renamed `$error` to `$errors` for PHP 8 named parameter support. * * @param string|WP_Error $errors Errors. + * + * @phpstan-impure */ public function error( $errors ) { if ( is_string( $errors ) && isset( $this->upgrader->strings[ $errors ] ) ) { @@ -179,6 +183,8 @@ public function bulk_footer() { * @since 3.0.0 * * @param string $title + * + * @phpstan-impure */ public function before( $title = '' ) { $this->in_loop = true; @@ -265,6 +271,8 @@ public function after( $title = '' ) { * Resets the properties used in the update process. * * @since 3.0.0 + * + * @phpstan-impure */ public function reset() { $this->in_loop = false; diff --git a/src/wp-admin/includes/class-core-upgrader.php b/src/wp-admin/includes/class-core-upgrader.php index 8a712a4afbc76..ee36f7a74bf51 100644 --- a/src/wp-admin/includes/class-core-upgrader.php +++ b/src/wp-admin/includes/class-core-upgrader.php @@ -28,6 +28,8 @@ class Core_Upgrader extends WP_Upgrader { * Initializes the upgrade strings. * * @since 2.8.0 + * + * @phpstan-impure */ public function upgrade_strings() { $this->strings['up_to_date'] = __( 'WordPress is at the latest version.' ); diff --git a/src/wp-admin/includes/class-custom-background.php b/src/wp-admin/includes/class-custom-background.php index 1e3a39da9440d..48cc9f77c9f92 100644 --- a/src/wp-admin/includes/class-custom-background.php +++ b/src/wp-admin/includes/class-custom-background.php @@ -127,6 +127,8 @@ public function admin_load() { * Executes custom background modification. * * @since 3.0.0 + * + * @phpstan-impure */ public function take_action() { if ( empty( $_POST ) ) { @@ -515,6 +517,8 @@ public function admin_page() { * Handles an Image upload for the background image. * * @since 3.0.0 + * + * @phpstan-impure */ public function handle_upload() { if ( empty( $_FILES ) ) { diff --git a/src/wp-admin/includes/class-custom-image-header.php b/src/wp-admin/includes/class-custom-image-header.php index 147f44cc1057b..f855433dacadb 100644 --- a/src/wp-admin/includes/class-custom-image-header.php +++ b/src/wp-admin/includes/class-custom-image-header.php @@ -216,6 +216,8 @@ public function css_includes() { * Executes custom header modification. * * @since 2.6.0 + * + * @phpstan-impure */ public function take_action() { if ( ! current_user_can( 'edit_theme_options' ) ) { @@ -277,6 +279,8 @@ public function take_action() { * @since 3.0.0 * * @global array $_wp_default_headers Default headers registered for themes. + * + * @phpstan-impure */ public function process_default_headers() { global $_wp_default_headers; @@ -1114,6 +1118,8 @@ public function step_3() { * Displays last step of custom header image page. * * @since 2.1.0 + * + * @phpstan-impure */ public function finished() { $this->updated = true; diff --git a/src/wp-admin/includes/class-language-pack-upgrader.php b/src/wp-admin/includes/class-language-pack-upgrader.php index 59a144ed4adc6..2d71e3f8db0e7 100644 --- a/src/wp-admin/includes/class-language-pack-upgrader.php +++ b/src/wp-admin/includes/class-language-pack-upgrader.php @@ -115,6 +115,8 @@ public static function async_upgrade( $upgrader = false ) { * Initializes the upgrade strings. * * @since 3.7.0 + * + * @phpstan-impure */ public function upgrade_strings() { $this->strings['starting_upgrade'] = __( 'Some of your translations need updating. Sit tight for a few more seconds while they are updated as well.' ); @@ -173,6 +175,8 @@ public function upgrade( $update = false, $args = array() ) { * } * @return array|bool|WP_Error Will return an array of results, or true if there are no updates, * false or WP_Error for initial errors. + * + * @phpstan-impure */ public function bulk_upgrade( $language_updates = array(), $args = array() ) { global $wp_filesystem; diff --git a/src/wp-admin/includes/class-plugin-installer-skin.php b/src/wp-admin/includes/class-plugin-installer-skin.php index ecfb1f7bd59b5..2173346326fb2 100644 --- a/src/wp-admin/includes/class-plugin-installer-skin.php +++ b/src/wp-admin/includes/class-plugin-installer-skin.php @@ -63,6 +63,8 @@ public function __construct( $args = array() ) { * Performs an action before installing a plugin. * * @since 2.8.0 + * + * @phpstan-impure */ public function before() { if ( ! empty( $this->api ) ) { @@ -196,6 +198,8 @@ public function after() { * @since 5.5.0 * * @return bool Whether the plugin can be overwritten and HTML was outputted. + * + * @phpstan-impure */ private function do_overwrite() { if ( 'upload' !== $this->type || ! is_wp_error( $this->result ) || 'folder_exists' !== $this->result->get_error_code() ) { diff --git a/src/wp-admin/includes/class-plugin-upgrader-skin.php b/src/wp-admin/includes/class-plugin-upgrader-skin.php index 1505e3d3a4977..962d6530af743 100644 --- a/src/wp-admin/includes/class-plugin-upgrader-skin.php +++ b/src/wp-admin/includes/class-plugin-upgrader-skin.php @@ -82,6 +82,8 @@ public function __construct( $args = array() ) { * Performs an action following a single plugin update. * * @since 2.8.0 + * + * @phpstan-impure */ public function after() { $this->plugin = $this->upgrader->plugin_info(); diff --git a/src/wp-admin/includes/class-plugin-upgrader.php b/src/wp-admin/includes/class-plugin-upgrader.php index 428cc5941dd90..b109c56672555 100644 --- a/src/wp-admin/includes/class-plugin-upgrader.php +++ b/src/wp-admin/includes/class-plugin-upgrader.php @@ -53,6 +53,8 @@ class Plugin_Upgrader extends WP_Upgrader { * Initializes the upgrade strings. * * @since 2.8.0 + * + * @phpstan-impure */ public function upgrade_strings() { $this->strings['up_to_date'] = __( 'The plugin is at the latest version.' ); @@ -71,6 +73,8 @@ public function upgrade_strings() { * Initializes the installation strings. * * @since 2.8.0 + * + * @phpstan-impure */ public function install_strings() { $this->strings['no_package'] = __( 'Installation package not available.' ); @@ -286,6 +290,8 @@ public function upgrade( $plugin, $args = array() ) { * @type bool $clear_update_cache Whether to clear the plugin updates cache if successful. Default true. * } * @return array|false An array of results indexed by plugin file, or false if unable to connect to the filesystem. + * + * @phpstan-impure */ public function bulk_upgrade( $plugins, $args = array() ) { $wp_version = wp_get_wp_version(); @@ -463,6 +469,8 @@ public function bulk_upgrade( $plugins, $args = array() ) { * * @param string $source The path to the downloaded package source. * @return string|WP_Error The source as passed, or a WP_Error object on failure. + * + * @phpstan-impure */ public function check_package( $source ) { global $wp_filesystem; diff --git a/src/wp-admin/includes/class-theme-installer-skin.php b/src/wp-admin/includes/class-theme-installer-skin.php index bd320ccb401c2..d90ce880d81e7 100644 --- a/src/wp-admin/includes/class-theme-installer-skin.php +++ b/src/wp-admin/includes/class-theme-installer-skin.php @@ -63,6 +63,8 @@ public function __construct( $args = array() ) { * Performs an action before installing a theme. * * @since 2.8.0 + * + * @phpstan-impure */ public function before() { if ( ! empty( $this->api ) ) { @@ -217,6 +219,8 @@ public function after() { * @since 5.5.0 * * @return bool Whether the theme can be overwritten and HTML was outputted. + * + * @phpstan-impure */ private function do_overwrite() { if ( 'upload' !== $this->type || ! is_wp_error( $this->result ) || 'folder_exists' !== $this->result->get_error_code() ) { diff --git a/src/wp-admin/includes/class-theme-upgrader.php b/src/wp-admin/includes/class-theme-upgrader.php index 7e571e17f5c70..63a2be590b098 100644 --- a/src/wp-admin/includes/class-theme-upgrader.php +++ b/src/wp-admin/includes/class-theme-upgrader.php @@ -52,6 +52,8 @@ class Theme_Upgrader extends WP_Upgrader { * Initializes the upgrade strings. * * @since 2.8.0 + * + * @phpstan-impure */ public function upgrade_strings() { $this->strings['up_to_date'] = __( 'The theme is at the latest version.' ); @@ -69,6 +71,8 @@ public function upgrade_strings() { * Initializes the installation strings. * * @since 2.8.0 + * + * @phpstan-impure */ public function install_strings() { $this->strings['no_package'] = __( 'Installation package not available.' ); @@ -123,6 +127,8 @@ public function install_strings() { * @return bool * * @phpstan-param non-empty-array $child_result + * + * @phpstan-impure */ public function check_parent_theme_filter( $install_result, $hook_extra, $child_result ) { // Check to see if we need to install a parent theme. @@ -386,6 +392,8 @@ public function upgrade( $theme, $args = array() ) { * Default true. * } * @return array[]|false An array of results, or false if unable to connect to the filesystem. + * + * @phpstan-impure */ public function bulk_upgrade( $themes, $args = array() ) { $wp_version = wp_get_wp_version(); @@ -565,6 +573,8 @@ public function bulk_upgrade( $themes, $args = array() ) { * * @param string $source The path to the downloaded package source. * @return string|WP_Error The source as passed, or a WP_Error object on failure. + * + * @phpstan-impure */ public function check_package( $source ) { global $wp_filesystem; diff --git a/src/wp-admin/includes/class-walker-nav-menu-checklist.php b/src/wp-admin/includes/class-walker-nav-menu-checklist.php index f720a4768e09a..417cc89fd111c 100644 --- a/src/wp-admin/includes/class-walker-nav-menu-checklist.php +++ b/src/wp-admin/includes/class-walker-nav-menu-checklist.php @@ -72,6 +72,8 @@ public function end_lvl( &$output, $depth = 0, $args = null ) { * @param int $depth Depth of menu item. Used for padding. * @param stdClass $args Not used. * @param int $current_object_id Optional. ID of the current menu item. Default 0. + * + * @phpstan-impure */ public function start_el( &$output, $data_object, $depth = 0, $args = null, $current_object_id = 0 ) { global $_nav_menu_placeholder, $nav_menu_selected_id; diff --git a/src/wp-admin/includes/class-walker-nav-menu-edit.php b/src/wp-admin/includes/class-walker-nav-menu-edit.php index a287a7c4b8cdd..d2511a7131ea9 100644 --- a/src/wp-admin/includes/class-walker-nav-menu-edit.php +++ b/src/wp-admin/includes/class-walker-nav-menu-edit.php @@ -56,6 +56,8 @@ public function end_lvl( &$output, $depth = 0, $args = null ) {} * @param int $depth Depth of menu item. Used for padding. * @param stdClass $args Not used. * @param int $current_object_id Optional. ID of the current menu item. Default 0. + * + * @phpstan-impure */ public function start_el( &$output, $data_object, $depth = 0, $args = null, $current_object_id = 0 ) { global $_wp_nav_menu_max_depth; diff --git a/src/wp-admin/includes/class-wp-application-passwords-list-table.php b/src/wp-admin/includes/class-wp-application-passwords-list-table.php index a5e143e30eccb..378038464664c 100644 --- a/src/wp-admin/includes/class-wp-application-passwords-list-table.php +++ b/src/wp-admin/includes/class-wp-application-passwords-list-table.php @@ -39,6 +39,8 @@ public function get_columns() { * @since 5.6.0 * * @global int $user_id User ID. + * + * @phpstan-impure */ public function prepare_items() { global $user_id; diff --git a/src/wp-admin/includes/class-wp-automatic-updater.php b/src/wp-admin/includes/class-wp-automatic-updater.php index d60507cd3cfbf..05c33ce0f38b8 100644 --- a/src/wp-admin/includes/class-wp-automatic-updater.php +++ b/src/wp-admin/includes/class-wp-automatic-updater.php @@ -462,6 +462,8 @@ protected function send_core_update_notification_email( $item ) { * $type is 'translation' ? array|bool|WP_Error|null : bool|WP_Error|null * ) * ) + * + * @phpstan-impure */ public function update( $type, $item ) { $skin = new Automatic_Upgrader_Skin(); @@ -1905,6 +1907,8 @@ protected function send_debug_email() { * @global int $upgrading The Unix timestamp marking when upgrading WordPress began. * * @return bool Whether a fatal error was detected. + * + * @phpstan-impure */ protected function has_fatal_error() { global $upgrading; diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 1dff5d26755ce..dd14f38391b80 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -88,6 +88,8 @@ public function ajax_user_can() { * @global string $comment_status Comment status filter. * @global string $comment_type Comment type filter. * @global string $search Search term. + * + * @phpstan-impure */ public function prepare_items() { global $mode, $post_id, $comment_status, $comment_type, $search; @@ -598,6 +600,8 @@ protected function get_default_primary_column_name() { * Overrides the parent display() method to render extra comments. * * @since 3.1.0 + * + * @phpstan-impure */ public function display() { wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' ); @@ -668,6 +672,8 @@ public function display() { * @global WP_Comment $comment Global comment object. * * @param WP_Comment $item The comment object. + * + * @phpstan-impure */ public function single_row( $item ) { global $post, $comment; @@ -1105,6 +1111,8 @@ public function column_date( $comment ) { * Outputs the response column. * * @param WP_Comment $comment The comment object. + * + * @phpstan-impure */ public function column_response( $comment ) { $post = get_post(); diff --git a/src/wp-admin/includes/class-wp-filesystem-base.php b/src/wp-admin/includes/class-wp-filesystem-base.php index 75ab85cd63d34..515cd6092bfee 100644 --- a/src/wp-admin/includes/class-wp-filesystem-base.php +++ b/src/wp-admin/includes/class-wp-filesystem-base.php @@ -153,6 +153,8 @@ public function wp_lang_dir() { * @param string $base Optional. The folder to start searching from. Default '.'. * @param bool $verbose Optional. True to display debug information. Default false. * @return string|false The location of the remote path, or false on failure. + * + * @phpstan-impure */ public function find_base_dir( $base = '.', $verbose = false ) { _deprecated_function( __FUNCTION__, '2.7.0', 'WP_Filesystem_Base::abspath() or WP_Filesystem_Base::wp_*_dir()' ); @@ -174,6 +176,8 @@ public function find_base_dir( $base = '.', $verbose = false ) { * @param string $base Optional. The folder to start searching from. Default '.'. * @param bool $verbose Optional. True to display debug information. Default false. * @return string|false The location of the remote path, or false on failure. + * + * @phpstan-impure */ public function get_base_dir( $base = '.', $verbose = false ) { _deprecated_function( __FUNCTION__, '2.7.0', 'WP_Filesystem_Base::abspath() or WP_Filesystem_Base::wp_*_dir()' ); @@ -191,6 +195,8 @@ public function get_base_dir( $base = '.', $verbose = false ) { * * @param string $folder the folder to locate. * @return string|false The location of the remote path, false on failure. + * + * @phpstan-impure */ public function find_folder( $folder ) { if ( isset( $this->cache[ $folder ] ) ) { diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpext.php b/src/wp-admin/includes/class-wp-filesystem-ftpext.php index 844c4e9c5b95b..24187afc0c7b9 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/src/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -118,6 +118,8 @@ public function __construct( $opt = null ) { * @since 2.5.0 * * @return bool True on success, false on failure. + * + * @phpstan-impure */ public function connect() { /* diff --git a/src/wp-admin/includes/class-wp-filesystem-ssh2.php b/src/wp-admin/includes/class-wp-filesystem-ssh2.php index f86b06ce0c4ce..5a2890a7946d2 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ssh2.php +++ b/src/wp-admin/includes/class-wp-filesystem-ssh2.php @@ -157,6 +157,8 @@ public function __construct( $opt = null ) { * @since 2.7.0 * * @return bool True on success, false on failure. + * + * @phpstan-impure */ public function connect() { /* diff --git a/src/wp-admin/includes/class-wp-importer.php b/src/wp-admin/includes/class-wp-importer.php index a1b76e388f04e..31c52bdead2a5 100644 --- a/src/wp-admin/includes/class-wp-importer.php +++ b/src/wp-admin/includes/class-wp-importer.php @@ -282,6 +282,8 @@ public function min_whitespace( $text ) { * * @global wpdb $wpdb WordPress database abstraction object. * @global int[] $wp_actions Stores the number of times each action was triggered. + * + * @phpstan-impure */ public function stop_the_insanity() { global $wpdb, $wp_actions; diff --git a/src/wp-admin/includes/class-wp-links-list-table.php b/src/wp-admin/includes/class-wp-links-list-table.php index 6da144bf502ad..285eb9697c0a5 100644 --- a/src/wp-admin/includes/class-wp-links-list-table.php +++ b/src/wp-admin/includes/class-wp-links-list-table.php @@ -46,6 +46,8 @@ public function ajax_user_can() { * @global string $s Search string. * @global string $orderby The field to order the links by. * @global string $order The direction to order the links. + * + * @phpstan-impure */ public function prepare_items() { global $cat_id, $s, $orderby, $order; diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index 08b31d5eb7ba0..944dc65809ba1 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -233,6 +233,8 @@ public function __get( $name ) { * * @param string $name Property to check if set. * @param mixed $value Property value. + * + * @phpstan-impure */ public function __set( $name, $value ) { if ( in_array( $name, $this->compat_fields, true ) ) { @@ -337,6 +339,8 @@ public function prepare_items() { * @since 3.1.0 * * @param array|string $args Array or string of arguments with information about the pagination. + * + * @phpstan-impure */ protected function set_pagination_args( $args ) { $args = wp_parse_args( @@ -605,6 +609,8 @@ protected function get_bulk_actions() { * * @param string $which The location of the bulk actions: Either 'top' or 'bottom'. * This is designated as optional for backward compatibility. + * + * @phpstan-impure */ protected function bulk_actions( $which = '' ) { if ( is_null( $this->_actions ) ) { @@ -1054,6 +1060,8 @@ protected function get_items_per_page( $option, $default_value = 20 ) { * @param string $which The location of the pagination: Either 'top' or 'bottom'. * * @phpstan-param 'top'|'bottom' $which + * + * @phpstan-impure */ protected function pagination( $which ) { if ( empty( $this->_pagination_args['total_items'] ) ) { @@ -1336,6 +1344,8 @@ protected function get_primary_column_name() { * @since 3.1.0 * * @return array Column information. + * + * @phpstan-impure */ protected function get_column_info() { // $_column_headers is already set / cached. diff --git a/src/wp-admin/includes/class-wp-media-list-table.php b/src/wp-admin/includes/class-wp-media-list-table.php index feac4753d3e92..910f7b22bdae6 100644 --- a/src/wp-admin/includes/class-wp-media-list-table.php +++ b/src/wp-admin/includes/class-wp-media-list-table.php @@ -84,6 +84,8 @@ public function ajax_user_can() { * @global WP_Query $wp_query WordPress Query object. * @global array $post_mime_types An array of post mime types. * @global array $avail_post_mime_types An array of available post mime types. + * + * @phpstan-impure */ public function prepare_items() { global $mode, $wp_query, $post_mime_types, $avail_post_mime_types; @@ -750,6 +752,8 @@ public function column_default( $item, $column_name ) { * * @global WP_Post $post Global post object. * @global WP_Query $wp_query WordPress Query object. + * + * @phpstan-impure */ public function display_rows() { global $post, $wp_query; diff --git a/src/wp-admin/includes/class-wp-ms-sites-list-table.php b/src/wp-admin/includes/class-wp-ms-sites-list-table.php index 2738856f8889b..0805ecd64af11 100644 --- a/src/wp-admin/includes/class-wp-ms-sites-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-sites-list-table.php @@ -67,6 +67,8 @@ public function ajax_user_can() { * * @global string $s Search string. * @global wpdb $wpdb WordPress database abstraction object. + * + * @phpstan-impure */ public function prepare_items() { global $s, $wpdb; diff --git a/src/wp-admin/includes/class-wp-ms-themes-list-table.php b/src/wp-admin/includes/class-wp-ms-themes-list-table.php index be0039b5ea965..2ffd106a6ebc0 100644 --- a/src/wp-admin/includes/class-wp-ms-themes-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-themes-list-table.php @@ -114,6 +114,8 @@ public function ajax_user_can() { * @global string $orderby The column to order the themes list by. * @global string $order The order of the themes list (ASC or DESC). * @global string $s The search string. + * + * @phpstan-impure */ public function prepare_items() { global $status, $totals, $page, $orderby, $order, $s; @@ -815,6 +817,8 @@ public function column_description( $theme ) { * @global int $page The current page number. * * @param WP_Theme $theme The current WP_Theme object. + * + * @phpstan-impure */ public function column_autoupdates( $theme ) { global $status, $page; diff --git a/src/wp-admin/includes/class-wp-ms-users-list-table.php b/src/wp-admin/includes/class-wp-ms-users-list-table.php index eaf6a8df47bfb..225e4f0961c8a 100644 --- a/src/wp-admin/includes/class-wp-ms-users-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-users-list-table.php @@ -33,6 +33,8 @@ public function ajax_user_can() { * * @global string $usersearch User search query. * @global string $role The user role to filter by. Only 'super' (super admins) is supported. + * + * @phpstan-impure */ public function prepare_items() { global $usersearch, $role; diff --git a/src/wp-admin/includes/class-wp-plugin-install-list-table.php b/src/wp-admin/includes/class-wp-plugin-install-list-table.php index 3f6d2a104d099..d39b97f4884e4 100644 --- a/src/wp-admin/includes/class-wp-plugin-install-list-table.php +++ b/src/wp-admin/includes/class-wp-plugin-install-list-table.php @@ -129,6 +129,8 @@ protected function get_installed_plugin_slugs() { * @global int $paged The current page number. * @global string $type The type of search being performed. * @global string $term The search term. + * + * @phpstan-impure */ public function prepare_items() { require_once ABSPATH . 'wp-admin/includes/plugin-install.php'; diff --git a/src/wp-admin/includes/class-wp-plugins-list-table.php b/src/wp-admin/includes/class-wp-plugins-list-table.php index 7778f21b4688b..8e8c82afa31de 100644 --- a/src/wp-admin/includes/class-wp-plugins-list-table.php +++ b/src/wp-admin/includes/class-wp-plugins-list-table.php @@ -109,6 +109,8 @@ public function ajax_user_can() { * @global string $orderby Column name to sort by. * @global string $order Sort direction, 'ASC' or 'DESC'. * @global string $s URL-encoded search term. + * + * @phpstan-impure */ public function prepare_items() { global $status, $plugins, $totals, $page, $orderby, $order, $s; @@ -814,6 +816,8 @@ public function display_rows() { * * @param array $item The current item. An array containing the plugin file path and plugin data. * @phpstan-param array{string, array} $item + * + * @phpstan-impure */ public function single_row( $item ) { global $status, $page, $s, $totals; diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index d461aacd312ae..5e0a18a697e18 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -133,6 +133,8 @@ public function __construct( $args = array() ) { * @since 4.2.0 * * @param bool $display Whether the table layout should be hierarchical. + * + * @phpstan-impure */ public function set_hierarchical_display( $display ) { $this->hierarchical_display = $display; @@ -150,6 +152,8 @@ public function ajax_user_can() { * @global array $avail_post_stati * @global WP_Query $wp_query WordPress Query object. * @global int $per_page + * + * @phpstan-impure */ public function prepare_items() { global $mode, $avail_post_stati, $wp_query, $per_page; @@ -810,6 +814,8 @@ public function display_rows( $posts = array(), $level = 0 ) { /** * @param array $posts * @param int $level + * + * @phpstan-impure */ private function _display_rows( $posts, $level = 0 ) { $post_type = $this->screen->post_type; @@ -837,6 +843,8 @@ private function _display_rows( $posts, $level = 0 ) { * @param array $pages * @param int $pagenum * @param int $per_page + * + * @phpstan-impure */ private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { global $wpdb; @@ -1139,6 +1147,8 @@ protected function get_primary_column_aria_label( $item ) { * @global string $mode List table view mode. * * @param WP_Post $post The current WP_Post object. + * + * @phpstan-impure */ public function column_title( $post ) { global $mode; @@ -1505,6 +1515,8 @@ public function column_default( $item, $column_name ) { * * @param int|WP_Post $post * @param int $level + * + * @phpstan-impure */ public function single_row( $post, $level = 0 ) { $global_post = get_post(); diff --git a/src/wp-admin/includes/class-wp-privacy-policy-content.php b/src/wp-admin/includes/class-wp-privacy-policy-content.php index 141f073cd260c..221452191001e 100644 --- a/src/wp-admin/includes/class-wp-privacy-policy-content.php +++ b/src/wp-admin/includes/class-wp-privacy-policy-content.php @@ -32,6 +32,8 @@ private function __construct() {} * * @param string $plugin_name The name of the plugin or theme that is suggesting content for the site's privacy policy. * @param string $policy_text The suggested content for inclusion in the policy. + * + * @phpstan-impure */ public static function add( $plugin_name, $policy_text ) { if ( empty( $plugin_name ) || empty( $policy_text ) ) { @@ -310,6 +312,8 @@ public static function get_suggested_policy_text() { * @global WP_Post $post Global post object. * * @param WP_Post|null $post The currently edited post. Default null. + * + * @phpstan-impure */ public static function notice( $post = null ) { if ( is_null( $post ) ) { diff --git a/src/wp-admin/includes/class-wp-privacy-requests-table.php b/src/wp-admin/includes/class-wp-privacy-requests-table.php index 106fc298dd619..c5b62835c6f3c 100644 --- a/src/wp-admin/includes/class-wp-privacy-requests-table.php +++ b/src/wp-admin/includes/class-wp-privacy-requests-table.php @@ -363,6 +363,8 @@ public function process_bulk_action() { * * @since 4.9.6 * @since 5.1.0 Added support for column sorting. + * + * @phpstan-impure */ public function prepare_items() { $this->items = array(); diff --git a/src/wp-admin/includes/class-wp-screen.php b/src/wp-admin/includes/class-wp-screen.php index 0008130355efb..851d613ebd513 100644 --- a/src/wp-admin/includes/class-wp-screen.php +++ b/src/wp-admin/includes/class-wp-screen.php @@ -208,6 +208,8 @@ final class WP_Screen { * @param string|WP_Screen|null $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen. * Defaults to the current $hook_suffix global. * @return WP_Screen Screen object. + * + * @phpstan-impure */ public static function get( $hook_name = '' ) { if ( $hook_name instanceof WP_Screen ) { @@ -408,6 +410,8 @@ public static function get( $hook_name = '' ) { * @global WP_Screen $current_screen WordPress current screen object. * @global string $typenow The post type of the current screen. * @global string $taxnow The taxonomy of the current screen. + * + * @phpstan-impure */ public function set_current_screen() { global $current_screen, $taxnow, $typenow; @@ -457,6 +461,8 @@ public function in_admin( $admin = null ) { * * @param bool $set Optional. Sets whether the block editor is loading on the current screen or not. * @return bool True if the block editor is being loaded, false otherwise. + * + * @phpstan-impure */ public function is_block_editor( $set = null ) { if ( null !== $set ) { @@ -473,6 +479,8 @@ public function is_block_editor( $set = null ) { * * @param WP_Screen $screen A screen object. * @param string $help Help text. + * + * @phpstan-impure */ public static function add_old_compat_help( $screen, $help ) { self::$_old_compat_help[ $screen->id ] = $help; @@ -486,6 +494,8 @@ public static function add_old_compat_help( $screen, $help ) { * @since 3.3.0 * * @param string $parent_file The parent file of the screen. Typically the $parent_file global. + * + * @phpstan-impure */ public function set_parentage( $parent_file ) { $this->parent_file = $parent_file; @@ -503,6 +513,8 @@ public function set_parentage( $parent_file ) { * * @param string $option Option ID. * @param mixed $args Option-dependent arguments. + * + * @phpstan-impure */ public function add_option( $option, $args = array() ) { $this->_options[ $option ] = $args; @@ -514,6 +526,8 @@ public function add_option( $option, $args = array() ) { * @since 3.8.0 * * @param string $option Option ID. + * + * @phpstan-impure */ public function remove_option( $option ) { unset( $this->_options[ $option ] ); @@ -523,6 +537,8 @@ public function remove_option( $option ) { * Removes all options from the screen. * * @since 3.8.0 + * + * @phpstan-impure */ public function remove_options() { $this->_options = array(); @@ -629,6 +645,8 @@ public function get_help_tab( $id ) { * @type callable $callback Optional. A callback to generate the tab content. Default false. * @type int $priority Optional. The priority of the tab, used for ordering. Default 10. * } + * + * @phpstan-impure */ public function add_help_tab( $args ) { $defaults = array( @@ -657,6 +675,8 @@ public function add_help_tab( $args ) { * @since 3.3.0 * * @param string $id The help tab ID. + * + * @phpstan-impure */ public function remove_help_tab( $id ) { unset( $this->_help_tabs[ $id ] ); @@ -666,6 +686,8 @@ public function remove_help_tab( $id ) { * Removes all help tabs from the contextual help for the screen. * * @since 3.3.0 + * + * @phpstan-impure */ public function remove_help_tabs() { $this->_help_tabs = array(); @@ -691,6 +713,8 @@ public function get_help_sidebar() { * @since 3.3.0 * * @param string $content Sidebar content in plain text or HTML. + * + * @phpstan-impure */ public function set_help_sidebar( $content ) { $this->_help_sidebar = $content; @@ -756,6 +780,8 @@ public function get_screen_reader_text( $key ) { * @type string $heading_list Screen reader text for the items list heading. * Default 'Items list'. * } + * + * @phpstan-impure */ public function set_screen_reader_content( $content = array() ) { $defaults = array( @@ -772,6 +798,8 @@ public function set_screen_reader_content( $content = array() ) { * Removes all the accessible hidden headings and text for the screen. * * @since 4.4.0 + * + * @phpstan-impure */ public function remove_screen_reader_content() { $this->_screen_reader_content = array(); @@ -785,6 +813,8 @@ public function remove_screen_reader_content() { * @since 3.3.0 * * @global string $screen_layout_columns + * + * @phpstan-impure */ public function render_screen_meta() { @@ -992,6 +1022,8 @@ public function render_screen_meta() { * @global array $wp_meta_boxes Global meta box state. * * @return bool Whether to show the Screen Options tab for the current screen. + * + * @phpstan-impure */ public function show_screen_options() { global $wp_meta_boxes; @@ -1349,6 +1381,8 @@ public function render_per_page_options() { * @since 4.4.0 * * @global string $mode List table view mode. + * + * @phpstan-impure */ public function render_view_mode() { global $mode; diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 6f6262f2c2811..0842221fcdcee 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -75,6 +75,8 @@ public function show_site_health_tab( $tab ) { * @since 5.4.0 * * @return WP_Site_Health|null + * + * @phpstan-impure */ public static function get_instance() { self::$instance ??= new WP_Site_Health(); @@ -211,6 +213,8 @@ private function perform_test( $callback ) { * @since 5.2.0 * * @global wpdb $wpdb WordPress database abstraction object. + * + * @phpstan-impure */ private function prepare_sql_data() { global $wpdb; @@ -3495,6 +3499,8 @@ public function admin_body_class( $body_class ) { * Initiates the WP_Cron schedule test cases. * * @since 5.2.0 + * + * @phpstan-impure */ private function wp_schedule_test_init() { $this->schedules = wp_get_schedules(); @@ -3505,6 +3511,8 @@ private function wp_schedule_test_init() { * Populates the list of cron events and store them to a class-wide variable. * * @since 5.2.0 + * + * @phpstan-impure */ private function get_cron_tasks() { $cron_tasks = _get_cron_array(); @@ -3544,6 +3552,8 @@ private function get_cron_tasks() { * @since 5.2.0 * * @return bool|WP_Error True if a cron was missed, false if not. WP_Error if the cron is set to that. + * + * @phpstan-impure */ public function has_missed_cron() { if ( is_wp_error( $this->crons ) ) { @@ -3570,6 +3580,8 @@ public function has_missed_cron() { * @since 5.3.0 * * @return bool|WP_Error True if a cron is late, false if not. WP_Error if the cron is set to that. + * + * @phpstan-impure */ public function has_late_cron() { if ( is_wp_error( $this->crons ) ) { diff --git a/src/wp-admin/includes/class-wp-site-icon.php b/src/wp-admin/includes/class-wp-site-icon.php index 82a94570bc953..6e3f480bf9f7d 100644 --- a/src/wp-admin/includes/class-wp-site-icon.php +++ b/src/wp-admin/includes/class-wp-site-icon.php @@ -144,6 +144,8 @@ public function insert_attachment( $attachment, $file ) { * * @param array[] $sizes Array of arrays containing information for additional sizes. * @return array[] Array of arrays containing additional image sizes. + * + * @phpstan-impure */ public function additional_sizes( $sizes = array() ) { $only_crop_sizes = array(); @@ -188,6 +190,8 @@ public function additional_sizes( $sizes = array() ) { * * @param string[] $sizes Array of image size names. * @return string[] Array of image size names. + * + * @phpstan-impure */ public function intermediate_image_sizes( $sizes = array() ) { /** This filter is documented in wp-admin/includes/class-wp-site-icon.php */ diff --git a/src/wp-admin/includes/class-wp-terms-list-table.php b/src/wp-admin/includes/class-wp-terms-list-table.php index 9481f0967a744..26acc420bac23 100644 --- a/src/wp-admin/includes/class-wp-terms-list-table.php +++ b/src/wp-admin/includes/class-wp-terms-list-table.php @@ -73,6 +73,8 @@ public function ajax_user_can() { } /** + * + * @phpstan-impure */ public function prepare_items() { $taxonomy = $this->screen->taxonomy; @@ -334,6 +336,8 @@ private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$coun * * @param WP_Term $tag Term object. * @param int $level + * + * @phpstan-impure */ public function single_row( $tag, $level = 0 ) { global $taxonomy; diff --git a/src/wp-admin/includes/class-wp-theme-install-list-table.php b/src/wp-admin/includes/class-wp-theme-install-list-table.php index 6e7b9d9279015..b22c15524233b 100644 --- a/src/wp-admin/includes/class-wp-theme-install-list-table.php +++ b/src/wp-admin/includes/class-wp-theme-install-list-table.php @@ -31,6 +31,8 @@ public function ajax_user_can() { * @global int $paged * @global string $type * @global array $theme_field_defaults + * + * @phpstan-impure */ public function prepare_items() { require ABSPATH . 'wp-admin/includes/theme-install.php'; diff --git a/src/wp-admin/includes/class-wp-themes-list-table.php b/src/wp-admin/includes/class-wp-themes-list-table.php index 3a8f11aba2779..5ea8930814850 100644 --- a/src/wp-admin/includes/class-wp-themes-list-table.php +++ b/src/wp-admin/includes/class-wp-themes-list-table.php @@ -46,6 +46,8 @@ public function ajax_user_can() { } /** + * + * @phpstan-impure */ public function prepare_items() { $themes = wp_get_themes( array( 'allowed' => true ) ); diff --git a/src/wp-admin/includes/class-wp-upgrader-skin.php b/src/wp-admin/includes/class-wp-upgrader-skin.php index 89fde5fc44e1e..667152596980d 100644 --- a/src/wp-admin/includes/class-wp-upgrader-skin.php +++ b/src/wp-admin/includes/class-wp-upgrader-skin.php @@ -82,6 +82,8 @@ public function __construct( $args = array() ) { * @since 2.8.0 * * @param WP_Upgrader $upgrader + * + * @phpstan-impure */ public function set_upgrader( &$upgrader ) { if ( is_object( $upgrader ) ) { @@ -104,6 +106,8 @@ public function add_strings() { * @since 2.8.0 * * @param string|bool|WP_Error $result The result of an upgrade. + * + * @phpstan-impure */ public function set_result( $result ) { $this->result = $result; @@ -143,6 +147,8 @@ public function request_filesystem_credentials( $error = false, $context = '', $ * Displays the header before the update process. * * @since 2.8.0 + * + * @phpstan-impure */ public function header() { if ( $this->done_header ) { @@ -157,6 +163,8 @@ public function header() { * Displays the footer following the update process. * * @since 2.8.0 + * + * @phpstan-impure */ public function footer() { if ( $this->done_footer ) { diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php index 3055c6641ca5d..45da07d3f881c 100644 --- a/src/wp-admin/includes/class-wp-upgrader.php +++ b/src/wp-admin/includes/class-wp-upgrader.php @@ -183,6 +183,8 @@ protected function schedule_temp_backup_cleanup() { * Adds the generic strings to WP_Upgrader::$strings. * * @since 2.8.0 + * + * @phpstan-impure */ public function generic_strings() { $this->strings['bad_request'] = __( 'Invalid data provided.' ); @@ -537,6 +539,8 @@ public function clear_destination( $remote_destination ) { * } * * @return array|WP_Error The result (also stored in `WP_Upgrader::$result`), or a WP_Error on failure. + * + * @phpstan-impure */ public function install_package( $args = array() ) { global $wp_filesystem, $wp_theme_directories; @@ -801,6 +805,8 @@ public function install_package( $args = array() ) { * } * @return array|false|WP_Error The result from self::install_package() on success, otherwise a WP_Error, * or false if unable to connect to the filesystem. + * + * @phpstan-impure */ public function run( $options ) { diff --git a/src/wp-admin/includes/class-wp-users-list-table.php b/src/wp-admin/includes/class-wp-users-list-table.php index 46eac2064660e..d31f19e192b4a 100644 --- a/src/wp-admin/includes/class-wp-users-list-table.php +++ b/src/wp-admin/includes/class-wp-users-list-table.php @@ -79,6 +79,8 @@ public function ajax_user_can() { * * @global string $role * @global string $usersearch + * + * @phpstan-impure */ public function prepare_items() { global $role, $usersearch; diff --git a/src/wp-content/themes/twentyfourteen/inc/featured-content.php b/src/wp-content/themes/twentyfourteen/inc/featured-content.php index 3193aa8b93549..93c3794937559 100644 --- a/src/wp-content/themes/twentyfourteen/inc/featured-content.php +++ b/src/wp-content/themes/twentyfourteen/inc/featured-content.php @@ -48,6 +48,8 @@ public static function setup() { * We'll just return early instead. * * @since Twenty Fourteen 1.0 + * + * @phpstan-impure */ public static function init() { $theme_support = get_theme_support( 'featured-content' ); diff --git a/src/wp-content/themes/twentyfourteen/inc/widgets.php b/src/wp-content/themes/twentyfourteen/inc/widgets.php index b375113b308b5..a1bace59285ee 100644 --- a/src/wp-content/themes/twentyfourteen/inc/widgets.php +++ b/src/wp-content/themes/twentyfourteen/inc/widgets.php @@ -71,6 +71,8 @@ public function enqueue_scripts() { * * @param array $args An array of standard parameters for widgets in this theme. * @param array $instance An array of settings for this widget instance. + * + * @phpstan-impure */ public function widget( $args, $instance ) { $format = isset( $instance['format'] ) ? $instance['format'] : ''; diff --git a/src/wp-includes/abilities-api/class-wp-abilities-registry.php b/src/wp-includes/abilities-api/class-wp-abilities-registry.php index dc0b30835d9d1..de5f5b7ceab08 100644 --- a/src/wp-includes/abilities-api/class-wp-abilities-registry.php +++ b/src/wp-includes/abilities-api/class-wp-abilities-registry.php @@ -89,6 +89,8 @@ final class WP_Abilities_Registry { * @return WP_Ability|null The registered ability instance on success, null on failure. * * @phpstan-param lowercase-string&non-falsy-string $name + * + * @phpstan-impure */ public function register( string $name, array $args ): ?WP_Ability { if ( ! preg_match( '/^[a-z0-9-]+\/[a-z0-9-]+$/', $name ) ) { @@ -216,6 +218,8 @@ public function register( string $name, array $args ): ?WP_Ability { * * @param string $name The name of the registered ability, with its namespace. * @return WP_Ability|null The unregistered ability instance on success, null on failure. + * + * @phpstan-impure */ public function unregister( string $name ): ?WP_Ability { if ( ! $this->is_registered( $name ) ) { @@ -298,6 +302,8 @@ public function get_registered( string $name ): ?WP_Ability { * @since 6.9.0 * * @return WP_Abilities_Registry|null The main registry instance, or null when `init` action has not fired. + * + * @phpstan-impure */ public static function get_instance(): ?self { if ( ! did_action( 'init' ) ) { diff --git a/src/wp-includes/abilities-api/class-wp-ability-categories-registry.php b/src/wp-includes/abilities-api/class-wp-ability-categories-registry.php index 92e6dbdd84f65..7d8808ad5ef70 100644 --- a/src/wp-includes/abilities-api/class-wp-ability-categories-registry.php +++ b/src/wp-includes/abilities-api/class-wp-ability-categories-registry.php @@ -55,6 +55,8 @@ final class WP_Ability_Categories_Registry { * @return WP_Ability_Category|null The registered ability category instance on success, null on failure. * * @phpstan-param lowercase-string&non-empty-string $slug + * + * @phpstan-impure */ public function register( string $slug, array $args ): ?WP_Ability_Category { if ( $this->is_registered( $slug ) ) { @@ -119,6 +121,8 @@ public function register( string $slug, array $args ): ?WP_Ability_Category { * * @param string $slug The slug of the registered ability category. * @return WP_Ability_Category|null The unregistered ability category instance on success, null on failure. + * + * @phpstan-impure */ public function unregister( string $slug ): ?WP_Ability_Category { if ( ! $this->is_registered( $slug ) ) { @@ -201,6 +205,8 @@ public function get_registered( string $slug ): ?WP_Ability_Category { * @since 6.9.0 * * @return WP_Ability_Categories_Registry|null The main registry instance, or null when `init` action has not fired. + * + * @phpstan-impure */ public static function get_instance(): ?self { if ( ! did_action( 'init' ) ) { diff --git a/src/wp-includes/abilities/class-wp-abilities-content.php b/src/wp-includes/abilities/class-wp-abilities-content.php index 17e1a81ac30df..2cb3227eda330 100644 --- a/src/wp-includes/abilities/class-wp-abilities-content.php +++ b/src/wp-includes/abilities/class-wp-abilities-content.php @@ -397,6 +397,8 @@ private function check_read_permission( WP_Post $post, array $checked_post_ids = * * @param mixed $input Optional. The ability input. Default empty array. * @return array|WP_Error A page of posts, or a WP_Error on failure. + * + * @phpstan-impure */ private function execute_content_query( $input = array() ) { $input = rest_sanitize_object( $input ); @@ -1349,6 +1351,8 @@ private function get_content_query_output_schema(): array { * * @param int $user_id The user ID. * @return WP_User|null The user, or null when they no longer exist or may not be seen. + * + * @phpstan-impure */ private function get_visible_author( int $user_id ): ?WP_User { $user = get_userdata( $user_id ); diff --git a/src/wp-includes/ai-client/class-wp-ai-client-builder.php b/src/wp-includes/ai-client/class-wp-ai-client-builder.php index db36442bb9f31..6f46d99068e4b 100644 --- a/src/wp-includes/ai-client/class-wp-ai-client-builder.php +++ b/src/wp-includes/ai-client/class-wp-ai-client-builder.php @@ -204,6 +204,8 @@ abstract protected function get_support_check_methods(): array; * @param string $name The method name in snake_case. * @param array $arguments The method arguments. * @return mixed The result of the method call. + * + * @phpstan-impure */ public function __call( string $name, array $arguments ) { /* diff --git a/src/wp-includes/block-template.php b/src/wp-includes/block-template.php index 3f24933dfcf59..1396f806263ca 100644 --- a/src/wp-includes/block-template.php +++ b/src/wp-includes/block-template.php @@ -354,6 +354,8 @@ function _block_template_add_skip_link( string $template_html ): string { * Inserts text before the current token. * * @param string $text Text to insert. + * + * @phpstan-impure */ public function insert_before( string $text ) { $this->set_bookmark( 'here' ); diff --git a/src/wp-includes/class-walker-comment.php b/src/wp-includes/class-walker-comment.php index 3d2eb012e4903..e6a7e8c80f6c5 100644 --- a/src/wp-includes/class-walker-comment.php +++ b/src/wp-includes/class-walker-comment.php @@ -51,6 +51,8 @@ class Walker_Comment extends Walker { * @param string $output Used to append additional content (passed by reference). * @param int $depth Optional. Depth of the current comment. Default 0. * @param array $args Optional. Uses 'style' argument for type of HTML list. Default empty array. + * + * @phpstan-impure */ public function start_lvl( &$output, $depth = 0, $args = array() ) { $GLOBALS['comment_depth'] = $depth + 1; @@ -80,6 +82,8 @@ public function start_lvl( &$output, $depth = 0, $args = array() ) { * @param int $depth Optional. Depth of the current comment. Default 0. * @param array $args Optional. Will only append content if style argument value is 'ol' or 'ul'. * Default empty array. + * + * @phpstan-impure */ public function end_lvl( &$output, $depth = 0, $args = array() ) { $GLOBALS['comment_depth'] = $depth + 1; @@ -169,6 +173,8 @@ public function display_element( $element, &$children_elements, $max_depth, $dep * @param int $depth Optional. Depth of the current comment in reference to parents. Default 0. * @param array $args Optional. An array of arguments. Default empty array. * @param int $current_object_id Optional. ID of the current comment. Default 0. + * + * @phpstan-impure */ public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) { // Restores the more descriptive, specific name for use within this method. diff --git a/src/wp-includes/class-wp-admin-bar.php b/src/wp-includes/class-wp-admin-bar.php index c8e3427bf17f3..20d78fd5d0526 100644 --- a/src/wp-includes/class-wp-admin-bar.php +++ b/src/wp-includes/class-wp-admin-bar.php @@ -32,6 +32,8 @@ class WP_Admin_Bar { * Initializes the admin bar. * * @since 3.1.0 + * + * @phpstan-impure */ public function initialize() { $this->user = new stdClass(); @@ -189,6 +191,8 @@ public function add_node( $args ) { * @since 3.3.0 * * @param array $args + * + * @phpstan-impure */ final protected function _set_node( $args ) { $this->nodes[ $args['id'] ] = (object) $args; @@ -295,6 +299,8 @@ public function remove_node( $id ) { * @since 3.3.0 * * @param string $id + * + * @phpstan-impure */ final protected function _unset_node( $id ) { unset( $this->nodes[ $id ] ); @@ -314,6 +320,8 @@ public function render() { * @since 3.3.0 * * @return object|null + * + * @phpstan-impure */ final protected function _bind() { if ( $this->bound ) { diff --git a/src/wp-includes/class-wp-ajax-response.php b/src/wp-includes/class-wp-ajax-response.php index b9946343ac79f..efa8ff6d990de 100644 --- a/src/wp-includes/class-wp-ajax-response.php +++ b/src/wp-includes/class-wp-ajax-response.php @@ -65,6 +65,8 @@ public function __construct( $args = '' ) { * @return string XML response. * * @phpstan-return non-falsy-string + * + * @phpstan-impure */ public function add( $args = '' ) { $defaults = array( diff --git a/src/wp-includes/class-wp-block-bindings-registry.php b/src/wp-includes/class-wp-block-bindings-registry.php index b20f0a692cd76..2624988d11039 100644 --- a/src/wp-includes/class-wp-block-bindings-registry.php +++ b/src/wp-includes/class-wp-block-bindings-registry.php @@ -82,6 +82,8 @@ final class WP_Block_Bindings_Registry { * @return WP_Block_Bindings_Source|false Source when the registration was successful, or `false` on failure. * * @phpstan-param lowercase-string&non-falsy-string $source_name + * + * @phpstan-impure */ public function register( string $source_name, array $source_properties ) { if ( ! is_string( $source_name ) ) { @@ -188,6 +190,8 @@ public function register( string $source_name, array $source_properties ) { * * @param string $source_name Block bindings source name including namespace. * @return WP_Block_Bindings_Source|false The unregistered block bindings source on success and `false` otherwise. + * + * @phpstan-impure */ public function unregister( string $source_name ) { if ( ! $this->is_registered( $source_name ) ) { @@ -272,6 +276,8 @@ public function __wakeup() { * @since 6.5.0 * * @return WP_Block_Bindings_Registry The main instance. + * + * @phpstan-impure */ public static function get_instance() { self::$instance ??= new self(); diff --git a/src/wp-includes/class-wp-block-list.php b/src/wp-includes/class-wp-block-list.php index 3d577f5656c3a..3ffb2ef27aa94 100644 --- a/src/wp-includes/class-wp-block-list.php +++ b/src/wp-includes/class-wp-block-list.php @@ -87,6 +87,8 @@ public function offsetExists( $offset ) { * * @param int $offset Offset of block value to retrieve. * @return WP_Block|null Block value if exists, or null. + * + * @phpstan-impure */ #[ReturnTypeWillChange] public function offsetGet( $offset ) { diff --git a/src/wp-includes/class-wp-block-metadata-registry.php b/src/wp-includes/class-wp-block-metadata-registry.php index b6d0416d5fc5e..a57f605ea6c4c 100644 --- a/src/wp-includes/class-wp-block-metadata-registry.php +++ b/src/wp-includes/class-wp-block-metadata-registry.php @@ -80,6 +80,8 @@ class WP_Block_Metadata_Registry { * @param string $path The absolute base path for the collection ( e.g., WP_PLUGIN_DIR . '/my-plugin/blocks/' ). * @param string $manifest The absolute path to the manifest file containing the metadata collection. * @return bool True if the collection was registered successfully, false otherwise. + * + * @phpstan-impure */ public static function register_collection( $path, $manifest ) { $path = rtrim( wp_normalize_path( $path ), '/' ); @@ -230,6 +232,8 @@ static function ( $block_name ) use ( $path ) { * * @param string $file_or_folder The normalized path to the file or folder. * @return string|null The normalized collection path if found, or null if not found. + * + * @phpstan-impure */ private static function find_collection_path( $file_or_folder ) { if ( empty( $file_or_folder ) ) { @@ -331,6 +335,8 @@ private static function is_valid_collection_path( $path, $collection_roots ) { * @since 6.7.2 * * @return string[] List of directory paths within which metadata collections are allowed. + * + * @phpstan-impure */ private static function get_default_collection_roots() { if ( isset( self::$default_collection_roots ) ) { diff --git a/src/wp-includes/class-wp-block-parser.php b/src/wp-includes/class-wp-block-parser.php index adc49c82ac766..ab0e6d3edd066 100644 --- a/src/wp-includes/class-wp-block-parser.php +++ b/src/wp-includes/class-wp-block-parser.php @@ -88,6 +88,8 @@ class WP_Block_Parser { * inner blocks were found. * } * } + * + * @phpstan-impure */ public function parse( $document ) { if ( is_object( $document ) && method_exists( $document, '__toString' ) ) { @@ -136,6 +138,8 @@ public function parse( $document ) { * @since 5.0.0 * * @return bool + * + * @phpstan-impure */ public function proceed() { // Ensure this is initialized, because some legacy code calls this method directly. @@ -297,6 +301,8 @@ public function proceed() { * @deprecated 7.2.0 Use {@see WP_Block_Processor} instead. * * @return array + * + * @phpstan-impure */ public function next_token() { // Ensure this is initialized, because some legacy code calls this method directly. @@ -354,6 +360,8 @@ public function freeform( $inner_html ) { * @since 5.0.0 * * @param null|int $length How many bytes of document text to output. + * + * @phpstan-impure */ public function add_freeform( $length = null ) { $length ??= strlen( $this->document ) - $this->offset; @@ -398,6 +406,8 @@ public function add_inner_block( WP_Block_Parser_Block $block, $token_start, $to * @since 5.0.0 * * @param int|null $end_offset byte offset into document for where we should stop sending text output as HTML. + * + * @phpstan-impure */ public function add_block_from_stack( $end_offset = null ) { $stack_top = array_pop( $this->stack ); diff --git a/src/wp-includes/class-wp-block-pattern-categories-registry.php b/src/wp-includes/class-wp-block-pattern-categories-registry.php index 87801c67cee39..fec9921a64c3d 100644 --- a/src/wp-includes/class-wp-block-pattern-categories-registry.php +++ b/src/wp-includes/class-wp-block-pattern-categories-registry.php @@ -50,6 +50,8 @@ final class WP_Block_Pattern_Categories_Registry { * @type string $description Optional. A human-readable description of the pattern category. * } * @return bool True if the pattern category was registered with success and false otherwise. + * + * @phpstan-impure */ public function register( $category_name, $category_properties ) { if ( ! isset( $category_name ) || ! is_string( $category_name ) ) { @@ -85,6 +87,8 @@ public function register( $category_name, $category_properties ) { * * @param string $category_name Pattern category name including namespace. * @return bool True if the pattern was unregistered with success and false otherwise. + * + * @phpstan-impure */ public function unregister( $category_name ) { if ( ! $this->is_registered( $category_name ) ) { @@ -155,6 +159,8 @@ public function is_registered( $category_name ) { * @since 5.5.0 * * @return WP_Block_Pattern_Categories_Registry The main instance. + * + * @phpstan-impure */ public static function get_instance() { self::$instance ??= new self(); diff --git a/src/wp-includes/class-wp-block-patterns-registry.php b/src/wp-includes/class-wp-block-patterns-registry.php index 5ed2cc1e0355f..71b2aa43aa1e9 100644 --- a/src/wp-includes/class-wp-block-patterns-registry.php +++ b/src/wp-includes/class-wp-block-patterns-registry.php @@ -85,6 +85,8 @@ final class WP_Block_Patterns_Registry { * @type string $filePath Optional. The full path to the file containing the block pattern content. * } * @return bool True if the pattern was registered with success and false otherwise. + * + * @phpstan-impure */ public function register( $pattern_name, $pattern_properties ) { if ( ! isset( $pattern_name ) || ! is_string( $pattern_name ) ) { @@ -140,6 +142,8 @@ public function register( $pattern_name, $pattern_properties ) { * * @param string $pattern_name Block pattern name including namespace. * @return bool True if the pattern was unregistered with success and false otherwise. + * + * @phpstan-impure */ public function unregister( $pattern_name ) { if ( ! $this->is_registered( $pattern_name ) ) { @@ -278,6 +282,8 @@ public function __wakeup() { * @since 5.5.0 * * @return WP_Block_Patterns_Registry The main instance. + * + * @phpstan-impure */ public static function get_instance() { self::$instance ??= new self(); diff --git a/src/wp-includes/class-wp-block-processor.php b/src/wp-includes/class-wp-block-processor.php index 0c6f9dcee132b..d8b12f7dcb0d2 100644 --- a/src/wp-includes/class-wp-block-processor.php +++ b/src/wp-includes/class-wp-block-processor.php @@ -733,6 +733,8 @@ public function next_delimiter( ?string $block_name = null ): bool { * @since 6.9.0 * * @return bool Whether a token was matched or the end of the document was reached without finding any. + * + * @phpstan-impure */ public function next_token(): bool { if ( $this->last_error || self::COMPLETE === $this->state || self::INCOMPLETE_INPUT === $this->state ) { @@ -1898,6 +1900,8 @@ public function get_attributes() { * @since 6.9.0 * * @return array|null Parsed JSON attributes, if present and valid, otherwise `null`. + * + * @phpstan-impure */ public function allocate_and_return_parsed_attributes(): ?array { $this->last_json_error = JSON_ERROR_NONE; diff --git a/src/wp-includes/class-wp-block-styles-registry.php b/src/wp-includes/class-wp-block-styles-registry.php index 8e4407223ccc8..0f3ebba8796a8 100644 --- a/src/wp-includes/class-wp-block-styles-registry.php +++ b/src/wp-includes/class-wp-block-styles-registry.php @@ -77,6 +77,8 @@ final class WP_Block_Styles_Registry { * @type array $style_data Theme.json-like object to generate CSS from. * } * @return bool True if the block style was registered with success and false otherwise. + * + * @phpstan-impure */ public function register( $block_name, $style_properties ) { @@ -130,6 +132,8 @@ public function register( $block_name, $style_properties ) { * @param string $block_name Block type name including namespace. * @param string $block_style_name Block style name. * @return bool True if the block style was unregistered with success and false otherwise. + * + * @phpstan-impure */ public function unregister( $block_name, $block_style_name ) { if ( ! $this->is_registered( $block_name, $block_style_name ) ) { @@ -213,6 +217,8 @@ public function is_registered( $block_name, $block_style_name ) { * @since 5.3.0 * * @return WP_Block_Styles_Registry The main instance. + * + * @phpstan-impure */ public static function get_instance() { self::$instance ??= new self(); diff --git a/src/wp-includes/class-wp-block-supports.php b/src/wp-includes/class-wp-block-supports.php index 0a93c2c45ab55..eb5fdf6c8a443 100644 --- a/src/wp-includes/class-wp-block-supports.php +++ b/src/wp-includes/class-wp-block-supports.php @@ -58,6 +58,8 @@ class WP_Block_Supports { * @since 5.6.0 * * @return WP_Block_Supports The main instance. + * + * @phpstan-impure */ public static function get_instance() { self::$instance ??= new self(); diff --git a/src/wp-includes/class-wp-block-templates-registry.php b/src/wp-includes/class-wp-block-templates-registry.php index fa1c180988844..47c2445bcb876 100644 --- a/src/wp-includes/class-wp-block-templates-registry.php +++ b/src/wp-includes/class-wp-block-templates-registry.php @@ -38,6 +38,8 @@ final class WP_Block_Templates_Registry { * @return WP_Block_Template|WP_Error The registered template on success, or WP_Error on failure. * * @phpstan-param lowercase-string&non-falsy-string $template_name + * + * @phpstan-impure */ public function register( $template_name, $args = array() ) { @@ -217,6 +219,8 @@ public function is_registered( $template_name ) { * * @param string $template_name Template name including namespace. * @return WP_Block_Template|WP_Error The unregistered template on success, or WP_Error on failure. + * + * @phpstan-impure */ public function unregister( $template_name ) { if ( ! $this->is_registered( $template_name ) ) { @@ -242,6 +246,8 @@ public function unregister( $template_name ) { * @since 6.7.0 * * @return WP_Block_Templates_Registry The main instance. + * + * @phpstan-impure */ public static function get_instance() { self::$instance ??= new self(); diff --git a/src/wp-includes/class-wp-block-type-registry.php b/src/wp-includes/class-wp-block-type-registry.php index d3fe35d15f901..ac727ae39a9fa 100644 --- a/src/wp-includes/class-wp-block-type-registry.php +++ b/src/wp-includes/class-wp-block-type-registry.php @@ -46,6 +46,8 @@ final class WP_Block_Type_Registry { * @return WP_Block_Type|false The registered block type on success, or false on failure. * * @phpstan-param (lowercase-string&non-falsy-string)|WP_Block_Type $name + * + * @phpstan-impure */ public function register( $name, $args = array() ) { $block_type = null; @@ -112,6 +114,8 @@ public function register( $name, $args = array() ) { * @param string|WP_Block_Type $name Block type name including namespace, or alternatively * a complete WP_Block_Type instance. * @return WP_Block_Type|false The unregistered block type on success, or false on failure. + * + * @phpstan-impure */ public function unregister( $name ) { if ( $name instanceof WP_Block_Type ) { @@ -195,6 +199,8 @@ public function __wakeup() { * @since 5.0.0 * * @return WP_Block_Type_Registry The main instance. + * + * @phpstan-impure */ public static function get_instance() { self::$instance ??= new self(); diff --git a/src/wp-includes/class-wp-block-type.php b/src/wp-includes/class-wp-block-type.php index b7e44273fd6c1..c68670bc4959c 100644 --- a/src/wp-includes/class-wp-block-type.php +++ b/src/wp-includes/class-wp-block-type.php @@ -426,6 +426,8 @@ public function __isset( $name ) { * * @param string $name Property name. * @param mixed $value Property value. + * + * @phpstan-impure */ public function __set( $name, $value ) { if ( ! in_array( $name, $this->deprecated_properties, true ) ) { @@ -546,6 +548,8 @@ public function prepare_attributes_for_render( $attributes ) { * * @param array|string $args Array or string of arguments for registering a block type. * See WP_Block_Type::__construct() for information on accepted arguments. + * + * @phpstan-impure */ public function set_props( $args ) { $args = wp_parse_args( @@ -603,6 +607,8 @@ public function get_attributes() { * @since 6.5.0 * * @return array[] + * + * @phpstan-impure */ public function get_variations() { if ( ! isset( $this->variations ) ) { diff --git a/src/wp-includes/class-wp-block.php b/src/wp-includes/class-wp-block.php index 8baf0f99bacde..e10dbfed73471 100644 --- a/src/wp-includes/class-wp-block.php +++ b/src/wp-includes/class-wp-block.php @@ -151,6 +151,8 @@ public function __construct( $block, $available_context = array(), $registry = n * for each inner block and updating their context based on the block's `provides_context` property. * * @since 6.8.0 + * + * @phpstan-impure */ public function refresh_context_dependents() { /* @@ -182,6 +184,8 @@ public function refresh_context_dependents() { * correct content and context are updated for each nested block. * * @since 6.8.0 + * + * @phpstan-impure */ public function refresh_parsed_block_dependents() { if ( ! empty( $this->parsed_block['innerBlocks'] ) ) { @@ -219,6 +223,8 @@ public function refresh_parsed_block_dependents() { * * @param string $name Property name. * @return array|null Prepared attributes, or null. + * + * @phpstan-impure */ public function __get( $name ) { if ( 'attributes' === $name ) { @@ -275,6 +281,8 @@ public function __get( $name ) { * @since 6.7.0 Return any updated bindings metadata in the computed attributes. * * @return array The computed block attributes for the provided block bindings. + * + * @phpstan-impure */ private function process_block_bindings() { $block_type = $this->name; @@ -452,6 +460,8 @@ private static function get_block_bindings_processor( string $block_content ) { * @param int[] $inner_block_offsets Optional. Byte offsets in the source HTML where * inner blocks' rendered output begins. Default empty array. * @return bool True on success. + * + * @phpstan-impure */ public function replace_rich_text( $rich_text, $inner_block_offsets = array() ) { if ( $this->is_tag_closer() || ! $this->expects_closer() ) { @@ -525,6 +535,8 @@ public function replace_rich_text( $rich_text, $inner_block_offsets = array() ) * @type bool $dynamic Defaults to 'true'. Optionally set to false to avoid using the block's render_callback. * } * @return string Rendered block output. + * + * @phpstan-impure */ public function render( $options = array() ) { global $post; diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php index ad706ba532114..1164d321a8e75 100644 --- a/src/wp-includes/class-wp-comment-query.php +++ b/src/wp-includes/class-wp-comment-query.php @@ -335,6 +335,8 @@ public function __construct( $query = '' ) { * @since 4.2.0 Extracted from WP_Comment_Query::query(). * * @param string|array $query WP_Comment_Query arguments. See WP_Comment_Query::__construct() for accepted arguments. + * + * @phpstan-impure */ public function parse_query( $query = '' ) { if ( empty( $query ) ) { @@ -371,6 +373,8 @@ public function parse_query( $query = '' ) { * $query is array{ fields: 'ids', ... } ? non-negative-int[] : array * ) * ) + * + * @phpstan-impure */ public function query( $query ) { $this->query_vars = wp_parse_args( $query ); @@ -386,6 +390,8 @@ public function query( $query ) { * * @return int|int[]|WP_Comment[] List of comments or number of found comments if `$count` argument is true. * @phpstan-return array|non-negative-int[]|non-negative-int + * + * @phpstan-impure */ public function get_comments() { global $wpdb; @@ -555,6 +561,8 @@ public function get_comments() { * * @return int|array A single count of comment IDs if a count query. An array of comment IDs if a full query. * @phpstan-return non-negative-int|list + * + * @phpstan-impure */ protected function get_comment_ids() { global $wpdb; @@ -1018,6 +1026,8 @@ protected function get_comment_ids() { * @since 4.6.0 * * @global wpdb $wpdb WordPress database abstraction object. + * + * @phpstan-impure */ private function set_found_comments() { global $wpdb; diff --git a/src/wp-includes/class-wp-comment.php b/src/wp-includes/class-wp-comment.php index c2ebe94ec8ef1..9c465963ef2da 100644 --- a/src/wp-includes/class-wp-comment.php +++ b/src/wp-includes/class-wp-comment.php @@ -386,6 +386,8 @@ public function to_array(): array { * ) * ) * ) + * + * @phpstan-impure */ public function get_children( $args = array() ) { $defaults = array( diff --git a/src/wp-includes/class-wp-connector-registry.php b/src/wp-includes/class-wp-connector-registry.php index 70b967e8ab517..c92aa29c4f2bd 100644 --- a/src/wp-includes/class-wp-connector-registry.php +++ b/src/wp-includes/class-wp-connector-registry.php @@ -146,6 +146,8 @@ final class WP_Connector_Registry { * } * } $args * @phpstan-return Connector|null + * + * @phpstan-impure */ public function register( string $id, array $args ): ?array { if ( ! preg_match( '/^[a-z0-9_-]+$/', $id ) ) { @@ -324,6 +326,8 @@ public function register( string $id, array $args ): ?array { * @return array|null The unregistered connector data on success, null on failure. * * @phpstan-return Connector|null + * + * @phpstan-impure */ public function unregister( string $id ): ?array { if ( ! $this->is_registered( $id ) ) { diff --git a/src/wp-includes/class-wp-customize-control.php b/src/wp-includes/class-wp-customize-control.php index 859958a2f6838..15daaec499333 100644 --- a/src/wp-includes/class-wp-customize-control.php +++ b/src/wp-includes/class-wp-customize-control.php @@ -310,6 +310,8 @@ final public function value( $setting_key = 'default' ) { * Refreshes the parameters passed to the JavaScript via JSON. * * @since 3.4.0 + * + * @phpstan-impure */ public function to_json() { $this->json['settings'] = array(); @@ -489,6 +491,8 @@ public function input_attrs() { * Control content can alternately be rendered in JS. See WP_Customize_Control::print_template(). * * @since 3.4.0 + * + * @phpstan-impure */ protected function render_content() { $input_id = '_customize-input-' . $this->id; diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index ad787986b75de..06184a695c11a 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -621,6 +621,8 @@ public function setup_theme() { * @since 4.9.0 * * @global string $pagenow The filename of the current screen. + * + * @phpstan-impure */ public function establish_loaded_changeset() { global $pagenow; @@ -682,6 +684,8 @@ public function after_setup_theme() { * to swap it out at runtime. * * @since 3.4.0 + * + * @phpstan-impure */ public function start_previewing_theme() { // Bail if we're already previewing. @@ -721,6 +725,8 @@ public function start_previewing_theme() { * Removes filters to change the active theme. * * @since 3.4.0 + * + * @phpstan-impure */ public function stop_previewing_theme() { if ( ! $this->is_preview() ) { @@ -787,6 +793,8 @@ public function autosaved() { * @see WP_Customize_Manager::establish_loaded_changeset() * * @return bool Is changeset branching. + * + * @phpstan-impure */ public function branching() { @@ -842,6 +850,8 @@ public function changeset_uuid() { * @since 3.4.0 * * @return WP_Theme + * + * @phpstan-impure */ public function theme() { if ( ! $this->theme ) { @@ -1103,6 +1113,8 @@ protected function dismiss_user_auto_draft_changesets() { * @since 4.7.0 * * @return int|null Post ID on success or null if there is no post yet saved. + * + * @phpstan-impure */ public function changeset_post_id() { if ( ! isset( $this->_changeset_post_id ) ) { @@ -1159,6 +1171,8 @@ protected function get_changeset_post_data( $post_id ) { * @since 4.9.0 This will return the changeset's data with a user's autosave revision merged on top, if one exists and $autosaved is true. * * @return array Changeset data. + * + * @phpstan-impure */ public function changeset_data() { if ( isset( $this->_changeset_data ) ) { @@ -1205,6 +1219,8 @@ public function changeset_data() { * @since 4.7.0 * * @param array $starter_content Starter content. Defaults to `get_theme_starter_content()`. + * + * @phpstan-impure */ public function import_theme_starter_content( $starter_content = array() ) { if ( empty( $starter_content ) ) { @@ -1718,6 +1734,8 @@ protected function prepare_starter_content_attachments( $attachments ) { * Saves starter content changeset. * * @since 4.7.0 + * + * @phpstan-impure */ public function _save_starter_content_changeset() { @@ -1762,6 +1780,8 @@ public function _save_starter_content_changeset() { * @type bool $exclude_post_data Whether the post input values should also be excluded. Defaults to false when lacking the customize capability. * } * @return array + * + * @phpstan-impure */ public function unsanitized_post_values( $args = array() ) { $args = array_merge( @@ -1869,6 +1889,8 @@ public function post_value( $setting, $default_value = null ) { * * @param string $setting_id ID for the WP_Customize_Setting instance. * @param mixed $value Post value. + * + * @phpstan-impure */ public function set_post_value( $setting_id, $value ) { $this->unsanitized_post_values(); // Populate _post_values from $_POST['customized']. @@ -2644,6 +2666,8 @@ public function save() { * } * * @return array|WP_Error Returns array on success and WP_Error with array data on error. + * + * @phpstan-impure */ public function save_changeset_post( $args = array() ) { @@ -3478,6 +3502,8 @@ public function _filter_revision_post_has_changed( $post_has_changed, $latest_re * * @param int $changeset_post_id ID for customize_changeset post. Defaults to the changeset for the current manager instance. * @return true|WP_Error True or error info. + * + * @phpstan-impure */ public function _publish_changeset_values( $changeset_post_id ) { global $wpdb; @@ -3779,6 +3805,8 @@ public function handle_dismiss_autosave_or_lock_request() { * See WP_Customize_Setting::__construct() for information * on accepted arguments. Default empty array. * @return WP_Customize_Setting The instance of the setting that was added. + * + * @phpstan-impure */ public function add_setting( $id, $args = array() ) { if ( $id instanceof WP_Customize_Setting ) { @@ -3880,6 +3908,8 @@ public function get_setting( $id ) { * @since 3.4.0 * * @param string $id Customize Setting ID. + * + * @phpstan-impure */ public function remove_setting( $id ) { unset( $this->settings[ $id ] ); @@ -3898,6 +3928,8 @@ public function remove_setting( $id ) { * See WP_Customize_Panel::__construct() for information * on accepted arguments. Default empty array. * @return WP_Customize_Panel The instance of the panel that was added. + * + * @phpstan-impure */ public function add_panel( $id, $args = array() ) { if ( $id instanceof WP_Customize_Panel ) { @@ -3930,6 +3962,8 @@ public function get_panel( $id ) { * @since 4.0.0 * * @param string $id Panel ID to remove. + * + * @phpstan-impure */ public function remove_panel( $id ) { // Removing core components this way is _doing_it_wrong(). @@ -3962,6 +3996,8 @@ public function remove_panel( $id ) { * @see WP_Customize_Panel * * @param string $panel Name of a custom panel which is a subclass of WP_Customize_Panel. + * + * @phpstan-impure */ public function register_panel_type( $panel ) { $this->registered_panel_types[] = $panel; @@ -3992,6 +4028,8 @@ public function render_panel_templates() { * See WP_Customize_Section::__construct() for information * on accepted arguments. Default empty array. * @return WP_Customize_Section The instance of the section that was added. + * + * @phpstan-impure */ public function add_section( $id, $args = array() ) { if ( $id instanceof WP_Customize_Section ) { @@ -4024,6 +4062,8 @@ public function get_section( $id ) { * @since 3.4.0 * * @param string $id Section ID. + * + * @phpstan-impure */ public function remove_section( $id ) { unset( $this->sections[ $id ] ); @@ -4039,6 +4079,8 @@ public function remove_section( $id ) { * @see WP_Customize_Section * * @param string $section Name of a custom section which is a subclass of WP_Customize_Section. + * + * @phpstan-impure */ public function register_section_type( $section ) { $this->registered_section_types[] = $section; @@ -4069,6 +4111,8 @@ public function render_section_templates() { * See WP_Customize_Control::__construct() for information * on accepted arguments. Default empty array. * @return WP_Customize_Control The instance of the control that was added. + * + * @phpstan-impure */ public function add_control( $id, $args = array() ) { if ( $id instanceof WP_Customize_Control ) { @@ -4101,6 +4145,8 @@ public function get_control( $id ) { * @since 3.4.0 * * @param string $id ID of the control. + * + * @phpstan-impure */ public function remove_control( $id ) { unset( $this->controls[ $id ] ); @@ -4115,6 +4161,8 @@ public function remove_control( $id ) { * * @param string $control Name of a custom control which is a subclass of * WP_Customize_Control. + * + * @phpstan-impure */ public function register_control_type( $control ) { $this->registered_control_types[] = $control; @@ -4435,6 +4483,8 @@ protected function _cmp_priority( $a, $b ) { * and sort by priority. * * @since 3.4.0 + * + * @phpstan-impure */ public function prepare_controls() { @@ -4599,6 +4649,8 @@ public function get_document_title_template() { * @since 4.4.0 * * @param string $preview_url URL to be previewed. + * + * @phpstan-impure */ public function set_preview_url( $preview_url ) { $preview_url = sanitize_url( $preview_url ); @@ -4687,6 +4739,8 @@ public function get_messenger_channel() { * @since 4.4.0 * * @param string $return_url URL for return link. + * + * @phpstan-impure */ public function set_return_url( $return_url ) { $return_url = sanitize_url( $return_url ); @@ -4750,6 +4804,8 @@ public function get_return_url() { * @type string $section ID for section to be autofocused. * @type string $panel ID for panel to be autofocused. * } + * + * @phpstan-impure */ public function set_autofocus( $autofocus ) { $this->autofocus = array_filter( wp_array_slice_assoc( $autofocus, array( 'panel', 'section', 'control' ) ), 'is_string' ); diff --git a/src/wp-includes/class-wp-customize-nav-menus.php b/src/wp-includes/class-wp-customize-nav-menus.php index b093509f2f5c2..8f172fa41f019 100644 --- a/src/wp-includes/class-wp-customize-nav-menus.php +++ b/src/wp-includes/class-wp-customize-nav-menus.php @@ -1358,6 +1358,8 @@ public function customize_preview_init() { * @since 4.7.0 * * @global stdClass[] $wp_post_statuses List of post statuses. + * + * @phpstan-impure */ public function make_auto_draft_status_previewable() { global $wp_post_statuses; @@ -1445,6 +1447,8 @@ public function save_nav_menus_created_posts( $setting ) { * * @param array $args An array containing wp_nav_menu() arguments. * @return array Arguments. + * + * @phpstan-impure */ public function filter_wp_nav_menu_args( $args ) { /* diff --git a/src/wp-includes/class-wp-customize-setting.php b/src/wp-includes/class-wp-customize-setting.php index 2658eb20fd02d..4143de3a00aa4 100644 --- a/src/wp-includes/class-wp-customize-setting.php +++ b/src/wp-includes/class-wp-customize-setting.php @@ -245,6 +245,8 @@ final public function id_data() { * calls get combined into one call, greatly improving performance. * * @since 4.4.0 + * + * @phpstan-impure */ protected function aggregate_multidimensional() { $id_base = $this->id_data['base']; @@ -271,6 +273,8 @@ protected function aggregate_multidimensional() { * * @since 4.5.0 * @ignore + * + * @phpstan-impure */ public static function reset_aggregated_multidimensionals() { self::$aggregated_multidimensionals = array(); @@ -318,6 +322,8 @@ public function is_current_blog_previewed() { * @since 4.4.0 Added boolean return value. * * @return bool False when preview short-circuits due no change needing to be previewed. + * + * @phpstan-impure */ public function preview() { if ( ! isset( $this->_previewed_blog_id ) ) { @@ -431,6 +437,8 @@ public function preview() { * * @see WP_Customize_Manager::set_post_value() * @see WP_Customize_Setting::_multidimensional_preview_filter() + * + * @phpstan-impure */ final public function _clear_aggregated_multidimensional_preview_applied_flag() { unset( self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['preview_applied_instances'][ $this->id ] ); @@ -479,6 +487,8 @@ public function _preview_filter( $original ) { * @see WP_Customize_Setting::$aggregated_multidimensionals * @param mixed $original Original root value. * @return mixed New or old value. + * + * @phpstan-impure */ final public function _multidimensional_preview_filter( $original ) { if ( ! $this->is_current_blog_previewed() ) { @@ -680,6 +690,8 @@ protected function set_root_value( $value ) { * * @param mixed $value The value to update. * @return bool The result of saving the value. + * + * @phpstan-impure */ protected function update( $value ) { $id_base = $this->id_data['base']; diff --git a/src/wp-includes/class-wp-customize-widgets.php b/src/wp-includes/class-wp-customize-widgets.php index dc45b3fb02b8a..360a0439f49cf 100644 --- a/src/wp-includes/class-wp-customize-widgets.php +++ b/src/wp-includes/class-wp-customize-widgets.php @@ -142,6 +142,8 @@ public function __construct( $manager ) { * * @return array Mapping of id_base to support. If theme doesn't support * selective refresh, an empty array is returned. + * + * @phpstan-impure */ public function get_selective_refreshable_widgets() { global $wp_widget_factory; @@ -266,6 +268,8 @@ protected function get_post_value( $name, $default_value = null ) { * * @global array $sidebars_widgets * @global array $_wp_sidebars_widgets + * + * @phpstan-impure */ public function override_sidebars_widgets_for_theme_switch() { global $sidebars_widgets; @@ -1343,6 +1347,8 @@ public function export_preview_data() { * @since 3.9.0 * * @param array $widget Rendered widget to tally. + * + * @phpstan-impure */ public function tally_rendered_widgets( $widget ) { $this->rendered_widgets[ $widget['id'] ] = true; @@ -1384,6 +1390,8 @@ public function is_sidebar_rendered( $sidebar_id ) { * @param bool $is_active Whether the sidebar is active. * @param string $sidebar_id Sidebar ID. * @return bool Whether the sidebar is active. + * + * @phpstan-impure */ public function tally_sidebars_via_is_active_sidebar_calls( $is_active, $sidebar_id ) { if ( is_registered_sidebar( $sidebar_id ) ) { @@ -1410,6 +1418,8 @@ public function tally_sidebars_via_is_active_sidebar_calls( $is_active, $sidebar * @param bool $has_widgets Whether the current sidebar has widgets. * @param string $sidebar_id Sidebar ID. * @return bool Whether the current sidebar has widgets. + * + * @phpstan-impure */ public function tally_sidebars_via_dynamic_sidebar_calls( $has_widgets, $sidebar_id ) { if ( is_registered_sidebar( $sidebar_id ) ) { @@ -1817,6 +1827,8 @@ public function selective_refresh_init() { * @type array $widget_args Widget args. * } * @return array Params. + * + * @phpstan-impure */ public function filter_dynamic_sidebar_params( $params ) { $sidebar_args = array_merge( @@ -1936,6 +1948,8 @@ public function filter_wp_kses_allowed_data_attributes( $allowed_html ) { * @since 4.5.0 * * @param int|string $index Index, name, or ID of the dynamic sidebar. + * + * @phpstan-impure */ public function start_dynamic_sidebar( $index ) { array_unshift( $this->current_dynamic_sidebar_id_stack, $index ); @@ -2008,6 +2022,8 @@ public function filter_sidebars_widgets_for_rendering_widget( $sidebars_widgets * @type int $sidebar_instance_number Disambiguating instance number. * } * @return string|false + * + * @phpstan-impure */ public function render_widget_partial( $partial, $context ) { $id_data = $partial->id_data(); @@ -2124,6 +2140,8 @@ protected function count_captured_options() { * Begins keeping track of changes to widget options, caching new values. * * @since 3.9.0 + * + * @phpstan-impure */ protected function start_capturing_option_updates() { if ( $this->_is_capturing_option_updates ) { @@ -2144,6 +2162,8 @@ protected function start_capturing_option_updates() { * @param string $option_name Name of the option. * @param mixed $old_value The old option value. * @return mixed Filtered option value. + * + * @phpstan-impure */ public function capture_filter_pre_update_option( $new_value, $option_name, $old_value ) { if ( $this->is_option_capture_ignored( $option_name ) ) { @@ -2184,6 +2204,8 @@ public function capture_filter_pre_get_option( $value ) { * Undoes any changes to the options since options capture began. * * @since 3.9.0 + * + * @phpstan-impure */ protected function stop_capturing_option_updates() { if ( ! $this->_is_capturing_option_updates ) { diff --git a/src/wp-includes/class-wp-dependencies.php b/src/wp-includes/class-wp-dependencies.php index f9aa688cca3af..fd1fa2ce40fd7 100644 --- a/src/wp-includes/class-wp-dependencies.php +++ b/src/wp-includes/class-wp-dependencies.php @@ -130,6 +130,8 @@ class WP_Dependencies { * Default false. * @param int|false $group Optional. Group level: level (int), no group (false). * @return string[] Array of handles of items that have been processed. + * + * @phpstan-impure */ public function do_items( $handles = false, $group = false ) { /* @@ -189,6 +191,8 @@ public function do_item( $handle, $group = false ) { * @param int|false $group Optional. Group level: level (int), no group (false). * Default false. * @return bool True on success, false on failure. + * + * @phpstan-impure */ public function all_deps( $handles, $recursion = false, $group = false ) { $handles = (array) $handles; @@ -277,6 +281,8 @@ public function all_deps( $handles, $recursion = false, $group = false ) { * @param mixed $args Optional. Custom property of the item. NOT the class property $args. * Examples: $media, $in_footer. * @return bool Whether the item has been registered. True on success, false on failure. + * + * @phpstan-impure */ public function add( $handle, $src, $deps = array(), $ver = false, $args = null ) { if ( isset( $this->registered[ $handle ] ) ) { @@ -355,6 +361,8 @@ public function get_data( $handle, $key ) { * @since 2.6.0 Moved from `WP_Scripts`. * * @param string|string[] $handles Item handle (string) or item handles (array of strings). + * + * @phpstan-impure */ public function remove( $handles ) { foreach ( (array) $handles as $handle ) { @@ -374,6 +382,8 @@ public function remove( $handles ) { * @since 2.6.0 Moved from `WP_Scripts`. * * @param string|string[] $handles Item handle (string) or item handles (array of strings). + * + * @phpstan-impure */ public function enqueue( $handles ) { foreach ( (array) $handles as $handle ) { @@ -408,6 +418,8 @@ public function enqueue( $handles ) { * @since 2.6.0 Moved from `WP_Scripts`. * * @param string|string[] $handles Item handle (string) or item handles (array of strings). + * + * @phpstan-impure */ public function dequeue( $handles ) { foreach ( (array) $handles as $handle ) { @@ -434,6 +446,8 @@ public function dequeue( $handles ) { * @param string[] $queue An array of queued _WP_Dependency handles. * @param string $handle Name of the item. Should be unique. * @return bool Whether the handle is found after recursively searching the dependency tree. + * + * @phpstan-impure */ protected function recurse_deps( $queue, $handle ) { if ( isset( $this->all_queued_deps ) ) { @@ -517,6 +531,8 @@ public function query( $handle, $status = 'registered' ) { * @param bool $recursion Internal flag that calling function was called recursively. * @param int|false $group Group level: level (int), no group (false). * @return bool Not already in the group or a lower group. + * + * @phpstan-impure */ public function set_group( $handle, $recursion, $group ) { $group = (int) $group; diff --git a/src/wp-includes/class-wp-dependency.php b/src/wp-includes/class-wp-dependency.php index 4900bf737ddeb..c8484919a4328 100644 --- a/src/wp-includes/class-wp-dependency.php +++ b/src/wp-includes/class-wp-dependency.php @@ -110,6 +110,8 @@ public function __construct( ...$args ) { * @param string $name The data key to add. * @param mixed $data The data value to add. * @return bool False if not scalar, true otherwise. + * + * @phpstan-impure */ public function add_data( $name, $data ) { if ( ! is_scalar( $name ) ) { @@ -127,6 +129,8 @@ public function add_data( $name, $data ) { * @param string $domain The translation textdomain. * @param string $path Optional. The full file path to the directory containing translation files. * @return bool False if $domain is not a string, true otherwise. + * + * @phpstan-impure */ public function set_translations( $domain, $path = '' ) { if ( ! is_string( $domain ) ) { diff --git a/src/wp-includes/class-wp-duotone.php b/src/wp-includes/class-wp-duotone.php index 49cf221c11af6..b53a2d08d2664 100644 --- a/src/wp-includes/class-wp-duotone.php +++ b/src/wp-includes/class-wp-duotone.php @@ -843,6 +843,8 @@ private static function get_global_styles_presets( $sources ) { * @param string $filter_id The filter ID. e.g. 'wp-duotone-000000-ffffff-2'. * @param string $duotone_selector The block's duotone selector. e.g. '.wp-block-image img'. * @param string $filter_value The filter CSS value. e.g. 'url(#wp-duotone-000000-ffffff-2)' or 'unset'. + * + * @phpstan-impure */ private static function enqueue_block_css( $filter_id, $duotone_selector, $filter_value ) { // Build the CSS selectors to which the filter will be applied. @@ -881,6 +883,8 @@ private static function enqueue_block_css( $filter_id, $duotone_selector, $filte * @param string $duotone_selector The block's duotone selector. e.g. '.wp-block-image img'. * @param string $filter_value The filter CSS value. e.g. 'url(#wp-duotone-000000-ffffff-2)' or 'unset'. * @param array $filter_data Duotone filter data with 'slug' and 'colors' keys. + * + * @phpstan-impure */ private static function enqueue_custom_filter( $filter_id, $duotone_selector, $filter_value, $filter_data ) { self::$used_svg_filter_data[ $filter_id ] = $filter_data; @@ -899,6 +903,8 @@ private static function enqueue_custom_filter( $filter_id, $duotone_selector, $f * @param string $filter_id The filter ID. e.g. 'wp-duotone-blue-orange'. * @param string $duotone_selector The block's duotone selector. e.g. '.wp-block-image img'. * @param string $filter_value The filter CSS value. e.g. 'url(#wp-duotone-blue-orange)' or 'unset'. + * + * @phpstan-impure */ private static function enqueue_global_styles_preset( $filter_id, $duotone_selector, $filter_value ) { $global_styles_presets = self::get_all_global_styles_presets(); @@ -998,6 +1004,8 @@ private static function get_selector( $block_type ) { * @since 6.3.0 * * @return array An array of global styles presets, keyed on the filter ID. + * + * @phpstan-impure */ private static function get_all_global_styles_presets() { if ( isset( self::$global_styles_presets ) ) { @@ -1028,6 +1036,8 @@ private static function get_all_global_styles_presets() { * @since 6.3.0 * * @return string[] An array of global style block slugs, keyed on the block name. + * + * @phpstan-impure */ private static function get_all_global_style_block_names() { if ( isset( self::$global_styles_block_names ) ) { diff --git a/src/wp-includes/class-wp-editor.php b/src/wp-includes/class-wp-editor.php index cda28aa94cdf9..0c784043dd8f9 100644 --- a/src/wp-includes/class-wp-editor.php +++ b/src/wp-includes/class-wp-editor.php @@ -66,6 +66,8 @@ private function __construct() {} * Quicktags using an array. Default true. * } * @return array Parsed arguments array. + * + * @phpstan-impure */ public static function parse_settings( $editor_id, $settings ) { @@ -155,6 +157,8 @@ public static function parse_settings( $editor_id, $settings ) { * @param string $editor_id HTML ID for the textarea and TinyMCE and Quicktags instances. * Should not contain square brackets. * @param array $settings See _WP_Editors::parse_settings() for description. + * + * @phpstan-impure */ public static function editor( $content, $editor_id, $settings = array() ) { $set = self::parse_settings( $editor_id, $settings ); @@ -317,6 +321,8 @@ public static function editor( $content, $editor_id, $settings = array() ) { * * @param string $editor_id Unique editor identifier, e.g. 'content'. * @param array $set Array of editor arguments. + * + * @phpstan-impure */ public static function editor_settings( $editor_id, $set ) { if ( empty( self::$first_init ) ) { @@ -1034,6 +1040,8 @@ public static function print_default_editor_scripts() { * @since 4.8.0 * * @return string + * + * @phpstan-impure */ public static function get_mce_locale() { if ( empty( self::$mce_locale ) ) { @@ -1050,6 +1058,8 @@ public static function get_mce_locale() { * @since 4.8.0 * * @return string + * + * @phpstan-impure */ public static function get_baseurl() { if ( empty( self::$baseurl ) ) { @@ -1135,6 +1145,8 @@ private static function default_settings() { * @since 4.7.0 * * @return array + * + * @phpstan-impure */ private static function get_translation() { if ( empty( self::$translation ) ) { @@ -1549,6 +1561,8 @@ public static function force_uncompressed_tinymce() { * Print (output) the main TinyMCE scripts. * * @since 4.8.0 + * + * @phpstan-impure */ public static function print_tinymce_scripts() { if ( self::$tinymce_scripts_printed ) { @@ -1860,6 +1874,8 @@ public static function wp_link_query( $args = array() ) { * Dialog for internal linking. * * @since 3.1.0 + * + * @phpstan-impure */ public static function wp_link_dialog() { // Run once. diff --git a/src/wp-includes/class-wp-embed.php b/src/wp-includes/class-wp-embed.php index bf13f187dfbe9..12774a964cbbf 100644 --- a/src/wp-includes/class-wp-embed.php +++ b/src/wp-includes/class-wp-embed.php @@ -58,6 +58,8 @@ public function __construct() { * * @param string $content Content to parse. * @return string Content with shortcode parsed. + * + * @phpstan-impure */ public function run_shortcode( $content ) { global $shortcode_tags; @@ -109,6 +111,8 @@ public function maybe_run_ajax_cache() { * @param int $priority Optional. Used to specify the order in which the registered handlers will be tested. * Lower numbers correspond with earlier testing, and handlers with the same priority are * tested in the order in which they were added to the action. Default 10. + * + * @phpstan-impure */ public function register_handler( $id, $regex, $callback, $priority = 10 ) { $this->handlers[ $priority ][ $id ] = array( @@ -124,6 +128,8 @@ public function register_handler( $id, $regex, $callback, $priority = 10 ) { * * @param string $id The handler ID that should be removed. * @param int $priority Optional. The priority of the handler to be removed (default: 10). + * + * @phpstan-impure */ public function unregister_handler( $id, $priority = 10 ) { unset( $this->handlers[ $priority ][ $id ] ); @@ -192,6 +198,8 @@ public function get_embed_handler_html( $attr, $url ) { * @param string $url The URL attempting to be embedded. * @return string|false The embed HTML on success, otherwise the original URL. * `->maybe_make_link()` can return false on failure. + * + * @phpstan-impure */ public function shortcode( $attr, $url = '' ) { $post = get_post(); @@ -400,6 +408,8 @@ public function delete_oembed_caches( $post_id ) { * Triggers a caching of all oEmbed results. * * @param int $post_id Post ID to do the caching for. + * + * @phpstan-impure */ public function cache_oembed( $post_id ) { $post = get_post( $post_id ); @@ -459,6 +469,8 @@ public function autoembed( $content ) { * * @param array $matches A regex match array. * @return string The embed HTML on success, otherwise the original URL. + * + * @phpstan-impure */ public function autoembed_callback( $matches ) { $oldval = $this->linkifunknown; diff --git a/src/wp-includes/class-wp-entity-actions-registry.php b/src/wp-includes/class-wp-entity-actions-registry.php index 664819e078add..322020a6ddcc2 100644 --- a/src/wp-includes/class-wp-entity-actions-registry.php +++ b/src/wp-includes/class-wp-entity-actions-registry.php @@ -110,6 +110,8 @@ class WP_Entity_Actions_Registry { * @since 7.2.0 * * @return WP_Entity_Actions_Registry The registry. + * + * @phpstan-impure */ public static function get_instance() { if ( null === self::$instance ) { @@ -151,6 +153,8 @@ public static function get_instance() { * call. Empty when none is, when called outside the * `wp_entity_actions_api_init` action, or when an argument is * invalid. + * + * @phpstan-impure */ public function register( $origin, $kind, $name, $actions, $script_module = null ) { if ( ! $this->validate_arguments( __METHOD__, $origin, $kind, $name, $actions, $script_module ) ) { @@ -315,6 +319,8 @@ protected function report_invalid_values( $method, $kind, $name, $actions ) { * Empty when none of the actions is registered, when * called outside the `wp_entity_actions_api_init` action, or * when the entity is invalid. + * + * @phpstan-impure */ public function unregister( $kind, $name, $ids = null ) { if ( ! $this->doing_entity_actions_api_init( __METHOD__ ) || ! $this->validate_entity( __METHOD__, $kind, $name ) ) { @@ -472,6 +478,8 @@ static function ( $modules ) { * doing_action() check for the reads made while it runs. * * @since 7.2.0 + * + * @phpstan-impure */ protected function initialize() { if ( $this->initialized ) { @@ -713,6 +721,8 @@ protected function skip_invalid_ids( $method, $kind, $name, $ids ) { * @param string $name The entity name. * @param string[] $ids The ids of the actions. * @param string|null $script_module The id of the script module, if any. + * + * @phpstan-impure */ protected function add_action_module( $kind, $name, $ids, $script_module ) { if ( null === $script_module ) { @@ -737,6 +747,8 @@ protected function add_action_module( $kind, $name, $ids, $script_module ) { * * @param string $kind The entity kind. * @param string $name The entity name. + * + * @phpstan-impure */ protected function forget_empty_entity( $kind, $name ) { if ( empty( $this->actions[ $kind ][ $name ] ) ) { diff --git a/src/wp-includes/class-wp-entity-fields-registry.php b/src/wp-includes/class-wp-entity-fields-registry.php index 864828ca1c243..93665d3ab906c 100644 --- a/src/wp-includes/class-wp-entity-fields-registry.php +++ b/src/wp-includes/class-wp-entity-fields-registry.php @@ -84,6 +84,8 @@ class WP_Entity_Fields_Registry { * @since 7.2.0 * * @return WP_Entity_Fields_Registry The registry. + * + * @phpstan-impure */ public static function get_instance() { if ( null === self::$instance ) { @@ -123,6 +125,8 @@ public static function get_instance() { * call. Empty when none is, when called outside the * `wp_entity_fields_api_init` action, or when an argument is * invalid. + * + * @phpstan-impure */ public function register( $origin, $kind, $name, $fields, $script_module = null ) { if ( ! $this->validate_arguments( __METHOD__, $origin, $kind, $name, $fields, $script_module ) ) { @@ -230,6 +234,8 @@ public function register( $origin, $kind, $name, $fields, $script_module = null * call. Empty when none is, when called outside the * `wp_entity_fields_api_init` action, or when an argument is * invalid. + * + * @phpstan-impure */ public function update( $origin, $kind, $name, $fields, $script_module = null ) { if ( ! $this->validate_arguments( __METHOD__, $origin, $kind, $name, $fields, $script_module ) ) { @@ -308,6 +314,8 @@ public function update( $origin, $kind, $name, $fields, $script_module = null ) * Empty when none of the fields is registered, when * called outside the `wp_entity_fields_api_init` action, or when * the entity is invalid. + * + * @phpstan-impure */ public function unregister( $kind, $name, $ids = null ) { if ( ! $this->doing_entity_fields_api_init( __METHOD__ ) || ! $this->validate_entity( __METHOD__, $kind, $name ) ) { @@ -551,6 +559,8 @@ static function ( $modules ) { * doing_action() check for the reads made while it runs. * * @since 7.2.0 + * + * @phpstan-impure */ protected function initialize() { if ( $this->initialized ) { @@ -1017,6 +1027,8 @@ protected static function require_file( $file ) { * @param string $name The entity name. * @param string[] $ids The ids of the fields. * @param string|null $script_module The id of the script module, if any. + * + * @phpstan-impure */ protected function add_field_module( $kind, $name, $ids, $script_module ) { if ( null === $script_module ) { @@ -1041,6 +1053,8 @@ protected function add_field_module( $kind, $name, $ids, $script_module ) { * * @param string $kind The entity kind. * @param string $name The entity name. + * + * @phpstan-impure */ protected function forget_empty_entity( $kind, $name ) { if ( empty( $this->fields[ $kind ][ $name ] ) ) { diff --git a/src/wp-includes/class-wp-hook.php b/src/wp-includes/class-wp-hook.php index e1ead15a8d213..329e66e54ac14 100644 --- a/src/wp-includes/class-wp-hook.php +++ b/src/wp-includes/class-wp-hook.php @@ -87,6 +87,8 @@ final class WP_Hook implements Iterator, ArrayAccess { * and functions with the same priority are executed in the order * in which they were added to the filter. * @param int $accepted_args The number of arguments the function accepts. + * + * @phpstan-impure */ public function add_filter( $hook_name, $callback, $priority, $accepted_args ) { if ( null === $priority ) { @@ -126,6 +128,8 @@ public function add_filter( $hook_name, $callback, $priority, $accepted_args ) { * for no priority being added. * @param bool $priority_existed Optional. Flag for whether the priority already existed before the new * filter was added. Default false. + * + * @phpstan-impure */ private function resort_active_iterations( $new_priority = false, $priority_existed = false ) { $new_priorities = $this->priorities; @@ -202,6 +206,8 @@ private function resort_active_iterations( $new_priority = false, $priority_exis * @param int $priority The exact priority used when adding the original filter callback. * @return bool Whether the callback existed before it was removed. * @phpstan-param callable|string|array{0: string|object, 1: string} $callback + * + * @phpstan-impure */ public function remove_filter( $hook_name, $callback, $priority ) { if ( null === $priority ) { @@ -305,6 +311,8 @@ public function has_filters() { * @since 4.7.0 * * @param int|false $priority Optional. The priority number to remove. Default false. + * + * @phpstan-impure */ public function remove_all_filters( $priority = false ) { if ( ! $this->callbacks ) { @@ -335,6 +343,8 @@ public function remove_all_filters( $priority = false ) { * at index 0. When called for an action by WP_Hook::do_action(), * it contains only the action arguments. * @return mixed The filtered value after all hooked functions are applied to it. + * + * @phpstan-impure */ public function apply_filters( $value, $args ) { if ( ! $this->callbacks ) { @@ -387,6 +397,8 @@ public function apply_filters( $value, $args ) { * @since 4.7.0 * * @param list $args Parameters to pass to the callback functions. + * + * @phpstan-impure */ public function do_action( $args ) { $this->doing_action = true; @@ -404,6 +416,8 @@ public function do_action( $args ) { * @since 4.7.0 * * @param list $args Arguments to pass to the hook callbacks. Passed by reference. + * + * @phpstan-impure */ public function do_all_hook( &$args ) { $nesting_level = $this->nesting_level++; diff --git a/src/wp-includes/class-wp-http-curl.php b/src/wp-includes/class-wp-http-curl.php index 4296bf42f2b00..b02c2ab609176 100644 --- a/src/wp-includes/class-wp-http-curl.php +++ b/src/wp-includes/class-wp-http-curl.php @@ -69,6 +69,8 @@ class WP_Http_Curl { * @param string $url The request URL. * @param string|array $args Optional. Override the defaults. * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error + * + * @phpstan-impure */ public function request( $url, $args = array() ) { $defaults = array( @@ -369,6 +371,8 @@ public function request( $url, $args = array() ) { * @param resource $handle cURL handle. * @param string $headers cURL request headers. * @return int Length of the request headers. + * + * @phpstan-impure */ private function stream_headers( $handle, $headers ) { $this->headers .= $headers; @@ -387,6 +391,8 @@ private function stream_headers( $handle, $headers ) { * @param resource $handle cURL handle. * @param string $data cURL request body. * @return int Total bytes of data written. + * + * @phpstan-impure */ private function stream_body( $handle, $data ) { $data_length = strlen( $data ); diff --git a/src/wp-includes/class-wp-http-response.php b/src/wp-includes/class-wp-http-response.php index d9d8d871c4bcd..8977ce9814e41 100644 --- a/src/wp-includes/class-wp-http-response.php +++ b/src/wp-includes/class-wp-http-response.php @@ -74,6 +74,8 @@ public function get_headers() { * @since 4.4.0 * * @param array $headers Map of header name to header value. + * + * @phpstan-impure */ public function set_headers( $headers ) { $this->headers = $headers; @@ -88,6 +90,8 @@ public function set_headers( $headers ) { * @param string $value Header value. * @param bool $replace Optional. Whether to replace an existing header of the same name. * Default true. + * + * @phpstan-impure */ public function header( $key, $value, $replace = true ) { if ( $replace || ! isset( $this->headers[ $key ] ) ) { @@ -118,6 +122,8 @@ public function get_status() { * @param int $code HTTP status. * * @phpstan-param int<100, 599> $code + * + * @phpstan-impure */ public function set_status( $code ) { $this->status = absint( $code ); @@ -140,6 +146,8 @@ public function get_data() { * @since 4.4.0 * * @param mixed $data Response data. + * + * @phpstan-impure */ public function set_data( $data ) { $this->data = $data; diff --git a/src/wp-includes/class-wp-icon-collections-registry.php b/src/wp-includes/class-wp-icon-collections-registry.php index e7e19d02b19e0..b2d0a071916a1 100644 --- a/src/wp-includes/class-wp-icon-collections-registry.php +++ b/src/wp-includes/class-wp-icon-collections-registry.php @@ -53,6 +53,8 @@ class WP_Icon_Collections_Registry { * @return bool True if the collection was registered successfully, false otherwise. * * @phpstan-param lowercase-string&non-empty-string $collection_slug + * + * @phpstan-impure */ public function register( $collection_slug, $collection_properties ) { if ( ! isset( $collection_slug ) || ! is_string( $collection_slug ) ) { @@ -159,6 +161,8 @@ public function register( $collection_slug, $collection_properties ) { * * @param string $collection_slug Icon collection slug. * @return bool True if the collection was unregistered successfully, false otherwise. + * + * @phpstan-impure */ public function unregister( $collection_slug ) { if ( ! $this->is_registered( $collection_slug ) ) { @@ -233,6 +237,8 @@ public function is_registered( $collection_slug ) { * @since 7.1.0 * * @return WP_Icon_Collections_Registry The main instance. + * + * @phpstan-impure */ public static function get_instance() { self::$instance ??= new self(); diff --git a/src/wp-includes/class-wp-icons-registry.php b/src/wp-includes/class-wp-icons-registry.php index 1140d0784af3b..2f7c2fd023d35 100644 --- a/src/wp-includes/class-wp-icons-registry.php +++ b/src/wp-includes/class-wp-icons-registry.php @@ -82,6 +82,8 @@ protected function __construct() {} * @return bool True if the icon was registered with success and false otherwise. * * @phpstan-param lowercase-string&non-falsy-string $icon_name + * + * @phpstan-impure */ public function register( $icon_name, $icon_properties ) { if ( ! isset( $icon_name ) || ! is_string( $icon_name ) ) { @@ -251,6 +253,8 @@ public function register( $icon_name, $icon_properties ) { * @param string $icon_name Namespaced icon name in the form "collection/icon-name" * (e.g. "core/arrow-left"). * @return bool True if the icon was unregistered successfully, false otherwise. + * + * @phpstan-impure */ public function unregister( $icon_name ) { if ( ! $this->is_registered( $icon_name ) ) { @@ -379,6 +383,8 @@ protected function sanitize_icon_content( $icon_content ) { * * @param string $icon_name Icon name including namespace. * @return string|null The content of the icon, if found. + * + * @phpstan-impure */ protected function get_content( $icon_name ) { if ( ! isset( $this->registered_icons[ $icon_name ]['content'] ) ) { @@ -426,6 +432,8 @@ protected function get_content( $icon_name ) { * * @param string $icon_path Icon file path, resolved with `realpath()`. * @return bool Whether the file is in the core icon library. + * + * @phpstan-impure */ private function is_core_icon_file( $icon_path ) { if ( null === $this->core_icon_library_directory ) { @@ -535,6 +543,8 @@ public function is_registered( $icon_name ) { * @return string|null Namespaced name of the replacement icon, such as `core-admin/pin`, * or null if the Dashicon has no replacement or the replacement * is not registered. + * + * @phpstan-impure */ public function get_admin_icon_name_for_dashicon( $dashicon ) { if ( ! is_string( $dashicon ) ) { @@ -574,6 +584,8 @@ public function get_admin_icon_name_for_dashicon( $dashicon ) { * @since 7.0.0 * * @return WP_Icons_Registry The main instance. + * + * @phpstan-impure */ public static function get_instance() { self::$instance ??= new self(); diff --git a/src/wp-includes/class-wp-image-editor-gd.php b/src/wp-includes/class-wp-image-editor-gd.php index 10eed8178b938..9dd5b25424335 100644 --- a/src/wp-includes/class-wp-image-editor-gd.php +++ b/src/wp-includes/class-wp-image-editor-gd.php @@ -86,6 +86,8 @@ public static function supports_mime_type( $mime_type ) { * @since 3.5.0 * * @return true|WP_Error True if loaded successfully; WP_Error on failure. + * + * @phpstan-impure */ public function load() { if ( $this->image ) { @@ -181,6 +183,8 @@ protected function update_size( $width = null, $height = null ) { * @type string $1 The y crop position. Accepts 'top', 'center', or 'bottom'. * } * @return true|WP_Error + * + * @phpstan-impure */ public function resize( $max_w, $max_h, $crop = false ) { if ( ( $this->size['width'] === $max_w ) && ( $this->size['height'] === $max_h ) ) { @@ -304,6 +308,8 @@ public function multi_resize( $sizes ) { * } * @return array|WP_Error The image data array for inclusion in the `sizes` array in the image meta, * WP_Error object on error. + * + * @phpstan-impure */ public function make_subsize( $size_data ) { if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) { @@ -350,6 +356,8 @@ public function make_subsize( $size_data ) { * @param int $dst_h Optional. The destination height. * @param bool $src_abs Optional. If the source crop points are absolute. * @return true|WP_Error + * + * @phpstan-impure */ public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) { /* @@ -404,6 +412,8 @@ public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = nu * * @param float $angle * @return true|WP_Error + * + * @phpstan-impure */ public function rotate( $angle ) { if ( function_exists( 'imagerotate' ) ) { @@ -510,6 +520,8 @@ public function flip( $horz, $vert ) { * @type string $mime-type The mime type of the image. * @type int $filesize File size of the image. * } + * + * @phpstan-impure */ public function save( $destfilename = null, $mime_type = null ) { $saved = $this->_save( $this->image, $destfilename, $mime_type ); @@ -623,6 +635,8 @@ protected function _save( $image, $filename = null, $mime_type = null ) { * @param int $quality Compression Quality. Range: [1,100] * @param array $dims Optional. Image dimensions array with 'width' and 'height' keys. * @return true|WP_Error True if set successfully; WP_Error on failure. + * + * @phpstan-impure */ public function set_quality( $quality = null, $dims = array() ) { $quality_result = parent::set_quality( $quality, $dims ); diff --git a/src/wp-includes/class-wp-image-editor-imagick.php b/src/wp-includes/class-wp-image-editor-imagick.php index 0be31905eae81..1209f8b08a5c4 100644 --- a/src/wp-includes/class-wp-image-editor-imagick.php +++ b/src/wp-includes/class-wp-image-editor-imagick.php @@ -146,6 +146,8 @@ public static function supports_mime_type( $mime_type ) { * @since 3.5.0 * * @return true|WP_Error True if loaded; WP_Error on failure. + * + * @phpstan-impure */ public function load() { if ( $this->image instanceof Imagick ) { @@ -866,6 +868,8 @@ public function multi_resize( $sizes ) { * } * @return array|WP_Error The image data array for inclusion in the `sizes` array in the image meta, * WP_Error object on error. + * + * @phpstan-impure */ public function make_subsize( $size_data ) { if ( ! isset( $size_data['width'] ) && ! isset( $size_data['height'] ) ) { @@ -1057,6 +1061,8 @@ public function maybe_exif_rotate() { * @type string $mime-type The mime type of the image. * @type int $filesize File size of the image. * } + * + * @phpstan-impure */ public function save( $destfilename = null, $mime_type = null ) { $saved = $this->_save( $this->image, $destfilename, $mime_type ); diff --git a/src/wp-includes/class-wp-image-editor.php b/src/wp-includes/class-wp-image-editor.php index df07c4229b623..9740b19aad50d 100644 --- a/src/wp-includes/class-wp-image-editor.php +++ b/src/wp-includes/class-wp-image-editor.php @@ -204,6 +204,8 @@ public function get_size() { * @param int|null $width Image width. * @param int|null $height Image height. * @return true + * + * @phpstan-impure */ protected function update_size( $width = null, $height = null ) { $this->size = array( @@ -238,6 +240,8 @@ public function get_quality() { * @param array $dims Optional. Image dimensions array with 'width' and 'height' keys. * @return true|WP_Error True if set successfully; WP_Error on failure. + * + * @phpstan-impure */ public function set_quality( $quality = null, $dims = array() ) { // Use the output mime type if present. If not, fall back to the input/initial mime type. @@ -340,6 +344,8 @@ protected function get_default_quality( $mime_type ) { * @param string $filename * @param string $mime_type * @return array { filename|null, extension, mime-type } + * + * @phpstan-impure */ protected function get_output_format( $filename = null, $mime_type = null ) { $new_ext = null; diff --git a/src/wp-includes/class-wp-list-util.php b/src/wp-includes/class-wp-list-util.php index da12a2d1a51aa..b9116b3fed93d 100644 --- a/src/wp-includes/class-wp-list-util.php +++ b/src/wp-includes/class-wp-list-util.php @@ -96,6 +96,8 @@ public function get_output() { * @return array Array of found values. * * @phpstan-param 'and'|'AND'|'or'|'OR'|'not'|'NOT' $operator + * + * @phpstan-impure */ public function filter( $args = array(), $operator = 'and' ) { if ( empty( $args ) ) { @@ -156,6 +158,8 @@ public function filter( $args = array(), $operator = 'and' ) { * @return array Array of found values. If `$index_key` is set, an array of found values with keys * corresponding to `$index_key`. If `$index_key` is null, array keys from the original * `$list` will be preserved in the results. + * + * @phpstan-impure */ public function pluck( $field, $index_key = null ) { $newlist = array(); @@ -227,6 +231,8 @@ public function pluck( $field, $index_key = null ) { * is a string. Default 'ASC'. * @param bool $preserve_keys Optional. Whether to preserve keys. Default false. * @return array The sorted array. + * + * @phpstan-impure */ public function sort( $orderby = array(), $order = 'ASC', $preserve_keys = false ) { if ( empty( $orderby ) ) { diff --git a/src/wp-includes/class-wp-locale-switcher.php b/src/wp-includes/class-wp-locale-switcher.php index 05fbc07a903df..cfa41a3174f8d 100644 --- a/src/wp-includes/class-wp-locale-switcher.php +++ b/src/wp-includes/class-wp-locale-switcher.php @@ -71,6 +71,8 @@ public function init() { * @param string $locale The locale to switch to. * @param int|false $user_id Optional. User ID as context. Default false. * @return bool True on success, false on failure. + * + * @phpstan-impure */ public function switch_to_locale( $locale, $user_id = false ) { $current_locale = determine_locale(); @@ -157,6 +159,8 @@ public function restore_previous_locale() { * @since 4.7.0 * * @return string|false Locale on success, false on failure. + * + * @phpstan-impure */ public function restore_current_locale() { if ( empty( $this->stack ) ) { @@ -276,6 +280,8 @@ private function load_translations( $locale ) { * @global PHPMailer\PHPMailer\PHPMailer $phpmailer * * @param string $locale The locale to change to. + * + * @phpstan-impure */ private function change_locale( $locale ) { global $wp_locale, $phpmailer; diff --git a/src/wp-includes/class-wp-locale.php b/src/wp-includes/class-wp-locale.php index cd022fdaf9c83..007cf20413ac5 100644 --- a/src/wp-includes/class-wp-locale.php +++ b/src/wp-includes/class-wp-locale.php @@ -142,6 +142,8 @@ public function __construct() { * @since 2.1.0 * * @global string $text_direction + * + * @phpstan-impure */ public function init() { // The weekdays. @@ -393,6 +395,8 @@ public function get_meridiem( $meridiem ) { * @global array $weekday_abbrev * @global array $month * @global array $month_abbrev + * + * @phpstan-impure */ public function register_globals() { $GLOBALS['weekday'] = $this->weekday; diff --git a/src/wp-includes/class-wp-meta-query.php b/src/wp-includes/class-wp-meta-query.php index 67e2d3d27ee0b..ccd82c9216a8c 100644 --- a/src/wp-includes/class-wp-meta-query.php +++ b/src/wp-includes/class-wp-meta-query.php @@ -188,6 +188,8 @@ public function __construct( $meta_query = array() ) { * * @param array $queries Array of query clauses. * @return array Sanitized array of query clauses. + * + * @phpstan-impure */ public function sanitize_query( $queries ) { $clean_queries = array(); @@ -353,6 +355,8 @@ public function get_cast_for_type( $type = '' ) { * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } + * + * @phpstan-impure */ public function get_sql( $type, $primary_table, $primary_id_column, $context = null ) { $meta_table = _get_meta_table( $type ); @@ -529,6 +533,8 @@ protected function get_sql_for_query( &$query, $depth = 0 ) { * @type string[] $join Array of SQL fragments to append to the main JOIN clause. * @type string[] $where Array of SQL fragments to append to the main WHERE clause. * } + * + * @phpstan-impure */ public function get_sql_for_clause( &$clause, $parent_query, $clause_key = '' ) { global $wpdb; diff --git a/src/wp-includes/class-wp-metadata-lazyloader.php b/src/wp-includes/class-wp-metadata-lazyloader.php index 2725cbfee32c6..7286961e6a82a 100644 --- a/src/wp-includes/class-wp-metadata-lazyloader.php +++ b/src/wp-includes/class-wp-metadata-lazyloader.php @@ -76,6 +76,8 @@ public function __construct() { * @param string $object_type Type of object whose meta is to be lazy-loaded. Accepts 'term' or 'comment'. * @param array $object_ids Array of object IDs. * @return void|WP_Error WP_Error on failure. + * + * @phpstan-impure */ public function queue_objects( $object_type, $object_ids ) { if ( ! isset( $this->settings[ $object_type ] ) ) { @@ -112,6 +114,8 @@ public function queue_objects( $object_type, $object_ids ) { * * @param string $object_type Object type. Accepts 'comment' or 'term'. * @return void|WP_Error WP_Error on failure. + * + * @phpstan-impure */ public function reset_queue( $object_type ) { if ( ! isset( $this->settings[ $object_type ] ) ) { diff --git a/src/wp-includes/class-wp-network-query.php b/src/wp-includes/class-wp-network-query.php index a7c747798f930..05835f4cb4fe9 100644 --- a/src/wp-includes/class-wp-network-query.php +++ b/src/wp-includes/class-wp-network-query.php @@ -155,6 +155,8 @@ public function __construct( $query = '' ) { * @since 4.6.0 * * @param string|array $query WP_Network_Query arguments. See WP_Network_Query::__construct() for accepted arguments. + * + * @phpstan-impure */ public function parse_query( $query = '' ) { if ( empty( $query ) ) { @@ -187,6 +189,8 @@ public function parse_query( $query = '' ) { * $query is array{ fields: 'ids', ... } ? int[] : array * ) * ) + * + * @phpstan-impure */ public function query( $query ) { $this->query_vars = wp_parse_args( $query ); @@ -200,6 +204,8 @@ public function query( $query ) { * * @return WP_Network[]|int[]|int List of WP_Network objects, a list of network IDs when 'fields' is set * to 'ids', or the number of networks when 'count' is passed as a query var. + * + * @phpstan-impure */ public function get_networks() { $this->parse_query(); @@ -338,6 +344,8 @@ public function get_networks() { * @global wpdb $wpdb WordPress database abstraction object. * * @return int|array A single count of network IDs if a count query. An array of network IDs if a full query. + * + * @phpstan-impure */ protected function get_network_ids() { global $wpdb; @@ -531,6 +539,8 @@ protected function get_network_ids() { * @since 4.6.0 * * @global wpdb $wpdb WordPress database abstraction object. + * + * @phpstan-impure */ private function set_found_networks() { global $wpdb; diff --git a/src/wp-includes/class-wp-network.php b/src/wp-includes/class-wp-network.php index b9f6b01f2938a..3bcc0606c6a07 100644 --- a/src/wp-includes/class-wp-network.php +++ b/src/wp-includes/class-wp-network.php @@ -202,6 +202,8 @@ public function __isset( $key ) { * * @param string $key Property to set. * @param mixed $value Value to assign to the property. + * + * @phpstan-impure */ public function __set( $key, $value ) { switch ( $key ) { @@ -226,6 +228,8 @@ public function __set( $key, $value ) { * @since 4.9.0 * * @return int The ID of the main site. + * + * @phpstan-impure */ private function get_main_site_id() { /** @@ -296,6 +300,8 @@ private function get_main_site_id() { * Sets the site name assigned to the network if one has not been populated. * * @since 4.4.0 + * + * @phpstan-impure */ private function _set_site_name() { if ( ! empty( $this->site_name ) ) { @@ -313,6 +319,8 @@ private function _set_site_name() { * @todo What if the domain of the network doesn't match the current site? * * @since 4.4.0 + * + * @phpstan-impure */ private function _set_cookie_domain() { if ( ! empty( $this->cookie_domain ) ) { diff --git a/src/wp-includes/class-wp-object-cache.php b/src/wp-includes/class-wp-object-cache.php index 443af49e3112d..f4eeedfa9cf01 100644 --- a/src/wp-includes/class-wp-object-cache.php +++ b/src/wp-includes/class-wp-object-cache.php @@ -103,6 +103,8 @@ public function __get( $name ) { * * @param string $name Property to set. * @param mixed $value Property value. + * + * @phpstan-impure */ public function __set( $name, $value ) { $this->$name = $value; @@ -299,6 +301,8 @@ public function replace( $key, $data, $group = 'default', $expire = 0 ) { * @param string $group Optional. Where to group the cache contents. Default 'default'. * @param int $expire Optional. Not used. * @return bool True if contents were set, false if key is invalid. + * + * @phpstan-impure */ public function set( $key, $data, $group = 'default', $expire = 0 ) { if ( ! $this->is_valid_key( $key ) ) { @@ -360,6 +364,8 @@ public function set_multiple( array $data, $group = '', $expire = 0 ) { * @param bool|null $found Optional. Whether the key was found in the cache (passed by reference). * Disambiguates a return of false, a storable value. Default null. * @return mixed|false The cache contents on success, false on failure to retrieve contents. + * + * @phpstan-impure */ public function get( $key, $group = 'default', $force = false, &$found = null ) { if ( ! $this->is_valid_key( $key ) ) { @@ -424,6 +430,8 @@ public function get_multiple( $keys, $group = 'default', $force = false ) { * @return bool True on success, false if the contents were not deleted. * * @phpstan-param false $deprecated + * + * @phpstan-impure */ public function delete( $key, $group = 'default', $deprecated = false ) { if ( ! $this->is_valid_key( $key ) ) { @@ -476,6 +484,8 @@ public function delete_multiple( array $keys, $group = '' ) { * Default 1. * @param string $group Optional. The group the key is in. Default 'default'. * @return int|false The item's new value on success, false on failure. + * + * @phpstan-impure */ public function incr( $key, $offset = 1, $group = 'default' ) { if ( ! $this->is_valid_key( $key ) ) { @@ -519,6 +529,8 @@ public function incr( $key, $offset = 1, $group = 'default' ) { * Default 1. * @param string $group Optional. The group the key is in. Default 'default'. * @return int|false The item's new value on success, false on failure. + * + * @phpstan-impure */ public function decr( $key, $offset = 1, $group = 'default' ) { if ( ! $this->is_valid_key( $key ) ) { @@ -558,6 +570,8 @@ public function decr( $key, $offset = 1, $group = 'default' ) { * @since 2.0.0 * * @return true Always returns true. + * + * @phpstan-impure */ public function flush() { $this->cache = array(); @@ -572,6 +586,8 @@ public function flush() { * * @param string $group Name of group to remove from cache. * @return true Always returns true. + * + * @phpstan-impure */ public function flush_group( $group ) { unset( $this->cache[ $group ] ); @@ -585,6 +601,8 @@ public function flush_group( $group ) { * @since 3.0.0 * * @param string|string[] $groups List of groups that are global. + * + * @phpstan-impure */ public function add_global_groups( $groups ) { $groups = (array) $groups; @@ -601,6 +619,8 @@ public function add_global_groups( $groups ) { * @since 3.5.0 * * @param int $blog_id Blog ID. + * + * @phpstan-impure */ public function switch_to_blog( $blog_id ) { $blog_id = (int) $blog_id; @@ -614,6 +634,8 @@ public function switch_to_blog( $blog_id ) { * * @deprecated 3.5.0 Use WP_Object_Cache::switch_to_blog() * @see switch_to_blog() + * + * @phpstan-impure */ public function reset() { _deprecated_function( __FUNCTION__, '3.5.0', 'WP_Object_Cache::switch_to_blog()' ); diff --git a/src/wp-includes/class-wp-oembed.php b/src/wp-includes/class-wp-oembed.php index 0ede8300f5a89..838f95a8faae3 100644 --- a/src/wp-includes/class-wp-oembed.php +++ b/src/wp-includes/class-wp-oembed.php @@ -364,6 +364,8 @@ public function get_provider( $url, $args = '' ) { * @param string $provider The URL to the oEmbed provider.. * @param bool $regex Optional. Whether the $format parameter is in a regex format. * Default false. + * + * @phpstan-impure */ public static function _add_provider_early( $format, $provider, $regex = false ) { if ( empty( self::$early_providers['add'] ) ) { @@ -387,6 +389,8 @@ public static function _add_provider_early( $format, $provider, $regex = false ) * * @param string $format The format of URL that this provider can handle. You can use * asterisks as wildcards. + * + * @phpstan-impure */ public static function _remove_provider_early( $format ) { if ( empty( self::$early_providers['remove'] ) ) { diff --git a/src/wp-includes/class-wp-phpmailer.php b/src/wp-includes/class-wp-phpmailer.php index 34747d295da6e..ccb9c587c9bf7 100644 --- a/src/wp-includes/class-wp-phpmailer.php +++ b/src/wp-includes/class-wp-phpmailer.php @@ -35,6 +35,8 @@ public function __construct( $exceptions = false ) { * @param string $langcode Optional. Unused. ISO 639-1 2-character language code. Default 'en'. * @param string $lang_path Optional. Unused. Path to the language file directory. Default empty string. * @return true Always returns true. + * + * @phpstan-impure */ public static function setLanguage( $langcode = 'en', $lang_path = '' ) { static::$language = array( diff --git a/src/wp-includes/class-wp-plugin-dependencies.php b/src/wp-includes/class-wp-plugin-dependencies.php index c96b98d08b550..d6273b6d2dd1e 100644 --- a/src/wp-includes/class-wp-plugin-dependencies.php +++ b/src/wp-includes/class-wp-plugin-dependencies.php @@ -117,6 +117,8 @@ class WP_Plugin_Dependencies { * Initializes by fetching plugin header and plugin API data. * * @since 6.5.0 + * + * @phpstan-impure */ public static function initialize() { if ( false === self::$initialized ) { @@ -531,6 +533,8 @@ function ( $dependency ) { * @since 6.5.0 * * @return array An array of plugin data. + * + * @phpstan-impure */ protected static function get_plugins() { if ( is_array( self::$plugins ) ) { @@ -547,6 +551,8 @@ protected static function get_plugins() { * Reads and stores dependency slugs from a plugin's 'Requires Plugins' header. * * @since 6.5.0 + * + * @phpstan-impure */ protected static function read_dependencies_from_plugin_headers() { self::$dependencies = array(); @@ -613,6 +619,8 @@ protected static function sanitize_dependency_slugs( $slugs ) { * @since 6.5.0 * * @return array An array of install dependencies filepaths, relative to the plugins directory. + * + * @phpstan-impure */ protected static function get_dependency_filepaths() { if ( is_array( self::$dependency_filepaths ) ) { @@ -646,6 +654,8 @@ protected static function get_dependency_filepaths() { * @global string $pagenow The filename of the current screen. * * @return array|null An array of dependency API data, or null on early exit. + * + * @phpstan-impure */ protected static function get_dependency_api_data() { global $pagenow; @@ -730,6 +740,8 @@ protected static function get_dependency_api_data() { * @since 6.5.0 * * @return array An array of plugin directory names. + * + * @phpstan-impure */ protected static function get_plugin_dirnames() { if ( is_array( self::$plugin_dirnames ) ) { @@ -753,6 +765,8 @@ protected static function get_plugin_dirnames() { * @since 6.5.0 * * @return array[] An array of circular dependency pairings. + * + * @phpstan-impure */ protected static function get_circular_dependencies() { if ( is_array( self::$circular_dependencies_pairs ) ) { @@ -791,6 +805,8 @@ protected static function get_circular_dependencies() { * @param array $dependents Array of dependent plugins. * @param array $dependencies Array of plugins dependencies. * @return array A circular dependency pairing, or an empty array if none exists. + * + * @phpstan-impure */ protected static function check_for_circular_dependencies( $dependents, $dependencies ) { $circular_dependencies_pairs = array(); diff --git a/src/wp-includes/class-wp-post-type.php b/src/wp-includes/class-wp-post-type.php index 0767deeb34162..76293d2a05e85 100644 --- a/src/wp-includes/class-wp-post-type.php +++ b/src/wp-includes/class-wp-post-type.php @@ -512,6 +512,8 @@ public function __construct( $post_type, $args = array() ) { * @since 4.6.0 * * @param array|string $args Array or string of arguments for registering a post type. + * + * @phpstan-impure */ public function set_props( $args ) { $args = wp_parse_args( $args ); @@ -690,6 +692,8 @@ public function set_props( $args ) { * Sets the features support for the post type. * * @since 4.6.0 + * + * @phpstan-impure */ public function add_supports() { if ( ! empty( $this->supports ) ) { @@ -802,6 +806,8 @@ public function register_taxonomies() { * @since 4.6.0 * * @global array $_wp_post_type_features Post type features. + * + * @phpstan-impure */ public function remove_supports() { global $_wp_post_type_features; @@ -818,6 +824,8 @@ public function remove_supports() { * * @global WP_Rewrite $wp_rewrite WordPress rewrite component. * @global WP $wp Current WordPress environment instance. + * + * @phpstan-impure */ public function remove_rewrite_rules() { global $wp, $wp_rewrite; @@ -879,6 +887,8 @@ public function remove_hooks() { * * @return WP_REST_Controller|null The controller instance, or null if the post type * is set not to show in rest. + * + * @phpstan-impure */ public function get_rest_controller() { if ( ! $this->show_in_rest ) { @@ -915,6 +925,8 @@ public function get_rest_controller() { * * @return WP_REST_Controller|null The controller instance, or null if the post type * is set not to show in rest. + * + * @phpstan-impure */ public function get_revisions_rest_controller() { if ( ! $this->show_in_rest ) { @@ -954,6 +966,8 @@ public function get_revisions_rest_controller() { * * @return WP_REST_Controller|null The controller instance, or null if the post type * is set not to show in rest. + * + * @phpstan-impure */ public function get_autosave_rest_controller() { if ( ! $this->show_in_rest ) { @@ -991,6 +1005,8 @@ public function get_autosave_rest_controller() { * @since 6.0.0 * * @return (string|null)[][] The default labels for post types. + * + * @phpstan-impure */ public static function get_default_labels() { if ( ! empty( self::$default_labels ) ) { @@ -1046,6 +1062,8 @@ public static function get_default_labels() { * Resets the cache for the default labels. * * @since 6.0.0 + * + * @phpstan-impure */ public static function reset_default_labels() { self::$default_labels = array(); diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index 56c1c4526de8f..0fc37118d137c 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -515,6 +515,8 @@ class WP_Query { * The query flags are what page info WordPress was able to figure out. * * @since 2.0.0 + * + * @phpstan-impure */ private function init_query_flags() { $this->is_single = false; @@ -553,6 +555,8 @@ private function init_query_flags() { * Initiates object properties and sets default values. * * @since 1.5.0 + * + * @phpstan-impure */ public function init() { unset( $this->posts ); @@ -821,6 +825,8 @@ public function fill_query_vars( $query_vars ) { * @type int $w The week number of the year. Default empty. Accepts numbers 1-53. * @type int $year The four-digit year. Default empty. Accepts any four-digit year. * } + * + * @phpstan-impure */ public function parse_query( $query = '' ) { if ( ! empty( $query ) ) { @@ -1190,6 +1196,8 @@ public function parse_query( $query = '' ) { * @since 3.1.0 * * @param array $query_vars The query variables. Passed by reference. + * + * @phpstan-impure */ public function parse_tax_query( &$query_vars ) { if ( ! empty( $query_vars['tax_query'] ) && is_array( $query_vars['tax_query'] ) ) { @@ -1604,6 +1612,8 @@ protected function parse_search_terms( $terms ) { * @since 3.7.0 * * @return string[] Stopwords. + * + * @phpstan-impure */ protected function get_search_stopwords() { if ( isset( $this->stopwords ) ) { @@ -1855,6 +1865,8 @@ protected function parse_order( $order ) { * Sets the 404 property and saves whether query is feed. * * @since 2.0.0 + * + * @phpstan-impure */ public function set_404() { $is_feed = $this->is_feed; @@ -1896,6 +1908,8 @@ public function get( $query_var, $default_value = '' ) { * * @param string $query_var Query variable key. * @param mixed $value Query variable value. + * + * @phpstan-impure */ public function set( $query_var, $value ) { $this->query_vars[ $query_var ] = $value; @@ -1917,6 +1931,8 @@ public function set( $query_var, $value ) { * @global wpdb $wpdb WordPress database abstraction object. * * @return WP_Post[]|int[] Array of post objects or post IDs. + * + * @phpstan-impure */ public function get_posts() { global $wpdb; @@ -3692,6 +3708,8 @@ public function get_posts() { * * @param array $query_vars Query variables. * @param string $limits LIMIT clauses of the query. + * + * @phpstan-impure */ private function set_found_posts( $query_vars, $limits ) { global $wpdb; @@ -3753,6 +3771,8 @@ private function set_found_posts( $query_vars, $limits ) { * @since 1.5.0 * * @return WP_Post Next post. + * + * @phpstan-impure */ public function next_post() { @@ -3772,6 +3792,8 @@ public function next_post() { * @since 1.5.0 * * @global WP_Post $post Global post object. + * + * @phpstan-impure */ public function the_post() { global $post; @@ -3887,6 +3909,8 @@ public function have_posts() { * Rewinds the posts and resets post index. * * @since 1.5.0 + * + * @phpstan-impure */ public function rewind_posts() { $this->current_post = -1; @@ -3901,6 +3925,8 @@ public function rewind_posts() { * @since 2.2.0 * * @return WP_Comment Comment object. + * + * @phpstan-impure */ public function next_comment() { ++$this->current_comment; @@ -3916,6 +3942,8 @@ public function next_comment() { * @since 2.2.0 * * @global WP_Comment $comment Global comment object. + * + * @phpstan-impure */ public function the_comment() { global $comment; @@ -3957,6 +3985,8 @@ public function have_comments() { * Rewinds the comments, resets the comment index and comment to first. * * @since 2.2.0 + * + * @phpstan-impure */ public function rewind_comments() { $this->current_comment = -1; @@ -3982,6 +4012,8 @@ public function rewind_comments() { * ? array * : WP_Post[] ) * ) + * + * @phpstan-impure */ public function query( $query ) { $this->init(); @@ -4000,6 +4032,8 @@ public function query( $query ) { * @since 1.5.0 * * @return WP_Term|WP_Post_Type|WP_Post|WP_User|null The queried object. + * + * @phpstan-impure */ public function get_queried_object() { if ( isset( $this->queried_object ) ) { @@ -4880,6 +4914,8 @@ public function is_main_query() { * * @param WP_Post|object|int $post WP_Post instance or Post ID/object. * @return bool True on success, false on failure. + * + * @phpstan-impure */ public function setup_postdata( $post ) { global $id, $authordata, $currentday, $currentmonth, $page, $pages, $multipage, $more, $numpages; @@ -5034,6 +5070,8 @@ public function generate_postdata( $post ) { * @param array $args Query arguments. * @param string $sql SQL statement. * @return string Cache key. + * + * @phpstan-impure */ protected function generate_cache_key( array $args, $sql ) { global $wpdb; @@ -5134,6 +5172,8 @@ static function ( &$value ) use ( $wpdb, $placeholder ) { * @since 3.7.0 * * @global WP_Post $post Global post object. + * + * @phpstan-impure */ public function reset_postdata() { if ( ! empty( $this->post ) ) { diff --git a/src/wp-includes/class-wp-recovery-mode.php b/src/wp-includes/class-wp-recovery-mode.php index 8ff172c425686..28aa5fd34d01c 100644 --- a/src/wp-includes/class-wp-recovery-mode.php +++ b/src/wp-includes/class-wp-recovery-mode.php @@ -88,6 +88,8 @@ public function __construct() { * Initialize recovery mode for the current request. * * @since 5.2.0 + * + * @phpstan-impure */ public function initialize() { $this->is_initialized = true; @@ -266,6 +268,8 @@ public function clean_expired_keys() { * Handles checking for the recovery mode cookie and validating it. * * @since 5.2.0 + * + * @phpstan-impure */ protected function handle_cookie() { $validated = $this->cookie_service->validate_cookie(); diff --git a/src/wp-includes/class-wp-rewrite.php b/src/wp-includes/class-wp-rewrite.php index d9f7a61f2e1f7..e2ac88a1ab4bf 100644 --- a/src/wp-includes/class-wp-rewrite.php +++ b/src/wp-includes/class-wp-rewrite.php @@ -503,6 +503,8 @@ public function page_rewrite_rules() { * @since 1.5.0 * * @return string|false Date permalink structure on success, false on failure. + * + * @phpstan-impure */ public function get_date_permastruct() { if ( isset( $this->date_structure ) ) { @@ -673,6 +675,8 @@ public function get_extra_permastruct( $name ) { * @since 1.5.0 * * @return string|false Author permalink structure on success, false on failure. + * + * @phpstan-impure */ public function get_author_permastruct() { if ( isset( $this->author_structure ) ) { @@ -699,6 +703,8 @@ public function get_author_permastruct() { * @since 1.5.0 * * @return string|false Search permalink structure on success, false on failure. + * + * @phpstan-impure */ public function get_search_permastruct() { if ( isset( $this->search_structure ) ) { @@ -725,6 +731,8 @@ public function get_search_permastruct() { * @since 1.5.0 * * @return string|false Page permalink structure on success, false on failure. + * + * @phpstan-impure */ public function get_page_permastruct() { if ( isset( $this->page_structure ) ) { @@ -751,6 +759,8 @@ public function get_page_permastruct() { * @since 1.5.0 * * @return string|false Feed permalink structure on success, false on failure. + * + * @phpstan-impure */ public function get_feed_permastruct() { if ( isset( $this->feed_structure ) ) { @@ -777,6 +787,8 @@ public function get_feed_permastruct() { * @since 1.5.0 * * @return string|false Comment feed permalink structure on success, false on failure. + * + * @phpstan-impure */ public function get_comment_feed_permastruct() { if ( isset( $this->comment_feed_structure ) ) { @@ -808,6 +820,8 @@ public function get_comment_feed_permastruct() { * @param string $tag Name of the rewrite tag to add or update. * @param string $regex Regular expression to substitute the tag for in rewrite rules. * @param string $query String to append to the rewritten query. Must end in '='. + * + * @phpstan-impure */ public function add_rewrite_tag( $tag, $regex, $query ) { $position = array_search( $tag, $this->rewritecode, true ); @@ -832,6 +846,8 @@ public function add_rewrite_tag( $tag, $regex, $query ) { * @see WP_Rewrite::$queryreplace * * @param string $tag Name of the rewrite tag to remove. + * + * @phpstan-impure */ public function remove_rewrite_tag( $tag ) { $position = array_search( $tag, $this->rewritecode, true ); @@ -1291,6 +1307,8 @@ public function generate_rewrite_rule( $permalink_structure, $walk_dirs = false * @since 1.5.0 * * @return array An associative array of matches and queries. + * + * @phpstan-impure */ public function rewrite_rules() { $rewrite = array(); @@ -1658,6 +1676,8 @@ public function random_rewrite_rules(): array { * @since 1.5.0 * * @return string[] Array of rewrite rules keyed by their regex pattern. + * + * @phpstan-impure */ public function wp_rewrite_rules() { $this->rules = get_option( 'rewrite_rules' ); @@ -1674,6 +1694,8 @@ public function wp_rewrite_rules() { * If the {@see 'wp_loaded'} action has not occurred yet, will postpone saving to the database. * * @since 6.4.0 + * + * @phpstan-impure */ private function refresh_rewrite_rules() { $this->rules = ''; @@ -1704,6 +1726,8 @@ private function refresh_rewrite_rules() { * @since 1.5.0 * * @return string + * + * @phpstan-impure */ public function mod_rewrite_rules() { if ( ! $this->using_permalinks() ) { @@ -1849,6 +1873,8 @@ public function iis7_url_rewrite_rules( $add_parent_tags = false ) { * @param string|array $query The corresponding query vars for this rewrite rule. * @param string $after Optional. Priority of the new rule. Accepts 'top' * or 'bottom'. Default 'bottom'. + * + * @phpstan-impure */ public function add_rule( $regex, $query, $after = 'bottom' ) { if ( is_array( $query ) ) { @@ -1880,6 +1906,8 @@ public function add_rule( $regex, $query, $after = 'bottom' ) { * * @param string $regex Regular expression to match request against. * @param string $query The corresponding query vars for this rewrite rule. + * + * @phpstan-impure */ public function add_external_rule( $regex, $query ) { $this->non_wp_rules[ $regex ] = $query; @@ -1917,6 +1945,8 @@ public function add_external_rule( $regex, $query ) { * @param string|bool $query_var Optional. Name of the corresponding query variable. Pass `false` to * skip registering a query_var for this endpoint. Defaults to the * value of `$name`. + * + * @phpstan-impure */ public function add_endpoint( $name, $places, $query_var = true ) { global $wp; @@ -1983,6 +2013,8 @@ public function add_endpoint( $name, $places, $query_var = true ) { * and rewrite rules built for each in-turn. Default true. * @type bool $endpoints Whether endpoints should be applied to the generated rules. Default true. * } + * + * @phpstan-impure */ public function add_permastruct( $name, $struct, $args = array() ) { // Back-compat for the old parameters: $with_front and $ep_mask. @@ -2024,6 +2056,8 @@ public function add_permastruct( $name, $struct, $args = array() ) { * @since 4.5.0 * * @param string $name Name for permalink structure. + * + * @phpstan-impure */ public function remove_permastruct( $name ) { unset( $this->extra_permastructs[ $name ] ); @@ -2084,6 +2118,8 @@ public function flush_rules( $hard = true ) { * '%tag%', or '%author%'. * * @since 1.5.0 + * + * @phpstan-impure */ public function init() { $this->extra_rules = array(); diff --git a/src/wp-includes/class-wp-role.php b/src/wp-includes/class-wp-role.php index 6e09096735bc6..948a29f516cb8 100644 --- a/src/wp-includes/class-wp-role.php +++ b/src/wp-includes/class-wp-role.php @@ -55,6 +55,8 @@ public function __construct( $role, $capabilities ) { * * @param string $cap Capability name. * @param bool $grant Whether role has capability privilege. + * + * @phpstan-impure */ public function add_cap( $cap, $grant = true ) { $this->capabilities[ $cap ] = $grant; @@ -67,6 +69,8 @@ public function add_cap( $cap, $grant = true ) { * @since 2.0.0 * * @param string $cap Capability name. + * + * @phpstan-impure */ public function remove_cap( $cap ) { unset( $this->capabilities[ $cap ] ); diff --git a/src/wp-includes/class-wp-roles.php b/src/wp-includes/class-wp-roles.php index 2cb9cdfe95296..1099f8ab036ef 100644 --- a/src/wp-includes/class-wp-roles.php +++ b/src/wp-includes/class-wp-roles.php @@ -172,6 +172,8 @@ public function reinit() { * @param array|array $capabilities Capabilities to be added to the role. * Default empty array. * @return WP_Role|null WP_Role object, if the role is added. + * + * @phpstan-impure */ public function add_role( $role, $display_name, $capabilities = array() ) { if ( empty( $role ) || isset( $this->roles[ $role ] ) ) { @@ -200,6 +202,8 @@ public function add_role( $role, $display_name, $capabilities = array() ) { * @since 2.0.0 * * @param string $role Role name. + * + * @phpstan-impure */ public function remove_role( $role ) { if ( ! isset( $this->role_objects[ $role ] ) ) { @@ -228,6 +232,8 @@ public function remove_role( $role ) { * @param string $cap Capability name. * @param bool $grant Optional. Whether role is capable of performing capability. * Default true. + * + * @phpstan-impure */ public function add_cap( $role, $cap, $grant = true ) { if ( ! isset( $this->roles[ $role ] ) ) { @@ -247,6 +253,8 @@ public function add_cap( $role, $cap, $grant = true ) { * * @param string $role Role name. * @param string $cap Capability name. + * + * @phpstan-impure */ public function remove_cap( $role, $cap ) { if ( ! isset( $this->roles[ $role ] ) ) { @@ -298,6 +306,8 @@ public function is_role( $role ) { * Initializes all of the available roles. * * @since 4.9.0 + * + * @phpstan-impure */ public function init_roles() { if ( empty( $this->roles ) ) { @@ -329,6 +339,8 @@ public function init_roles() { * @global wpdb $wpdb WordPress database abstraction object. * * @param int $site_id Site ID to initialize roles for. Default is the current site. + * + * @phpstan-impure */ public function for_site( $site_id = null ) { global $wpdb; diff --git a/src/wp-includes/class-wp-script-modules.php b/src/wp-includes/class-wp-script-modules.php index a42b3f3a83f70..b68d5ab61c655 100644 --- a/src/wp-includes/class-wp-script-modules.php +++ b/src/wp-includes/class-wp-script-modules.php @@ -141,6 +141,8 @@ class WP_Script_Modules { * @type bool $in_footer Whether to print the script module in the footer. Only relevant to block themes. Default 'false'. Optional. * @type 'auto'|'low'|'high' $fetchpriority Fetch priority. Default 'auto'. Optional. * } + * + * @phpstan-impure */ public function register( string $id, string $src, array $deps = array(), $version = false, array $args = array() ) { if ( '' === $id ) { @@ -231,6 +233,8 @@ private function is_valid_fetchpriority( $priority ): bool { * @param string $id Script module identifier. * @param 'auto'|'low'|'high' $priority Fetch priority for the script module. * @return bool Whether setting the fetchpriority was successful. + * + * @phpstan-impure */ public function set_fetchpriority( string $id, string $priority ): bool { if ( ! isset( $this->registered[ $id ] ) ) { @@ -265,6 +269,8 @@ public function set_fetchpriority( string $id, string $priority ): bool { * @param string $id Script module identifier. * @param bool $in_footer Whether to print in the footer. * @return bool Whether setting the printing location was successful. + * + * @phpstan-impure */ public function set_in_footer( string $id, bool $in_footer ): bool { if ( ! isset( $this->registered[ $id ] ) ) { @@ -313,6 +319,8 @@ public function set_in_footer( string $id, bool $in_footer ): bool { * @type bool $in_footer Whether to print the script module in the footer. Only relevant to block themes. Default 'false'. Optional. * @type 'auto'|'low'|'high' $fetchpriority Fetch priority. Default 'auto'. Optional. * } + * + * @phpstan-impure */ public function enqueue( string $id, string $src = '', array $deps = array(), $version = false, array $args = array() ) { if ( '' === $id ) { @@ -334,6 +342,8 @@ public function enqueue( string $id, string $src = '', array $deps = array(), $v * @since 6.5.0 * * @param string $id The identifier of the script module. + * + * @phpstan-impure */ public function dequeue( string $id ) { $this->queue = array_values( array_diff( $this->queue, array( $id ) ) ); @@ -345,6 +355,8 @@ public function dequeue( string $id ) { * @since 6.5.0 * * @param string $id The identifier of the script module. + * + * @phpstan-impure */ public function deregister( string $id ) { $this->dequeue( $id ); @@ -366,6 +378,8 @@ public function deregister( string $id ) { * @param string $domain Optional. Text domain. Default 'default'. * @param string $path Optional. The full file path to the directory containing translation files. * @return bool True if the text domain was registered, false if the module is not registered. + * + * @phpstan-impure */ public function set_translations( string $id, string $domain = 'default', string $path = '' ): bool { if ( ! isset( $this->registered[ $id ] ) ) { @@ -573,6 +587,8 @@ public function print_enqueued_script_modules() { * @since 6.9.0 * * @param string $id The script module identifier. + * + * @phpstan-impure */ private function print_script_module( string $id ) { if ( in_array( $id, $this->done, true ) || ! in_array( $id, $this->queue, true ) ) { @@ -670,6 +686,8 @@ public function print_import_map() { * * @return array> Array with an `imports` key mapping to an array of script module * identifiers and their respective URLs, including the version query. + * + * @phpstan-impure */ private function get_import_map(): array { global $wp_scripts; @@ -848,6 +866,8 @@ private function get_dependencies( array $ids, array $import_types = array( 'sta * * @param string $id The script ID. * @return string[] Script module IDs. + * + * @phpstan-impure */ private function get_dependents( string $id ): array { // Check if dependents map for the handle in question is present. If so, use it. @@ -944,6 +964,8 @@ private function get_sorted_dependencies( array $ids, array $import_types = arra * @param string[] $import_types Optional. Import types of dependencies to retrieve: 'static', 'dynamic', or both. * @param string[] &$sorted The array of sorted identifiers, passed by reference. * @return bool True on success, false on failure (e.g., missing dependency). + * + * @phpstan-impure */ private function sort_item_dependencies( string $id, array $import_types, array &$sorted ): bool { // If already processed, don't do it again. diff --git a/src/wp-includes/class-wp-scripts.php b/src/wp-includes/class-wp-scripts.php index 2a74bff8f65d9..9592e3728bc06 100644 --- a/src/wp-includes/class-wp-scripts.php +++ b/src/wp-includes/class-wp-scripts.php @@ -284,6 +284,8 @@ private function are_all_dependents_in_footer( $handle ) { * @param int|false $group Optional. Group level: level (int), no groups (false). * Default false. * @return bool True on success, false on failure. + * + * @phpstan-impure */ public function do_item( $handle, $group = false ) { if ( ! parent::do_item( $handle ) ) { @@ -770,6 +772,8 @@ public function print_translations( $handle, $display = true ) { * @param int|false $group Optional. Group level: level (int), no groups (false). * Default false. * @return bool True on success, false on failure. + * + * @phpstan-impure */ public function all_deps( $handles, $recursion = false, $group = false ) { $result = parent::all_deps( $handles, $recursion, $group ); @@ -846,6 +850,8 @@ public function in_default_dir( $src ) { * @param string $key The data key. * @param mixed $value The data value. * @return bool True on success, false on failure. + * + * @phpstan-impure */ public function add_data( $handle, $key, $value ) { if ( ! isset( $this->registered[ $handle ] ) ) { @@ -967,6 +973,8 @@ public function add_data( $handle, $key, $value ) { * * @param string $handle The script handle. * @return string[] Script handles. + * + * @phpstan-impure */ private function get_dependents( $handle ) { // Check if dependents map for the handle in question is present. If so, use it. @@ -1203,6 +1211,8 @@ private function has_inline_script( $handle, $position = null ) { * Resets class properties. * * @since 2.8.0 + * + * @phpstan-impure */ public function reset() { $this->do_concat = false; diff --git a/src/wp-includes/class-wp-site-query.php b/src/wp-includes/class-wp-site-query.php index aab8b511fcf83..6609869f62213 100644 --- a/src/wp-includes/class-wp-site-query.php +++ b/src/wp-includes/class-wp-site-query.php @@ -239,6 +239,8 @@ public function __construct( $query = '' ) { * @see WP_Site_Query::__construct() * * @param string|array $query Array or string of WP_Site_Query arguments. See WP_Site_Query::__construct(). + * + * @phpstan-impure */ public function parse_query( $query = '' ) { if ( empty( $query ) ) { @@ -271,6 +273,8 @@ public function parse_query( $query = '' ) { * $query is array{ fields: 'ids', ... } ? int[] : array * ) * ) + * + * @phpstan-impure */ public function query( $query ) { $this->query_vars = wp_parse_args( $query ); @@ -287,6 +291,8 @@ public function query( $query ) { * * @return WP_Site[]|int[]|int List of WP_Site objects, a list of site IDs when 'fields' is set to 'ids', * or the number of sites when 'count' is passed as a query var. + * + * @phpstan-impure */ public function get_sites() { global $wpdb; @@ -442,6 +448,8 @@ public function get_sites() { * @global wpdb $wpdb WordPress database abstraction object. * * @return int|array A single count of site IDs if a count query. An array of site IDs if a full query. + * + * @phpstan-impure */ protected function get_site_ids() { global $wpdb; @@ -735,6 +743,8 @@ protected function get_site_ids() { * @since 4.6.0 * * @global wpdb $wpdb WordPress database abstraction object. + * + * @phpstan-impure */ private function set_found_sites() { global $wpdb; diff --git a/src/wp-includes/class-wp-site.php b/src/wp-includes/class-wp-site.php index bb6c2d50a3428..db4f103044c02 100644 --- a/src/wp-includes/class-wp-site.php +++ b/src/wp-includes/class-wp-site.php @@ -308,6 +308,8 @@ public function __isset( $key ) { * * @param string $key Property to set. * @param mixed $value Value to assign to the property. + * + * @phpstan-impure */ public function __set( $key, $value ) { switch ( $key ) { diff --git a/src/wp-includes/class-wp-speculation-rules.php b/src/wp-includes/class-wp-speculation-rules.php index 11794c83b8717..ae8153db450d9 100644 --- a/src/wp-includes/class-wp-speculation-rules.php +++ b/src/wp-includes/class-wp-speculation-rules.php @@ -69,6 +69,8 @@ final class WP_Speculation_Rules implements JsonSerializable { * @param string $id Unique string identifier for the speculation rule. * @param array $rule Associative array of rule arguments. * @return bool True on success, false if invalid parameters are provided. + * + * @phpstan-impure */ public function add_rule( string $mode, string $id, array $rule ): bool { if ( ! self::is_valid_mode( $mode ) ) { diff --git a/src/wp-includes/class-wp-styles.php b/src/wp-includes/class-wp-styles.php index 39e18f7dd6e14..e7f5fce764ba4 100644 --- a/src/wp-includes/class-wp-styles.php +++ b/src/wp-includes/class-wp-styles.php @@ -369,6 +369,8 @@ public function print_inline_style( $handle, $display = true ) { * @param string $key The data key. * @param mixed $value The data value. * @return bool True on success, false on failure. + * + * @phpstan-impure */ public function add_data( $handle, $key, $value ) { if ( ! isset( $this->registered[ $handle ] ) ) { @@ -395,6 +397,8 @@ public function add_data( $handle, $key, $value ) { * @param int|false $group Optional. Group level: level (int), no groups (false). * Default false. * @return bool True on success, false on failure. + * + * @phpstan-impure */ public function all_deps( $handles, $recursion = false, $group = false ) { $result = parent::all_deps( $handles, $recursion, $group ); @@ -562,6 +566,8 @@ public function do_footer_items() { * Resets class properties. * * @since 3.3.0 + * + * @phpstan-impure */ public function reset() { $this->do_concat = false; diff --git a/src/wp-includes/class-wp-tax-query.php b/src/wp-includes/class-wp-tax-query.php index e10915251365c..3df8a9de63a7a 100644 --- a/src/wp-includes/class-wp-tax-query.php +++ b/src/wp-includes/class-wp-tax-query.php @@ -132,6 +132,8 @@ public function __construct( $tax_query ) { * * @param array $queries Array of queries clauses. * @return array Sanitized array of query clauses. + * + * @phpstan-impure */ public function sanitize_query( $queries ) { $cleaned_query = array(); @@ -240,6 +242,8 @@ protected static function is_first_order_clause( $query ) { * @type string $join SQL fragment to append to the main JOIN clause. * @type string $where SQL fragment to append to the main WHERE clause. * } + * + * @phpstan-impure */ public function get_sql( $primary_table, $primary_id_column ) { $this->primary_table = $primary_table; @@ -377,6 +381,8 @@ protected function get_sql_for_query( &$query, $depth = 0 ) { * @type string[] $join Array of SQL fragments to append to the main JOIN clause. * @type string[] $where Array of SQL fragments to append to the main WHERE clause. * } + * + * @phpstan-impure */ public function get_sql_for_clause( &$clause, $parent_query ) { global $wpdb; diff --git a/src/wp-includes/class-wp-taxonomy.php b/src/wp-includes/class-wp-taxonomy.php index f44ce34a11def..2301e5ffff368 100644 --- a/src/wp-includes/class-wp-taxonomy.php +++ b/src/wp-includes/class-wp-taxonomy.php @@ -308,6 +308,8 @@ public function __construct( $taxonomy, $object_type, $args = array() ) { * * @param string|string[] $object_type Name or array of names of the object types for the taxonomy. * @param array|string $args Array or query string of arguments for registering a taxonomy. + * + * @phpstan-impure */ public function set_props( $object_type, $args ) { $args = wp_parse_args( $args ); @@ -564,6 +566,8 @@ public function remove_hooks() { * * @return WP_REST_Controller|null The controller instance, or null if the taxonomy * is set not to show in rest. + * + * @phpstan-impure */ public function get_rest_controller() { if ( ! $this->show_in_rest ) { @@ -597,6 +601,8 @@ public function get_rest_controller() { * @since 6.0.0 * * @return (string|null)[][] The default labels for taxonomies. + * + * @phpstan-impure */ public static function get_default_labels() { if ( ! empty( self::$default_labels ) ) { @@ -653,6 +659,8 @@ public static function get_default_labels() { * Resets the cache for the default labels. * * @since 6.0.0 + * + * @phpstan-impure */ public static function reset_default_labels() { self::$default_labels = array(); diff --git a/src/wp-includes/class-wp-term-query.php b/src/wp-includes/class-wp-term-query.php index 0f4e85ae80433..6e2cc6d095355 100644 --- a/src/wp-includes/class-wp-term-query.php +++ b/src/wp-includes/class-wp-term-query.php @@ -239,6 +239,8 @@ public function __construct( $query = '' ) { * @since 4.6.0 * * @param string|array $query WP_Term_Query arguments. See WP_Term_Query::__construct() for accepted arguments. + * + * @phpstan-impure */ public function parse_query( $query = '' ) { if ( empty( $query ) ) { @@ -318,6 +320,8 @@ public function parse_query( $query = '' ) { * ? array * : WP_Term[] ) ) ) ) * ) + * + * @phpstan-impure */ public function query( $query ) { $this->query_vars = wp_parse_args( $query ); @@ -362,6 +366,8 @@ public function query( $query ) { * taxonomy hierarchy. * * @phpstan-return 0|numeric-string|int[]|array|string[]|array|WP_Term[] + * + * @phpstan-impure */ public function get_terms() { global $wpdb; diff --git a/src/wp-includes/class-wp-textdomain-registry.php b/src/wp-includes/class-wp-textdomain-registry.php index 8387d382ec1c0..1a23f04bc402f 100644 --- a/src/wp-includes/class-wp-textdomain-registry.php +++ b/src/wp-includes/class-wp-textdomain-registry.php @@ -142,6 +142,8 @@ public function has( $domain ) { * @param string $domain Text domain. * @param string $locale Locale. * @param string|false $path Language directory path or false if there is none available. + * + * @phpstan-impure */ public function set( $domain, $locale, $path ) { $this->all[ $domain ][ $locale ] = $path ? rtrim( $path, '/' ) . '/' : false; @@ -157,6 +159,8 @@ public function set( $domain, $locale, $path ) { * * @param string $domain Text domain. * @param string $path Language directory path. + * + * @phpstan-impure */ public function set_custom_path( $domain, $path ) { // If just-in-time loading was triggered before, reset the entry so it can be tried again. diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php index 42a64809d82f5..6a23f95aec6cb 100644 --- a/src/wp-includes/class-wp-theme-json-resolver.php +++ b/src/wp-includes/class-wp-theme-json-resolver.php @@ -110,6 +110,8 @@ class WP_Theme_JSON_Resolver { * * @param string $file_path Path to file. Empty if no file. * @return array Contents that adhere to the theme.json schema. + * + * @phpstan-impure */ protected static function read_json_file( $file_path ) { if ( $file_path ) { @@ -150,6 +152,8 @@ public static function get_fields_to_translate() { * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. * Default 'default'. * @return array Returns the modified $theme_json_structure. + * + * @phpstan-impure */ protected static function translate( $theme_json, $domain = 'default' ) { if ( null === static::$i18n_schema ) { @@ -166,6 +170,8 @@ protected static function translate( $theme_json, $domain = 'default' ) { * @since 5.8.0 * * @return WP_Theme_JSON Entity that holds core data. + * + * @phpstan-impure */ public static function get_core_data() { if ( null !== static::$core && static::has_same_registered_blocks( 'core' ) ) { @@ -208,6 +214,8 @@ public static function get_core_data() { * Valid values are 'core', 'blocks', 'theme', 'user', * and 'merged'. * @return bool True on success, false otherwise. + * + * @phpstan-impure */ protected static function has_same_registered_blocks( $origin ) { // Bail out if the origin is invalid. @@ -254,6 +262,8 @@ protected static function has_same_registered_blocks( $origin ) { * @return WP_Theme_JSON Entity that holds theme data. * * @phpstan-param array{} $deprecated + * + * @phpstan-impure */ public static function get_theme_data( $deprecated = array(), $options = array() ) { if ( ! empty( $deprecated ) ) { @@ -402,6 +412,8 @@ public static function get_theme_data( $deprecated = array(), $options = array() * @since 6.1.0 * * @return WP_Theme_JSON + * + * @phpstan-impure */ public static function get_block_data() { $registry = WP_Block_Type_Registry::get_instance(); @@ -553,6 +565,8 @@ public static function get_user_data_from_wp_global_styles( $theme, $create_post * Register the block style variations coming from the user data. * * @return WP_Theme_JSON Entity that holds styles for user data. + * + * @phpstan-impure */ public static function get_user_data() { if ( null !== static::$user && static::has_same_registered_blocks( 'user' ) ) { @@ -655,6 +669,8 @@ public static function get_user_data() { * @param string $origin Optional. To what level should we merge data: 'default', 'blocks', 'theme' or 'custom'. * 'custom' is used as default value as well as fallback value if the origin is unknown. * @return WP_Theme_JSON + * + * @phpstan-impure */ public static function get_merged_data( $origin = 'custom' ) { if ( is_array( $origin ) ) { @@ -703,6 +719,8 @@ public static function get_merged_data( $origin = 'custom' ) { * @since 5.9.0 * * @return int|null ID for a post of type `wp_global_styles`, or null if not available. + * + * @phpstan-impure */ public static function get_user_global_styles_post_id() { if ( null !== static::$user_custom_post_type_id ) { @@ -761,6 +779,8 @@ protected static function get_file_path_from_theme( $file_name, $template = fals * @since 6.1.0 Added the `$blocks` and `$blocks_cache` variables * to reset. * @since 7.2.0 Added the `$merged` variable to reset. + * + * @phpstan-impure */ public static function clean_cached_data() { static::$core = null; diff --git a/src/wp-includes/class-wp-theme-json.php b/src/wp-includes/class-wp-theme-json.php index 15d08fba457a9..959f3bdb7bb23 100644 --- a/src/wp-includes/class-wp-theme-json.php +++ b/src/wp-includes/class-wp-theme-json.php @@ -1930,6 +1930,8 @@ protected static function split_selector_list( $selector ): array { * @since 6.6.0 Updated to include block style variations from the block styles registry. * * @return array Block metadata. + * + * @phpstan-impure */ protected static function get_blocks_metadata() { $registry = WP_Block_Type_Registry::get_instance(); @@ -4670,6 +4672,8 @@ protected static function get_metadata_boolean( $data, $path, $default_value = f * @since 6.7.0 Replace background image objects during merge. * * @param WP_Theme_JSON $incoming Data to merge. + * + * @phpstan-impure */ public function merge( $incoming ) { $incoming_data = $incoming->get_raw_data(); diff --git a/src/wp-includes/class-wp-theme.php b/src/wp-includes/class-wp-theme.php index 47ec3db9194d5..abb6c55351674 100644 --- a/src/wp-includes/class-wp-theme.php +++ b/src/wp-includes/class-wp-theme.php @@ -857,6 +857,8 @@ private function cache_get( $key ) { * Clears the cache for the theme. * * @since 3.4.0 + * + * @phpstan-impure */ public function cache_delete() { foreach ( array( 'theme', 'screenshot', 'headers', 'post_templates' ) as $key ) { @@ -899,6 +901,8 @@ public function cache_delete() { * ? string|false * : false ) * ) + * + * @phpstan-impure */ public function get( $header ) { if ( ! isset( $this->headers[ $header ] ) ) { @@ -1091,6 +1095,8 @@ private function markup_header( $header, $value, $translate ) { * @return string|string[] Translated value. An array for Tags header, string otherwise. * * @phpstan-return ( $value is string ? string : string[] ) + * + * @phpstan-impure */ private function translate_header( $header, $value ) { switch ( $header ) { @@ -1283,6 +1289,8 @@ public function get_theme_root() { * @since 3.4.0 * * @return string Theme root URI. + * + * @phpstan-impure */ public function get_theme_root_uri() { if ( ! isset( $this->theme_root_uri ) ) { @@ -1559,6 +1567,8 @@ private static function scandir( $path, $extensions = null, $depth = 0, $relativ * * @return bool True if the textdomain was successfully loaded or has already been loaded. * False if no textdomain was specified in the file headers, or if the domain could not be loaded. + * + * @phpstan-impure */ public function load_textdomain() { if ( isset( $this->textdomain_loaded ) ) { @@ -1626,6 +1636,8 @@ public function is_allowed( $check = 'both', $blog_id = null ) { * @since 5.9.0 * * @return bool + * + * @phpstan-impure */ public function is_block_theme() { if ( isset( $this->block_theme ) ) { @@ -1837,6 +1849,8 @@ public static function get_allowed_on_site( $blog_id = null ) { * @type string $wp_template Theme-relative directory name for block templates. * @type string $wp_template_part Theme-relative directory name for block template parts. * } + * + * @phpstan-impure */ public function get_block_template_folders() { // Return set/cached value if available. diff --git a/src/wp-includes/class-wp-user-query.php b/src/wp-includes/class-wp-user-query.php index 61fc3edbc8ef9..0b68dc9566e03 100644 --- a/src/wp-includes/class-wp-user-query.php +++ b/src/wp-includes/class-wp-user-query.php @@ -261,6 +261,8 @@ public static function fill_query_vars( $args ) { * logins will not be included in results. Default empty array. * @type bool $cache_results Whether to cache user information. Default true. * } + * + * @phpstan-impure */ public function prepare_query( $query = array() ) { global $wpdb, $wp_roles; @@ -778,6 +780,8 @@ public function prepare_query( $query = array() ) { * @since 3.1.0 * * @global wpdb $wpdb WordPress database abstraction object. + * + * @phpstan-impure */ public function query() { global $wpdb; @@ -920,6 +924,8 @@ public function get( $query_var ) { * * @param string $query_var Query variable key. * @param mixed $value Query variable value. + * + * @phpstan-impure */ public function set( $query_var, $value ) { $this->query_vars[ $query_var ] = $value; @@ -989,6 +995,8 @@ public function get_total() { * * @param string $orderby Alias for the field to order by. * @return string Value to used in the ORDER clause, if `$orderby` is valid. + * + * @phpstan-impure */ protected function parse_orderby( $orderby ) { global $wpdb; @@ -1154,6 +1162,8 @@ public function __get( $name ) { * * @param string $name Property to check if set. * @param mixed $value Property value. + * + * @phpstan-impure */ public function __set( $name, $value ) { if ( in_array( $name, $this->compat_fields, true ) ) { diff --git a/src/wp-includes/class-wp-user.php b/src/wp-includes/class-wp-user.php index b50a6790a2dc7..68027ec126d35 100644 --- a/src/wp-includes/class-wp-user.php +++ b/src/wp-includes/class-wp-user.php @@ -179,6 +179,8 @@ public function __construct( $id = 0, $name = '', $site_id = 0 ) { * * @param object $data User DB row object. * @param int $site_id Optional. The site ID to initialize for. + * + * @phpstan-impure */ public function init( $data, $site_id = 0 ) { if ( ! isset( $data->ID ) ) { @@ -352,6 +354,8 @@ public function __get( $key ) { * * @param string $key User meta key. * @param mixed $value User meta value. + * + * @phpstan-impure */ public function __set( $key, $value ) { if ( 'id' === $key ) { @@ -480,6 +484,8 @@ public function __call( $name, $arguments ) { * @global wpdb $wpdb WordPress database abstraction object. * * @param string $cap_key Optional capability key + * + * @phpstan-impure */ protected function _init_caps( $cap_key = '' ) { global $wpdb; @@ -509,6 +515,8 @@ protected function _init_caps( $cap_key = '' ) { * * @return bool[] Array of key/value pairs where keys represent a capability name * and boolean values represent whether the user has that capability. + * + * @phpstan-impure */ public function get_role_caps() { $switch_site = false; @@ -554,6 +562,8 @@ public function get_role_caps() { * @since 2.0.0 * * @param string $role Role name. + * + * @phpstan-impure */ public function add_role( $role ) { if ( empty( $role ) ) { @@ -586,6 +596,8 @@ public function add_role( $role ) { * @since 2.0.0 * * @param string $role Role name. + * + * @phpstan-impure */ public function remove_role( $role ) { if ( ! in_array( $role, $this->roles, true ) ) { @@ -618,6 +630,8 @@ public function remove_role( $role ) { * @since 2.0.0 * * @param string $role Role name. + * + * @phpstan-impure */ public function set_role( $role ) { if ( 1 === count( $this->roles ) && current( $this->roles ) === $role ) { @@ -705,6 +719,8 @@ public function level_reduction( $max, $item ) { * @since 2.0.0 * * @global wpdb $wpdb WordPress database abstraction object. + * + * @phpstan-impure */ public function update_user_level_from_caps() { global $wpdb; @@ -719,6 +735,8 @@ public function update_user_level_from_caps() { * * @param string $cap Capability name. * @param bool $grant Whether to grant capability to user. + * + * @phpstan-impure */ public function add_cap( $cap, $grant = true ) { $this->caps[ $cap ] = $grant; @@ -733,6 +751,8 @@ public function add_cap( $cap, $grant = true ) { * @since 2.0.0 * * @param string $cap Capability name. + * + * @phpstan-impure */ public function remove_cap( $cap ) { if ( ! isset( $this->caps[ $cap ] ) ) { @@ -750,6 +770,8 @@ public function remove_cap( $cap ) { * @since 2.1.0 * * @global wpdb $wpdb WordPress database abstraction object. + * + * @phpstan-impure */ public function remove_all_caps() { global $wpdb; @@ -871,6 +893,8 @@ public function for_blog( $blog_id = 0 ) { * @global wpdb $wpdb WordPress database abstraction object. * * @param int $site_id Site ID to initialize user capabilities for. Default is the current site. + * + * @phpstan-impure */ public function for_site( $site_id = 0 ) { global $wpdb; diff --git a/src/wp-includes/class-wp-view-config-data.php b/src/wp-includes/class-wp-view-config-data.php index a1f6fd37f99b1..add6e7d20b931 100644 --- a/src/wp-includes/class-wp-view-config-data.php +++ b/src/wp-includes/class-wp-view-config-data.php @@ -257,6 +257,8 @@ public function set( array $patch, int $version ) { * @param array $spec The names to remove, keyed to match the configuration shape. * @param int $version The schema version the spec was authored against. * @return WP_View_Config_Data The instance, for chaining. + * + * @phpstan-impure */ public function remove( array $spec, int $version ) { if ( $version <= 0 || $version > self::LATEST_VERSION ) { @@ -406,6 +408,8 @@ public function merge( array $patch, int $version ) { * @param string $method The public method the patch was passed to, for misuse reporting. * @param string $mode How to apply each named key's value: `merge`, `replace`, or `set`. * @return WP_View_Config_Data The instance, for chaining. + * + * @phpstan-impure */ private function apply( array $patch, int $version, $method, $mode ) { if ( $version <= 0 || $version > self::LATEST_VERSION ) { diff --git a/src/wp-includes/class-wp-walker.php b/src/wp-includes/class-wp-walker.php index 2c40984119165..bfbe3781db413 100644 --- a/src/wp-includes/class-wp-walker.php +++ b/src/wp-includes/class-wp-walker.php @@ -129,6 +129,8 @@ public function end_el( &$output, $data_object, $depth = 0, $args = array() ) {} * @param int $depth Depth of current element. * @param array $args An array of arguments. * @param string $output Used to append additional content (passed by reference). + * + * @phpstan-impure */ public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) { if ( ! $element ) { @@ -299,6 +301,8 @@ public function walk( $elements, $max_depth, ...$args ) { * @param int $per_page Number of elements per page. * @param mixed ...$args Optional additional arguments. * @return string XHTML of the specified page of elements. + * + * @phpstan-impure */ public function paged_walk( $elements, $max_depth, $page_num, $per_page, ...$args ) { $output = ''; diff --git a/src/wp-includes/class-wp-widget-factory.php b/src/wp-includes/class-wp-widget-factory.php index 1f6ed3a58919e..3feb49f7ccd52 100644 --- a/src/wp-includes/class-wp-widget-factory.php +++ b/src/wp-includes/class-wp-widget-factory.php @@ -69,6 +69,8 @@ public function WP_Widget_Factory() { * @since 7.1.1 The key for an instance is prefixed so that it is never cast to an integer. * * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass. + * + * @phpstan-impure */ public function register( $widget ) { if ( $widget instanceof WP_Widget ) { @@ -87,6 +89,8 @@ public function register( $widget ) { * @since 7.1.1 The key for an instance is prefixed so that it is never cast to an integer. * * @param string|WP_Widget $widget Either the name of a `WP_Widget` subclass or an instance of a `WP_Widget` subclass. + * + * @phpstan-impure */ public function unregister( $widget ) { if ( $widget instanceof WP_Widget ) { @@ -102,6 +106,8 @@ public function unregister( $widget ) { * @since 2.8.0 * * @global array $wp_registered_widgets + * + * @phpstan-impure */ public function _register_widgets() { global $wp_registered_widgets; diff --git a/src/wp-includes/class-wp-widget.php b/src/wp-includes/class-wp-widget.php index f1d432c0d3fb5..632ca2091753e 100644 --- a/src/wp-includes/class-wp-widget.php +++ b/src/wp-includes/class-wp-widget.php @@ -288,6 +288,8 @@ public function _register() { * * @param int $number The unique order number of this widget instance compared to other * instances of the same class. + * + * @phpstan-impure */ public function _set( $number ) { $this->number = $number; @@ -414,6 +416,8 @@ public function display_callback( $args, $widget_args = 1 ) { * @param int $deprecated Not used. * * @final + * + * @phpstan-impure */ public function update_callback( $deprecated = 1 ) { global $wp_registered_widgets; diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php index 4ac680065f036..934409b9a5425 100644 --- a/src/wp-includes/class-wp-xmlrpc-server.php +++ b/src/wp-includes/class-wp-xmlrpc-server.php @@ -185,6 +185,8 @@ public function __construct() { * and set the is_enabled property accordingly. * * @since 5.7.3 + * + * @phpstan-impure */ private function set_is_enabled() { /* @@ -271,6 +273,8 @@ public function sayHello() { * @type int $1 A second number to add. * } * @return int|IXR_Error Sum of the two given numbers. + * + * @phpstan-impure */ public function addTwoNumbers( $args ) { if ( ! is_array( $args ) || count( $args ) !== 2 || ! is_int( $args[0] ) || ! is_int( $args[1] ) ) { @@ -295,6 +299,8 @@ public function addTwoNumbers( $args ) { * * @phpstan-assert-if-true =scalar $username * @phpstan-assert-if-true =scalar $password + * + * @phpstan-impure */ public function login( $username, @@ -549,6 +555,8 @@ public function set_term_custom_fields( $term_id, $fields ) { * Passes property through {@see 'xmlrpc_blog_options'} filter. * * @since 2.6.0 + * + * @phpstan-impure */ public function initialise_blog_option_info() { $this->blog_options = array( @@ -815,6 +823,8 @@ public function wp_getUsersBlogs( $args ) { * @param array $args An array of arguments to check. * @param int $count Minimum number of arguments. * @return bool True if `$args` contains at least `$count` arguments, false otherwise. + * + * @phpstan-impure */ protected function minimum_args( $args, $count ) { if ( ! is_array( $args ) || count( $args ) < $count ) { @@ -834,6 +844,8 @@ protected function minimum_args( $args, $count ) { * @return bool True if `$fields` is an array, false otherwise. * * @phpstan-assert-if-true array $fields + * + * @phpstan-impure */ protected function _is_fields_array( $fields ): bool { if ( ! is_array( $fields ) ) { @@ -5147,6 +5159,8 @@ public function blogger_getPost( $args ) { * @type int $4 Optional. Number of posts. * } * @return array|IXR_Error + * + * @phpstan-impure */ public function blogger_getRecentPosts( $args ) { @@ -6576,6 +6590,8 @@ public function mw_getCategories( $args ) { * } * } * @return array|IXR_Error + * + * @phpstan-impure */ public function mw_newMediaObject( $args ) { if ( ! $this->minimum_args( $args, 4 ) ) { @@ -6715,6 +6731,8 @@ public function mw_newMediaObject( $args ) { * @type int $3 Optional. Number of posts. * } * @return array|IXR_Error + * + * @phpstan-impure */ public function mt_getRecentPostTitles( $args ) { $this->escape( $args ); diff --git a/src/wp-includes/class-wp.php b/src/wp-includes/class-wp.php index b9b86116d37ae..41cb2c9098ee1 100644 --- a/src/wp-includes/class-wp.php +++ b/src/wp-includes/class-wp.php @@ -90,6 +90,8 @@ class WP { * @since 2.1.0 * * @param string $qv Query variable name. + * + * @phpstan-impure */ public function add_query_var( $qv ) { if ( ! in_array( $qv, $this->public_query_vars, true ) ) { @@ -103,6 +105,8 @@ public function add_query_var( $qv ) { * @since 4.5.0 * * @param string $name Query variable name. + * + * @phpstan-impure */ public function remove_query_var( $name ) { $this->public_query_vars = array_diff( $this->public_query_vars, array( $name ) ); @@ -115,6 +119,8 @@ public function remove_query_var( $name ) { * * @param string $key Query variable name. * @param mixed $value Query variable value. + * + * @phpstan-impure */ public function set_query_var( $key, $value ) { $this->query_vars[ $key ] = $value; @@ -133,6 +139,8 @@ public function set_query_var( $key, $value ) { * * @param array|string $extra_query_vars Set the extra query variables. * @return bool Whether the request was parsed. + * + * @phpstan-impure */ public function parse_request( $extra_query_vars = '' ) { global $wp_rewrite; @@ -604,6 +612,8 @@ public function send_headers() { * use the {@see 'request'} filter instead. * * @since 2.0.0 + * + * @phpstan-impure */ public function build_query_string() { $this->query_string = ''; @@ -657,6 +667,8 @@ public function build_query_string() { * @global int $more Only set, if single page or post. * @global int $single If single page or post. Only set, if single page or post. * @global WP_User|false|null $authordata Only set, if author archive. + * + * @phpstan-impure */ public function register_globals() { global $wp_query; diff --git a/src/wp-includes/class-wpdb.php b/src/wp-includes/class-wpdb.php index 5f5c05bd1553e..0117de593c580 100644 --- a/src/wp-includes/class-wpdb.php +++ b/src/wp-includes/class-wpdb.php @@ -812,6 +812,8 @@ public function __get( $name ) { * * @param string $name The private member to set. * @param mixed $value The value to set. + * + * @phpstan-impure */ public function __set( $name, $value ) { $protected_members = array( @@ -853,6 +855,8 @@ public function __unset( $name ) { * Sets $this->charset and $this->collate. * * @since 3.1.0 + * + * @phpstan-impure */ public function init_charset() { $charset = ''; @@ -1011,6 +1015,8 @@ public function set_sql_mode( $modes = array() ) { * @param bool $set_table_names Optional. Whether the table names, e.g. wpdb::$posts, * should be updated or not. Default true. * @return string|WP_Error Old prefix or WP_Error on error. + * + * @phpstan-impure */ public function set_prefix( $prefix, $set_table_names = true ) { @@ -1056,6 +1062,8 @@ public function set_prefix( $prefix, $set_table_names = true ) { * @param int $blog_id * @param int $network_id Optional. Network ID. Default 0. * @return int Previous blog ID. + * + * @phpstan-impure */ public function set_blog_id( $blog_id, $network_id = 0 ) { if ( ! empty( $network_id ) ) { @@ -1205,6 +1213,8 @@ public function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) { * @param string $db Database name. * @param mysqli $dbh Optional. Database connection. * Defaults to the current database handle. + * + * @phpstan-impure */ public function select( $db, $dbh = null ) { if ( is_null( $dbh ) ) { @@ -1823,6 +1833,8 @@ public function esc_like( $text ) { * * @param string $str The error to display. * @return void|false Void if the showing of errors is enabled, false if disabled. + * + * @phpstan-impure */ public function print_error( $str = '' ) { global $EZSQL_ERROR; @@ -1897,6 +1909,8 @@ public function print_error( $str = '' ) { * * @param bool $show Optional. Whether to show errors. Default true. * @return bool Whether showing of errors was previously active. + * + * @phpstan-impure */ public function show_errors( $show = true ) { $errors = $this->show_errors; @@ -1914,6 +1928,8 @@ public function show_errors( $show = true ) { * @see wpdb::show_errors() * * @return bool Whether showing of errors was previously active. + * + * @phpstan-impure */ public function hide_errors() { $show = $this->show_errors; @@ -1932,6 +1948,8 @@ public function hide_errors() { * * @param bool $suppress Optional. Whether to suppress errors. Default true. * @return bool Whether suppressing of errors was previously active. + * + * @phpstan-impure */ public function suppress_errors( $suppress = true ) { $errors = $this->suppress_errors; @@ -1943,6 +1961,8 @@ public function suppress_errors( $suppress = true ) { * Kills cached query results. * * @since 0.71 + * + * @phpstan-impure */ public function flush() { $this->last_result = array(); @@ -1979,6 +1999,8 @@ public function flush() { * * @param bool $allow_bail Optional. Allows the function to bail. Default true. * @return bool True with a successful connection, false on failure. + * + * @phpstan-impure */ public function db_connect( $allow_bail = true ) { $this->is_mysql = true; @@ -2242,6 +2264,8 @@ public function check_connection( $allow_bail = true ) { * @param string $query Database query. * @return int|bool Boolean true for CREATE, ALTER, TRUNCATE and DROP queries. Number of rows * affected/selected for all other queries. Boolean false on error. + * + * @phpstan-impure */ public function query( $query ) { if ( ! $this->ready ) { @@ -2375,6 +2399,8 @@ public function query( $query ) { * @see wpdb::query() * * @param string $query The query to run. + * + * @phpstan-impure */ private function _do_query( $query ) { if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) { @@ -2408,6 +2434,8 @@ private function _do_query( $query ) { * @param string $query_callstack Comma-separated list of the calling functions. * @param float $query_start Unix timestamp of the time at the start of the query. * @param array $query_data Custom query data. + * + * @phpstan-impure */ public function log_query( $query, $query_time, $query_callstack, $query_start, $query_data ) { /** @@ -2614,6 +2642,8 @@ public function replace( $table, $data, $format = null ) { * @param string $type Optional. Type of operation. Either 'INSERT' or 'REPLACE'. * Default 'INSERT'. * @return int|false The number of rows affected, or false on error. + * + * @phpstan-impure */ public function _insert_replace_helper( $table, $data, $format = null, $type = 'INSERT' ) { $this->insert_id = 0; @@ -2708,6 +2738,8 @@ public function _insert_replace_helper( $table, $data, $format = null, $type = ' * If omitted, all values in $where will be treated as strings unless otherwise * specified in wpdb::$field_types. Default null. * @return int|false The number of rows updated, or false on error. + * + * @phpstan-impure */ public function update( $table, $data, $where, $format = null, $where_format = null ) { if ( ! is_array( $data ) || ! is_array( $where ) ) { @@ -2793,6 +2825,8 @@ public function update( $table, $data, $where, $format = null, $where_format = n * If omitted, all values in $where will be treated as strings unless otherwise * specified in wpdb::$field_types. Default null. * @return int|false The number of rows deleted, or false on error. + * + * @phpstan-impure */ public function delete( $table, $where, $where_format = null ) { if ( ! is_array( $where ) ) { @@ -2840,6 +2874,8 @@ public function delete( $table, $where, $where_format = null ) { * @param string[]|string $format Formats or format to be mapped to the values in the data. * @return array|false An array of fields that contain paired value and formats. * False for invalid values. + * + * @phpstan-impure */ protected function process_fields( $table, $data, $format ) { $data = $this->process_field_formats( $data, $format ); @@ -3061,6 +3097,8 @@ protected function process_field_lengths( $data, $table ) { * @param int $y Optional. Row of value to return. Indexed from 0. Default 0. * @return string|null Database query result (as string), or null on failure or when the value is an empty string. * @phpstan-return non-empty-string|null + * + * @phpstan-impure */ public function get_var( $query = null, $x = 0, $y = 0 ) { $this->func_call = "\$db->get_var(\"$query\", $x, $y)"; @@ -3121,6 +3159,8 @@ public function get_var( $query = null, $x = 0, $y = 0 ) { * ) * : null * ) + * + * @phpstan-impure */ public function get_row( $query = null, $output = OBJECT, $y = 0 ) { $this->func_call = "\$db->get_row(\"$query\",$output,$y)"; @@ -3167,6 +3207,8 @@ public function get_row( $query = null, $output = OBJECT, $y = 0 ) { * @param int $x Optional. Column to return. Indexed from 0. Default 0. * @return array Database query result. Array indexed from 0 by SQL result row number. * @phpstan-return list + * + * @phpstan-impure */ public function get_col( $query = null, $x = 0 ) { if ( $query ) { @@ -3233,6 +3275,8 @@ public function get_col( $query = null, $x = 0 ) { * ) * : null * ) + * + * @phpstan-impure */ public function get_results( $query = null, $output = OBJECT ) { $this->func_call = "\$db->get_results(\"$query\", $output)"; @@ -3304,6 +3348,8 @@ public function get_results( $query = null, $output = OBJECT ) { * * @param string $table Table name. * @return string|WP_Error Table character set, WP_Error object if it couldn't be found. + * + * @phpstan-impure */ protected function get_table_charset( $table ) { $tablekey = strtolower( $table ); @@ -3582,6 +3628,8 @@ protected function check_ascii( $input_string ) { * * @param string $query The query to check. * @return bool True if the collation is safe, false if it isn't. + * + * @phpstan-impure */ protected function check_safe_collation( $query ) { if ( $this->checking_collation ) { @@ -3652,6 +3700,8 @@ protected function check_safe_collation( $query ) { * This works as a passthrough: any additional keys such as 'field' are * retained in each value array. If we cannot remove invalid characters, * a WP_Error object is returned. + * + * @phpstan-impure */ protected function strip_invalid_text( $data ) { $db_check_string = false; @@ -3964,6 +4014,8 @@ protected function get_table_from_query( $query ) { * Loads the column metadata from the last query. * * @since 3.5.0 + * + * @phpstan-impure */ protected function load_col_info() { if ( $this->col_info || ! $this->result instanceof mysqli_result ) { @@ -4015,6 +4067,8 @@ public function get_col_info( $info_type = 'name', $col_offset = -1 ) { * @since 1.5.0 * * @return true + * + * @phpstan-impure */ public function timer_start() { $this->time_start = microtime( true ); @@ -4043,6 +4097,8 @@ public function timer_stop() { * @param string $error_code Optional. A computer-readable string to identify the error. * Default '500'. * @return false False if the showing of errors is disabled. + * + * @phpstan-impure */ public function bail( $message, $error_code = '500' ) { if ( $this->show_errors ) { @@ -4077,6 +4133,8 @@ public function bail( $message, $error_code = '500' ) { * * @return bool True if the connection was successfully closed, * false if it wasn't, or if the connection doesn't exist. + * + * @phpstan-impure */ public function close() { if ( ! $this->dbh ) { diff --git a/src/wp-includes/customize/class-wp-customize-code-editor-control.php b/src/wp-includes/customize/class-wp-customize-code-editor-control.php index c22d6ea036ed4..e5c85d3e25c49 100644 --- a/src/wp-includes/customize/class-wp-customize-code-editor-control.php +++ b/src/wp-includes/customize/class-wp-customize-code-editor-control.php @@ -45,6 +45,8 @@ class WP_Customize_Code_Editor_Control extends WP_Customize_Control { * Enqueue control related scripts/styles. * * @since 4.9.0 + * + * @phpstan-impure */ public function enqueue() { $this->editor_settings = wp_enqueue_code_editor( diff --git a/src/wp-includes/customize/class-wp-customize-color-control.php b/src/wp-includes/customize/class-wp-customize-color-control.php index e218b551fa435..499e5bd21c8d0 100644 --- a/src/wp-includes/customize/class-wp-customize-color-control.php +++ b/src/wp-includes/customize/class-wp-customize-color-control.php @@ -70,6 +70,8 @@ public function enqueue() { * * @since 3.4.0 * @uses WP_Customize_Control::to_json() + * + * @phpstan-impure */ public function to_json() { parent::to_json(); diff --git a/src/wp-includes/customize/class-wp-customize-cropped-image-control.php b/src/wp-includes/customize/class-wp-customize-cropped-image-control.php index 5f0debba2984a..1655073706433 100644 --- a/src/wp-includes/customize/class-wp-customize-cropped-image-control.php +++ b/src/wp-includes/customize/class-wp-customize-cropped-image-control.php @@ -73,6 +73,8 @@ public function enqueue() { * @since 4.3.0 * * @see WP_Customize_Control::to_json() + * + * @phpstan-impure */ public function to_json() { parent::to_json(); diff --git a/src/wp-includes/customize/class-wp-customize-custom-css-setting.php b/src/wp-includes/customize/class-wp-customize-custom-css-setting.php index ed825618b2dc1..d4b70a64594c4 100644 --- a/src/wp-includes/customize/class-wp-customize-custom-css-setting.php +++ b/src/wp-includes/customize/class-wp-customize-custom-css-setting.php @@ -79,6 +79,8 @@ public function __construct( $manager, $id, $args = array() ) { * @since 4.7.9 * * @return bool False when preview short-circuits due no change needing to be previewed. + * + * @phpstan-impure */ public function preview() { if ( $this->is_previewed ) { diff --git a/src/wp-includes/customize/class-wp-customize-header-image-control.php b/src/wp-includes/customize/class-wp-customize-header-image-control.php index 23018366425e9..b246f17c93749 100644 --- a/src/wp-includes/customize/class-wp-customize-header-image-control.php +++ b/src/wp-includes/customize/class-wp-customize-header-image-control.php @@ -104,6 +104,8 @@ public function enqueue() { * @since 3.9.0 * * @global Custom_Image_Header $custom_image_header + * + * @phpstan-impure */ public function prepare_control() { global $custom_image_header; diff --git a/src/wp-includes/customize/class-wp-customize-header-image-setting.php b/src/wp-includes/customize/class-wp-customize-header-image-setting.php index 8076e1e65c349..5ed98ba3bfa27 100644 --- a/src/wp-includes/customize/class-wp-customize-header-image-setting.php +++ b/src/wp-includes/customize/class-wp-customize-header-image-setting.php @@ -45,6 +45,8 @@ final class WP_Customize_Header_Image_Setting extends WP_Customize_Setting { * * @param mixed $value The value to update. * @return true Always returns true. + * + * @phpstan-impure */ public function update( $value ) { global $custom_image_header; diff --git a/src/wp-includes/customize/class-wp-customize-media-control.php b/src/wp-includes/customize/class-wp-customize-media-control.php index 40d644ca84e5e..027b0dfc8837d 100644 --- a/src/wp-includes/customize/class-wp-customize-media-control.php +++ b/src/wp-includes/customize/class-wp-customize-media-control.php @@ -76,6 +76,8 @@ public function enqueue() { * @since 4.2.0 Moved from WP_Customize_Upload_Control. * * @see WP_Customize_Control::to_json() + * + * @phpstan-impure */ public function to_json() { parent::to_json(); diff --git a/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php b/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php index de6c6a1fe13ef..6b8ca69e9b2dd 100644 --- a/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php +++ b/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php @@ -191,6 +191,8 @@ public function __construct( WP_Customize_Manager $manager, $id, array $args = a * * @param int $menu_id The term ID for the menu. * @param int $menu_item_id The post ID for the menu item. + * + * @phpstan-impure */ public function flush_cached_value( $menu_id, $menu_item_id ) { unset( $menu_id ); @@ -207,6 +209,8 @@ public function flush_cached_value( $menu_id, $menu_item_id ) { * @see wp_setup_nav_menu_item() * * @return array|false Instance data array, or false if the item is marked for deletion. + * + * @phpstan-impure */ public function value() { $type_label = null; @@ -349,6 +353,8 @@ protected function get_type_label( $item ) { * @since 4.3.0 * * @see WP_Customize_Nav_Menu_Item_Setting::value() + * + * @phpstan-impure */ protected function populate_value() { if ( ! is_array( $this->value ) ) { @@ -446,6 +452,8 @@ protected function populate_value() { * @see WP_Customize_Manager::post_value() * * @return bool False if method short-circuited due to no-op. + * + * @phpstan-impure */ public function preview() { if ( $this->is_previewed ) { @@ -767,6 +775,8 @@ public function sanitize( $value ) { * entirely. See WP_Customize_Nav_Menu_Item_Setting::$default for what the value * should consist of. * @return bool Whether updated. + * + * @phpstan-impure */ protected function update( $value ) { if ( $this->is_updated ) { diff --git a/src/wp-includes/customize/class-wp-customize-nav-menu-location-control.php b/src/wp-includes/customize/class-wp-customize-nav-menu-location-control.php index b0340b1eeed4f..8de71b6675da0 100644 --- a/src/wp-includes/customize/class-wp-customize-nav-menu-location-control.php +++ b/src/wp-includes/customize/class-wp-customize-nav-menu-location-control.php @@ -40,6 +40,8 @@ class WP_Customize_Nav_Menu_Location_Control extends WP_Customize_Control { * @since 4.3.0 * * @see WP_Customize_Control::to_json() + * + * @phpstan-impure */ public function to_json() { parent::to_json(); diff --git a/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php b/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php index 045bf1045dcc5..15d9b84cf0be4 100644 --- a/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php +++ b/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php @@ -201,6 +201,8 @@ public function value() { * @see WP_Customize_Manager::post_value() * * @return bool False if method short-circuited due to no-op. + * + * @phpstan-impure */ public function preview() { if ( $this->is_previewed ) { @@ -480,6 +482,8 @@ public function sanitize( $value ) { * @type bool $auto_add Whether pages will auto_add to this menu. Default false. * } * @return bool Whether updated. + * + * @phpstan-impure */ protected function update( $value ) { if ( $this->is_updated ) { @@ -624,6 +628,8 @@ protected function filter_nav_menu_options_value( $nav_menu_options, $menu_id, $ * * @param array $data Additional information passed back to the 'saved' event on `wp.customize`. * @return array Export data. + * + * @phpstan-impure */ public function amend_customize_save_response( $data ) { $data['nav_menu_updates'] ??= array(); diff --git a/src/wp-includes/customize/class-wp-customize-selective-refresh.php b/src/wp-includes/customize/class-wp-customize-selective-refresh.php index c4f0d5d3f94e8..ae29d045bd020 100644 --- a/src/wp-includes/customize/class-wp-customize-selective-refresh.php +++ b/src/wp-includes/customize/class-wp-customize-selective-refresh.php @@ -91,6 +91,8 @@ public function partials() { * See WP_Customize_Partial::__construct() for information * on accepted arguments. Default empty array. * @return WP_Customize_Partial The instance of the partial that was added. + * + * @phpstan-impure */ public function add_partial( $id, $args = array() ) { if ( $id instanceof WP_Customize_Partial ) { @@ -129,6 +131,8 @@ public function get_partial( $id ) { * @since 4.5.0 * * @param string $id Customize Partial ID. + * + * @phpstan-impure */ public function remove_partial( $id ) { unset( $this->partials[ $id ] ); @@ -280,6 +284,8 @@ public function is_render_partials_request() { * @param string $errfile Error file. * @param int $errline Error line. * @return true Always true. + * + * @phpstan-impure */ public function handle_error( $errno, $errstr, $errfile = null, $errline = null ) { $this->triggered_errors[] = array( @@ -296,6 +302,8 @@ public function handle_error( $errno, $errstr, $errfile = null, $errline = null * Handles the Ajax request to return the rendered partials for the requested placements. * * @since 4.5.0 + * + * @phpstan-impure */ public function handle_render_partials_request() { if ( ! $this->is_render_partials_request() ) { diff --git a/src/wp-includes/customize/class-wp-customize-theme-control.php b/src/wp-includes/customize/class-wp-customize-theme-control.php index 81c36dd421c49..0fbe458dd5c67 100644 --- a/src/wp-includes/customize/class-wp-customize-theme-control.php +++ b/src/wp-includes/customize/class-wp-customize-theme-control.php @@ -38,6 +38,8 @@ class WP_Customize_Theme_Control extends WP_Customize_Control { * @since 4.2.0 * * @see WP_Customize_Control::to_json() + * + * @phpstan-impure */ public function to_json() { parent::to_json(); diff --git a/src/wp-includes/customize/class-wp-customize-upload-control.php b/src/wp-includes/customize/class-wp-customize-upload-control.php index c992146784bdd..5734cf1e7a9e2 100644 --- a/src/wp-includes/customize/class-wp-customize-upload-control.php +++ b/src/wp-includes/customize/class-wp-customize-upload-control.php @@ -49,6 +49,8 @@ class WP_Customize_Upload_Control extends WP_Customize_Media_Control { * @since 3.4.0 * * @uses WP_Customize_Media_Control::to_json() + * + * @phpstan-impure */ public function to_json() { parent::to_json(); diff --git a/src/wp-includes/customize/class-wp-widget-area-customize-control.php b/src/wp-includes/customize/class-wp-widget-area-customize-control.php index bcc27e23ab02d..0bbbf23ccb18e 100644 --- a/src/wp-includes/customize/class-wp-widget-area-customize-control.php +++ b/src/wp-includes/customize/class-wp-widget-area-customize-control.php @@ -36,6 +36,8 @@ class WP_Widget_Area_Customize_Control extends WP_Customize_Control { * Refreshes the parameters passed to the JavaScript via JSON. * * @since 3.9.0 + * + * @phpstan-impure */ public function to_json() { parent::to_json(); diff --git a/src/wp-includes/customize/class-wp-widget-form-customize-control.php b/src/wp-includes/customize/class-wp-widget-form-customize-control.php index 3ac0e69969ed5..d77ae9d8c2d5e 100644 --- a/src/wp-includes/customize/class-wp-widget-form-customize-control.php +++ b/src/wp-includes/customize/class-wp-widget-form-customize-control.php @@ -85,6 +85,8 @@ class WP_Widget_Form_Customize_Control extends WP_Customize_Control { * @since 3.9.0 * * @global array $wp_registered_widgets + * + * @phpstan-impure */ public function to_json() { global $wp_registered_widgets; diff --git a/src/wp-includes/fonts/class-wp-font-collection.php b/src/wp-includes/fonts/class-wp-font-collection.php index b915e3ea58d0d..0b054fdf02fba 100644 --- a/src/wp-includes/fonts/class-wp-font-collection.php +++ b/src/wp-includes/fonts/class-wp-font-collection.php @@ -80,6 +80,8 @@ public function __construct( string $slug, array $args ) { * @since 6.5.0 * * @return array|WP_Error An array containing the font collection data, or a WP_Error on failure. + * + * @phpstan-impure */ public function get_data() { if ( is_wp_error( $this->data ) ) { diff --git a/src/wp-includes/fonts/class-wp-font-library.php b/src/wp-includes/fonts/class-wp-font-library.php index 046ae3e40f0b3..7ba621c128b15 100644 --- a/src/wp-includes/fonts/class-wp-font-library.php +++ b/src/wp-includes/fonts/class-wp-font-library.php @@ -42,6 +42,8 @@ class WP_Font_Library { * @param array $args Font collection data. See wp_register_font_collection() for information on accepted arguments. * @return WP_Font_Collection|WP_Error A font collection if it was registered successfully, * or WP_Error object on failure. + * + * @phpstan-impure */ public function register_font_collection( string $slug, array $args ) { $new_collection = new WP_Font_Collection( $slug, $args ); @@ -70,6 +72,8 @@ public function register_font_collection( string $slug, array $args ) { * * @param string $slug Font collection slug. * @return bool True if the font collection was unregistered successfully and false otherwise. + * + * @phpstan-impure */ public function unregister_font_collection( string $slug ) { if ( ! $this->is_collection_registered( $slug ) ) { @@ -131,6 +135,8 @@ public function get_font_collection( string $slug ) { * @since 6.5.0 * * @return WP_Font_Library The main instance. + * + * @phpstan-impure */ public static function get_instance() { self::$instance ??= new self(); diff --git a/src/wp-includes/html-api/class-wp-html-active-formatting-elements.php b/src/wp-includes/html-api/class-wp-html-active-formatting-elements.php index d9cf45fff8129..2351430c11825 100644 --- a/src/wp-includes/html-api/class-wp-html-active-formatting-elements.php +++ b/src/wp-includes/html-api/class-wp-html-active-formatting-elements.php @@ -111,6 +111,8 @@ public function insert_marker(): void { * @link https://html.spec.whatwg.org/#push-onto-the-list-of-active-formatting-elements * * @param WP_HTML_Token $token Push this node onto the stack. + * + * @phpstan-impure */ public function push( WP_HTML_Token $token ) { /* diff --git a/src/wp-includes/html-api/class-wp-html-processor.php b/src/wp-includes/html-api/class-wp-html-processor.php index dd4469d5277d9..518b9e555047a 100644 --- a/src/wp-includes/html-api/class-wp-html-processor.php +++ b/src/wp-includes/html-api/class-wp-html-processor.php @@ -814,6 +814,8 @@ public function next_token(): bool { * @ignore * * @return bool + * + * @phpstan-impure */ private function next_visitable_token(): bool { $this->current_element = null; @@ -1032,6 +1034,8 @@ public function expects_closer( ?WP_HTML_Token $node = null ): ?bool { * * @param string $node_to_process Whether to parse the next node or reprocess the current node. * @return bool Whether a tag was matched. + * + * @phpstan-impure */ public function step( $node_to_process = self::PROCESS_NEXT_NODE ): bool { // Refuse to proceed if there was a previous error. @@ -1582,6 +1586,8 @@ private static function escape_text_for_serialization( string $text ): string { * @link https://html.spec.whatwg.org/#the-initial-insertion-mode * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_initial(): bool { $token_name = $this->get_token_name(); @@ -1656,6 +1662,8 @@ private function step_initial(): bool { * @link https://html.spec.whatwg.org/#the-before-html-insertion-mode * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_before_html(): bool { $token_name = $this->get_token_name(); @@ -1755,6 +1763,8 @@ private function step_before_html(): bool { * @link https://html.spec.whatwg.org/#the-before-head-insertion-mode * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_before_head(): bool { $token_name = $this->get_token_name(); @@ -1853,6 +1863,8 @@ private function step_before_head(): bool { * @link https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inhead * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_in_head(): bool { $token_name = $this->get_token_name(); @@ -2076,6 +2088,8 @@ private function step_in_head(): bool { * @link https://html.spec.whatwg.org/#parsing-main-inheadnoscript * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_in_head_noscript(): bool { $token_name = $this->get_token_name(); @@ -2181,6 +2195,8 @@ private function step_in_head_noscript(): bool { * @link https://html.spec.whatwg.org/#the-after-head-insertion-mode * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_after_head(): bool { $token_name = $this->get_token_name(); @@ -2326,6 +2342,8 @@ private function step_after_head(): bool { * @link https://html.spec.whatwg.org/#parsing-main-inbody * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_in_body(): bool { $token_name = $this->get_token_name(); @@ -3445,6 +3463,8 @@ private function in_body_any_other_end_tag(): bool { * @link https://html.spec.whatwg.org/#parsing-main-intable * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_in_table(): bool { $token_name = $this->get_token_name(); @@ -3723,6 +3743,8 @@ private function step_in_table_text(): bool { * @link https://html.spec.whatwg.org/#parsing-main-incaption * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_in_caption(): bool { $tag_name = $this->get_tag(); @@ -3808,6 +3830,8 @@ private function step_in_caption(): bool { * @link https://html.spec.whatwg.org/#parsing-main-incolgroup * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_in_column_group(): bool { $token_name = $this->get_token_name(); @@ -3918,6 +3942,8 @@ private function step_in_column_group(): bool { * @link https://html.spec.whatwg.org/#parsing-main-intbody * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_in_table_body(): bool { $tag_name = $this->get_tag(); @@ -4022,6 +4048,8 @@ private function step_in_table_body(): bool { * @link https://html.spec.whatwg.org/#parsing-main-intr * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_in_row(): bool { $tag_name = $this->get_tag(); @@ -4133,6 +4161,8 @@ private function step_in_row(): bool { * @link https://html.spec.whatwg.org/#parsing-main-intd * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_in_cell(): bool { $tag_name = $this->get_tag(); @@ -4238,6 +4268,8 @@ private function step_in_cell(): bool { * @link https://html.spec.whatwg.org/#parsing-main-intemplate * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_in_template(): bool { $token_name = $this->get_token_name(); @@ -4370,6 +4402,8 @@ private function step_in_template(): bool { * @link https://html.spec.whatwg.org/#parsing-main-afterbody * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_after_body(): bool { $tag_name = $this->get_token_name(); @@ -4461,6 +4495,8 @@ private function step_after_body(): bool { * @link https://html.spec.whatwg.org/#parsing-main-inframeset * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_in_frameset(): bool { $tag_name = $this->get_token_name(); @@ -4583,6 +4619,8 @@ private function step_in_frameset(): bool { * @link https://html.spec.whatwg.org/#parsing-main-afterframeset * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_after_frameset(): bool { $tag_name = $this->get_token_name(); @@ -4671,6 +4709,8 @@ private function step_after_frameset(): bool { * @link https://html.spec.whatwg.org/#the-after-after-body-insertion-mode * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_after_after_body(): bool { $tag_name = $this->get_token_name(); @@ -4807,6 +4847,8 @@ private function step_after_after_frameset(): bool { * @link https://html.spec.whatwg.org/#parsing-main-inforeign * * @return bool Whether an element was found. + * + * @phpstan-impure */ private function step_in_foreign_content(): bool { $tag_name = $this->get_token_name(); @@ -5120,6 +5162,8 @@ private function step_in_foreign_content(): bool { * @throws Exception When unable to allocate requested bookmark. * * @return string Name of created bookmark. + * + * @phpstan-impure */ private function bookmark_token() { if ( ! parent::set_bookmark( (string) ++$this->bookmark_counter ) ) { @@ -5533,6 +5577,8 @@ public function release_bookmark( $bookmark_name ): bool { * * @param string $bookmark_name Jump to the place in the document identified by this bookmark name. * @return bool Whether the internal cursor was successfully moved to the bookmark's location. + * + * @phpstan-impure */ public function seek( $bookmark_name ): bool { // Flush any pending updates to the document before beginning. @@ -6297,6 +6343,8 @@ private function insert_foreign_element( WP_HTML_Token $token, bool $only_add_to * @return WP_HTML_Token Newly-created virtual token. * * @phpstan-param non-falsy-string $token_name + * + * @phpstan-impure */ private function insert_virtual_node( $token_name, $bookmark_name = null ): WP_HTML_Token { $here = $this->bookmarks[ $this->state->current_token->bookmark_name ]; diff --git a/src/wp-includes/html-api/class-wp-html-tag-processor.php b/src/wp-includes/html-api/class-wp-html-tag-processor.php index 7e047c4808081..9fd80fb4f33d3 100644 --- a/src/wp-includes/html-api/class-wp-html-tag-processor.php +++ b/src/wp-includes/html-api/class-wp-html-tag-processor.php @@ -878,6 +878,8 @@ public function __construct( $html ) { * @param string $new_namespace One of 'html', 'svg', or 'math' indicating into what * namespace the next tokens will be processed. * @return bool Whether the namespace was valid and changed. + * + * @phpstan-impure */ public function change_parsing_namespace( string $new_namespace ): bool { if ( ! in_array( $new_namespace, array( 'html', 'math', 'svg' ), true ) ) { @@ -974,6 +976,8 @@ public function next_token(): bool { * @ignore * * @return bool Whether a token was parsed. + * + * @phpstan-impure */ private function base_class_next_token(): bool { $was_at = $this->bytes_already_parsed; @@ -1354,6 +1358,8 @@ public function has_class( $wanted_class ): ?bool { * * @param string $name Identifies this particular bookmark. * @return bool Whether the bookmark was successfully created. + * + * @phpstan-impure */ public function set_bookmark( $name ): bool { // It only makes sense to set a bookmark if the parser has paused on a concrete token. @@ -1389,6 +1395,8 @@ public function set_bookmark( $name ): bool { * * @param string $name Name of the bookmark to remove. * @return bool Whether the bookmark already existed before removal. + * + * @phpstan-impure */ public function release_bookmark( $name ): bool { if ( ! array_key_exists( $name, $this->bookmarks ) ) { @@ -1430,6 +1438,8 @@ private function skip_rawtext( string $tag_name ): bool { * * @param string $tag_name The uppercase tag name which will close the RCDATA region. * @return bool Whether an end to the RCDATA region was found before the end of the document. + * + * @phpstan-impure */ private function skip_rcdata( string $tag_name ): bool { $html = $this->html; @@ -1519,6 +1529,8 @@ private function skip_rcdata( string $tag_name ): bool { * @ignore * * @return bool Whether the script tag was closed before the end of the document. + * + * @phpstan-impure */ private function skip_script_data(): bool { $state = 'unescaped'; @@ -2208,6 +2220,8 @@ private function parse_next_tag(): bool { * * @return bool Whether an attribute was found. Returns `false` upon reaching the end * of the tag (`>` or `/>`) or the end of the document. + * + * @phpstan-impure */ private function parse_next_attribute(): bool { $doc_length = strlen( $this->html ); @@ -2602,6 +2616,8 @@ private function class_name_updates_to_attributes_updates(): void { * * @param int $shift_this_point Accumulate and return shift for this position. * @return int How many bytes the given pointer moved in response to the updates. + * + * @phpstan-impure */ private function apply_attributes_updates( int $shift_this_point ): int { if ( ! count( $this->lexical_updates ) ) { @@ -2714,6 +2730,8 @@ public function has_bookmark( $bookmark_name ): bool { * * @param string $bookmark_name Jump to the place in the document identified by this bookmark name. * @return bool Whether the internal cursor was successfully moved to the bookmark's location. + * + * @phpstan-impure */ public function seek( $bookmark_name ): bool { if ( ! array_key_exists( $bookmark_name, $this->bookmarks ) ) { @@ -3733,6 +3751,8 @@ public function get_full_comment_text(): ?string { * @since 6.7.0 * * @return bool Whether the text node was subdivided. + * + * @phpstan-impure */ public function subdivide_text_appropriately(): bool { if ( self::STATE_TEXT_NODE !== $this->parser_state ) { @@ -3976,6 +3996,8 @@ public function get_modifiable_text(): string { * * @param string $plaintext_content New text content to represent in the matched token. * @return bool Whether the text was able to update. + * + * @phpstan-impure */ public function set_modifiable_text( string $plaintext_content ): bool { if ( self::STATE_TEXT_NODE === $this->parser_state ) { @@ -4619,6 +4641,8 @@ private static function escape_javascript_script_contents( string $sourcecode ): * @param string $name The attribute name to target. * @param string|bool $value The new attribute value. * @return bool Whether an attribute value was set. + * + * @phpstan-impure */ public function set_attribute( $name, $value ): bool { if ( @@ -4770,6 +4794,8 @@ public function set_attribute( $name, $value ): bool { * * @param string $name The attribute name to remove. * @return bool Whether an attribute was removed. + * + * @phpstan-impure */ public function remove_attribute( $name ): bool { if ( @@ -4848,6 +4874,8 @@ public function remove_attribute( $name ): bool { * * @param string $class_name The class name to add. * @return bool Whether the class was set to be added. + * + * @phpstan-impure */ public function add_class( $class_name ): bool { if ( @@ -4890,6 +4918,8 @@ public function add_class( $class_name ): bool { * * @param string $class_name The class name to remove. * @return bool Whether the class was set to be removed. + * + * @phpstan-impure */ public function remove_class( $class_name ): bool { if ( @@ -4946,6 +4976,8 @@ public function __toString(): string { * @since 6.4.0 No longer calls subclass method `next_tag()` after updating HTML. * * @return string The processed HTML. + * + * @phpstan-impure */ public function get_updated_html(): string { $requires_no_updating = 0 === count( $this->classname_updates ) && 0 === count( $this->lexical_updates ); @@ -5013,6 +5045,8 @@ public function get_updated_html(): string { * @type string $tag_closers "visit" or "skip": whether to stop on tag closers, e.g. . * } * @phpstan-param Query $query + * + * @phpstan-impure */ private function parse_query( $query ) { if ( null !== $query && $query === $this->last_query ) { diff --git a/src/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php b/src/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php index f3aeae5d7df30..33c713eb21648 100644 --- a/src/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php +++ b/src/wp-includes/interactivity-api/class-wp-interactivity-api-directives-processor.php @@ -69,6 +69,8 @@ public function get_content_between_balanced_template_tags() { * * @param string $new_content The string to replace the content between the matching tags. * @return bool Whether the content was successfully replaced. + * + * @phpstan-impure */ public function set_content_between_balanced_tags( string $new_content ): bool { $positions = $this->get_after_opener_tag_and_before_closer_tag_positions( true ); @@ -104,6 +106,8 @@ public function set_content_between_balanced_tags( string $new_content ): bool { * @param string $new_content The markup to replace the content between the matching tags with. * @return bool Whether the matching closer tag was found. When it is not found, the cursor is at the end * of the HTML and nothing is replaced. + * + * @phpstan-impure */ public function skip_to_balanced_tag_closer( string $new_content ): bool { $bookmarks = $this->get_balanced_tag_bookmarks(); @@ -139,6 +143,8 @@ public function skip_to_balanced_tag_closer( string $new_content ): bool { * * @param string $new_content The string to append after the closing template tag. * @return bool Whether the content was successfully appended. + * + * @phpstan-impure */ public function append_content_after_template_tag_closer( string $new_content ): bool { if ( empty( $new_content ) || 'TEMPLATE' !== $this->get_tag() || ! $this->is_tag_closer() ) { diff --git a/src/wp-includes/interactivity-api/class-wp-interactivity-api.php b/src/wp-includes/interactivity-api/class-wp-interactivity-api.php index b4f9ed1afcb98..b9bc494e2ee12 100644 --- a/src/wp-includes/interactivity-api/class-wp-interactivity-api.php +++ b/src/wp-includes/interactivity-api/class-wp-interactivity-api.php @@ -220,6 +220,8 @@ final class WP_Interactivity_API { * store namespace. * @return array The current state for the specified store namespace. This will be the updated state if a $state * argument was provided. + * + * @phpstan-impure */ public function state( ?string $store_namespace = null, ?array $state = null ): array { if ( ! $store_namespace ) { @@ -274,6 +276,8 @@ public function state( ?string $store_namespace = null, ?array $state = null ): * specified store namespace. * @return array The configuration for the specified store namespace. This will be the updated configuration if a * $config argument was provided. + * + * @phpstan-impure */ public function config( string $store_namespace, array $config = array() ): array { $this->config_data[ $store_namespace ] ??= array(); @@ -495,6 +499,8 @@ public function add_load_on_client_navigation_attribute_to_script_modules( $attr * @since 6.9.0 * * @param string $script_module_id The script module identifier. + * + * @phpstan-impure */ public function add_client_navigation_support_to_script_module( string $script_module_id ) { $this->script_modules_that_can_load_on_client_navigation[ $script_module_id ] = true; @@ -513,6 +519,8 @@ public function add_client_navigation_support_to_script_module( string $script_m * * @param string $html The HTML content to process. * @return string The processed HTML content. It returns the original content when the HTML contains unbalanced tags. + * + * @phpstan-impure */ public function process_directives( string $html ): string { if ( ! str_contains( $html, 'data-wp-' ) ) { @@ -578,6 +586,8 @@ public function process_directives( string $html ): string { * * @param string $html The HTML content to process. * @return string|null The processed HTML content. It returns null when the HTML contains unbalanced tags. + * + * @phpstan-impure */ private function _process_directives( string $html ) { $p = new WP_Interactivity_API_Directives_Processor( $html ); @@ -769,6 +779,8 @@ private function _process_directives( string $html ) { * * @param array $entry An array containing a whole directive entry with its namespace, value, suffix, or unique ID. * @return mixed|null The result of the evaluation. Null if the reference path doesn't exist or the namespace is falsy. + * + * @phpstan-impure */ private function evaluate( $entry ) { $context = end( $this->context_stack ); @@ -1129,6 +1141,8 @@ function ( $matches ) { * * @param WP_Interactivity_API_Directives_Processor $p The directives processor instance. * @param string $mode Whether the processing is entering or exiting the tag. + * + * @phpstan-impure */ private function data_wp_interactive_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) { // When exiting tags, it removes the last namespace from the stacks. @@ -1193,6 +1207,8 @@ private function data_wp_interactive_processor( WP_Interactivity_API_Directives_ * * @param WP_Interactivity_API_Directives_Processor $p The directives processor instance. * @param string $mode Whether the processing is entering or exiting the tag. + * + * @phpstan-impure */ private function data_wp_context_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) { // When exiting tags, it removes the last context from the stack. @@ -1909,6 +1925,8 @@ class="wp-interactivity-router-loading-bar" * * @param WP_Interactivity_API_Directives_Processor $p The directives processor instance. * @param string $mode Whether the processing is entering or exiting the tag. + * + * @phpstan-impure */ private function data_wp_router_region_processor( WP_Interactivity_API_Directives_Processor $p, string $mode ) { if ( 'enter' === $mode && ! $this->has_processed_router_region ) { @@ -1945,6 +1963,8 @@ private function data_wp_router_region_processor( WP_Interactivity_API_Directive * @param WP_Interactivity_API_Directives_Processor $p The directives processor instance. * @param string $mode Whether the processing is entering or exiting the tag. * @param array $tag_stack The reference to the tag stack. + * + * @phpstan-impure */ private function data_wp_each_processor( WP_Interactivity_API_Directives_Processor $p, string $mode, array &$tag_stack ) { if ( 'enter' === $mode && 'TEMPLATE' === $p->get_tag() ) { diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index f2195e2f3335a..51a9b48bca634 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -1193,6 +1193,8 @@ private function get_span() { * @param string $name Name of HTML attribute to set. * @param string|true $value Value to set; `true` for boolean attribute. * @return bool Whether the attribute was set. + * + * @phpstan-impure */ public function set_attribute( $name, $value ): bool { $lower_name = strtolower( $name ); @@ -1390,6 +1392,8 @@ private static function contains_a_block_delimiter( string $text ): bool { * @access private * * @return string Sanitized copy of given input HTML. + * + * @phpstan-impure */ public function sanitize() { $template_depth = 0; diff --git a/src/wp-includes/l10n/class-wp-translation-controller.php b/src/wp-includes/l10n/class-wp-translation-controller.php index f04849fea3bf7..617d24fed3b9e 100644 --- a/src/wp-includes/l10n/class-wp-translation-controller.php +++ b/src/wp-includes/l10n/class-wp-translation-controller.php @@ -57,6 +57,8 @@ final class WP_Translation_Controller { * @since 6.5.0 * * @return WP_Translation_Controller + * + * @phpstan-impure */ public static function get_instance(): WP_Translation_Controller { self::$instance ??= new self(); @@ -81,6 +83,8 @@ public function get_locale(): string { * @since 6.5.0 * * @param string $locale Locale. + * + * @phpstan-impure */ public function set_locale( string $locale ) { $this->current_locale = $locale; @@ -95,6 +99,8 @@ public function set_locale( string $locale ) { * @param string $textdomain Optional. Text domain. Default 'default'. * @param string $locale Optional. Locale. Default current locale. * @return bool True on success, false otherwise. + * + * @phpstan-impure */ public function load_file( string $translation_file, string $textdomain = 'default', ?string $locale = null ): bool { $locale ??= $this->current_locale; @@ -146,6 +152,8 @@ public function load_file( string $translation_file, string $textdomain = 'defau * @param string $textdomain Optional. Text domain. Default 'default'. * @param string $locale Optional. Locale. Defaults to all locales. * @return bool True on success, false otherwise. + * + * @phpstan-impure */ public function unload_file( $file, string $textdomain = 'default', ?string $locale = null ): bool { if ( is_string( $file ) ) { @@ -191,6 +199,8 @@ public function unload_file( $file, string $textdomain = 'default', ?string $loc * @param string $textdomain Optional. Text domain. Default 'default'. * @param string $locale Optional. Locale. Defaults to all locales. * @return bool True on success, false otherwise. + * + * @phpstan-impure */ public function unload_textdomain( string $textdomain = 'default', ?string $locale = null ): bool { $unloaded = false; diff --git a/src/wp-includes/l10n/class-wp-translation-file-mo.php b/src/wp-includes/l10n/class-wp-translation-file-mo.php index 36d782cd5151d..52b6fb95c2395 100644 --- a/src/wp-includes/l10n/class-wp-translation-file-mo.php +++ b/src/wp-includes/l10n/class-wp-translation-file-mo.php @@ -40,6 +40,8 @@ class WP_Translation_File_MO extends WP_Translation_File { * * @param string $header File contents. * @return false|'V'|'N' V for little endian, N for big endian, or false on failure. + * + * @phpstan-impure */ protected function detect_endian_and_validate_file( string $header ) { $big = unpack( 'N', $header ); @@ -86,6 +88,8 @@ protected function detect_endian_and_validate_file( string $header ) { * @since 6.5.0 * * @return bool True on success, false otherwise. + * + * @phpstan-impure */ protected function parse_file(): bool { $this->parsed = true; @@ -184,6 +188,8 @@ protected function parse_file(): bool { * @since 6.5.0 * * @return string Translation file contents. + * + * @phpstan-impure */ public function export(): string { // Prefix the headers as the first key. diff --git a/src/wp-includes/l10n/class-wp-translation-file-php.php b/src/wp-includes/l10n/class-wp-translation-file-php.php index f93dd0163fddc..aef12d5aee7ed 100644 --- a/src/wp-includes/l10n/class-wp-translation-file-php.php +++ b/src/wp-includes/l10n/class-wp-translation-file-php.php @@ -17,6 +17,8 @@ class WP_Translation_File_PHP extends WP_Translation_File { * Parses the file. * * @since 6.5.0 + * + * @phpstan-impure */ protected function parse_file() { $this->parsed = true; diff --git a/src/wp-includes/l10n/class-wp-translation-file.php b/src/wp-includes/l10n/class-wp-translation-file.php index 336b3a7814900..eef19e1f2a4b6 100644 --- a/src/wp-includes/l10n/class-wp-translation-file.php +++ b/src/wp-includes/l10n/class-wp-translation-file.php @@ -213,6 +213,8 @@ public function translate( string $text ) { * * @param int $number Count. * @return int Plural form. + * + * @phpstan-impure */ public function get_plural_form( int $number ): int { if ( ! $this->parsed ) { @@ -281,6 +283,8 @@ protected function make_plural_form_function( string $expression ): callable { * * @param WP_Translation_File $source Source file. * @return bool True on success, false otherwise. + * + * @phpstan-impure */ protected function import( WP_Translation_File $source ): bool { if ( null !== $source->error() ) { diff --git a/src/wp-includes/rest-api/class-wp-rest-request.php b/src/wp-includes/rest-api/class-wp-rest-request.php index 5efb16b28ff5d..dd3091bd9e876 100644 --- a/src/wp-includes/rest-api/class-wp-rest-request.php +++ b/src/wp-includes/rest-api/class-wp-rest-request.php @@ -201,6 +201,8 @@ public function get_method() { * @since 4.4.0 * * @param string $method HTTP method. + * + * @phpstan-impure */ public function set_method( $method ) { $this->method = strtoupper( $method ); @@ -305,6 +307,8 @@ public function get_header_as_array( $key ) { * * @param string $key Header name. * @param string|string[] $value Header value, or list of values. + * + * @phpstan-impure */ public function set_header( $key, $value ) { $key = static::canonicalize_header_name( $key ); @@ -320,6 +324,8 @@ public function set_header( $key, $value ) { * * @param string $key Header name. * @param string|string[] $value Header value, or list of values. + * + * @phpstan-impure */ public function add_header( $key, $value ) { $key = static::canonicalize_header_name( $key ); @@ -334,6 +340,8 @@ public function add_header( $key, $value ) { * @since 4.4.0 * * @param string $key Header name. + * + * @phpstan-impure */ public function remove_header( $key ) { $key = static::canonicalize_header_name( $key ); @@ -347,6 +355,8 @@ public function remove_header( $key ) { * * @param array $headers Map of header name to value, or list of values. * @param bool $override If true, replace the request's headers. Otherwise, merge with existing. + * + * @phpstan-impure */ public function set_headers( $headers, $override = true ) { if ( true === $override ) { @@ -519,6 +529,8 @@ public function has_param( $key ) { * * @param string $key Parameter name. * @param mixed $value Parameter value. + * + * @phpstan-impure */ public function set_param( $key, $value ) { $order = $this->get_parameter_order(); @@ -590,6 +602,8 @@ public function get_url_params() { * @since 4.4.0 * * @param array $params Parameter map of key to value. + * + * @phpstan-impure */ public function set_url_params( $params ) { $this->params['URL'] = $params; @@ -616,6 +630,8 @@ public function get_query_params() { * @since 4.4.0 * * @param array $params Parameter map of key to value. + * + * @phpstan-impure */ public function set_query_params( $params ) { $this->params['GET'] = $params; @@ -642,6 +658,8 @@ public function get_body_params() { * @since 4.4.0 * * @param array $params Parameter map of key to value. + * + * @phpstan-impure */ public function set_body_params( $params ) { $this->params['POST'] = $params; @@ -672,6 +690,8 @@ public function get_file_params() { * @param array> $params Parameter map of key to value. * * @phpstan-param array $params + * + * @phpstan-impure */ public function set_file_params( $params ) { $this->params['FILES'] = $params; @@ -698,6 +718,8 @@ public function get_default_params() { * @since 4.4.0 * * @param array $params Parameter map of key to value. + * + * @phpstan-impure */ public function set_default_params( $params ) { $this->params['defaults'] = $params; @@ -720,6 +742,8 @@ public function get_body() { * @since 4.4.0 * * @param string $data Binary data from the request body. + * + * @phpstan-impure */ public function set_body( $data ) { $this->body = $data; @@ -754,6 +778,8 @@ public function get_json_params() { * @since 4.4.0 * @since 4.7.0 Returns error instance if value cannot be decoded. * @return true|WP_Error True if the JSON data was passed or no JSON data was provided, WP_Error if invalid JSON was passed. + * + * @phpstan-impure */ protected function parse_json_params() { if ( $this->parsed_json ) { @@ -802,6 +828,8 @@ protected function parse_json_params() { * natively by PHP. * * @since 4.4.0 + * + * @phpstan-impure */ protected function parse_body_params() { if ( $this->parsed_body ) { @@ -846,6 +874,8 @@ public function get_route() { * @since 4.4.0 * * @param string $route Route matching regex. + * + * @phpstan-impure */ public function set_route( $route ) { $this->route = $route; @@ -874,6 +904,8 @@ public function get_attributes() { * @param array $attributes Attributes for the request. * * @phpstan-param Attributes $attributes + * + * @phpstan-impure */ public function set_attributes( $attributes ) { $this->attributes = $attributes; @@ -888,6 +920,8 @@ public function set_attributes( $attributes ) { * @since 4.4.0 * * @return true|WP_Error True if parameters were sanitized, WP_Error if an error occurred during sanitization. + * + * @phpstan-impure */ public function sanitize_params() { $attributes = $this->get_attributes(); diff --git a/src/wp-includes/rest-api/class-wp-rest-response.php b/src/wp-includes/rest-api/class-wp-rest-response.php index 7ec735a8f7a41..1ba522a12dd78 100644 --- a/src/wp-includes/rest-api/class-wp-rest-response.php +++ b/src/wp-includes/rest-api/class-wp-rest-response.php @@ -103,6 +103,8 @@ class WP_REST_Response extends WP_HTTP_Response { * @phpstan-param non-falsy-string $rel * @phpstan-param non-falsy-string $href * @phpstan-param Link_Attributes $attributes + * + * @phpstan-impure */ public function add_link( $rel, $href, $attributes = array() ) { if ( empty( $this->links[ $rel ] ) ) { @@ -130,6 +132,8 @@ public function add_link( $rel, $href, $attributes = array() ) { * Default null. * * @phpstan-param non-falsy-string $rel + * + * @phpstan-impure */ public function remove_link( $rel, $href = null ) { if ( ! isset( $this->links[ $rel ] ) ) { @@ -234,6 +238,8 @@ public function get_matched_route() { * @since 4.4.0 * * @param string $route Route name. + * + * @phpstan-impure */ public function set_matched_route( $route ) { $this->matched_route = $route; @@ -260,6 +266,8 @@ public function get_matched_handler() { * @param array $handler The matched handler. * * @phpstan-param Route_Handler $handler + * + * @phpstan-impure */ public function set_matched_handler( $handler ) { $this->matched_handler = $handler; @@ -304,6 +312,8 @@ public function get_data_processing() { * and `links` features are on. A feature not named stays on. * * @phpstan-param bool|array{fields?: bool, embed?: bool, links?: bool} $processing + * + * @phpstan-impure */ public function set_data_processing( $processing ) { $this->data_processing = WP_REST_Server::resolve_data_processing( array( 'data_processing' => $processing ) ); diff --git a/src/wp-includes/rest-api/class-wp-rest-server.php b/src/wp-includes/rest-api/class-wp-rest-server.php index be4af523d3992..e806fdb5ab3f6 100644 --- a/src/wp-includes/rest-api/class-wp-rest-server.php +++ b/src/wp-includes/rest-api/class-wp-rest-server.php @@ -329,6 +329,8 @@ protected function get_json_encode_options( WP_REST_Request $request ) { * @param string|null $path Optional. The request route. If not set, `$_SERVER['PATH_INFO']` will be used. * Default null. * @return null|false Null if not served and a HEAD request, false otherwise. + * + * @phpstan-impure */ public function serve_request( $path = null ) { // Refuse to start a fresh top-level REST cycle while another dispatch @@ -636,6 +638,8 @@ public function serve_request( $path = null ) { * @return mixed Data with sub-requests embedded: an array with the links under `_links` and the embedded * resources under `_embedded`, or scalar and object data as it is unless the object * implements `ArrayAccess`. + * + * @phpstan-impure */ public function response_to_data( $response, $embed ) { $data = $response->get_data(); @@ -838,6 +842,8 @@ public static function get_compact_response_links( $response ) { * @type array $_links Links. * @type array $_embedded Embedded objects. * } + * + * @phpstan-impure */ protected function embed_links( $data, $embed = true ) { if ( empty( $data['_links'] ) ) { @@ -964,6 +970,8 @@ public function envelope_response( $response, $embed ) { * Default false. * * @phpstan-param non-empty-string $route + * + * @phpstan-impure */ public function register_route( $route_namespace, $route, $route_args, $override = false ) { if ( ! isset( $this->namespaces[ $route_namespace ] ) ) { @@ -1028,6 +1036,8 @@ public function register_route( $route_namespace, $route, $route_args, $override * `$handler` is an array of endpoint arguments. * * @phpstan-return array> + * + * @phpstan-impure */ public function get_routes( $route_namespace = '' ) { $endpoints = $this->endpoints; @@ -1220,6 +1230,8 @@ public static function resolve_data_processing( $handler, $route_options = null * * @param WP_REST_Request $request Request to attempt dispatching. * @return WP_REST_Response Response returned by the callback. + * + * @phpstan-impure */ public function dispatch( $request ) { $this->dispatching_requests[] = $request; @@ -2155,6 +2167,8 @@ public function remove_header( $key ) { * @global string $HTTP_RAW_POST_DATA Raw post data. * * @return string Raw request data. + * + * @phpstan-impure */ public static function get_raw_data() { // phpcs:disable PHPCompatibility.Variables.RemovedPredefinedGlobalVariables.http_raw_post_dataDeprecatedRemoved diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php index 767917d6f6fd0..ce059e6e35ef9 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php @@ -781,6 +781,8 @@ public function get_collection_params() { * @since 5.6.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php index 0277a7dd44f76..6a116e6836fba 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php @@ -1767,6 +1767,8 @@ protected function prepare_links( $post ) { * @since 4.7.0 * * @return array Item schema as an array. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php index c0d58160467b2..38643d7faac6a 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php @@ -342,6 +342,8 @@ public function get_items( $request ) { * @since 5.0.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php index 8bb4116daab41..659f67cf6dd97 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php @@ -213,6 +213,8 @@ protected function find_plugin_for_slug( $slug ) { * @since 5.5.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php index 17efc869f8bc9..36433af9eba16 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-block-pattern-categories-controller.php @@ -128,6 +128,8 @@ public function prepare_item_for_response( $item, $request ) { * @since 6.0.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php index 065b863be46f1..580229dcff847 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-block-patterns-controller.php @@ -100,6 +100,8 @@ public function get_items_permissions_check( $request ) { * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. + * + * @phpstan-impure */ public function get_items( $request ) { if ( ! $this->remote_patterns_loaded ) { @@ -203,6 +205,8 @@ public function prepare_item_for_response( $item, $request ) { * @since 6.3.0 Added `source` property. * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php index de7e147c38917..abdd36b83b099 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php @@ -107,6 +107,8 @@ public function register_routes() { * * @param WP_REST_Request $request Request. * @return true|WP_Error True if the request has read access, WP_Error object otherwise. + * + * @phpstan-impure */ public function get_item_permissions_check( $request ) { global $post; @@ -149,6 +151,8 @@ public function get_item_permissions_check( $request ) { * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. + * + * @phpstan-impure */ public function get_item( $request ) { global $post; @@ -200,6 +204,8 @@ public function get_item( $request ) { * @since 5.0.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php index a6b3192f52d42..7378103482a4c 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php @@ -417,6 +417,8 @@ protected function prepare_links( $block_type ) { * @since 6.3.0 Added `selectors` field. * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php index b7286bea746e4..aa6c0279d6ad5 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-blocks-controller.php @@ -69,6 +69,8 @@ public function filter_response_by_context( $data, $context ) { * @since 5.0.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php index f5739e6b3a3f3..618cdd57643c1 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php @@ -260,6 +260,8 @@ public function get_items_permissions_check( $request ) { * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or error object on failure. + * + * @phpstan-impure */ public function get_items( $request ) { @@ -1456,6 +1458,8 @@ public function delete_item( $request ) { * @param WP_Comment $item Comment object. * @param WP_REST_Request $request Request object. * @return WP_REST_Response Response object. + * + * @phpstan-impure */ public function prepare_item_for_response( $item, $request ) { // Restores the more descriptive, specific name for use within this method. @@ -1879,6 +1883,8 @@ protected function prepare_item_for_database( $request ) { * @since 4.7.0 * * @return array + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { @@ -2335,6 +2341,8 @@ protected function check_read_post_permission( $post, $request ) { * @global wpdb $wpdb WordPress database abstraction object. * * @param int[] $note_ids Array of note comment IDs. + * + * @phpstan-impure */ protected function prefetch_reaction_summaries( $note_ids ) { global $wpdb; diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-entity-actions-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-entity-actions-controller.php index bf9ebcf895a16..fb8e5a0552c1b 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-entity-actions-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-entity-actions-controller.php @@ -213,6 +213,8 @@ public function get_items( $request ) { * @since 7.2.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-entity-fields-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-entity-fields-controller.php index c9738f2a7bb6e..e458512f89432 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-entity-fields-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-entity-fields-controller.php @@ -175,6 +175,8 @@ public function get_items( $request ) { * @since 7.2.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-font-collections-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-font-collections-controller.php index 8ed02e1414a84..420e026e3b067 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-font-collections-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-font-collections-controller.php @@ -242,6 +242,8 @@ public function prepare_item_for_response( $item, $request ) { * @since 6.5.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php index 2aaf63cd1058f..59b8182f8bedf 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php @@ -499,6 +499,8 @@ public function prepare_item_for_response( $item, $request ) { * @since 6.5.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-font-families-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-font-families-controller.php index a126055b4c807..694eb9f492447 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-font-families-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-font-families-controller.php @@ -285,6 +285,8 @@ public function prepare_item_for_response( $item, $request ) { * @since 6.5.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php index daa83ba3526b7..7beed191c1360 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php @@ -468,6 +468,8 @@ public function get_collection_params() { * @since 5.9.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php index 32f628a99e7ce..0e731b33b93d2 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php @@ -383,6 +383,8 @@ public function prepare_item_for_response( $post, $request ) { * @since 6.6.0 Merged parent and parent controller schema data. * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-icon-collections-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-icon-collections-controller.php index ab6c83f2ea6c5..39e64b8d9a015 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-icon-collections-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-icon-collections-controller.php @@ -219,6 +219,8 @@ public function prepare_item_for_response( $item, $request ) { * @since 7.1.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-icons-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-icons-controller.php index afcf80f4b25e9..cea85f3d41400 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-icons-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-icons-controller.php @@ -284,6 +284,8 @@ public function prepare_item_for_response( $item, $request ) { * @since 7.2.0 Added the `keywords` property. * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php index 25ff7be699759..2ebd141844235 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php @@ -742,6 +742,8 @@ protected function get_schema_links() { * @since 5.9.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php index c9ce88ce24f36..311fdc6c8b3d6 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-menu-locations-controller.php @@ -264,6 +264,8 @@ protected function prepare_links( $location ) { * @since 5.9.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php index 887662e06ad33..366acd4c7471e 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php @@ -525,6 +525,8 @@ protected function handle_locations( $menu_id, $request ) { * @since 5.9.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-navigation-fallback-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-navigation-fallback-controller.php index a299ab3c604b3..f9cc335d0a548 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-navigation-fallback-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-navigation-fallback-controller.php @@ -117,6 +117,8 @@ public function get_item( $request ) { * @since 6.3.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php index fe6c056eb7f16..a65d59a847766 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php @@ -227,6 +227,8 @@ public function prepare_item_for_response( $item, $request ) { * @since 6.2.0 Added `'block_types'` to schema. * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php index 32659e253e88c..d81ba14d5ff0e 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php @@ -874,6 +874,8 @@ protected function is_filesystem_available() { * @since 5.5.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php index fab2307a2ea7d..502bd682897d5 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php @@ -291,6 +291,8 @@ public function prepare_item_for_response( $item, $request ) { * @since 4.7.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php index 0a6638934693a..e6f30a3e1be7f 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php @@ -318,6 +318,8 @@ protected function prepare_links( $post_type ) { * @since 6.1.0 The `icon` property was added. * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 0c24925ff9245..5e20d0f081a3b 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -1880,6 +1880,8 @@ protected function check_delete_permission( $post ) { * @param WP_Post $item Post object. * @param WP_REST_Request $request Request object. * @return WP_REST_Response Response object. + * + * @phpstan-impure */ public function prepare_item_for_response( $item, $request ) { // Restores the more descriptive, specific name for use within this method. @@ -2425,6 +2427,8 @@ protected function get_available_actions( $post, $request ) { * properties: array>, * ... * } + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php index a68f0cd5a513f..149081f09be68 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php @@ -604,6 +604,8 @@ protected function prepare_items_query( $prepared_args = array(), $request = nul * @param WP_Post $item Post revision object. * @param WP_REST_Request $request Request object. * @return WP_REST_Response Response object. + * + * @phpstan-impure */ public function prepare_item_for_response( $item, $request ) { /* @@ -818,6 +820,8 @@ protected function prepare_date_response( $date_gmt, $date = null ) { * @since 7.2.0 The `meta` property only describes the meta keys that are revisioned for the parent post type. * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php index 4a9c6103d3f0a..6fa92dd4ebf77 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php @@ -243,6 +243,8 @@ public function prepare_item_for_response( $item, $request ) { * @since 5.0.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php index 142836c7c8921..3f4e60d88380f 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php @@ -272,6 +272,8 @@ protected function get_registered_options() { * @since 4.7.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php index 80efbf5ea5bb0..8980beb6ff644 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-sidebars-controller.php @@ -299,6 +299,8 @@ protected function get_sidebar( $id ) { * @since 5.9.0 * * @see retrieve_widgets() + * + * @phpstan-impure */ protected function retrieve_widgets() { if ( ! $this->widgets_retrieved ) { @@ -431,6 +433,8 @@ protected function prepare_links( $sidebar ) { * @since 5.8.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php index 41e15337add5f..98aa37833c5a6 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-site-health-controller.php @@ -346,6 +346,8 @@ protected function load_admin_textdomain() { * @since 5.6.0 * * @return array The test schema. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php index 082067b23eef2..8c63c2903eee7 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php @@ -328,6 +328,8 @@ protected function prepare_links( $taxonomy ) { * @since 5.9.0 The `rest_namespace` property was added. * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-template-autosaves-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-template-autosaves-controller.php index 30e7dcdcd38c0..7bb9d703b419f 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-template-autosaves-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-template-autosaves-controller.php @@ -260,6 +260,8 @@ protected function prepare_links( $template ) { * @since 6.4.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php index f88b60372b038..94e69d14e1e29 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-template-revisions-controller.php @@ -291,6 +291,8 @@ protected function prepare_links( $template ) { * @since 6.4.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php index b2429f1f482cb..fc5fe93f1d39b 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php @@ -1065,6 +1065,8 @@ public function get_collection_params() { * @since 5.9.0 Added `'area'`. * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php index 1f7d676dfa893..469e9e24fd20f 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php @@ -1041,6 +1041,8 @@ protected function prepare_links( $term ) { * @since 4.7.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php index dbdb46333f29b..a773a8382c993 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php @@ -476,6 +476,8 @@ protected function prepare_theme_support( $support, $args, $feature, $request ) * @since 5.0.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php index ab126f981c340..27792a4331c23 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php @@ -63,6 +63,8 @@ public function register_routes() { * @since 5.9.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php index 2f70bf71a34b6..f9e792d17e65c 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php @@ -1399,6 +1399,8 @@ public function check_user_password( * @since 4.7.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-view-config-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-view-config-controller.php index 7da61b0486868..997cd2acb859a 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-view-config-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-view-config-controller.php @@ -187,6 +187,8 @@ protected function cast_empty_objects( $value, $schema ) { * @since 7.1.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php index cd905188512b3..7beb750aad5a6 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php @@ -388,6 +388,8 @@ protected function prepare_links( $widget_type ) { * @since 5.8.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php index 9b25298c347ba..eea7418af1c72 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php @@ -503,6 +503,8 @@ protected function permissions_check( $request ) { * @since 5.9.0 * * @see retrieve_widgets() + * + * @phpstan-impure */ protected function retrieve_widgets() { if ( ! $this->widgets_retrieved ) { @@ -804,6 +806,8 @@ public function get_collection_params() { * @since 5.8.0 * * @return array Item schema data. + * + * @phpstan-impure */ public function get_item_schema() { if ( $this->schema ) { diff --git a/src/wp-includes/secrets/class-wp-secrets-key-manager.php b/src/wp-includes/secrets/class-wp-secrets-key-manager.php index 096d34dceaf62..ca808ef59aefb 100644 --- a/src/wp-includes/secrets/class-wp-secrets-key-manager.php +++ b/src/wp-includes/secrets/class-wp-secrets-key-manager.php @@ -208,6 +208,8 @@ public function get_master_key( string $scope, ?int $site_id = null, bool $creat * @param bool $create Optional. Whether to generate and store a root key if none * exists. Default true. * @return string|WP_Error 32 raw bytes on success. WP_Error on failure. + * + * @phpstan-impure */ public function get_root_key( bool $create = true ) { $wrapped = $this->get_wrapped_root_key(); @@ -264,6 +266,8 @@ public function get_root_key( bool $create = true ) { * @param WP_Secrets_Keyring $old_keyring Unwraps the current wrapped root key. * @param WP_Secrets_Keyring $new_keyring Wraps it again for storage. * @return true|WP_Error + * + * @phpstan-impure */ public function rotate_site_key( WP_Secrets_Keyring $old_keyring, WP_Secrets_Keyring $new_keyring ) { $wrapped = $this->get_wrapped_root_key(); @@ -365,6 +369,8 @@ private function get_wrapped_root_key() { * @global wpdb $wpdb WordPress database abstraction object. * * @return string|WP_Error + * + * @phpstan-impure */ private function generate_root_key() { global $wpdb; diff --git a/src/wp-includes/sitemaps/class-wp-sitemaps-registry.php b/src/wp-includes/sitemaps/class-wp-sitemaps-registry.php index 4775ae5da151f..64cf87e709812 100644 --- a/src/wp-includes/sitemaps/class-wp-sitemaps-registry.php +++ b/src/wp-includes/sitemaps/class-wp-sitemaps-registry.php @@ -33,6 +33,8 @@ class WP_Sitemaps_Registry { * @param string $name Name of the sitemap provider. * @param WP_Sitemaps_Provider $provider Instance of a WP_Sitemaps_Provider. * @return bool Whether the provider was added successfully. + * + * @phpstan-impure */ public function add_provider( $name, WP_Sitemaps_Provider $provider ) { if ( isset( $this->providers[ $name ] ) ) { diff --git a/src/wp-includes/style-engine/class-wp-style-engine-css-declarations.php b/src/wp-includes/style-engine/class-wp-style-engine-css-declarations.php index 797947d1e9e75..f68c159c2eb38 100644 --- a/src/wp-includes/style-engine/class-wp-style-engine-css-declarations.php +++ b/src/wp-includes/style-engine/class-wp-style-engine-css-declarations.php @@ -65,6 +65,8 @@ public function __construct( $declarations = array() ) { * @type bool $important Whether to output the declaration with !important. Default false. * } * @return WP_Style_Engine_CSS_Declarations Returns the object to allow chaining methods. + * + * @phpstan-impure */ public function add_declaration( $property, $value, $options = array() ) { // Sanitizes the property. @@ -111,6 +113,8 @@ public function add_declaration( $property, $value, $options = array() ) { * * @param string $property The CSS property. * @return WP_Style_Engine_CSS_Declarations Returns the object to allow chaining methods. + * + * @phpstan-impure */ public function remove_declaration( $property ) { unset( $this->declarations[ $property ] ); diff --git a/src/wp-includes/style-engine/class-wp-style-engine-css-rule.php b/src/wp-includes/style-engine/class-wp-style-engine-css-rule.php index a483911335ad9..8051872d4d00b 100644 --- a/src/wp-includes/style-engine/class-wp-style-engine-css-rule.php +++ b/src/wp-includes/style-engine/class-wp-style-engine-css-rule.php @@ -71,6 +71,8 @@ public function __construct( $selector = '', $declarations = array(), $rules_gro * * @param string $selector The CSS selector. * @return WP_Style_Engine_CSS_Rule Returns the object to allow chaining of methods. + * + * @phpstan-impure */ public function set_selector( $selector ) { $this->selector = $selector; @@ -86,6 +88,8 @@ public function set_selector( $selector ) { * @param string[]|WP_Style_Engine_CSS_Declarations $declarations An array of declarations (property => value pairs), * or a WP_Style_Engine_CSS_Declarations object. * @return WP_Style_Engine_CSS_Rule Returns the object to allow chaining of methods. + * + * @phpstan-impure */ public function add_declarations( $declarations ) { $is_declarations_object = ! is_array( $declarations ); @@ -119,6 +123,8 @@ public function add_declarations( $declarations ) { * @param string $rules_group A parent CSS selector in the case of nested CSS, or a CSS nested @rule, * such as `@media (min-width: 80rem)` or `@layer module`. * @return WP_Style_Engine_CSS_Rule Returns the object to allow chaining of methods. + * + * @phpstan-impure */ public function set_rules_group( $rules_group ) { $this->rules_group = $rules_group; diff --git a/src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php b/src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php index ea55ceaa64f79..2f4069156acfd 100644 --- a/src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php +++ b/src/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php @@ -52,6 +52,8 @@ class WP_Style_Engine_CSS_Rules_Store { * * @param string $store_name The name of the store. * @return WP_Style_Engine_CSS_Rules_Store|null + * + * @phpstan-impure */ public static function get_store( $store_name = 'default' ) { if ( ! is_string( $store_name ) || empty( $store_name ) ) { @@ -80,6 +82,8 @@ public static function get_stores() { * Clears all stores from static::$stores. * * @since 6.1.0 + * + * @phpstan-impure */ public static function remove_all_stores() { static::$stores = array(); @@ -91,6 +95,8 @@ public static function remove_all_stores() { * @since 6.1.0 * * @param string $name The store name. + * + * @phpstan-impure */ public function set_name( $name ) { $this->name = $name; @@ -130,6 +136,8 @@ public function get_all_rules() { * such as `@media (min-width: 80rem)` or `@layer module`. * @return WP_Style_Engine_CSS_Rule|null Returns a WP_Style_Engine_CSS_Rule object, * or null if the selector is empty. + * + * @phpstan-impure */ public function add_rule( $selector, $rules_group = '' ) { $selector = $selector ? trim( $selector ) : ''; @@ -161,6 +169,8 @@ public function add_rule( $selector, $rules_group = '' ) { * @since 6.1.0 * * @param string $selector The CSS selector. + * + * @phpstan-impure */ public function remove_rule( $selector ) { unset( $this->rules[ $selector ] ); diff --git a/src/wp-includes/style-engine/class-wp-style-engine-processor.php b/src/wp-includes/style-engine/class-wp-style-engine-processor.php index a896ea675975e..3c7f76de70242 100644 --- a/src/wp-includes/style-engine/class-wp-style-engine-processor.php +++ b/src/wp-includes/style-engine/class-wp-style-engine-processor.php @@ -38,6 +38,8 @@ class WP_Style_Engine_Processor { * * @param WP_Style_Engine_CSS_Rules_Store $store The store to add. * @return WP_Style_Engine_Processor Returns the object to allow chaining methods. + * + * @phpstan-impure */ public function add_store( $store ) { if ( ! $store instanceof WP_Style_Engine_CSS_Rules_Store ) { @@ -64,6 +66,8 @@ public function add_store( $store ) { * WP_Style_Engine_CSS_Rule objects * from a store or otherwise. * @return WP_Style_Engine_Processor Returns the object to allow chaining methods. + * + * @phpstan-impure */ public function add_rules( $css_rules ) { if ( ! is_array( $css_rules ) ) { @@ -146,6 +150,8 @@ public function get_css( $options = array() ) { * Combines selectors from the rules store when they have the same styles. * * @since 6.1.0 + * + * @phpstan-impure */ private function combine_rules_selectors() { // Build an array of selectors along with the JSON-ified styles to make comparisons easier. diff --git a/src/wp-includes/widgets/class-wp-widget-calendar.php b/src/wp-includes/widgets/class-wp-widget-calendar.php index 9103934173f8e..27f1a5e24775b 100644 --- a/src/wp-includes/widgets/class-wp-widget-calendar.php +++ b/src/wp-includes/widgets/class-wp-widget-calendar.php @@ -46,6 +46,8 @@ public function __construct() { * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance The settings for the particular instance of the widget. + * + * @phpstan-impure */ public function widget( $args, $instance ) { $title = ! empty( $instance['title'] ) ? $instance['title'] : ''; diff --git a/src/wp-includes/widgets/class-wp-widget-custom-html.php b/src/wp-includes/widgets/class-wp-widget-custom-html.php index 4cb17ad365de8..42814ae8067fd 100644 --- a/src/wp-includes/widgets/class-wp-widget-custom-html.php +++ b/src/wp-includes/widgets/class-wp-widget-custom-html.php @@ -61,6 +61,8 @@ public function __construct() { * * @param int $number Optional. The unique order number of this widget instance * compared to other instances of the same class. Default -1. + * + * @phpstan-impure */ public function _register_one( $number = -1 ) { parent::_register_one( $number ); @@ -113,6 +115,8 @@ public function _filter_gallery_shortcode_attrs( $attrs ) { * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance Settings for the current Custom HTML widget instance. + * + * @phpstan-impure */ public function widget( $args, $instance ) { global $post; diff --git a/src/wp-includes/widgets/class-wp-widget-media.php b/src/wp-includes/widgets/class-wp-widget-media.php index ef3192ea8491b..4d3ef171dfa28 100644 --- a/src/wp-includes/widgets/class-wp-widget-media.php +++ b/src/wp-includes/widgets/class-wp-widget-media.php @@ -99,6 +99,8 @@ public function __construct( $id_base, $name, $widget_options = array(), $contro * * @param int $number Optional. The unique order number of this widget instance * compared to other instances of the same class. Default -1. + * + * @phpstan-impure */ public function _register_one( $number = -1 ) { parent::_register_one( $number ); @@ -448,6 +450,8 @@ public function render_control_template_scripts() { * Resets the cache for the default labels. * * @since 6.0.0 + * + * @phpstan-impure */ public static function reset_default_labels() { self::$default_description = ''; @@ -472,6 +476,8 @@ protected function has_content( $instance ) { * @since 6.0.0 * * @return string + * + * @phpstan-impure */ protected static function get_default_description() { if ( self::$default_description ) { @@ -488,6 +494,8 @@ protected static function get_default_description() { * @since 6.0.0 * * @return (string|array)[] + * + * @phpstan-impure */ protected static function get_l10n_defaults() { if ( ! empty( self::$l10n_defaults ) ) { diff --git a/src/wp-includes/widgets/class-wp-widget-text.php b/src/wp-includes/widgets/class-wp-widget-text.php index 707c5f6e9c3e0..60ebd9463946e 100644 --- a/src/wp-includes/widgets/class-wp-widget-text.php +++ b/src/wp-includes/widgets/class-wp-widget-text.php @@ -48,6 +48,8 @@ public function __construct() { * * @param int $number Optional. The unique order number of this widget instance * compared to other instances of the same class. Default -1. + * + * @phpstan-impure */ public function _register_one( $number = -1 ) { parent::_register_one( $number ); @@ -223,6 +225,8 @@ public function _filter_gallery_shortcode_attrs( $attrs ) { * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance Settings for the current Text widget instance. + * + * @phpstan-impure */ public function widget( $args, $instance ) { global $post; diff --git a/tests/phpstan/GlobalDocBlockVisitor.php b/tests/phpstan/GlobalDocBlockVisitor.php index 8656215461302..f74a9aa18aa05 100644 --- a/tests/phpstan/GlobalDocBlockVisitor.php +++ b/tests/phpstan/GlobalDocBlockVisitor.php @@ -59,6 +59,8 @@ final class GlobalDocBlockVisitor extends NodeVisitorAbstract { * * @param array $nodes Top-level nodes about to be traversed. * @return array|null + * + * @phpstan-impure */ public function beforeTraverse( array $nodes ): ?array { $this->stack = array(); @@ -71,6 +73,8 @@ public function beforeTraverse( array $nodes ): ?array { * * @param Node $node The node being entered. * @return null + * + * @phpstan-impure */ public function enterNode( Node $node ): ?Node { if ( $node instanceof Node\FunctionLike ) { diff --git a/tests/phpstan/HashNotationVisitor.php b/tests/phpstan/HashNotationVisitor.php index d5be69a572d64..3e1211723b074 100644 --- a/tests/phpstan/HashNotationVisitor.php +++ b/tests/phpstan/HashNotationVisitor.php @@ -235,6 +235,8 @@ final class HashNotationVisitor extends NodeVisitorAbstract { * * @param Node[] $nodes The nodes of the file. * @return null Always null, leaving the nodes as they are. + * + * @phpstan-impure */ public function beforeTraverse( array $nodes ) { $this->scope_local_types = array(); @@ -248,6 +250,8 @@ public function beforeTraverse( array $nodes ) { * * @param Node $node The node being left. * @return null Always null, leaving the node as it is. + * + * @phpstan-impure */ public function leaveNode( Node $node ) { if ( $node instanceof Node\Stmt\ClassLike || $node instanceof Node\FunctionLike ) { @@ -271,6 +275,8 @@ public function leaveNode( Node $node ) { * * @param Node $node The node being entered. * @return null + * + * @phpstan-impure */ public function enterNode( Node $node ): ?Node { // Each namespace has imports of its own, so entering one starts afresh. @@ -394,6 +400,8 @@ private function by_reference_parameters( Node\FunctionLike $node ): array { * @param string $text Raw docblock text including the `/**` markers. * @param array $by_reference Parameters the function takes by reference. * @return list Tag lines, without the leading ` * `. + * + * @phpstan-impure */ private function build_additions( string $text, array $by_reference ): array { $additions = array(); @@ -962,6 +970,8 @@ private function described_element( string $member, array $entries ): ?TypeNode * * @param TypeNode $type Parsed type, which is left unchanged. * @return string|null The normalized type, or null if it names a template type or type alias. + * + * @phpstan-impure */ private function normalize_type( TypeNode $type ): ?string { $key = ( $this->resolves_names ? 'resolved' : '' ) . ';' . implode( ',', array_keys( $this->local_types ) ) . ';' . $type; @@ -1019,6 +1029,8 @@ public function enterNode( DocNode $node ): DocNode { * @param string $name Name as written. * @return string The name lowercased, and stripped of a leading backslash where * names are not resolved against a namespace or imports. + * + * @phpstan-impure */ private function normalize_name( string $name ): string { $name = strtolower( $name ); @@ -1256,6 +1268,8 @@ private function parses_as_type( string $type ): bool { * * @param string $type Type as written in the docblock. * @return TypeNode|null The parsed type, or null if the whole string is not one. + * + * @phpstan-impure */ private function parse_type( string $type ): ?TypeNode { if ( ! array_key_exists( $type, $this->parsed ) ) { @@ -1270,6 +1284,8 @@ private function parse_type( string $type ): ?TypeNode { * * @param string $type Type as written in the docblock. * @return TypeNode|null The parsed type, or null if the whole string is not one. + * + * @phpstan-impure */ private function parse_uncached( string $type ): ?TypeNode { if ( null === $this->lexer || null === $this->type_parser ) { diff --git a/tests/phpstan/HookDocBlock.php b/tests/phpstan/HookDocBlock.php index 05f75ae85d927..9f3f405f69cf2 100644 --- a/tests/phpstan/HookDocBlock.php +++ b/tests/phpstan/HookDocBlock.php @@ -446,6 +446,8 @@ private function findHookDoc( string $file, array $matcher ): ?string { * * @param string $file Absolute path to the file. * @return HookDocs + * + * @phpstan-impure */ private function getHookDocs( string $file ): array { $this->fileHookDocs[ $file ] ??= self::loadHookDocs( $file ); diff --git a/tests/phpstan/HookDocsVisitor.php b/tests/phpstan/HookDocsVisitor.php index a025c1127f402..18cc9dddf1069 100644 --- a/tests/phpstan/HookDocsVisitor.php +++ b/tests/phpstan/HookDocsVisitor.php @@ -63,6 +63,8 @@ final class HookDocsVisitor extends NodeVisitorAbstract { * * @param Node[] $nodes Nodes about to be traversed. * @return Node[]|null + * + * @phpstan-impure */ public function beforeTraverse( array $nodes ): ?array { $this->latestDocComment = null; @@ -76,6 +78,8 @@ public function beforeTraverse( array $nodes ): ?array { * * @param Node $node Node being entered. * @return Node|null + * + * @phpstan-impure */ public function enterNode( Node $node ): ?Node { $doc = $node->getDocComment(); @@ -108,6 +112,8 @@ public function enterNode( Node $node ): ?Node { * * @param Node $node Node being left. * @return Node|null + * + * @phpstan-impure */ public function leaveNode( Node $node ): ?Node { $top = end( $this->stack ); diff --git a/tests/phpstan/baselines/property.notFound.neon b/tests/phpstan/baselines/property.notFound.neon index 425d00444ca8e..6d869c17a42fe 100644 --- a/tests/phpstan/baselines/property.notFound.neon +++ b/tests/phpstan/baselines/property.notFound.neon @@ -46,7 +46,7 @@ parameters: - message: '#^Access to an undefined property WP_Upgrader_Skin\:\:\$api\.$#' identifier: property.notFound - count: 2 + count: 3 path: ../../../src/wp-admin/includes/class-theme-upgrader.php - message: '#^Access to an undefined property WP_Upgrader_Skin\:\:\$theme_info\.$#' From e1c6c0638fd9b79e27ee4e14b8c9ac75447f1146 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sat, 14 Nov 2026 12:15:49 -0800 Subject: [PATCH 3/3] Build/Test Tools: Enable `MissingImpureTagRule` by default. Now that every method it reports is marked `@phpstan-impure`, the rule is registered in the base configuration, so that new methods that change state are held to the same requirement. The opt-in configuration file is no longer needed. Co-Authored-By: Claude Opus 5.5 (medium effort) Claude-Code-Session-Id: dfb24569-a61a-4404-8588-60a387d2cccb --- tests/phpstan/base.neon | 7 +++++++ tests/phpstan/missing-impure-tag-rule.neon | 20 -------------------- 2 files changed, 7 insertions(+), 20 deletions(-) delete mode 100644 tests/phpstan/missing-impure-tag-rule.neon diff --git a/tests/phpstan/base.neon b/tests/phpstan/base.neon index e5e14d984fe79..476d494aac91d 100644 --- a/tests/phpstan/base.neon +++ b/tests/phpstan/base.neon @@ -59,6 +59,13 @@ services: tags: - phpstan.rules.rule + # Enforces that a non-void method which writes object, class, or global state is + # marked `@phpstan-impure`, so that callers do not keep stale narrowed types. + - + class: WordPress\PHPStan\MissingImpureTagRule + tags: + - phpstan.rules.rule + # Runs the visitors above over every file PHPStan parses, not only the ones it # analyzes. # diff --git a/tests/phpstan/missing-impure-tag-rule.neon b/tests/phpstan/missing-impure-tag-rule.neon deleted file mode 100644 index 3de6a227400b0..0000000000000 --- a/tests/phpstan/missing-impure-tag-rule.neon +++ /dev/null @@ -1,20 +0,0 @@ -# Opt-in audit for methods that write object, class, or global state without being marked -# `@phpstan-impure`. It is not part of the default configuration, because most of the -# methods it finds never mislead a caller. Run it with a local config that includes both -# this file and `phpstan.neon.dist`. -# -# Set `missingImpureTagRuleTransitive: true` to also report methods that change state -# only by calling another method of the class that PHPStan already treats as impure. -services: - - - class: WordPress\PHPStan\MissingImpureTagRule - arguments: - report_transitive: %missingImpureTagRuleTransitive% - tags: - - phpstan.rules.rule - -parametersSchema: - missingImpureTagRuleTransitive: bool() - -parameters: - missingImpureTagRuleTransitive: false