From 919a855f3403594f7f262746f69f1a71d490b9db Mon Sep 17 00:00:00 2001 From: alex-mpoet Date: Wed, 19 Feb 2025 17:21:56 +0300 Subject: [PATCH 01/26] Update mocha [MAILPOET-6486] --- mailpoet/package.json | 2 +- pnpm-lock.yaml | 152 +++++++++++++++++++----------------------- 2 files changed, 68 insertions(+), 86 deletions(-) diff --git a/mailpoet/package.json b/mailpoet/package.json index 18b6785428..96e6467136 100644 --- a/mailpoet/package.json +++ b/mailpoet/package.json @@ -162,7 +162,7 @@ "js-yaml": "^4.1.0", "jsdom": "^24.1.0", "json-loader": "^0.5.7", - "mocha": "^10.4.0", + "mocha": "^10.8.2", "phplint": "^2.0.5", "postcss-cli": "^11.0.0", "postcss-scss": "^4.0.9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a462dac039..19b096d5dd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -482,8 +482,8 @@ importers: specifier: ^0.5.7 version: 0.5.7 mocha: - specifier: ^10.4.0 - version: 10.4.0 + specifier: ^10.8.2 + version: 10.8.2 phplint: specifier: ^2.0.5 version: 2.0.5 @@ -992,7 +992,7 @@ packages: '@wordpress/primitives': 3.56.0 '@wordpress/react-i18n': 3.36.0 classnames: 2.5.1 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) react: 18.3.1 react-dom: 18.3.1(react@18.3.1) react-popper: 2.3.0(@popperjs/core@2.11.8)(react-dom@18.3.1)(react@18.3.1) @@ -1168,7 +1168,7 @@ packages: '@babel/core': 7.24.7 '@babel/helper-compilation-targets': 7.24.7 '@babel/helper-plugin-utils': 7.24.8 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) lodash.debounce: 4.0.8 resolve: 1.22.8 transitivePeerDependencies: @@ -2528,7 +2528,7 @@ packages: '@babel/helper-split-export-declaration': 7.24.7 '@babel/parser': 7.24.7 '@babel/types': 7.24.7 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -2542,7 +2542,7 @@ packages: '@babel/parser': 7.26.3 '@babel/template': 7.25.9 '@babel/types': 7.26.3 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -3109,7 +3109,7 @@ packages: deprecated: Use @eslint/config-array instead dependencies: '@humanwhocodes/object-schema': 1.2.1 - debug: 4.4.0 + debug: 4.3.5(supports-color@9.3.1) minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -3572,7 +3572,7 @@ packages: typescript: optional: true dependencies: - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 extract-zip: 2.0.1 progress: 2.0.3 proxy-agent: 6.3.0 @@ -4651,7 +4651,7 @@ packages: '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/type-utils': 5.62.0(typescript@5.0.2) '@typescript-eslint/utils': 5.62.0(typescript@5.0.2) - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) graphemer: 1.4.0 ignore: 5.3.1 natural-compare-lite: 1.4.0 @@ -4679,7 +4679,7 @@ packages: '@typescript-eslint/type-utils': 6.21.0(eslint@8.36.0)(typescript@5.0.2) '@typescript-eslint/utils': 6.21.0(eslint@8.36.0)(typescript@5.0.2) '@typescript-eslint/visitor-keys': 6.21.0 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) eslint: 8.36.0 graphemer: 1.4.0 ignore: 5.3.1 @@ -4724,7 +4724,7 @@ packages: '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.0.2) - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) typescript: 5.0.2 transitivePeerDependencies: - supports-color @@ -4744,7 +4744,7 @@ packages: '@typescript-eslint/types': 6.21.0 '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.0.2) '@typescript-eslint/visitor-keys': 6.21.0 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) eslint: 8.36.0 typescript: 5.0.2 transitivePeerDependencies: @@ -4787,7 +4787,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 5.56.0(typescript@5.0.2) '@typescript-eslint/utils': 5.56.0(eslint@8.36.0)(typescript@5.0.2) - debug: 4.4.0 + debug: 4.3.5(supports-color@9.3.1) eslint: 8.36.0 tsutils: 3.21.0(typescript@5.0.2) typescript: 5.0.2 @@ -4807,7 +4807,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.0.2) '@typescript-eslint/utils': 5.62.0(typescript@5.0.2) - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) tsutils: 3.21.0(typescript@5.0.2) typescript: 5.0.2 transitivePeerDependencies: @@ -4826,7 +4826,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.0.2) '@typescript-eslint/utils': 6.21.0(eslint@8.36.0)(typescript@5.0.2) - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) eslint: 8.36.0 ts-api-utils: 1.3.0(typescript@5.0.2) typescript: 5.0.2 @@ -4860,7 +4860,7 @@ packages: dependencies: '@typescript-eslint/types': 5.56.0 '@typescript-eslint/visitor-keys': 5.56.0 - debug: 4.4.0 + debug: 4.3.5(supports-color@9.3.1) globby: 11.1.0 is-glob: 4.0.3 semver: 7.6.2 @@ -4881,7 +4881,7 @@ packages: dependencies: '@typescript-eslint/types': 5.62.0 '@typescript-eslint/visitor-keys': 5.62.0 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) globby: 11.1.0 is-glob: 4.0.3 semver: 7.6.2 @@ -4902,7 +4902,7 @@ packages: dependencies: '@typescript-eslint/types': 6.21.0 '@typescript-eslint/visitor-keys': 6.21.0 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) globby: 11.1.0 is-glob: 4.0.3 minimatch: 9.0.3 @@ -8272,7 +8272,7 @@ packages: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} dependencies: - debug: 4.4.0 + debug: 4.3.4 transitivePeerDependencies: - supports-color dev: true @@ -8281,7 +8281,7 @@ packages: resolution: {integrity: sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==} engines: {node: '>= 14'} dependencies: - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) transitivePeerDependencies: - supports-color dev: true @@ -8361,8 +8361,8 @@ packages: uri-js: 4.4.1 dev: true - /ansi-colors@4.1.1: - resolution: {integrity: sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==} + /ansi-colors@4.1.3: + resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} engines: {node: '>=6'} dev: true @@ -9017,8 +9017,8 @@ packages: resolution: {integrity: sha512-1ugUSr8BHXRnK23KfuYS+gVMC3LB8QGH9W1iGtDPsNWoQbgtXSExkBu2aDR4epiGWZOjZsj6lDl/N/AqqTC3UA==} dev: true - /bare-events@2.5.0: - resolution: {integrity: sha512-/E8dDe9dsbLyh2qrZ64PEPadOQ0F4gbl1sUJOrmph7xOiIxfY8vwab/4bFLh4Y88/Hk/ujKcrQKc+ps0mv873A==} + /bare-events@2.5.4: + resolution: {integrity: sha512-+gFfDkR8pj4/TrWCGUGWmJIkBwuxPS5F+a5yWjOHQt2hHvNZd5YLzadjmDUtFmMM4y429bnKLa8bYBMHcYdnQA==} requiresBuild: true dev: true optional: true @@ -10325,7 +10325,7 @@ packages: ms: 2.1.2 dev: false - /debug@4.3.4(supports-color@8.1.1): + /debug@4.3.4: resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} peerDependencies: @@ -10335,7 +10335,6 @@ packages: optional: true dependencies: ms: 2.1.2 - supports-color: 8.1.1 dev: true /debug@4.3.5(supports-color@9.3.1): @@ -10351,7 +10350,7 @@ packages: supports-color: 9.3.1 dev: true - /debug@4.4.0: + /debug@4.4.0(supports-color@8.1.1): resolution: {integrity: sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==} engines: {node: '>=6.0'} peerDependencies: @@ -10361,6 +10360,7 @@ packages: optional: true dependencies: ms: 2.1.3 + supports-color: 8.1.1 /decamelize-keys@1.1.1: resolution: {integrity: sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg==} @@ -10591,11 +10591,6 @@ packages: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} engines: {node: '>=0.3.1'} - /diff@5.0.0: - resolution: {integrity: sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==} - engines: {node: '>=0.3.1'} - dev: true - /diff@5.2.0: resolution: {integrity: sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==} engines: {node: '>=0.3.1'} @@ -10876,7 +10871,7 @@ packages: resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} engines: {node: '>=8.6'} dependencies: - ansi-colors: 4.1.1 + ansi-colors: 4.1.3 strip-ansi: 6.0.1 dev: true @@ -11137,7 +11132,7 @@ packages: optional: true dependencies: '@nolyfill/is-core-module': 1.0.39 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) enhanced-resolve: 5.17.1 fast-glob: 3.3.2 get-tsconfig: 4.8.1 @@ -11399,7 +11394,7 @@ packages: '@es-joy/jsdoccomment': 0.41.0 are-docs-informative: 0.0.2 comment-parser: 1.4.1 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) escape-string-regexp: 4.0.0 eslint: 8.36.0 esquery: 1.5.0 @@ -11791,7 +11786,7 @@ packages: engines: {node: '>= 10.17.0'} hasBin: true dependencies: - debug: 4.4.0 + debug: 4.3.4 get-stream: 5.2.0 yauzl: 2.10.0 optionalDependencies: @@ -11995,7 +11990,7 @@ packages: dependencies: chalk: 4.1.2 commander: 5.1.0 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) transitivePeerDependencies: - supports-color dev: true @@ -12370,7 +12365,7 @@ packages: dependencies: basic-ftp: 5.0.5 data-uri-to-buffer: 6.0.2 - debug: 4.4.0 + debug: 4.3.4 fs-extra: 11.2.0 transitivePeerDependencies: - supports-color @@ -12419,7 +12414,7 @@ packages: fs.realpath: 1.0.0 inflight: 1.0.6 inherits: 2.0.4 - minimatch: 5.0.1 + minimatch: 5.1.6 once: 1.4.0 dev: true @@ -12678,7 +12673,6 @@ packages: /has-flag@4.0.0: resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} engines: {node: '>=8'} - dev: true /has-property-descriptors@1.0.2: resolution: {integrity: sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==} @@ -12886,7 +12880,7 @@ packages: dependencies: '@tootallnate/once': 2.0.0 agent-base: 6.0.2 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) transitivePeerDependencies: - supports-color dev: true @@ -12896,7 +12890,7 @@ packages: engines: {node: '>= 14'} dependencies: agent-base: 7.1.1 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) transitivePeerDependencies: - supports-color dev: true @@ -12936,7 +12930,7 @@ packages: engines: {node: '>= 6'} dependencies: agent-base: 6.0.2 - debug: 4.4.0 + debug: 4.3.4 transitivePeerDependencies: - supports-color dev: true @@ -12946,7 +12940,7 @@ packages: engines: {node: '>= 14'} dependencies: agent-base: 7.1.1 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) transitivePeerDependencies: - supports-color dev: true @@ -12971,7 +12965,7 @@ packages: '@babel/runtime': 7.24.7 '@tannin/sprintf': 1.2.0 '@wordpress/compose': 5.20.0(react@18.3.1) - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) events: 3.3.0 hash.js: 1.1.7 lodash: 4.17.21 @@ -13564,7 +13558,7 @@ packages: resolution: {integrity: sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==} engines: {node: '>=10'} dependencies: - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) istanbul-lib-coverage: 3.2.2 source-map: 0.6.1 transitivePeerDependencies: @@ -15002,8 +14996,8 @@ packages: dependencies: brace-expansion: 1.1.11 - /minimatch@5.0.1: - resolution: {integrity: sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==} + /minimatch@5.1.6: + resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} engines: {node: '>=10'} dependencies: brace-expansion: 2.0.1 @@ -15051,30 +15045,30 @@ packages: minimist: 1.2.8 dev: true - /mocha@10.4.0: - resolution: {integrity: sha512-eqhGB8JKapEYcC4ytX/xrzKforgEc3j1pGlAXVy3eRwrtAy5/nIfT1SvgGzfN0XZZxeLq0aQWkOUAmqIJiv+bA==} + /mocha@10.8.2: + resolution: {integrity: sha512-VZlYo/WE8t1tstuRmqgeyBgCbJc/lEdopaa+axcKzTBJ+UIdlAB9XnmvTCAH4pwR4ElNInaedhEBmZD8iCSVEg==} engines: {node: '>= 14.0.0'} hasBin: true dependencies: - ansi-colors: 4.1.1 + ansi-colors: 4.1.3 browser-stdout: 1.3.1 chokidar: 3.5.3 - debug: 4.3.4(supports-color@8.1.1) - diff: 5.0.0 + debug: 4.4.0(supports-color@8.1.1) + diff: 5.2.0 escape-string-regexp: 4.0.0 find-up: 5.0.0 glob: 8.1.0 he: 1.2.0 js-yaml: 4.1.0 log-symbols: 4.1.0 - minimatch: 5.0.1 + minimatch: 5.1.6 ms: 2.1.3 - serialize-javascript: 6.0.0 + serialize-javascript: 6.0.2 strip-json-comments: 3.1.1 supports-color: 8.1.1 - workerpool: 6.2.1 + workerpool: 6.5.1 yargs: 16.2.0 - yargs-parser: 20.2.4 + yargs-parser: 20.2.9 yargs-unparser: 2.0.0 dev: true @@ -15262,7 +15256,7 @@ packages: ajv-errors: 1.0.1(ajv@6.12.6) chalk: 4.1.2 cosmiconfig: 8.3.6(typescript@5.0.2) - debug: 4.3.5(supports-color@9.3.1) + debug: 4.4.0(supports-color@8.1.1) globby: 11.1.0 ignore: 5.3.1 is-plain-obj: 3.0.0 @@ -15558,7 +15552,7 @@ packages: dependencies: '@tootallnate/quickjs-emscripten': 0.23.0 agent-base: 7.1.1 - debug: 4.4.0 + debug: 4.3.4 get-uri: 6.0.3 http-proxy-agent: 7.0.2 https-proxy-agent: 7.0.5 @@ -15752,7 +15746,7 @@ packages: dependencies: '@babel/runtime': 7.24.7 crc32: 0.2.2 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) seed-random: 2.2.0 transitivePeerDependencies: - supports-color @@ -16434,7 +16428,7 @@ packages: engines: {node: '>= 14'} dependencies: agent-base: 7.1.1 - debug: 4.4.0 + debug: 4.3.4 http-proxy-agent: 7.0.2 https-proxy-agent: 7.0.5 lru-cache: 7.18.3 @@ -16483,7 +16477,7 @@ packages: engines: {node: '>=10.18.1'} dependencies: cross-fetch: 3.1.5 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 devtools-protocol: 0.0.981744 extract-zip: 2.0.1 https-proxy-agent: 5.0.1 @@ -16513,7 +16507,7 @@ packages: '@puppeteer/browsers': 1.4.6(typescript@5.0.2) chromium-bidi: 0.4.16(devtools-protocol@0.0.1147663) cross-fetch: 4.0.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.4 devtools-protocol: 0.0.1147663 typescript: 5.0.2 ws: 8.18.0 @@ -17617,12 +17611,6 @@ packages: tslib: 2.6.3 upper-case-first: 2.0.2 - /serialize-javascript@6.0.0: - resolution: {integrity: sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==} - dependencies: - randombytes: 2.1.0 - dev: true - /serialize-javascript@6.0.2: resolution: {integrity: sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==} dependencies: @@ -17766,7 +17754,7 @@ packages: resolution: {integrity: sha512-D1SaWpOW8afq1CZGWB8xTfrT3FekjQmPValrqncJMX7QFl8YwhrPTZvMCANLtgBwwdS+7zURyqxDDEmY558tTw==} dependencies: buffer: 6.0.3 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) err-code: 3.0.1 get-browser-rtc: 1.1.0 queue-microtask: 1.2.3 @@ -17878,7 +17866,7 @@ packages: base64-arraybuffer: 0.1.5 component-bind: 1.0.0 component-emitter: 1.2.1 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) engine.io-client: 3.4.4 has-binary2: 1.0.3 has-cors: 1.1.0 @@ -17917,7 +17905,7 @@ packages: engines: {node: '>= 14'} dependencies: agent-base: 7.1.1 - debug: 4.4.0 + debug: 4.3.4 socks: 2.8.3 transitivePeerDependencies: - supports-color @@ -18037,7 +18025,7 @@ packages: /spdy-transport@3.0.0: resolution: {integrity: sha512-hsLVFE5SjA6TCisWeJXFKniGGOpBgMLmerfO2aCyCU5s7nJ/rpAepqmFifv/GCbSbueEeAJJnmSQ2rKC/g8Fcw==} dependencies: - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) detect-node: 2.1.0 hpack.js: 2.1.6 obuf: 1.1.2 @@ -18051,7 +18039,7 @@ packages: resolution: {integrity: sha512-r46gZQZQV+Kl9oItvl1JZZqJKGr+oEkB08A6BzkiR7593/7IbtuncXHd2YoYeTsG4157ZssMu9KYvUHLcjcDoA==} engines: {node: '>=6.0.0'} dependencies: - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) handle-thing: 2.0.1 http-deceiver: 1.2.7 select-hose: 2.0.0 @@ -18120,7 +18108,7 @@ packages: queue-tick: 1.0.1 text-decoder: 1.1.1 optionalDependencies: - bare-events: 2.5.0 + bare-events: 2.5.4 dev: true /string-argv@0.3.1: @@ -18386,7 +18374,7 @@ packages: colord: 2.9.3 cosmiconfig: 7.1.0 css-functions-list: 3.2.2 - debug: 4.3.5(supports-color@9.3.1) + debug: 4.4.0(supports-color@8.1.1) fast-glob: 3.3.2 fastest-levenshtein: 1.0.16 file-entry-cache: 6.0.1 @@ -18498,7 +18486,6 @@ packages: engines: {node: '>=10'} dependencies: has-flag: 4.0.0 - dev: true /supports-color@9.3.1: resolution: {integrity: sha512-knBY82pjmnIzK3NifMo3RxEIRD9E0kIzV4BKcyTZ9+9kWgLMxd4PrsTSMoFQUabgRBbF8KOLRDCyKgNV+iK44Q==} @@ -19714,8 +19701,8 @@ packages: resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} dev: false - /workerpool@6.2.1: - resolution: {integrity: sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==} + /workerpool@6.5.1: + resolution: {integrity: sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==} dev: true /wp-error@1.3.0: @@ -19747,7 +19734,7 @@ packages: resolution: {integrity: sha512-NMp0YsBM40CuI5vWtHpjWOuf96rPfbpGkamlJpVwYvgenIh1ynRzqVnGfsnjofgz13T2qcKkdwJY0Y2X7z+W+w==} dependencies: '@babel/runtime': 7.24.7 - debug: 4.4.0 + debug: 4.4.0(supports-color@8.1.1) progress-event: 1.0.0 uuid: 7.0.3 wp-error: 1.3.0 @@ -19931,11 +19918,6 @@ packages: camelcase: 5.3.1 decamelize: 1.2.0 - /yargs-parser@20.2.4: - resolution: {integrity: sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==} - engines: {node: '>=10'} - dev: true - /yargs-parser@20.2.9: resolution: {integrity: sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==} engines: {node: '>=10'} From 838d896cec5227b3e4a36edd1d41d77a6f5e0692 Mon Sep 17 00:00:00 2001 From: Pavel Dohnal Date: Thu, 6 Feb 2025 13:25:10 +0100 Subject: [PATCH 02/26] Update the page capability type MailPoet default pages were created with the default post capability type. This means post navigation links (previous and next) are often found on the default pages, such as the unsubscribe and the manage subscription page. [MAILPOET-6424] --- mailpoet/lib/Settings/Pages.php | 1 + 1 file changed, 1 insertion(+) diff --git a/mailpoet/lib/Settings/Pages.php b/mailpoet/lib/Settings/Pages.php index 7de9787f2e..bb232f3732 100644 --- a/mailpoet/lib/Settings/Pages.php +++ b/mailpoet/lib/Settings/Pages.php @@ -27,6 +27,7 @@ class Pages { 'can_export' => false, 'publicly_queryable' => true, 'exclude_from_search' => true, + 'capability_type' => 'page', ]); } From e9baeadd6e7cae6df28459c9bcb767d42fc637eb Mon Sep 17 00:00:00 2001 From: Pavel Dohnal Date: Thu, 20 Feb 2025 13:13:27 +0100 Subject: [PATCH 03/26] Make sure the navigation links are hidden on all themes [MAILPOET-6424] --- mailpoet/lib/Settings/Pages.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mailpoet/lib/Settings/Pages.php b/mailpoet/lib/Settings/Pages.php index bb232f3732..85780c1084 100644 --- a/mailpoet/lib/Settings/Pages.php +++ b/mailpoet/lib/Settings/Pages.php @@ -29,6 +29,16 @@ class Pages { 'exclude_from_search' => true, 'capability_type' => 'page', ]); + + WPFunctions::get()->addFilter('next_post_link', [$this, 'disableNavigationLinks']); + WPFunctions::get()->addFilter('previous_post_link', [$this, 'disableNavigationLinks']); + } + + public function disableNavigationLinks($output) { + if (is_singular('mailpoet_page')) { + return ''; // Return an empty string to remove navigation links + } + return $output; } public static function createMailPoetPage($postName) { From c05670a8602a4e9477111279ee93f485443e1a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Fri, 21 Feb 2025 23:31:50 +0100 Subject: [PATCH 04/26] Add additional QIT test commands [MAILPOET-6487] --- mailpoet/RoboFile.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/mailpoet/RoboFile.php b/mailpoet/RoboFile.php index 72b787e63d..25a5244502 100644 --- a/mailpoet/RoboFile.php +++ b/mailpoet/RoboFile.php @@ -815,6 +815,47 @@ class RoboFile extends \Robo\Tasks { return $this->_exec('./vendor/bin/qit run:security mailpoet --zip=mailpoet.zip --wait'); } + public function qaQitMalware() { + return $this->_exec('./vendor/bin/qit run:malware mailpoet --zip=mailpoet.zip --wait'); + } + + public function qaQitPhpCompatibility() { + return $this->_exec('./vendor/bin/qit run:phpcompatibility mailpoet --zip=mailpoet.zip --wait'); + } + + public function qaQitActivation($opts = ['wp' => 'stable', 'wc' => 'stable']) { + $command = './vendor/bin/qit run:activation mailpoet --zip=mailpoet.zip --wait'; + if ($opts['wp']) { + $command .= ' --wordpress_version=' . $opts['wp']; + } + if ($opts['wc']) { + $command .= ' --woocommerce_version=' . $opts['wc']; + } + return $this->_exec($command); + } + + public function qaQitWooApi($opts = ['wp' => 'stable', 'wc' => 'stable']) { + $command = './vendor/bin/qit run:woo-api mailpoet --zip=mailpoet.zip --wait'; + if ($opts['wp']) { + $command .= ' --wordpress_version=' . $opts['wp']; + } + if ($opts['wc']) { + $command .= ' --woocommerce_version=' . $opts['wc']; + } + return $this->_exec($command); + } + + public function qaQitWooE2e($opts = ['wp' => 'stable', 'wc' => 'stable']) { + $command = './vendor/bin/qit run:woo-e2e mailpoet --zip=mailpoet.zip --wait'; + if ($opts['wp']) { + $command .= ' --wordpress_version=' . $opts['wp']; + } + if ($opts['wc']) { + $command .= ' --woocommerce_version=' . $opts['wc']; + } + return $this->_exec($command); + } + public function svnCheckout() { $svnDir = ".mp_svn"; From 0e680d50e1e07c06e69a895bfdea82e2ec5fef4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Sat, 22 Feb 2025 10:29:30 +0100 Subject: [PATCH 05/26] Add QIT workflow to CircleCI --- .circleci/config.yml | 173 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1d35640064..22c5a5b187 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -888,6 +888,146 @@ jobs: - store_artifacts: path: tests/_output + qit_malware_scan: + executor: wpcli_php_latest + steps: + - attach_workspace: + at: /home/circleci + - run: + name: 'Set up environment' + command: | + # Copy built ZIP to local directory for easier access from QIT + cp /home/circleci/mailpoet/mailpoet.zip . + # Authenticate in QIT + ./vendor/bin/qit partner:add --user="${QIT_PARTNER_USER}" --application_password="${QIT_PARTNER_SECRET}" + - run: + name: 'QIT Malware Scan' + command: ./do qa:qit-malware | tee tests/_output/qit-malware + - run: + name: 'Retrieve test results' + command: | + grep "Result Url" tests/_output/qit-malware | awk '{ print $3 }' | xargs curl -o tests/_output/report.html + when: always + - store_artifacts: + path: tests/_output + + qit_php_compatibility: + executor: wpcli_php_latest + steps: + - attach_workspace: + at: /home/circleci + - run: + name: 'Set up environment' + command: | + # Copy built ZIP to local directory for easier access from QIT + cp /home/circleci/mailpoet/mailpoet.zip . + # Authenticate in QIT + ./vendor/bin/qit partner:add --user="${QIT_PARTNER_USER}" --application_password="${QIT_PARTNER_SECRET}" + - run: + name: 'QIT PHP Compatibility Check' + command: ./do qa:qit-php-compatibility | tee tests/_output/qit-php-compatibility + - run: + name: 'Retrieve test results' + command: | + grep "Result Url" tests/_output/qit-php-compatibility | awk '{ print $3 }' | xargs curl -o tests/_output/report.html + when: always + - store_artifacts: + path: tests/_output + + qit_activation_tests: + executor: wpcli_php_latest + steps: + - attach_workspace: + at: /home/circleci + - run: + name: 'Set up environment' + command: | + # Copy built ZIP to local directory for easier access from QIT + cp /home/circleci/mailpoet/mailpoet.zip . + # Authenticate in QIT + ./vendor/bin/qit partner:add --user="${QIT_PARTNER_USER}" --application_password="${QIT_PARTNER_SECRET}" + - run: + name: 'QIT Activation Tests' + command: | + LATEST_WC_BETA=$(../.circleci/check_woocommerce_beta.sh | grep 'LATEST_BETA' | cut -d'=' -f2) + if [ -z "$LATEST_WC_BETA" ]; then + echo "No WooCommerce Beta version found. Using stable." + ./do qa:qit-activation | tee tests/_output/qit-activation + else + echo "Using WooCommerce Beta Version: $LATEST_WC_BETA" + ./do qa:qit-activation --wc=$LATEST_WC_BETA | tee tests/_output/qit-activation + fi + - run: + name: 'Retrieve test results' + command: | + grep "Result Url" tests/_output/qit-activation | awk '{ print $3 }' | xargs curl -o tests/_output/report.html + when: always + - store_artifacts: + path: tests/_output + + qit_woo_api_tests: + executor: wpcli_php_latest + steps: + - attach_workspace: + at: /home/circleci + - run: + name: 'Set up environment' + command: | + # Copy built ZIP to local directory for easier access from QIT + cp /home/circleci/mailpoet/mailpoet.zip . + # Authenticate in QIT + ./vendor/bin/qit partner:add --user="${QIT_PARTNER_USER}" --application_password="${QIT_PARTNER_SECRET}" + - run: + name: 'QIT Woo API Tests' + command: | + LATEST_WC_BETA=$(../.circleci/check_woocommerce_beta.sh | grep 'LATEST_BETA' | cut -d'=' -f2) + if [ -z "$LATEST_WC_BETA" ]; then + echo "No WooCommerce Beta version found. Using stable." + ./do qa:qit-woo-api | tee tests/_output/qit-woo-api + else + echo "Using WooCommerce Beta Version: $LATEST_WC_BETA" + ./do qa:qit-woo-api --wc=$LATEST_WC_BETA | tee tests/_output/qit-woo-api + fi + - run: + name: 'Retrieve test results' + command: | + grep "Result Url" tests/_output/qit-woo-api | awk '{ print $3 }' | xargs curl -o tests/_output/report.html + when: always + - store_artifacts: + path: tests/_output + + qit_woo_e2e_tests: + executor: wpcli_php_latest + steps: + - attach_workspace: + at: /home/circleci + - run: + name: 'Set up environment' + command: | + # Copy built ZIP to local directory for easier access from QIT + cp /home/circleci/mailpoet/mailpoet.zip . + # Authenticate in QIT + ./vendor/bin/qit partner:add --user="${QIT_PARTNER_USER}" --application_password="${QIT_PARTNER_SECRET}" + - run: + name: 'QIT Woo E2E Tests' + no_output_timeout: 1h # Woo E2E tests usually takes ~45m + command: | + LATEST_WC_BETA=$(../.circleci/check_woocommerce_beta.sh | grep 'LATEST_BETA' | cut -d'=' -f2) + if [ -z "$LATEST_WC_BETA" ]; then + echo "No WooCommerce Beta version found. Using stable." + ./do qa:qit-woo-e2e | tee tests/_output/qit-woo-e2e + else + echo "Using WooCommerce Beta Version: $LATEST_WC_BETA" + ./do qa:qit-woo-e2e --wc=$LATEST_WC_BETA | tee tests/_output/qit-woo-e2e + fi + - run: + name: 'Retrieve test results' + command: | + grep "Result Url" tests/_output/qit-woo-e2e | awk '{ print $3 }' | xargs curl -o tests/_output/report.html + when: always + - store_artifacts: + path: tests/_output + workflows: build_and_test: jobs: @@ -1209,3 +1349,36 @@ workflows: mysql_image: mysql:5.5 requires: - build_premium + + nightly_qit: + jobs: + - build: + <<: *slack-fail-post-step + - build_release_zip: + <<: *slack-fail-post-step + requires: + - build + - qit_security_scan: + <<: *slack-fail-post-step + requires: + - build_release_zip + - qit_activation_tests: + <<: *slack-fail-post-step + requires: + - build_release_zip + - qit_malware_scan: + <<: *slack-fail-post-step + requires: + - build_release_zip + - qit_php_compatibility: + <<: *slack-fail-post-step + requires: + - build_release_zip + - qit_woo_api_tests: + <<: *slack-fail-post-step + requires: + - build_release_zip + - qit_woo_e2e_tests: + <<: *slack-fail-post-step + requires: + - build_release_zip From 1d28e8d7c6b9d32f5ff99f55a5df8c96325d3a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Sat, 22 Feb 2025 10:31:17 +0100 Subject: [PATCH 06/26] Run QIT workflow weekly (Wednesday at 2am) --- .circleci/config.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 22c5a5b187..815218a5ed 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1351,6 +1351,13 @@ workflows: - build_premium nightly_qit: + triggers: + - schedule: + cron: '0 2 * * 3' # Every Wednesday at 2am UTC + filters: + branches: + only: + - trunk jobs: - build: <<: *slack-fail-post-step From a3ec922ca522d660d83ce55b235a3417227f0702 Mon Sep 17 00:00:00 2001 From: alex-mpoet Date: Thu, 20 Feb 2025 15:00:47 +0300 Subject: [PATCH 07/26] Add an option to restrict coupon to current subscriber [MAILPOET-6384] --- .../src/newsletter-editor/blocks/coupon.tsx | 5 +++ .../blocks/coupon/usage-restriction.tsx | 22 ++++++++++++ .../newsletter-editor/components/content.js | 3 ++ .../lib/Newsletter/Renderer/Preprocessor.php | 2 +- .../lib/WooCommerce/CouponPreProcessor.php | 34 ++++++++++++++----- 5 files changed, 57 insertions(+), 9 deletions(-) diff --git a/mailpoet/assets/js/src/newsletter-editor/blocks/coupon.tsx b/mailpoet/assets/js/src/newsletter-editor/blocks/coupon.tsx index b5c81f8d6a..a65f422513 100644 --- a/mailpoet/assets/js/src/newsletter-editor/blocks/coupon.tsx +++ b/mailpoet/assets/js/src/newsletter-editor/blocks/coupon.tsx @@ -19,6 +19,7 @@ Module.CouponBlockModel = base.BlockModel.extend({ return this._getDefaults( { isStandardEmail: App.getNewsletter().isStandardEmail(), + isAutomationEmail: App.getNewsletter().isAutomationEmail(), productIds: [], // selected product ids, excludedProductIds: [], productCategoryIds: [], // selected categories id @@ -33,6 +34,10 @@ Module.CouponBlockModel = base.BlockModel.extend({ minimumAmount: '', maximumAmount: '', emailRestrictions: '', + restrictToSubscriber: false, + showRestrictToSubscriber: + App.getNewsletter().isAutomationEmail() || + App.getNewsletter().isWelcomeEmail(), styles: { block: { backgroundColor: '#ffffff', diff --git a/mailpoet/assets/js/src/newsletter-editor/blocks/coupon/usage-restriction.tsx b/mailpoet/assets/js/src/newsletter-editor/blocks/coupon/usage-restriction.tsx index 650c0a2b61..fee556f060 100644 --- a/mailpoet/assets/js/src/newsletter-editor/blocks/coupon/usage-restriction.tsx +++ b/mailpoet/assets/js/src/newsletter-editor/blocks/coupon/usage-restriction.tsx @@ -31,6 +31,7 @@ type State = { productCategoryIds: Post[]; excludedProductCategoryIds: Post[]; emailRestrictions: string; + restrictToSubscriber: boolean; }; class UsageRestriction extends Component { @@ -62,6 +63,8 @@ class UsageRestriction extends Component { 'excludedProductCategoryIds', ).toJSON() as Post[], emailRestrictions: this.getValueCallback('emailRestrictions') as string, + restrictToSubscriber: + (this.getValueCallback('restrictToSubscriber') as boolean) || false, }; } @@ -262,6 +265,25 @@ class UsageRestriction extends Component { )} /> + {this.getValueCallback('showRestrictToSubscriber') && ( + + { + this.setValueCallback( + 'restrictToSubscriber', + restrictToSubscriber, + ); + this.setState({ restrictToSubscriber }); + }} + help={__( + 'Restrict coupon usage to the subscriber receiving this email.', + 'mailpoet', + )} + /> + + )} ); diff --git a/mailpoet/assets/js/src/newsletter-editor/components/content.js b/mailpoet/assets/js/src/newsletter-editor/components/content.js index 0eba43ee87..f79122ed60 100644 --- a/mailpoet/assets/js/src/newsletter-editor/components/content.js +++ b/mailpoet/assets/js/src/newsletter-editor/components/content.js @@ -35,6 +35,9 @@ Module.NewsletterModel = SuperModel.extend({ isStandardEmail: function isStandardEmail() { return this.get('type') === NewsletterType.Standard; }, + isWelcomeEmail: function isWelcomeEmail() { + return this.get('type') === NewsletterType.Welcome; + }, }); // Content block view and model handlers for different content types diff --git a/mailpoet/lib/Newsletter/Renderer/Preprocessor.php b/mailpoet/lib/Newsletter/Renderer/Preprocessor.php index 64c78d782c..e23b68d22f 100644 --- a/mailpoet/lib/Newsletter/Renderer/Preprocessor.php +++ b/mailpoet/lib/Newsletter/Renderer/Preprocessor.php @@ -53,7 +53,7 @@ class Preprocessor { return $content; } $contentBlocks = $content['blocks']; - $contentBlocks = $this->couponPreProcessor->processCoupons($newsletter, $contentBlocks, $preview); + $contentBlocks = $this->couponPreProcessor->processCoupons($newsletter, $contentBlocks, $preview, $sendingQueue); $content['blocks'] = $this->processContainer($newsletter, $contentBlocks, $preview, $sendingQueue); return $content; } diff --git a/mailpoet/lib/WooCommerce/CouponPreProcessor.php b/mailpoet/lib/WooCommerce/CouponPreProcessor.php index 119afc61df..e5024b247d 100644 --- a/mailpoet/lib/WooCommerce/CouponPreProcessor.php +++ b/mailpoet/lib/WooCommerce/CouponPreProcessor.php @@ -3,6 +3,7 @@ namespace MailPoet\WooCommerce; use MailPoet\Entities\NewsletterEntity; +use MailPoet\Entities\SendingQueueEntity; use MailPoet\Newsletter\NewslettersRepository; use MailPoet\Newsletter\Renderer\Blocks\Coupon; use MailPoet\NewsletterProcessingException; @@ -30,12 +31,12 @@ class CouponPreProcessor { /** * @throws NewsletterProcessingException */ - public function processCoupons(NewsletterEntity $newsletter, array $blocks, bool $preview = false): array { + public function processCoupons(NewsletterEntity $newsletter, array $blocks, bool $preview = false, ?SendingQueueEntity $sendingQueue = null): array { if ($preview) { return $blocks; } - $generated = $this->ensureCouponForBlocks($blocks, $newsletter); + $generated = $this->ensureCouponForBlocks($blocks, $newsletter, $sendingQueue); $body = $newsletter->getBody(); if ($generated && $body && $this->shouldPersist($newsletter)) { @@ -54,11 +55,10 @@ class CouponPreProcessor { return $blocks; } - private function ensureCouponForBlocks(array &$blocks, NewsletterEntity $newsletter): bool { - + private function ensureCouponForBlocks(array &$blocks, NewsletterEntity $newsletter, ?SendingQueueEntity $sendingQueue): bool { foreach ($blocks as &$innerBlock) { if (isset($innerBlock['blocks']) && !empty($innerBlock['blocks'])) { - $this->ensureCouponForBlocks($innerBlock['blocks'], $newsletter); + $this->ensureCouponForBlocks($innerBlock['blocks'], $newsletter, $sendingQueue); } if (isset($innerBlock['type']) && $innerBlock['type'] === Coupon::TYPE) { if (!$this->wcHelper->isWooCommerceActive()) { @@ -66,7 +66,7 @@ class CouponPreProcessor { } if ($this->shouldGenerateCoupon($innerBlock)) { try { - $innerBlock['couponId'] = $this->addOrUpdateCoupon($innerBlock, $newsletter); + $innerBlock['couponId'] = $this->addOrUpdateCoupon($innerBlock, $newsletter, $sendingQueue); $this->generated = true; } catch (\Exception $e) { throw NewsletterProcessingException::create()->withMessage($e->getMessage())->withCode($e->getCode()); @@ -81,10 +81,11 @@ class CouponPreProcessor { /** * @param array $couponBlock * @param NewsletterEntity $newsletter + * @param SendingQueueEntity|null $sendingQueue * @return int * @throws \WC_Data_Exception|\Exception */ - private function addOrUpdateCoupon(array $couponBlock, NewsletterEntity $newsletter) { + private function addOrUpdateCoupon(array $couponBlock, NewsletterEntity $newsletter, ?SendingQueueEntity $sendingQueue) { $coupon = $this->wcHelper->createWcCoupon($couponBlock['couponId'] ?? ''); if ($this->shouldGenerateCoupon($couponBlock)) { $code = isset($couponBlock['code']) && $couponBlock['code'] !== Coupon::CODE_PLACEHOLDER ? $couponBlock['code'] : $this->generateRandomCode(); @@ -128,7 +129,24 @@ class CouponPreProcessor { $coupon->set_product_categories($this->getItemIds($couponBlock['productCategoryIds'] ?? [])); $coupon->set_excluded_product_categories($this->getItemIds($couponBlock['excludedProductCategoryIds'] ?? [])); - $coupon->set_email_restrictions(explode(',', $couponBlock['emailRestrictions'] ?? '')); + $emailRestrictions = []; + if (!empty($couponBlock['emailRestrictions'])) { + $emailRestrictions = explode(',', $couponBlock['emailRestrictions']); + } + + if (!empty($couponBlock['restrictToSubscriber']) && $sendingQueue && $sendingQueue->getTask()) { + $subscribers = $sendingQueue->getTask()->getSubscribers(); + if (is_iterable($subscribers) && count($subscribers) === 1) { // Only apply to single-subscriber sending queues + foreach ($subscribers as $taskSubscriber) { + $subscriber = $taskSubscriber->getSubscriber(); + if ($subscriber && $subscriber->getEmail()) { + $emailRestrictions[] = $subscriber->getEmail(); + } + } + } + } + + $coupon->set_email_restrictions(array_unique(array_filter($emailRestrictions))); // usage limit $coupon->set_usage_limit($couponBlock['usageLimit'] ?? 0); From e23e4c49741343fb95334e2369fdfdfcde4fca15 Mon Sep 17 00:00:00 2001 From: alex-mpoet Date: Thu, 20 Feb 2025 15:14:28 +0300 Subject: [PATCH 08/26] Add tests [MAILPOET-6384] --- .../WooCommerce/CouponPreProcessorTest.php | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/mailpoet/tests/unit/WooCommerce/CouponPreProcessorTest.php b/mailpoet/tests/unit/WooCommerce/CouponPreProcessorTest.php index 4789e7f933..547d3f2566 100644 --- a/mailpoet/tests/unit/WooCommerce/CouponPreProcessorTest.php +++ b/mailpoet/tests/unit/WooCommerce/CouponPreProcessorTest.php @@ -5,11 +5,16 @@ namespace unit\WooCommerce; use Codeception\Stub; use Helper\WordPress; use MailPoet\Entities\NewsletterEntity; +use MailPoet\Entities\ScheduledTaskEntity; +use MailPoet\Entities\ScheduledTaskSubscriberEntity; +use MailPoet\Entities\SendingQueueEntity; +use MailPoet\Entities\SubscriberEntity; use MailPoet\Newsletter\NewslettersRepository; use MailPoet\Newsletter\Renderer\Blocks\Coupon; use MailPoet\NewsletterProcessingException; use MailPoet\WooCommerce\CouponPreProcessor; use MailPoet\WooCommerce\Helper; +use MailPoetVendor\Doctrine\Common\Collections\ArrayCollection; class CouponPreProcessorTest extends \MailPoetUnitTest { @@ -176,6 +181,68 @@ class CouponPreProcessorTest extends \MailPoetUnitTest { $processor->processCoupons($newsletter, $blocks, false); } + public function testItRestrictsCouponToSubscriber(): void { + $subscriberEmail = 'test@example.com'; + $wcCoupon = $this->createCouponMock(); + + $subscriber = $this->make(SubscriberEntity::class, [ + 'getEmail' => $subscriberEmail, + ]); + + $taskSubscriber = $this->make(ScheduledTaskSubscriberEntity::class, [ + 'getSubscriber' => $subscriber, + ]); + + $task = $this->make(ScheduledTaskEntity::class, [ + 'getSubscribers' => new ArrayCollection([$taskSubscriber]), + ]); + + $queue = $this->make(SendingQueueEntity::class, [ + 'getTask' => $task, + ]); + + $wcHelper = $this->make(Helper::class, [ + 'createWcCoupon' => $wcCoupon, + 'isWooCommerceActive' => true, + ]); + + $processor = new CouponPreProcessor( + $wcHelper, + $this->make(NewslettersRepository::class) + ); + + $newsletter = new NewsletterEntity(); + $newsletter->setType(NewsletterEntity::TYPE_AUTOMATION); + $blocks = [ + [ + 'type' => 'any', + 'blocks' => [ + [ + 'type' => Coupon::TYPE, + 'discountType' => 'percent', + 'amount' => '100', + 'restrictToSubscriber' => true, + ], + ], + ], + ]; + $newsletter->setBody(['blocks' => $blocks, 'content' => []]); + + $wcCoupon->expects($this->exactly(2)) + ->method('set_email_restrictions') + ->withConsecutive( + [[$subscriberEmail]], + [['other@example.com', $subscriberEmail]] + ); + + // Test with restrictToSubscriber enabled + $processor->processCoupons($newsletter, $blocks, false, $queue); + + // Test with additional emailRestrictions + $blocks[0]['blocks'][0]['emailRestrictions'] = 'other@example.com'; + $processor->processCoupons($newsletter, $blocks, false, $queue); + } + private function assertWCCouponReceivesCorrectValues($mockedWCCoupon, $expectedCouponId, $expiryDay) { $mockedWCCoupon->method('save')->willReturn($expectedCouponId); From 19abc8963a1757e7cb30a41b309425c001a23b46 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 24 Feb 2025 06:06:56 +0000 Subject: [PATCH 09/26] Update used Automate Woo plugin in Circle CI - latest version: 6.1.7 - previous version: 6.0.33 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 815218a5ed..1bd2fe6a84 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -200,7 +200,7 @@ jobs: ./do download:woo-commerce-zip 9.6.2 ./do download:woo-commerce-subscriptions-zip 7.2.1 ./do download:woo-commerce-memberships-zip 1.26.5 - ./do download:automate-woo-zip 6.1.6 + ./do download:automate-woo-zip 6.1.7 - run: name: Dump tests ENV variables for acceptance tests command: | From 355baa9a9b3e66fa717bb096a885171ef418b8e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Mon, 24 Feb 2025 20:55:43 +0100 Subject: [PATCH 10/26] Release 5.8.0 --- mailpoet/changelog.txt | 5 +++++ mailpoet/mailpoet.php | 4 ++-- mailpoet/readme.txt | 9 +++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mailpoet/changelog.txt b/mailpoet/changelog.txt index 9cce33698b..e4891e62e9 100644 --- a/mailpoet/changelog.txt +++ b/mailpoet/changelog.txt @@ -1,5 +1,10 @@ == Changelog == += 5.8.0 - 2025-02-24 = +* Added: allow generating coupon code in automations for a subscriber the email is sent to; +* Changed: default MailPoet pages capability changed from post to page (one of improvements is hidden previous/next post links); +* Fixed: Prevent removing the content block from the Newsletter template in the new editor. + = 5.7.1 - 2025-02-17 = * Improved: Apply get_the_excerpt filter to MailPoets post excerpts; * Fixed: conflict with Rank Math plugin breaking "Scheduled Actions" page. diff --git a/mailpoet/mailpoet.php b/mailpoet/mailpoet.php index a79c1094f8..f1ca3e559a 100644 --- a/mailpoet/mailpoet.php +++ b/mailpoet/mailpoet.php @@ -2,7 +2,7 @@ /* * Plugin Name: MailPoet - * Version: 5.7.1 + * Version: 5.8.0 * Plugin URI: https://www.mailpoet.com * Description: Create and send newsletters, post notifications and welcome emails from your WordPress. * Author: MailPoet @@ -20,7 +20,7 @@ */ $mailpoetPlugin = [ - 'version' => '5.7.1', + 'version' => '5.8.0', 'filename' => __FILE__, 'path' => dirname(__FILE__), 'autoloader' => dirname(__FILE__) . '/vendor/autoload.php', diff --git a/mailpoet/readme.txt b/mailpoet/readme.txt index df219339f9..cafab78db6 100644 --- a/mailpoet/readme.txt +++ b/mailpoet/readme.txt @@ -3,7 +3,7 @@ Contributors: mailpoet, woocommerce, automattic Tags: email marketing, post notification, woocommerce emails, email automation, newsletter Requires at least: 6.6 Tested up to: 6.7 -Stable tag: 5.7.1 +Stable tag: 5.8.0 Requires PHP: 7.4 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -222,8 +222,9 @@ Check our [Knowledge Base](https://kb.mailpoet.com) or contact us through our [s == Changelog == -= 5.7.1 - 2025-02-17 = -* Improved: Apply get_the_excerpt filter to MailPoets post excerpts; -* Fixed: conflict with Rank Math plugin breaking "Scheduled Actions" page. += 5.8.0 - 2025-02-24 = +* Added: allow generating coupon code in automations for a subscriber the email is sent to; +* Changed: default MailPoet pages capability changed from post to page (one of improvements is hidden previous/next post links); +* Fixed: Prevent removing the content block from the Newsletter template in the new editor. [See the changelog for all versions.](https://github.com/mailpoet/mailpoet/blob/trunk/mailpoet/changelog.txt) From 83b1f90b535df8392c83c2cbb1b68c9764b98802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Thu, 27 Feb 2025 08:06:51 +0100 Subject: [PATCH 11/26] Bump WooCommerce minimum version to 9.6 [MAILPOET-6490] --- .circleci/config.yml | 2 +- mailpoet/mailpoet.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1bd2fe6a84..08deb5db0d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -197,7 +197,7 @@ jobs: - run: name: Download additional WP Plugins for tests command: | - ./do download:woo-commerce-zip 9.6.2 + ./do download:woo-commerce-zip 9.7.0 ./do download:woo-commerce-subscriptions-zip 7.2.1 ./do download:woo-commerce-memberships-zip 1.26.5 ./do download:automate-woo-zip 6.1.7 diff --git a/mailpoet/mailpoet.php b/mailpoet/mailpoet.php index f1ca3e559a..2ef5205b83 100644 --- a/mailpoet/mailpoet.php +++ b/mailpoet/mailpoet.php @@ -11,8 +11,8 @@ * Text Domain: mailpoet * Domain Path: /lang * - * WC requires at least: 9.5.1 - * WC tested up to: 9.6.0 + * WC requires at least: 9.6.2 + * WC tested up to: 9.7.0 * * @package WordPress * @author MailPoet @@ -28,7 +28,7 @@ $mailpoetPlugin = [ ]; const MAILPOET_MINIMUM_REQUIRED_WP_VERSION = '6.6'; // L-1 version, not the latest -const MAILPOET_MINIMUM_REQUIRED_WOOCOMMERCE_VERSION = '9.5'; // L-1 version, not the latest +const MAILPOET_MINIMUM_REQUIRED_WOOCOMMERCE_VERSION = '9.6'; // L-1 version, not the latest // Display WP version error notice From c57844cb0500da25ea582dc7f918cbe3cbabe460 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Fri, 28 Feb 2025 14:47:38 +0100 Subject: [PATCH 12/26] Update tests with oldest supported WC version [MAILPOET-6493] --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 08deb5db0d..500073566a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1222,7 +1222,7 @@ workflows: - acceptance_tests: <<: *slack-fail-post-step name: acceptance_oldest - woo_core_version: 9.5.2 + woo_core_version: 9.6.2 woo_subscriptions_version: 7.1.0 woo_memberships_version: 1.25.2 automate_woo_version: 6.0.33 @@ -1263,7 +1263,7 @@ workflows: - integration_tests: <<: *slack-fail-post-step name: integration_oldest - woo_core_version: 9.5.2 + woo_core_version: 9.6.2 woo_subscriptions_version: 7.1.0 woo_memberships_version: 1.25.2 automate_woo_version: 6.0.33 @@ -1326,7 +1326,7 @@ workflows: - acceptance_tests: <<: *slack-fail-post-step name: acceptance_with_premium_oldest - woo_core_version: 9.5.2 + woo_core_version: 9.6.2 woo_subscriptions_version: 7.1.0 woo_memberships_version: 1.25.2 automate_woo_version: 6.0.33 @@ -1338,7 +1338,7 @@ workflows: - integration_tests: <<: *slack-fail-post-step name: integration_with_premium_oldest - woo_core_version: 9.5.2 + woo_core_version: 9.6.2 woo_subscriptions_version: 7.1.0 woo_memberships_version: 1.25.2 automate_woo_version: 6.0.33 From afc27fabd664227f8e85c330496366849b69b75c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Fri, 28 Feb 2025 15:43:52 +0100 Subject: [PATCH 13/26] Prevent auto refreshing MailPoet listing components when any items are selected This is to prevent losing the selected state [MAILPOET-6493] --- mailpoet/assets/js/src/listing/listing.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mailpoet/assets/js/src/listing/listing.jsx b/mailpoet/assets/js/src/listing/listing.jsx index 17098ed328..2143ae2dd7 100644 --- a/mailpoet/assets/js/src/listing/listing.jsx +++ b/mailpoet/assets/js/src/listing/listing.jsx @@ -34,7 +34,10 @@ class ListingComponent extends Component { if (autoRefresh) { jQuery(document).on('heartbeat-tick.mailpoet', () => { - this.getItems(); + // Skip auto-refresh if any items are selected for bulk editing + if (this.state.selected_ids.length === 0) { + this.getItems(); + } }); } From bf3bc6d8cbf72f67c0604c32d7b0e8dc3d5652b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Fri, 28 Feb 2025 22:43:58 +0100 Subject: [PATCH 14/26] Fix captcha title being applied to menu items in non-block based themes [MAILPOET-6485] --- mailpoet/lib/Captcha/PageRenderer.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mailpoet/lib/Captcha/PageRenderer.php b/mailpoet/lib/Captcha/PageRenderer.php index cbb6c3f7d6..f91c55a926 100644 --- a/mailpoet/lib/Captcha/PageRenderer.php +++ b/mailpoet/lib/Captcha/PageRenderer.php @@ -39,18 +39,18 @@ class PageRenderer { if ($separatorLocation === 'right') { // first part - $titleParts[0] = $this->setPageTitle(); + $titleParts[0] = $this->getPageTitle(); } else { // last part $lastIndex = count($titleParts) - 1; - $titleParts[$lastIndex] = $this->setPageTitle(); + $titleParts[$lastIndex] = $this->getPageTitle(); } return implode(" $separator ", $titleParts); } public function setWindowTitleParts($meta = []) { - $meta['title'] = $this->setPageTitle(); + $meta['title'] = $this->getPageTitle(); return $meta; } @@ -58,8 +58,11 @@ class PageRenderer { echo ''; } - public function setPageTitle() { - return __("Confirm you’re not a robot", 'mailpoet'); + public function setPageTitle($title = '') { + if ($title === __('MailPoet Page', 'mailpoet')) { + return $this->getPageTitle(); + } + return $title; } public function setPageContent($pageContent) { @@ -72,4 +75,8 @@ class PageRenderer { return str_replace('[mailpoet_page]', trim($content), $pageContent); } + + private function getPageTitle() { + return __('Confirm you’re not a robot', 'mailpoet'); + } } From c424fe4b7a61d2158c92e040b320d50decccd151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Fri, 28 Feb 2025 23:05:43 +0100 Subject: [PATCH 15/26] Fix showing Captcha title in themes that rely on single_post_title, such as Rufous or Silverstorm [MAILPOET-6485] --- mailpoet/lib/Captcha/PageRenderer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/mailpoet/lib/Captcha/PageRenderer.php b/mailpoet/lib/Captcha/PageRenderer.php index f91c55a926..0f16cd47bf 100644 --- a/mailpoet/lib/Captcha/PageRenderer.php +++ b/mailpoet/lib/Captcha/PageRenderer.php @@ -28,6 +28,7 @@ class PageRenderer { $this->wp->removeAction('wp_head', 'noindex', 1); $this->wp->addAction('wp_head', [$this, 'setMetaRobots'], 1); $this->wp->addFilter('the_title', [$this, 'setPageTitle']); + $this->wp->addFilter('single_post_title', [$this, 'setPageTitle']); $this->wp->addFilter('the_content', [$this, 'setPageContent']); } From a2e164a8323c5e4627fdb3f5b4c842434fe4bff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lys=C3=BD?= Date: Mon, 3 Mar 2025 13:27:10 +0100 Subject: [PATCH 16/26] Release 5.8.1 --- mailpoet/changelog.txt | 3 +++ mailpoet/mailpoet.php | 4 ++-- mailpoet/readme.txt | 8 +++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/mailpoet/changelog.txt b/mailpoet/changelog.txt index e4891e62e9..747af679b4 100644 --- a/mailpoet/changelog.txt +++ b/mailpoet/changelog.txt @@ -1,5 +1,8 @@ == Changelog == += 5.8.1 - 2025-03-03 = +* Changed: minimum required WooCommerce is 9.6. + = 5.8.0 - 2025-02-24 = * Added: allow generating coupon code in automations for a subscriber the email is sent to; * Changed: default MailPoet pages capability changed from post to page (one of improvements is hidden previous/next post links); diff --git a/mailpoet/mailpoet.php b/mailpoet/mailpoet.php index 2ef5205b83..d9f69606bf 100644 --- a/mailpoet/mailpoet.php +++ b/mailpoet/mailpoet.php @@ -2,7 +2,7 @@ /* * Plugin Name: MailPoet - * Version: 5.8.0 + * Version: 5.8.1 * Plugin URI: https://www.mailpoet.com * Description: Create and send newsletters, post notifications and welcome emails from your WordPress. * Author: MailPoet @@ -20,7 +20,7 @@ */ $mailpoetPlugin = [ - 'version' => '5.8.0', + 'version' => '5.8.1', 'filename' => __FILE__, 'path' => dirname(__FILE__), 'autoloader' => dirname(__FILE__) . '/vendor/autoload.php', diff --git a/mailpoet/readme.txt b/mailpoet/readme.txt index cafab78db6..4ae4137014 100644 --- a/mailpoet/readme.txt +++ b/mailpoet/readme.txt @@ -3,7 +3,7 @@ Contributors: mailpoet, woocommerce, automattic Tags: email marketing, post notification, woocommerce emails, email automation, newsletter Requires at least: 6.6 Tested up to: 6.7 -Stable tag: 5.8.0 +Stable tag: 5.8.1 Requires PHP: 7.4 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -222,9 +222,7 @@ Check our [Knowledge Base](https://kb.mailpoet.com) or contact us through our [s == Changelog == -= 5.8.0 - 2025-02-24 = -* Added: allow generating coupon code in automations for a subscriber the email is sent to; -* Changed: default MailPoet pages capability changed from post to page (one of improvements is hidden previous/next post links); -* Fixed: Prevent removing the content block from the Newsletter template in the new editor. += 5.8.1 - 2025-03-03 = +* Changed: minimum required WooCommerce is 9.6. [See the changelog for all versions.](https://github.com/mailpoet/mailpoet/blob/trunk/mailpoet/changelog.txt) From 5ac069813fc9038a48029e175bbfa23cf53201ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Mon, 3 Mar 2025 13:24:04 +0100 Subject: [PATCH 17/26] Hide all WooCommerce email settings when MailPoet customizer is enabled [MAILPOET-6484] --- mailpoet/views/woocommerce/settings_overlay.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mailpoet/views/woocommerce/settings_overlay.html b/mailpoet/views/woocommerce/settings_overlay.html index ac37378edc..49672e66a8 100644 --- a/mailpoet/views/woocommerce/settings_overlay.html +++ b/mailpoet/views/woocommerce/settings_overlay.html @@ -1,5 +1,11 @@ - + \ No newline at end of file From a6beaa70253690aa559fbf792f6074aa8f8fdedc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Mon, 3 Mar 2025 15:24:17 +0100 Subject: [PATCH 20/26] Add new Woo email templates These are copy-pasted from WC email preview without any change [MAILPOET-6484] --- .../completed_order.hbs | 116 +++++++++++++++++ .../customer_note.hbs | 120 ++++++++++++++++++ .../new_account.hbs | 27 ++++ .../processing_order.hbs | 116 +++++++++++++++++ 4 files changed, 379 insertions(+) create mode 100644 mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/completed_order.hbs create mode 100644 mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/customer_note.hbs create mode 100644 mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/new_account.hbs create mode 100644 mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/processing_order.hbs diff --git a/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/completed_order.hbs b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/completed_order.hbs new file mode 100644 index 0000000000..eeeade7dae --- /dev/null +++ b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/completed_order.hbs @@ -0,0 +1,116 @@ +
+
+

<%= __('Autogenerated content by WooCommerce') %>

+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ Billing address +
+ John Doe
Company
123 Fake Street
Faketown, CA 12345
United States (US)
555-555-5555
john@company.com
+
+ Shipping address +
+ John Doe
Company
123 Fake Street
Faketown, CA 12345
United States (US)
555-555-5555
+
+
+ + + + +
+ + +
+
diff --git a/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/customer_note.hbs b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/customer_note.hbs new file mode 100644 index 0000000000..e48812b734 --- /dev/null +++ b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/customer_note.hbs @@ -0,0 +1,120 @@ +
+
+

<%= __('Autogenerated content by WooCommerce') %>

+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ Billing address +
+ John Doe
Company
123 Fake Street
Faketown, CA 12345
United States (US)
555-555-5555
john@company.com
+
+ Shipping address +
+ John Doe
Company
123 Fake Street
Faketown, CA 12345
United States (US)
555-555-5555
+
+
+ + + + +
+ + +
+
diff --git a/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/new_account.hbs b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/new_account.hbs new file mode 100644 index 0000000000..6125b1ecfa --- /dev/null +++ b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/new_account.hbs @@ -0,0 +1,27 @@ +
+
+

<%= __('Autogenerated content by WooCommerce') %>

+
+
+ + + + + + + +
+ + +
+
diff --git a/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/processing_order.hbs b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/processing_order.hbs new file mode 100644 index 0000000000..5d237e72a2 --- /dev/null +++ b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/processing_order.hbs @@ -0,0 +1,116 @@ +
+
+

<%= __('Autogenerated content by WooCommerce') %>

+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ Billing address +
+ John Doe
Company
123 Fake Street
Faketown, CA 12345
United States (US)
555-555-5555
john@company.com
+
+ Shipping address +
+ John Doe
Company
123 Fake Street
Faketown, CA 12345
United States (US)
555-555-5555
+
+
+ + + + +
+ + +
+
From 40d61001d4593ef64c863da4de528e7233056f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Mon, 3 Mar 2025 15:37:46 +0100 Subject: [PATCH 21/26] Check if email improvements feature is enabled in WooCommerce [MAILPOET-6484] --- mailpoet/lib/Twig/Functions.php | 9 +++++++++ mailpoet/lib/WooCommerce/Helper.php | 12 ++++++++++++ mailpoet/views/layout.html | 1 + 3 files changed, 22 insertions(+) diff --git a/mailpoet/lib/Twig/Functions.php b/mailpoet/lib/Twig/Functions.php index 6988b5e63c..2835e9e819 100644 --- a/mailpoet/lib/Twig/Functions.php +++ b/mailpoet/lib/Twig/Functions.php @@ -167,6 +167,11 @@ class Functions extends AbstractExtension { [$this, 'isWoocommerceActive'], ['is_safe' => ['all']] ), + new TwigFunction( + 'is_woocommerce_email_improvements_enabled', + [$this, 'isWoocommerceEmailImprovementsEnabled'], + ['is_safe' => ['all']] + ), new TwigFunction( 'get_woocommerce_version', [$this, 'getWooCommerceVersion'], @@ -312,6 +317,10 @@ class Functions extends AbstractExtension { return $this->getWooCommerceHelper()->isWooCommerceActive(); } + public function isWoocommerceEmailImprovementsEnabled() { + return $this->getWooCommerceHelper()->isWooCommerceEmailImprovementsEnabled(); + } + public function getWooCommerceVersion() { return $this->getWooCommerceHelper()->getWooCommerceVersion(); } diff --git a/mailpoet/lib/WooCommerce/Helper.php b/mailpoet/lib/WooCommerce/Helper.php index d115d2f245..ceec87ec4a 100644 --- a/mailpoet/lib/WooCommerce/Helper.php +++ b/mailpoet/lib/WooCommerce/Helper.php @@ -340,4 +340,16 @@ class Helper { return $isRegularCheckout || $isBlockCheckout; } + + public function isWooCommerceEmailImprovementsEnabled(): bool { + if (!class_exists('\Automattic\WooCommerce\Utilities\FeaturesUtil')) { + return false; + } + // By this point, the feature should be enabled by default for everyone + $wcVersion = $this->getWooCommerceVersion(); + if (version_compare($wcVersion, '10.0.0', '>')) { + return true; + } + return \Automattic\WooCommerce\Utilities\FeaturesUtil::feature_is_enabled('email_improvements'); + } } diff --git a/mailpoet/views/layout.html b/mailpoet/views/layout.html index c290cece8c..400cd3e3c1 100644 --- a/mailpoet/views/layout.html +++ b/mailpoet/views/layout.html @@ -51,6 +51,7 @@ var mailpoet_analytics_new_public_id = <%= is_analytics_public_id_new() | json_encode %>; var mailpoet_free_domains = <%= json_encode(mailpoet_free_domains()) %>; var mailpoet_woocommerce_active = <%= json_encode(is_woocommerce_active()) %>; + var mailpoet_woocommerce_email_improvements_enabled = <%= json_encode(is_woocommerce_email_improvements_enabled()) %>; var mailpoet_woocommerce_subscriptions_active = <%= json_encode(is_woocommerce_subscriptions_active) %>; var mailpoet_woocommerce_store_config = <%= json_encode(woocommerce_store_config) %>; // RFC 5322 standard; http://emailregex.com/ combined with https://google.github.io/closure-library/api/goog.format.EmailAddress.html#isValid From fce1ac1e4ae7a3bf29a0e67bdc0c52fdb0bbfd5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Mon, 3 Mar 2025 15:38:11 +0100 Subject: [PATCH 22/26] Load new email templates if email improvements feature is enabled in WooCommerce [MAILPOET-6484] --- .../blocks/woocommerce-content.js | 12 ++++++++ mailpoet/views/newsletter/editor.html | 29 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/mailpoet/assets/js/src/newsletter-editor/blocks/woocommerce-content.js b/mailpoet/assets/js/src/newsletter-editor/blocks/woocommerce-content.js index 0b0be5c3b4..d56ada0fa1 100644 --- a/mailpoet/assets/js/src/newsletter-editor/blocks/woocommerce-content.js +++ b/mailpoet/assets/js/src/newsletter-editor/blocks/woocommerce-content.js @@ -46,6 +46,18 @@ const BlockView = BaseBlock.BlockView.extend({ }); }, getTemplate() { + if (window.mailpoet_woocommerce_email_improvements_enabled) { + if (this.model.get('selected') === 'new_account') { + return window.templates.woocommerceNewAccountImproved; + } + if (this.model.get('selected') === 'processing_order') { + return window.templates.woocommerceProcessingOrderImproved; + } + if (this.model.get('selected') === 'completed_order') { + return window.templates.woocommerceCompletedOrderImproved; + } + return window.templates.woocommerceCustomerNoteImproved; + } if (this.model.get('selected') === 'new_account') { return window.templates.woocommerceNewAccount; } diff --git a/mailpoet/views/newsletter/editor.html b/mailpoet/views/newsletter/editor.html index 2174ca4839..feab632971 100644 --- a/mailpoet/views/newsletter/editor.html +++ b/mailpoet/views/newsletter/editor.html @@ -301,6 +301,22 @@ 'newsletter_editor_template_woocommerce_customer_note_content', 'newsletter/templates/blocks/woocommerceContent/customer_note.hbs' ) %> + <%= partial( + 'newsletter_editor_template_woocommerce_new_account_content_improved', + 'newsletter/templates/blocks/woocommerceContentImproved/new_account.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_woocommerce_processing_order_content_improved', + 'newsletter/templates/blocks/woocommerceContentImproved/processing_order.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_woocommerce_completed_order_content_improved', + 'newsletter/templates/blocks/woocommerceContentImproved/completed_order.hbs' + ) %> + <%= partial( + 'newsletter_editor_template_woocommerce_customer_note_content_improved', + 'newsletter/templates/blocks/woocommerceContentImproved/customer_note.hbs' + ) %> <%= partial( 'newsletter_editor_template_woocommerce_content_widget', 'newsletter/templates/blocks/woocommerceContent/widget.hbs' @@ -646,6 +662,19 @@ jQuery('#newsletter_editor_template_woocommerce_content_widget').html() ), + woocommerceNewAccountImproved: Handlebars.compile( + jQuery('#newsletter_editor_template_woocommerce_new_account_content_improved').html() + ), + woocommerceProcessingOrderImproved: Handlebars.compile( + jQuery('#newsletter_editor_template_woocommerce_processing_order_content_improved').html() + ), + woocommerceCompletedOrderImproved: Handlebars.compile( + jQuery('#newsletter_editor_template_woocommerce_completed_order_content_improved').html() + ), + woocommerceCustomerNoteImproved: Handlebars.compile( + jQuery('#newsletter_editor_template_woocommerce_customer_note_content_improved').html() + ), + woocommerceHeadingBlock: Handlebars.compile( jQuery('#newsletter_editor_template_woocommerce_heading_block').html() ), From 0508874349c5898009d18ba9170f7aed05cb850b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ja=CC=81n=20Mikla=CC=81s=CC=8C?= Date: Mon, 3 Mar 2025 17:04:36 +0100 Subject: [PATCH 23/26] Translate WooCommerce email templates [MAILPOET-6484] --- .../completed_order.hbs | 46 ++++++++++--------- .../customer_note.hbs | 42 ++++++++--------- .../new_account.hbs | 12 ++--- .../processing_order.hbs | 40 ++++++++-------- 4 files changed, 72 insertions(+), 68 deletions(-) diff --git a/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/completed_order.hbs b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/completed_order.hbs index eeeade7dae..99456455c1 100644 --- a/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/completed_order.hbs +++ b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/completed_order.hbs @@ -7,12 +7,12 @@
@@ -21,9 +21,11 @@ + <%= __('Subtotal:', 'woocommerce') %> + <%= __('Discount:', 'woocommerce') %> + <%= __('Shipping:', 'woocommerce') %> <%= __('Flat rate', 'woocommerce') %> + <%= __('Total:', 'woocommerce') %> - + <%= __('Payment method:', 'woocommerce') %> + + <%= __('It can be multiple lines. If there’s no note, this section is hidden.', 'woocommerce') %> @@ -91,12 +95,12 @@ @@ -106,7 +110,7 @@
- Billing address + <%= __('Billing address', 'woocommerce') %>
John Doe
Company
123 Fake Street
Faketown, CA 12345
United States (US)
555-555-5555
john@company.com
- Shipping address + <%= __('Shipping address', 'woocommerce') %>
John Doe
Company
123 Fake Street
Faketown, CA 12345
United States (US)
555-555-5555
diff --git a/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/customer_note.hbs b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/customer_note.hbs index e48812b734..51278dcc23 100644 --- a/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/customer_note.hbs +++ b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/customer_note.hbs @@ -7,16 +7,16 @@
@@ -27,7 +27,7 @@ @@ -43,8 +43,8 @@ - Dummy Product Variation + <%= __('Dummy Product Variation', 'woocommerce') %> @@ -58,36 +58,36 @@ - Subtotal: + <%= __('Subtotal:', 'woocommerce') %> 70,00 $ - Discount: + <%= __('Discount:', 'woocommerce') %> -10,00 $ - Shipping: Flat rate + <%= __('Shipping:', 'woocommerce') %> <%= __('Flat rate', 'woocommerce') %> 5,00 $ - Total: + <%= __('Total:', 'woocommerce') %> 65,00 $ - Payment method: - Direct bank transfer + <%= __('Payment method:', 'woocommerce') %> + <%= __('Direct bank transfer', 'woocommerce') %> - Customer note
- This is a customer note. Customers can add a note to their order on checkout.
+ <%= __('Customer note', 'woocommerce') %>
+ <%= __('This is a customer note. Customers can add a note to their order on checkout.', 'woocommerce') %>

- It can be multiple lines. If there’s no note, this section is hidden. + <%= __('It can be multiple lines. If there’s no note, this section is hidden.', 'woocommerce') %> @@ -95,12 +95,12 @@ @@ -110,7 +110,7 @@
- Billing address + <%= __('Billing address', 'woocommerce') %>
John Doe
Company
123 Fake Street
Faketown, CA 12345
United States (US)
555-555-5555
john@company.com
- Shipping address + <%= __('Shipping address', 'woocommerce') %>
John Doe
Company
123 Fake Street
Faketown, CA 12345
United States (US)
555-555-5555
diff --git a/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/new_account.hbs b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/new_account.hbs index 6125b1ecfa..8768771d21 100644 --- a/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/new_account.hbs +++ b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/new_account.hbs @@ -6,18 +6,18 @@
diff --git a/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/processing_order.hbs b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/processing_order.hbs index 5d237e72a2..4adf703044 100644 --- a/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/processing_order.hbs +++ b/mailpoet/views/newsletter/templates/blocks/woocommerceContentImproved/processing_order.hbs @@ -7,12 +7,12 @@
@@ -23,7 +23,7 @@ @@ -39,8 +39,8 @@ - Dummy Product Variation + <%= __('Dummy Product Variation', 'woocommerce') %> @@ -54,36 +54,36 @@ - Subtotal: + <%= __('Subtotal:', 'woocommerce') %> 70,00 $ - Discount: + <%= __('Discount:', 'woocommerce') %> -10,00 $ - Shipping: Flat rate + <%= __('Shipping:', 'woocommerce') %> <%= __('Flat rate', 'woocommerce') %> 5,00 $ - Total: + <%= __('Total:', 'woocommerce') %> 65,00 $ - Payment method: - Direct bank transfer + <%= __('Payment method:', 'woocommerce') %> + <%= __('Direct bank transfer', 'woocommerce') %> - Customer note
- This is a customer note. Customers can add a note to their order on checkout.
+ <%= __('Customer note', 'woocommerce') %>
+ <%= __('This is a customer note. Customers can add a note to their order on checkout.', 'woocommerce') %>

- It can be multiple lines. If there’s no note, this section is hidden. + <%= __('It can be multiple lines. If there’s no note, this section is hidden.', 'woocommerce') %> @@ -91,12 +91,12 @@ @@ -106,11 +106,11 @@
- Billing address + <%= __('Billing address', 'woocommerce') %>
John Doe
Company
123 Fake Street
Faketown, CA 12345
United States (US)
555-555-5555
john@company.com
- Shipping address + <%= __('Shipping address', 'woocommerce') %>
John Doe
Company
123 Fake Street
Faketown, CA 12345
United States (US)
555-555-5555
- +
From 540feb6364b222d9a6d02576e493f34b5564c1a1 Mon Sep 17 00:00:00 2001 From: David Remer Date: Thu, 6 Mar 2025 08:13:52 +0200 Subject: [PATCH 24/26] Add PHPCS rule to avoid implicit nullables [MAILPOET-6491] --- mailpoet/tasks/code_sniffer/MailPoet/shared-ruleset.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mailpoet/tasks/code_sniffer/MailPoet/shared-ruleset.xml b/mailpoet/tasks/code_sniffer/MailPoet/shared-ruleset.xml index da9938bee3..5e9ea288d8 100644 --- a/mailpoet/tasks/code_sniffer/MailPoet/shared-ruleset.xml +++ b/mailpoet/tasks/code_sniffer/MailPoet/shared-ruleset.xml @@ -382,6 +382,8 @@ + + From 0a3d49c0cd4fe8020e8418d9a7a6c60b35ae5340 Mon Sep 17 00:00:00 2001 From: David Remer Date: Thu, 6 Mar 2025 08:16:02 +0200 Subject: [PATCH 25/26] Apply non-implicit nullables rule [MAILPOET-6491] --- mailpoet/RoboFile.php | 2 +- .../NewslettersResponseBuilder.php | 2 +- mailpoet/lib/API/REST/Response.php | 2 +- mailpoet/lib/AdminPages/Pages/Help.php | 2 +- .../WooCommerce/Events/FirstPurchase.php | 2 +- .../Events/PurchasedInCategory.php | 2 +- .../WooCommerce/Events/PurchasedProduct.php | 2 +- .../Engine/Control/StepRunController.php | 6 ++--- .../Engine/Control/StepRunLogger.php | 2 +- .../Engine/Control/StepScheduler.php | 8 +++---- .../lib/Automation/Engine/Data/Automation.php | 4 ++-- .../Automation/Engine/Data/AutomationRun.php | 4 ++-- .../Engine/Data/AutomationRunLog.php | 2 +- mailpoet/lib/Automation/Engine/Data/Step.php | 2 +- .../Engine/Exceptions/Exception.php | 8 +++---- .../Engine/Mappers/AutomationMapper.php | 2 +- mailpoet/lib/Automation/Engine/Registry.php | 4 ++-- .../Storage/AutomationRunLogStorage.php | 2 +- .../Engine/Storage/AutomationRunStorage.php | 2 +- .../Storage/AutomationStatisticsStorage.php | 6 ++--- .../Engine/Storage/AutomationStorage.php | 6 ++--- mailpoet/lib/Automation/Engine/WordPress.php | 2 +- .../MailPoet/Actions/SendEmailAction.php | 2 +- .../MailPoet/Analytics/Entities/Query.php | 2 +- .../Analytics/Entities/QueryWithCompare.php | 2 +- .../SubscriberAutomationFieldsFactory.php | 2 +- .../Fields/SubscriberCustomFieldsFactory.php | 2 +- .../Fields/CustomerOrderFieldsFactory.php | 2 +- .../Fields/CustomerReviewFieldsFactory.php | 2 +- .../WooCommerce/Payloads/CustomerPayload.php | 4 ++-- mailpoet/lib/Captcha/CaptchaPhrase.php | 2 +- .../lib/Captcha/Validator/ValidationError.php | 2 +- mailpoet/lib/Config/Capabilities.php | 2 +- mailpoet/lib/Config/HooksWooCommerce.php | 2 +- mailpoet/lib/Config/Menu.php | 4 ++-- mailpoet/lib/Config/TwigEnvironment.php | 2 +- mailpoet/lib/Cron/DaemonHttpRunner.php | 4 ++-- .../Cron/Workers/SendingQueue/Tasks/Links.php | 2 +- .../Workers/SendingQueue/Tasks/Mailer.php | 2 +- .../Workers/SendingQueue/Tasks/Newsletter.php | 8 +++---- .../Workers/SendingQueue/Tasks/Shortcodes.php | 2 +- .../Workers/StatsNotifications/Worker.php | 2 +- mailpoet/lib/DI/ContainerConfigurator.php | 2 +- mailpoet/lib/DI/ContainerWrapper.php | 2 +- mailpoet/lib/Doctrine/Repository.php | 8 +++---- mailpoet/lib/Entities/FormEntity.php | 2 +- mailpoet/lib/Entities/NewsletterEntity.php | 4 ++-- mailpoet/lib/Entities/ScheduledTaskEntity.php | 2 +- .../ScheduledTaskSubscriberEntity.php | 2 +- .../Entities/StatisticsNewsletterEntity.php | 2 +- .../Entities/StatisticsUnsubscribeEntity.php | 4 ++-- mailpoet/lib/Entities/SubscriberEntity.php | 4 ++-- mailpoet/lib/Form/Renderer.php | 4 ++-- mailpoet/lib/Listing/ListingDefinition.php | 4 ++-- mailpoet/lib/Logging/LogRepository.php | 10 ++++---- mailpoet/lib/Mailer/MailerFactory.php | 6 ++--- mailpoet/lib/Mailer/MailerLog.php | 24 +++++++++---------- mailpoet/lib/Mailer/MetaInfo.php | 2 +- .../Mailer/Methods/Common/BlacklistCheck.php | 2 +- mailpoet/lib/Migrator/Migrator.php | 2 +- .../Newsletter/Editor/PostContentManager.php | 2 +- .../lib/Newsletter/Editor/PostTransformer.php | 2 +- .../Listing/NewsletterListingRepository.php | 2 +- .../Renderer/Blocks/AbandonedCartContent.php | 6 ++--- .../lib/Newsletter/Renderer/Preprocessor.php | 4 ++-- mailpoet/lib/Newsletter/Renderer/Renderer.php | 4 ++-- .../Categories/CategoryInterface.php | 6 ++--- .../Newsletter/Shortcodes/Categories/Date.php | 6 ++--- .../Newsletter/Shortcodes/Categories/Link.php | 12 +++++----- .../Shortcodes/Categories/Newsletter.php | 6 ++--- .../Newsletter/Shortcodes/Categories/Site.php | 6 ++--- .../Shortcodes/Categories/Subscriber.php | 6 ++--- .../lib/Newsletter/Shortcodes/Shortcodes.php | 6 ++--- .../NewsletterStatisticsRepository.php | 14 +++++------ .../ViewInBrowser/ViewInBrowserRenderer.php | 4 ++-- .../DynamicSegments/Filters/EmailAction.php | 2 +- .../Filters/WooFilterHelper.php | 2 +- .../Segments/SegmentSubscribersRepository.php | 12 +++++----- .../Segments/SegmentsSimpleListRepository.php | 2 +- .../Services/AuthorizedEmailsController.php | 4 ++-- mailpoet/lib/Services/Bridge.php | 2 +- mailpoet/lib/Settings/TrackingConfig.php | 8 +++---- .../lib/Statistics/Track/Unsubscribes.php | 4 ++-- .../RequiredCustomFieldValidator.php | 4 ++-- mailpoet/lib/Subscription/Blacklist.php | 4 ++-- .../Subscription/SubscriptionUrlFactory.php | 12 +++++----- mailpoet/lib/Twig/Assets.php | 2 +- .../lib/Util/License/Features/Subscribers.php | 2 +- .../Util/Notices/UnauthorizedEmailNotice.php | 2 +- mailpoet/lib/Validator/Builder.php | 4 ++-- mailpoet/lib/WP/DateTime.php | 2 +- mailpoet/lib/WP/Emoji.php | 2 +- mailpoet/lib/WP/Functions.php | 4 ++-- mailpoet/tasks/release/JiraController.php | 2 +- mailpoet/tests/DataFactories/Automation.php | 2 +- .../tests/DataFactories/AutomationRun.php | 2 +- .../tests/DataFactories/ScheduledTask.php | 4 ++-- .../DataFactories/ScheduledTaskSubscriber.php | 2 +- mailpoet/tests/DataFactories/SendingQueue.php | 2 +- .../Generators/WooCommercePastRevenues.php | 2 +- mailpoet/tests/_support/AcceptanceTester.php | 2 +- mailpoet/tests/_support/IntegrationTester.php | 2 +- .../acceptance/Automation/AnalyticsCest.php | 2 +- .../API/JSON/v1/SubscribersTest.php | 2 +- .../AutomationStatisticsStorageTest.php | 2 +- .../Fields/NewsletterLinkFieldsTest.php | 2 +- .../SubscriberAutomationFieldsFactoryTest.php | 2 +- .../Triggers/BuysAProductTriggerTest.php | 2 +- .../Triggers/BuysFromACategoryTriggerTest.php | 2 +- .../Triggers/BuysFromATagTriggerTest.php | 2 +- .../Cron/Triggers/WordPressTest.php | 2 +- .../Workers/KeyCheck/KeyCheckWorkerTest.php | 2 +- .../Editor/PostContentTransformerTest.php | 2 +- .../NewsletterSaveControllerTest.php | 6 ++--- .../Scheduler/ReEngagementSchedulerTest.php | 2 +- .../Sending/SendingQueuesRepositoryTest.php | 2 +- .../integration/Newsletter/ShortcodesTest.php | 2 +- .../ViewInBrowserControllerTest.php | 8 +++---- .../tests/integration/REST/API/Endpoint.php | 2 +- .../integration/REST/API/EndpointTest.php | 6 ++--- .../Filters/EmailActionClickAnyTest.php | 2 +- .../Filters/NumberOfClicksTest.php | 2 +- .../DynamicSegments/Filters/UserRoleTest.php | 2 +- .../Filters/WooCommerceCountryTest.php | 2 +- .../Filters/WooCommerceSubscriptionTest.php | 2 +- .../Filters/WooCommerceUsedCouponCodeTest.php | 2 +- .../Segments/SegmentsFinderTest.php | 2 +- .../integration/Segments/WooCommerceTest.php | 2 +- .../NewsletterClicksExporterTest.php | 2 +- .../NewsletterOpensExporterTest.php | 2 +- .../ManageSubscriptionFormRendererTest.php | 2 +- .../integration/Subscription/PagesTest.php | 4 ++-- .../AutomationRules/UnknownStepRuleTest.php | 2 +- mailpoet/tests/unit/Cron/CronTriggerTest.php | 4 ++-- 134 files changed, 237 insertions(+), 237 deletions(-) diff --git a/mailpoet/RoboFile.php b/mailpoet/RoboFile.php index 25a5244502..b0f6d363c1 100644 --- a/mailpoet/RoboFile.php +++ b/mailpoet/RoboFile.php @@ -1383,7 +1383,7 @@ class RoboFile extends \Robo\Tasks { $this->say("Release '$version[name]' info was published on Slack."); } - public function releaseRerunCircleWorkflow(string $project = null) { + public function releaseRerunCircleWorkflow(?string $project = null) { $circleciController = $this->createCircleCiController(); $result = $circleciController->rerunLatestWorkflow($project); // Sometimes can be useful to know which Circle project workflow was restarted diff --git a/mailpoet/lib/API/JSON/ResponseBuilders/NewslettersResponseBuilder.php b/mailpoet/lib/API/JSON/ResponseBuilders/NewslettersResponseBuilder.php index 98b45207b2..b763d83c1a 100644 --- a/mailpoet/lib/API/JSON/ResponseBuilders/NewslettersResponseBuilder.php +++ b/mailpoet/lib/API/JSON/ResponseBuilders/NewslettersResponseBuilder.php @@ -158,7 +158,7 @@ class NewslettersResponseBuilder { * @param SendingQueueEntity|null $latestQueue * @return array */ - private function buildListingItem(NewsletterEntity $newsletter, NewsletterStatistics $statistics = null, SendingQueueEntity $latestQueue = null): array { + private function buildListingItem(NewsletterEntity $newsletter, ?NewsletterStatistics $statistics = null, ?SendingQueueEntity $latestQueue = null): array { $couponBlockLogs = array_map(function ($item) { return "Coupon block: $item"; }, $this->logRepository->getRawMessagesForNewsletter($newsletter, LoggerFactory::TOPIC_COUPONS)); diff --git a/mailpoet/lib/API/REST/Response.php b/mailpoet/lib/API/REST/Response.php index 09c7e01bde..bc51e10fb8 100644 --- a/mailpoet/lib/API/REST/Response.php +++ b/mailpoet/lib/API/REST/Response.php @@ -6,7 +6,7 @@ use WP_REST_Response; class Response extends WP_REST_Response { public function __construct( - array $data = null, + ?array $data = null, int $status = 200 ) { parent::__construct(['data' => $data], $status); diff --git a/mailpoet/lib/AdminPages/Pages/Help.php b/mailpoet/lib/AdminPages/Pages/Help.php index 936fa9b593..b5353c150f 100644 --- a/mailpoet/lib/AdminPages/Pages/Help.php +++ b/mailpoet/lib/AdminPages/Pages/Help.php @@ -107,7 +107,7 @@ class Help { return $actionSchedulerData; } - private function getLatestActionSchedulerActionDate(string $hook, string $status = null): ?string { + private function getLatestActionSchedulerActionDate(string $hook, ?string $status = null): ?string { $query = [ 'per_page' => 1, 'order' => 'DESC', diff --git a/mailpoet/lib/AutomaticEmails/WooCommerce/Events/FirstPurchase.php b/mailpoet/lib/AutomaticEmails/WooCommerce/Events/FirstPurchase.php index 6c51aae16b..4433c8b8de 100644 --- a/mailpoet/lib/AutomaticEmails/WooCommerce/Events/FirstPurchase.php +++ b/mailpoet/lib/AutomaticEmails/WooCommerce/Events/FirstPurchase.php @@ -36,7 +36,7 @@ class FirstPurchase { private $subscribersRepository; public function __construct( - WCHelper $helper = null + ?WCHelper $helper = null ) { if ($helper === null) { $helper = ContainerWrapper::getInstance()->get(WCHelper::class); diff --git a/mailpoet/lib/AutomaticEmails/WooCommerce/Events/PurchasedInCategory.php b/mailpoet/lib/AutomaticEmails/WooCommerce/Events/PurchasedInCategory.php index c23601582c..79d3c1ebae 100644 --- a/mailpoet/lib/AutomaticEmails/WooCommerce/Events/PurchasedInCategory.php +++ b/mailpoet/lib/AutomaticEmails/WooCommerce/Events/PurchasedInCategory.php @@ -34,7 +34,7 @@ class PurchasedInCategory { private $subscribersRepository; public function __construct( - WCHelper $woocommerceHelper = null + ?WCHelper $woocommerceHelper = null ) { if ($woocommerceHelper === null) { $woocommerceHelper = ContainerWrapper::getInstance()->get(WCHelper::class); diff --git a/mailpoet/lib/AutomaticEmails/WooCommerce/Events/PurchasedProduct.php b/mailpoet/lib/AutomaticEmails/WooCommerce/Events/PurchasedProduct.php index 0156954f81..29694fb181 100644 --- a/mailpoet/lib/AutomaticEmails/WooCommerce/Events/PurchasedProduct.php +++ b/mailpoet/lib/AutomaticEmails/WooCommerce/Events/PurchasedProduct.php @@ -35,7 +35,7 @@ class PurchasedProduct { private $subscribersRepository; public function __construct( - WCHelper $helper = null + ?WCHelper $helper = null ) { if ($helper === null) { $helper = ContainerWrapper::getInstance()->get(WCHelper::class); diff --git a/mailpoet/lib/Automation/Engine/Control/StepRunController.php b/mailpoet/lib/Automation/Engine/Control/StepRunController.php index 05521351d6..b43f1946bd 100644 --- a/mailpoet/lib/Automation/Engine/Control/StepRunController.php +++ b/mailpoet/lib/Automation/Engine/Control/StepRunController.php @@ -25,15 +25,15 @@ class StepRunController { $this->stepRunLogger = $stepRunLogger; } - public function scheduleProgress(int $timestamp = null): int { + public function scheduleProgress(?int $timestamp = null): int { return $this->stepScheduler->scheduleProgress($this->stepRunArgs, $timestamp); } - public function scheduleNextStep(int $timestamp = null): int { + public function scheduleNextStep(?int $timestamp = null): int { return $this->stepScheduler->scheduleNextStep($this->stepRunArgs, $timestamp); } - public function scheduleNextStepByIndex(int $nextStepIndex, int $timestamp = null): int { + public function scheduleNextStepByIndex(int $nextStepIndex, ?int $timestamp = null): int { return $this->stepScheduler->scheduleNextStepByIndex($this->stepRunArgs, $nextStepIndex, $timestamp); } diff --git a/mailpoet/lib/Automation/Engine/Control/StepRunLogger.php b/mailpoet/lib/Automation/Engine/Control/StepRunLogger.php index d727431439..0006907339 100644 --- a/mailpoet/lib/Automation/Engine/Control/StepRunLogger.php +++ b/mailpoet/lib/Automation/Engine/Control/StepRunLogger.php @@ -42,7 +42,7 @@ class StepRunLogger { string $stepId, string $stepType, int $runNumber, - bool $isWpDebug = null + ?bool $isWpDebug = null ) { $this->automationRunLogStorage = $automationRunLogStorage; $this->hooks = $hooks; diff --git a/mailpoet/lib/Automation/Engine/Control/StepScheduler.php b/mailpoet/lib/Automation/Engine/Control/StepScheduler.php index 94f3bf48c0..caf0c0627e 100644 --- a/mailpoet/lib/Automation/Engine/Control/StepScheduler.php +++ b/mailpoet/lib/Automation/Engine/Control/StepScheduler.php @@ -23,13 +23,13 @@ class StepScheduler { $this->automationRunStorage = $automationRunStorage; } - public function scheduleProgress(StepRunArgs $args, int $timestamp = null): int { + public function scheduleProgress(StepRunArgs $args, ?int $timestamp = null): int { $runId = $args->getAutomationRun()->getId(); $data = $this->getActionData($runId, $args->getStep()->getId(), $args->getRunNumber() + 1); return $this->scheduleStepAction($data, $timestamp); } - public function scheduleNextStep(StepRunArgs $args, int $timestamp = null): int { + public function scheduleNextStep(StepRunArgs $args, ?int $timestamp = null): int { $step = $args->getStep(); $nextSteps = $step->getNextSteps(); @@ -46,7 +46,7 @@ class StepScheduler { return $this->scheduleNextStepByIndex($args, 0, $timestamp); } - public function scheduleNextStepByIndex(StepRunArgs $args, int $nextStepIndex, int $timestamp = null): int { + public function scheduleNextStepByIndex(StepRunArgs $args, int $nextStepIndex, ?int $timestamp = null): int { $step = $args->getStep(); $nextStep = $step->getNextSteps()[$nextStepIndex] ?? null; if (!$nextStep) { @@ -95,7 +95,7 @@ class StepScheduler { return $this->hasScheduledNextStep($args) || $this->hasScheduledProgress($args); } - private function scheduleStepAction(array $data, int $timestamp = null): int { + private function scheduleStepAction(array $data, ?int $timestamp = null): int { return $timestamp === null ? $this->actionScheduler->enqueue(Hooks::AUTOMATION_STEP, $data) : $this->actionScheduler->schedule($timestamp, Hooks::AUTOMATION_STEP, $data); diff --git a/mailpoet/lib/Automation/Engine/Data/Automation.php b/mailpoet/lib/Automation/Engine/Data/Automation.php index bd34c2c36c..cc59a3b7a6 100644 --- a/mailpoet/lib/Automation/Engine/Data/Automation.php +++ b/mailpoet/lib/Automation/Engine/Data/Automation.php @@ -53,8 +53,8 @@ class Automation { string $name, array $steps, \WP_User $author, - int $id = null, - int $versionId = null + ?int $id = null, + ?int $versionId = null ) { $this->name = $name; $this->steps = $steps; diff --git a/mailpoet/lib/Automation/Engine/Data/AutomationRun.php b/mailpoet/lib/Automation/Engine/Data/AutomationRun.php index 972e2d5be7..a6dcea1071 100644 --- a/mailpoet/lib/Automation/Engine/Data/AutomationRun.php +++ b/mailpoet/lib/Automation/Engine/Data/AutomationRun.php @@ -42,7 +42,7 @@ class AutomationRun { int $versionId, string $triggerKey, array $subjects, - int $id = null + ?int $id = null ) { $this->automationId = $automationId; $this->versionId = $versionId; @@ -91,7 +91,7 @@ class AutomationRun { } /** @return Subject[] */ - public function getSubjects(string $key = null): array { + public function getSubjects(?string $key = null): array { if ($key) { return array_values( array_filter($this->subjects, function (Subject $subject) use ($key) { diff --git a/mailpoet/lib/Automation/Engine/Data/AutomationRunLog.php b/mailpoet/lib/Automation/Engine/Data/AutomationRunLog.php index 358a73c7ea..cebc3d226b 100644 --- a/mailpoet/lib/Automation/Engine/Data/AutomationRunLog.php +++ b/mailpoet/lib/Automation/Engine/Data/AutomationRunLog.php @@ -60,7 +60,7 @@ class AutomationRunLog { int $automationRunId, string $stepId, string $stepType, - int $id = null + ?int $id = null ) { $this->automationRunId = $automationRunId; $this->stepId = $stepId; diff --git a/mailpoet/lib/Automation/Engine/Data/Step.php b/mailpoet/lib/Automation/Engine/Data/Step.php index e7c04e0664..6962e8efe3 100644 --- a/mailpoet/lib/Automation/Engine/Data/Step.php +++ b/mailpoet/lib/Automation/Engine/Data/Step.php @@ -35,7 +35,7 @@ class Step { string $key, array $args, array $nextSteps, - Filters $filters = null + ?Filters $filters = null ) { $this->id = $id; $this->type = $type; diff --git a/mailpoet/lib/Automation/Engine/Exceptions/Exception.php b/mailpoet/lib/Automation/Engine/Exceptions/Exception.php index 10a2cf5dae..161a72806b 100644 --- a/mailpoet/lib/Automation/Engine/Exceptions/Exception.php +++ b/mailpoet/lib/Automation/Engine/Exceptions/Exception.php @@ -20,16 +20,16 @@ abstract class Exception extends PhpException implements RestException { protected $errors = []; final public function __construct( - string $message = null, - string $errorCode = null, - Throwable $previous = null + ?string $message = null, + ?string $errorCode = null, + ?Throwable $previous = null ) { parent::__construct($message ?? __('Unknown error.', 'mailpoet'), 0, $previous); $this->errorCode = $errorCode ?? 'mailpoet_automation_unknown_error'; } /** @return static */ - public static function create(Throwable $previous = null) { + public static function create(?Throwable $previous = null) { return new static(null, null, $previous); } diff --git a/mailpoet/lib/Automation/Engine/Mappers/AutomationMapper.php b/mailpoet/lib/Automation/Engine/Mappers/AutomationMapper.php index 0ffbbbb9e7..d15879b45c 100644 --- a/mailpoet/lib/Automation/Engine/Mappers/AutomationMapper.php +++ b/mailpoet/lib/Automation/Engine/Mappers/AutomationMapper.php @@ -19,7 +19,7 @@ class AutomationMapper { $this->statisticsStorage = $statisticsStorage; } - public function buildAutomation(Automation $automation, AutomationStatistics $statistics = null): array { + public function buildAutomation(Automation $automation, ?AutomationStatistics $statistics = null): array { return [ 'id' => $automation->getId(), diff --git a/mailpoet/lib/Automation/Engine/Registry.php b/mailpoet/lib/Automation/Engine/Registry.php index b37f4babde..ad5b242d98 100644 --- a/mailpoet/lib/Automation/Engine/Registry.php +++ b/mailpoet/lib/Automation/Engine/Registry.php @@ -98,7 +98,7 @@ class Registry { } /** @return array */ - public function getTemplates(string $category = null): array { + public function getTemplates(?string $category = null): array { return $category ? array_filter( $this->templates, @@ -254,7 +254,7 @@ class Registry { $this->wordPress->addAction(Hooks::AUTOMATION_BEFORE_SAVE, $callback, $priority); } - public function onBeforeAutomationStepSave(callable $callback, string $key = null, int $priority = 10): void { + public function onBeforeAutomationStepSave(callable $callback, ?string $key = null, int $priority = 10): void { $keyPart = $key ? "/key=$key" : ''; $this->wordPress->addAction(Hooks::AUTOMATION_STEP_BEFORE_SAVE . $keyPart, $callback, $priority, 2); } diff --git a/mailpoet/lib/Automation/Engine/Storage/AutomationRunLogStorage.php b/mailpoet/lib/Automation/Engine/Storage/AutomationRunLogStorage.php index 13a49fc03f..7b65616cd5 100644 --- a/mailpoet/lib/Automation/Engine/Storage/AutomationRunLogStorage.php +++ b/mailpoet/lib/Automation/Engine/Storage/AutomationRunLogStorage.php @@ -32,7 +32,7 @@ class AutomationRunLogStorage { } } - public function getAutomationRunStatisticsForAutomationInTimeFrame(int $automationId, string $status, \DateTimeImmutable $after, \DateTimeImmutable $before, int $versionId = null): array { + public function getAutomationRunStatisticsForAutomationInTimeFrame(int $automationId, string $status, \DateTimeImmutable $after, \DateTimeImmutable $before, ?int $versionId = null): array { global $wpdb; $andWhere = $versionId ? 'AND run.version_id = %d' : ''; $results = $wpdb->get_results( diff --git a/mailpoet/lib/Automation/Engine/Storage/AutomationRunStorage.php b/mailpoet/lib/Automation/Engine/Storage/AutomationRunStorage.php index ecc8d12ebd..352a659bb0 100644 --- a/mailpoet/lib/Automation/Engine/Storage/AutomationRunStorage.php +++ b/mailpoet/lib/Automation/Engine/Storage/AutomationRunStorage.php @@ -218,7 +218,7 @@ class AutomationRunStorage { } } - public function getAutomationStepStatisticForTimeFrame(int $automationId, string $status, \DateTimeImmutable $after, \DateTimeImmutable $before, int $versionId = null): array { + public function getAutomationStepStatisticForTimeFrame(int $automationId, string $status, \DateTimeImmutable $after, \DateTimeImmutable $before, ?int $versionId = null): array { global $wpdb; $andWhere = $versionId ? 'AND version_id = %d' : ''; $result = $wpdb->get_results( diff --git a/mailpoet/lib/Automation/Engine/Storage/AutomationStatisticsStorage.php b/mailpoet/lib/Automation/Engine/Storage/AutomationStatisticsStorage.php index d20fc59d50..1b34624133 100644 --- a/mailpoet/lib/Automation/Engine/Storage/AutomationStatisticsStorage.php +++ b/mailpoet/lib/Automation/Engine/Storage/AutomationStatisticsStorage.php @@ -39,7 +39,7 @@ class AutomationStatisticsStorage { return $statistics; } - public function getAutomationStats(int $automationId, int $versionId = null, \DateTimeImmutable $after = null, \DateTimeImmutable $before = null): AutomationStatistics { + public function getAutomationStats(int $automationId, ?int $versionId = null, ?\DateTimeImmutable $after = null, ?\DateTimeImmutable $before = null): AutomationStatistics { $data = $this->getStatistics([$automationId], $versionId, $after, $before); return new AutomationStatistics( $automationId, @@ -53,7 +53,7 @@ class AutomationStatisticsStorage { * @param int[] $automationIds * @return array */ - private function getStatistics(array $automationIds, int $versionId = null, \DateTimeImmutable $after = null, \DateTimeImmutable $before = null): array { + private function getStatistics(array $automationIds, ?int $versionId = null, ?\DateTimeImmutable $after = null, ?\DateTimeImmutable $before = null): array { global $wpdb; $totalSubquery = $this->getStatsQuery($automationIds, $versionId, $after, $before); $runningSubquery = $this->getStatsQuery($automationIds, $versionId, $after, $before, AutomationRun::STATUS_RUNNING); @@ -71,7 +71,7 @@ class AutomationStatisticsStorage { return array_combine(array_column($results, 'id'), $results) ?: []; } - private function getStatsQuery(array $automationIds, int $versionId = null, \DateTimeImmutable $after = null, \DateTimeImmutable $before = null, string $status = null): string { + private function getStatsQuery(array $automationIds, ?int $versionId = null, ?\DateTimeImmutable $after = null, ?\DateTimeImmutable $before = null, ?string $status = null): string { global $wpdb; $versionCondition = $versionId ? 'AND version_id = %d' : ''; diff --git a/mailpoet/lib/Automation/Engine/Storage/AutomationStorage.php b/mailpoet/lib/Automation/Engine/Storage/AutomationStorage.php index 3a478c1242..a7b098529a 100644 --- a/mailpoet/lib/Automation/Engine/Storage/AutomationStorage.php +++ b/mailpoet/lib/Automation/Engine/Storage/AutomationStorage.php @@ -126,7 +126,7 @@ class AutomationStorage { ) : []; } - public function getAutomation(int $automationId, int $versionId = null): ?Automation { + public function getAutomation(int $automationId, ?int $versionId = null): ?Automation { global $wpdb; if ($versionId) { @@ -153,7 +153,7 @@ class AutomationStorage { } /** @return Automation[] */ - public function getAutomations(array $status = null): array { + public function getAutomations(?array $status = null): array { global $wpdb; $statusFilter = $status ? 'AND a.status IN (' . implode(',', array_fill(0, count($status), '%s')) . ')' : ''; @@ -184,7 +184,7 @@ class AutomationStorage { } /** @return int[] */ - public function getAutomationIdsBySubject(Subject $subject, array $runStatus = null, int $inTheLastSeconds = null): array { + public function getAutomationIdsBySubject(Subject $subject, ?array $runStatus = null, ?int $inTheLastSeconds = null): array { global $wpdb; $statusFilter = $runStatus ? 'AND r.status IN (' . implode(',', array_fill(0, count($runStatus), '%s')) . ')' : ''; diff --git a/mailpoet/lib/Automation/Engine/WordPress.php b/mailpoet/lib/Automation/Engine/WordPress.php index a9abefc60b..ed52c4fa39 100644 --- a/mailpoet/lib/Automation/Engine/WordPress.php +++ b/mailpoet/lib/Automation/Engine/WordPress.php @@ -68,7 +68,7 @@ class WordPress { } /** @return WP_Post[]|int[] */ - public function getPosts(array $args = null): array { + public function getPosts(?array $args = null): array { return get_posts($args); } diff --git a/mailpoet/lib/Automation/Integrations/MailPoet/Actions/SendEmailAction.php b/mailpoet/lib/Automation/Integrations/MailPoet/Actions/SendEmailAction.php index 5596f7c12b..f6505c3bd2 100644 --- a/mailpoet/lib/Automation/Integrations/MailPoet/Actions/SendEmailAction.php +++ b/mailpoet/lib/Automation/Integrations/MailPoet/Actions/SendEmailAction.php @@ -423,7 +423,7 @@ class SendEmailAction implements Action { $this->newslettersRepository->flush(); } - private function storeNewsletterOption(NewsletterEntity $newsletter, string $optionName, string $optionValue = null): void { + private function storeNewsletterOption(NewsletterEntity $newsletter, string $optionName, ?string $optionValue = null): void { $options = $newsletter->getOptions()->toArray(); foreach ($options as $key => $option) { if ($option->getName() === $optionName) { diff --git a/mailpoet/lib/Automation/Integrations/MailPoet/Analytics/Entities/Query.php b/mailpoet/lib/Automation/Integrations/MailPoet/Analytics/Entities/Query.php index 7b6d04ee99..d1c4e75577 100644 --- a/mailpoet/lib/Automation/Integrations/MailPoet/Analytics/Entities/Query.php +++ b/mailpoet/lib/Automation/Integrations/MailPoet/Analytics/Entities/Query.php @@ -41,7 +41,7 @@ class Query { string $orderDirection = 'asc', int $page = 1, array $filter = [], - string $search = null + ?string $search = null ) { $this->primaryAfter = $primaryAfter; $this->primaryBefore = $primaryBefore; diff --git a/mailpoet/lib/Automation/Integrations/MailPoet/Analytics/Entities/QueryWithCompare.php b/mailpoet/lib/Automation/Integrations/MailPoet/Analytics/Entities/QueryWithCompare.php index bbf6fc1af4..f6dd1f0243 100644 --- a/mailpoet/lib/Automation/Integrations/MailPoet/Analytics/Entities/QueryWithCompare.php +++ b/mailpoet/lib/Automation/Integrations/MailPoet/Analytics/Entities/QueryWithCompare.php @@ -25,7 +25,7 @@ class QueryWithCompare extends Query { string $orderDirection = 'asc', int $page = 0, array $filter = [], - string $search = null + ?string $search = null ) { parent::__construct($primaryAfter, $primaryBefore, $limit, $orderBy, $orderDirection, $page, $filter, $search); $this->secondaryAfter = $secondaryAfter; diff --git a/mailpoet/lib/Automation/Integrations/MailPoet/Fields/SubscriberAutomationFieldsFactory.php b/mailpoet/lib/Automation/Integrations/MailPoet/Fields/SubscriberAutomationFieldsFactory.php index 22bebbc4fb..0a840b8322 100644 --- a/mailpoet/lib/Automation/Integrations/MailPoet/Fields/SubscriberAutomationFieldsFactory.php +++ b/mailpoet/lib/Automation/Integrations/MailPoet/Fields/SubscriberAutomationFieldsFactory.php @@ -66,7 +66,7 @@ class SubscriberAutomationFieldsFactory { ]; } - private function getAutomationIds(SubscriberPayload $payload, array $status = null, array $params = []): array { + private function getAutomationIds(SubscriberPayload $payload, ?array $status = null, array $params = []): array { $inTheLastSeconds = isset($params['in_the_last']) ? (int)$params['in_the_last'] : null; $subject = new Subject(SubscriberSubject::KEY, ['subscriber_id' => $payload->getId()]); return $this->automationStorage->getAutomationIdsBySubject($subject, $status, $inTheLastSeconds); diff --git a/mailpoet/lib/Automation/Integrations/MailPoet/Fields/SubscriberCustomFieldsFactory.php b/mailpoet/lib/Automation/Integrations/MailPoet/Fields/SubscriberCustomFieldsFactory.php index fced812012..b207956a46 100644 --- a/mailpoet/lib/Automation/Integrations/MailPoet/Fields/SubscriberCustomFieldsFactory.php +++ b/mailpoet/lib/Automation/Integrations/MailPoet/Fields/SubscriberCustomFieldsFactory.php @@ -141,7 +141,7 @@ class SubscriberCustomFieldsFactory { private function getCustomFieldValue(SubscriberPayload $payload, CustomFieldEntity $customField): ?string { $subscriberCustomField = $payload->getSubscriber()->getSubscriberCustomFields()->filter( - function (SubscriberCustomFieldEntity $subscriberCustomField = null) use ($customField) { + function (?SubscriberCustomFieldEntity $subscriberCustomField = null) use ($customField) { return $subscriberCustomField && $subscriberCustomField->getCustomField() === $customField; } )->first() ?: null; diff --git a/mailpoet/lib/Automation/Integrations/WooCommerce/Fields/CustomerOrderFieldsFactory.php b/mailpoet/lib/Automation/Integrations/WooCommerce/Fields/CustomerOrderFieldsFactory.php index d54044fe4c..339120ef40 100644 --- a/mailpoet/lib/Automation/Integrations/WooCommerce/Fields/CustomerOrderFieldsFactory.php +++ b/mailpoet/lib/Automation/Integrations/WooCommerce/Fields/CustomerOrderFieldsFactory.php @@ -332,7 +332,7 @@ class CustomerOrderFieldsFactory { return $date ? new DateTimeImmutable($date, new DateTimeZone('GMT')) : null; } - private function getOrderProductTermIds(WC_Customer $customer, string $taxonomy, int $inTheLastSeconds = null): array { + private function getOrderProductTermIds(WC_Customer $customer, string $taxonomy, ?int $inTheLastSeconds = null): array { global $wpdb; $statuses = array_map(function (string $status) { diff --git a/mailpoet/lib/Automation/Integrations/WooCommerce/Fields/CustomerReviewFieldsFactory.php b/mailpoet/lib/Automation/Integrations/WooCommerce/Fields/CustomerReviewFieldsFactory.php index 4d56cdd595..2c66cadc61 100644 --- a/mailpoet/lib/Automation/Integrations/WooCommerce/Fields/CustomerReviewFieldsFactory.php +++ b/mailpoet/lib/Automation/Integrations/WooCommerce/Fields/CustomerReviewFieldsFactory.php @@ -53,7 +53,7 @@ class CustomerReviewFieldsFactory { * Calculate the customer's review count excluding multiple reviews on the same product. * Inspired by AutomateWoo implementation. */ - private function getUniqueProductReviewCount(WC_Customer $customer, int $inTheLastSeconds = null): int { + private function getUniqueProductReviewCount(WC_Customer $customer, ?int $inTheLastSeconds = null): int { global $wpdb; $inTheLastFilter = isset($inTheLastSeconds) ? 'AND c.comment_date_gmt >= DATE_SUB(current_timestamp, INTERVAL %d SECOND)' : ''; diff --git a/mailpoet/lib/Automation/Integrations/WooCommerce/Payloads/CustomerPayload.php b/mailpoet/lib/Automation/Integrations/WooCommerce/Payloads/CustomerPayload.php index c09b764832..e24509abeb 100644 --- a/mailpoet/lib/Automation/Integrations/WooCommerce/Payloads/CustomerPayload.php +++ b/mailpoet/lib/Automation/Integrations/WooCommerce/Payloads/CustomerPayload.php @@ -11,8 +11,8 @@ class CustomerPayload implements Payload { private ?WC_Order $order; public function __construct( - WC_Customer $customer = null, - WC_Order $order = null + ?WC_Customer $customer = null, + ?WC_Order $order = null ) { $this->customer = $customer; $this->order = $order; diff --git a/mailpoet/lib/Captcha/CaptchaPhrase.php b/mailpoet/lib/Captcha/CaptchaPhrase.php index 394c56bec9..2c895ff998 100644 --- a/mailpoet/lib/Captcha/CaptchaPhrase.php +++ b/mailpoet/lib/Captcha/CaptchaPhrase.php @@ -10,7 +10,7 @@ class CaptchaPhrase { public function __construct( CaptchaSession $session, - PhraseBuilder $phraseBuilder = null + ?PhraseBuilder $phraseBuilder = null ) { $this->session = $session; $this->phraseBuilder = $phraseBuilder ?? new PhraseBuilder(); diff --git a/mailpoet/lib/Captcha/Validator/ValidationError.php b/mailpoet/lib/Captcha/Validator/ValidationError.php index 300ad10462..a6fe4a3ff7 100644 --- a/mailpoet/lib/Captcha/Validator/ValidationError.php +++ b/mailpoet/lib/Captcha/Validator/ValidationError.php @@ -10,7 +10,7 @@ class ValidationError extends \RuntimeException { $message = "", array $meta = [], $code = 0, - \Throwable $previous = null + ?\Throwable $previous = null ) { $this->meta = $meta; $this->meta['error'] = $message; diff --git a/mailpoet/lib/Config/Capabilities.php b/mailpoet/lib/Config/Capabilities.php index d55f3632f7..80e3c05f39 100644 --- a/mailpoet/lib/Config/Capabilities.php +++ b/mailpoet/lib/Config/Capabilities.php @@ -16,7 +16,7 @@ class Capabilities { public function __construct( $renderer = null, - WPFunctions $wp = null + ?WPFunctions $wp = null ) { if ($renderer !== null) { $this->renderer = $renderer; diff --git a/mailpoet/lib/Config/HooksWooCommerce.php b/mailpoet/lib/Config/HooksWooCommerce.php index 20049fd7f0..764a346185 100644 --- a/mailpoet/lib/Config/HooksWooCommerce.php +++ b/mailpoet/lib/Config/HooksWooCommerce.php @@ -145,7 +145,7 @@ class HooksWooCommerce { } } - public function onRegister($errors, string $userLogin, string $userEmail = null) { + public function onRegister($errors, string $userLogin, ?string $userEmail = null) { try { if (empty($errors->errors)) { $this->subscriberRegistration->onRegister($errors, $userLogin, $userEmail); diff --git a/mailpoet/lib/Config/Menu.php b/mailpoet/lib/Config/Menu.php index a9c2fd1c91..9358e4265d 100644 --- a/mailpoet/lib/Config/Menu.php +++ b/mailpoet/lib/Config/Menu.php @@ -711,7 +711,7 @@ class Menu { ); } - public static function isOnMailPoetAdminPage(array $exclude = null, $screenId = null) { + public static function isOnMailPoetAdminPage(?array $exclude = null, $screenId = null) { if (is_null($screenId)) { if (empty($_REQUEST['page'])) { return false; @@ -762,7 +762,7 @@ class Menu { // Used for displaying admin notices only } - public function checkPremiumKey(ServicesChecker $checker = null) { + public function checkPremiumKey(?ServicesChecker $checker = null) { $showNotices = isset($_SERVER['SCRIPT_NAME']) && stripos(sanitize_text_field(wp_unslash($_SERVER['SCRIPT_NAME'])), 'plugins.php') !== false; $checker = $checker ?: $this->servicesChecker; diff --git a/mailpoet/lib/Config/TwigEnvironment.php b/mailpoet/lib/Config/TwigEnvironment.php index 286ae2a656..1bea356a17 100644 --- a/mailpoet/lib/Config/TwigEnvironment.php +++ b/mailpoet/lib/Config/TwigEnvironment.php @@ -14,7 +14,7 @@ class TwigEnvironment extends Environment { * We need to produce the same class regardless of PHP_VERSION. Therefore, we * overwrite this method. **/ - public function getTemplateClass(string $name, int $index = null): string { + public function getTemplateClass(string $name, ?int $index = null): string { return $this->templateClassPrefix . \hash('sha256', $name) . (null === $index ? '' : '___' . $index); } } diff --git a/mailpoet/lib/Cron/DaemonHttpRunner.php b/mailpoet/lib/Cron/DaemonHttpRunner.php index b8ac5a2c76..8e58033564 100644 --- a/mailpoet/lib/Cron/DaemonHttpRunner.php +++ b/mailpoet/lib/Cron/DaemonHttpRunner.php @@ -27,7 +27,7 @@ class DaemonHttpRunner { private $wordpressTrigger; public function __construct( - Daemon $daemon = null, + ?Daemon $daemon = null, CronHelper $cronHelper, SettingsController $settings, WordPress $wordpressTrigger @@ -140,7 +140,7 @@ class DaemonHttpRunner { * * @return bool */ - private function shouldTerminateExecution(array $settingsDaemonData = null) { + private function shouldTerminateExecution(?array $settingsDaemonData = null) { return !$settingsDaemonData || $settingsDaemonData['token'] !== $this->token || (isset($settingsDaemonData['status']) && $settingsDaemonData['status'] !== CronHelper::DAEMON_STATUS_ACTIVE); diff --git a/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Links.php b/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Links.php index dc16899c9e..0675d5b1d8 100644 --- a/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Links.php +++ b/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Links.php @@ -64,7 +64,7 @@ class Links { return $this->newsletterLinks->save($links, $newsletter->getId(), $queue->getId()); } - public function getUnsubscribeUrl($queueId, SubscriberEntity $subscriber = null) { + public function getUnsubscribeUrl($queueId, ?SubscriberEntity $subscriber = null) { if ($this->trackingConfig->isEmailTrackingEnabled() && $subscriber) { $linkHash = $this->newsletterLinkRepository->findOneBy( [ diff --git a/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Mailer.php b/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Mailer.php index 71d22b3e19..a0fa9aa106 100644 --- a/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Mailer.php +++ b/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Mailer.php @@ -23,7 +23,7 @@ class Mailer { $this->mailer = $this->configureMailer(); } - public function configureMailer(NewsletterEntity $newsletter = null) { + public function configureMailer(?NewsletterEntity $newsletter = null) { $sender['address'] = ($newsletter && !empty($newsletter->getSenderAddress())) ? $newsletter->getSenderAddress() : null; diff --git a/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Newsletter.php b/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Newsletter.php index 9af577cc59..6f452a2b27 100644 --- a/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Newsletter.php +++ b/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Newsletter.php @@ -79,10 +79,10 @@ class Newsletter { private $personalizer; public function __construct( - WPFunctions $wp = null, - PostsTask $postsTask = null, - GATracking $gaTracking = null, - Emoji $emoji = null + ?WPFunctions $wp = null, + ?PostsTask $postsTask = null, + ?GATracking $gaTracking = null, + ?Emoji $emoji = null ) { $trackingConfig = ContainerWrapper::getInstance()->get(TrackingConfig::class); $this->trackingEnabled = $trackingConfig->isEmailTrackingEnabled(); diff --git a/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Shortcodes.php b/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Shortcodes.php index a0e4b96ce2..c17775c0f9 100644 --- a/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Shortcodes.php +++ b/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Shortcodes.php @@ -16,7 +16,7 @@ class Shortcodes { * @param SubscriberEntity|null $subscriber * @param SendingQueueEntity|null $queue */ - public static function process($content, $contentSource = null, NewsletterEntity $newsletter = null, SubscriberEntity $subscriber = null, SendingQueueEntity $queue = null) { + public static function process($content, $contentSource = null, ?NewsletterEntity $newsletter = null, ?SubscriberEntity $subscriber = null, ?SendingQueueEntity $queue = null) { /** @var NewsletterShortcodes $shortcodes */ $shortcodes = ContainerWrapper::getInstance()->get(NewsletterShortcodes::class); diff --git a/mailpoet/lib/Cron/Workers/StatsNotifications/Worker.php b/mailpoet/lib/Cron/Workers/StatsNotifications/Worker.php index cf8064b377..dc8beae4f4 100644 --- a/mailpoet/lib/Cron/Workers/StatsNotifications/Worker.php +++ b/mailpoet/lib/Cron/Workers/StatsNotifications/Worker.php @@ -138,7 +138,7 @@ class Worker { ]; } - private function prepareContext(NewsletterEntity $newsletter, SendingQueueEntity $sendingQueue, NewsletterLinkEntity $link = null) { + private function prepareContext(NewsletterEntity $newsletter, SendingQueueEntity $sendingQueue, ?NewsletterLinkEntity $link = null) { $statistics = $this->newsletterStatisticsRepository->getStatistics($newsletter); $clicked = ($statistics->getClickCount() * 100) / $statistics->getTotalSentCount(); $opened = ($statistics->getOpenCount() * 100) / $statistics->getTotalSentCount(); diff --git a/mailpoet/lib/DI/ContainerConfigurator.php b/mailpoet/lib/DI/ContainerConfigurator.php index 0fa11a7253..477e87cb53 100644 --- a/mailpoet/lib/DI/ContainerConfigurator.php +++ b/mailpoet/lib/DI/ContainerConfigurator.php @@ -699,7 +699,7 @@ class ContainerConfigurator implements IContainerConfigurator { return $container; } - public static function getPremiumService($id, ContainerInterface $container = null) { + public static function getPremiumService($id, ?ContainerInterface $container = null) { if ($container === null) { return null; } diff --git a/mailpoet/lib/DI/ContainerWrapper.php b/mailpoet/lib/DI/ContainerWrapper.php index 643cd50ffc..6550147bbd 100644 --- a/mailpoet/lib/DI/ContainerWrapper.php +++ b/mailpoet/lib/DI/ContainerWrapper.php @@ -20,7 +20,7 @@ class ContainerWrapper implements ContainerInterface { public function __construct( Container $freeContainer, - Container $premiumContainer = null + ?Container $premiumContainer = null ) { $this->freeContainer = $freeContainer; $this->premiumContainer = $premiumContainer; diff --git a/mailpoet/lib/Doctrine/Repository.php b/mailpoet/lib/Doctrine/Repository.php index 6fe09254f1..76a8b27463 100644 --- a/mailpoet/lib/Doctrine/Repository.php +++ b/mailpoet/lib/Doctrine/Repository.php @@ -41,7 +41,7 @@ abstract class Repository { * @param int|null $offset * @return T[] */ - public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) { + public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null) { return $this->doctrineRepository->findBy($criteria, $orderBy, $limit, $offset); } @@ -62,7 +62,7 @@ abstract class Repository { * @param array|null $orderBy * @return T|null */ - public function findOneBy(array $criteria, array $orderBy = null) { + public function findOneBy(array $criteria, ?array $orderBy = null) { return $this->doctrineRepository->findOneBy($criteria, $orderBy); } @@ -114,7 +114,7 @@ abstract class Repository { /** * @param callable(T): bool|null $filter */ - public function refreshAll(callable $filter = null): void { + public function refreshAll(?callable $filter = null): void { $entities = $this->getAllFromIdentityMap(); foreach ($entities as $entity) { if ($filter && !$filter($entity)) { @@ -142,7 +142,7 @@ abstract class Repository { /** * @param callable(T): bool|null $filter */ - public function detachAll(callable $filter = null): void { + public function detachAll(?callable $filter = null): void { $entities = $this->getAllFromIdentityMap(); foreach ($entities as $entity) { if ($filter && !$filter($entity)) { diff --git a/mailpoet/lib/Entities/FormEntity.php b/mailpoet/lib/Entities/FormEntity.php index 5e3e192fc4..bd8612ae23 100644 --- a/mailpoet/lib/Entities/FormEntity.php +++ b/mailpoet/lib/Entities/FormEntity.php @@ -174,7 +174,7 @@ class FormEntity { ]; } - public function getBlocksByTypes(array $types, array $blocks = null): array { + public function getBlocksByTypes(array $types, ?array $blocks = null): array { $found = []; if ($blocks === null) { $blocks = $this->getBody() ?? []; diff --git a/mailpoet/lib/Entities/NewsletterEntity.php b/mailpoet/lib/Entities/NewsletterEntity.php index c90fd24495..470d136878 100644 --- a/mailpoet/lib/Entities/NewsletterEntity.php +++ b/mailpoet/lib/Entities/NewsletterEntity.php @@ -474,7 +474,7 @@ class NewsletterEntity { * @return int[] */ public function getSegmentIds() { - return array_filter($this->newsletterSegments->map(function(NewsletterSegmentEntity $newsletterSegment = null) { + return array_filter($this->newsletterSegments->map(function(?NewsletterSegmentEntity $newsletterSegment = null) { if (!$newsletterSegment) return null; $segment = $newsletterSegment->getSegment(); return $segment ? (int)$segment->getId() : null; @@ -489,7 +489,7 @@ class NewsletterEntity { } public function getOption(string $name): ?NewsletterOptionEntity { - $option = $this->options->filter(function (NewsletterOptionEntity $option = null) use ($name): bool { + $option = $this->options->filter(function (?NewsletterOptionEntity $option = null) use ($name): bool { if (!$option) return false; return ($field = $option->getOptionField()) ? $field->getName() === $name : false; })->first(); diff --git a/mailpoet/lib/Entities/ScheduledTaskEntity.php b/mailpoet/lib/Entities/ScheduledTaskEntity.php index 7acfe3cb9c..d44e23b326 100644 --- a/mailpoet/lib/Entities/ScheduledTaskEntity.php +++ b/mailpoet/lib/Entities/ScheduledTaskEntity.php @@ -243,7 +243,7 @@ class ScheduledTaskEntity { public function getSubscribersByProcessed(int $processed): array { $criteria = Criteria::create() ->where(Criteria::expr()->eq('processed', $processed)); - $subscribers = $this->subscribers->matching($criteria)->map(function (ScheduledTaskSubscriberEntity $taskSubscriber = null): ?SubscriberEntity { + $subscribers = $this->subscribers->matching($criteria)->map(function (?ScheduledTaskSubscriberEntity $taskSubscriber = null): ?SubscriberEntity { if (!$taskSubscriber) return null; return $taskSubscriber->getSubscriber(); }); diff --git a/mailpoet/lib/Entities/ScheduledTaskSubscriberEntity.php b/mailpoet/lib/Entities/ScheduledTaskSubscriberEntity.php index 268b34a4e2..d9199619b1 100644 --- a/mailpoet/lib/Entities/ScheduledTaskSubscriberEntity.php +++ b/mailpoet/lib/Entities/ScheduledTaskSubscriberEntity.php @@ -61,7 +61,7 @@ class ScheduledTaskSubscriberEntity { SubscriberEntity $subscriber, int $processed = 0, int $failed = 0, - string $error = null + ?string $error = null ) { $this->task = $task; $this->subscriber = $subscriber; diff --git a/mailpoet/lib/Entities/StatisticsNewsletterEntity.php b/mailpoet/lib/Entities/StatisticsNewsletterEntity.php index 5dbd23a778..c8c80da81c 100644 --- a/mailpoet/lib/Entities/StatisticsNewsletterEntity.php +++ b/mailpoet/lib/Entities/StatisticsNewsletterEntity.php @@ -45,7 +45,7 @@ class StatisticsNewsletterEntity { NewsletterEntity $newsletter, SendingQueueEntity $queue, SubscriberEntity $subscriber, - \DateTimeInterface $sentAt = null + ?\DateTimeInterface $sentAt = null ) { $this->newsletter = $newsletter; $this->queue = $queue; diff --git a/mailpoet/lib/Entities/StatisticsUnsubscribeEntity.php b/mailpoet/lib/Entities/StatisticsUnsubscribeEntity.php index 99395ecd67..732e63b846 100644 --- a/mailpoet/lib/Entities/StatisticsUnsubscribeEntity.php +++ b/mailpoet/lib/Entities/StatisticsUnsubscribeEntity.php @@ -67,8 +67,8 @@ class StatisticsUnsubscribeEntity { private $method = self::METHOD_UNKNOWN; public function __construct( - NewsletterEntity $newsletter = null, - SendingQueueEntity $queue = null, + ?NewsletterEntity $newsletter = null, + ?SendingQueueEntity $queue = null, SubscriberEntity $subscriber ) { $this->newsletter = $newsletter; diff --git a/mailpoet/lib/Entities/SubscriberEntity.php b/mailpoet/lib/Entities/SubscriberEntity.php index 111c4f0db9..f3de869cef 100644 --- a/mailpoet/lib/Entities/SubscriberEntity.php +++ b/mailpoet/lib/Entities/SubscriberEntity.php @@ -504,7 +504,7 @@ class SubscriberEntity { /** * @return Collection */ public function getSegments() { - return $this->subscriberSegments->map(function (SubscriberSegmentEntity $subscriberSegment = null) { + return $this->subscriberSegments->map(function (?SubscriberSegmentEntity $subscriberSegment = null) { if (!$subscriberSegment) return null; return $subscriberSegment->getSegment(); })->filter(function (?SegmentEntity $segment = null) { @@ -635,7 +635,7 @@ class SubscriberEntity { /** @ORM\PreFlush */ public function cleanupSubscriberSegments(): void { // Delete old orphan SubscriberSegments to avoid errors on update - $this->subscriberSegments->map(function (SubscriberSegmentEntity $subscriberSegment = null) { + $this->subscriberSegments->map(function (?SubscriberSegmentEntity $subscriberSegment = null) { if (!$subscriberSegment) return null; if ($subscriberSegment->getSegment() === null) { $this->subscriberSegments->removeElement($subscriberSegment); diff --git a/mailpoet/lib/Form/Renderer.php b/mailpoet/lib/Form/Renderer.php index 2cea3028ad..a36253f07e 100644 --- a/mailpoet/lib/Form/Renderer.php +++ b/mailpoet/lib/Form/Renderer.php @@ -41,14 +41,14 @@ class Renderer { return $html; } - public function renderHTML(FormEntity $form = null): string { + public function renderHTML(?FormEntity $form = null): string { if (($form instanceof FormEntity) && !empty($form->getBody()) && is_array($form->getSettings())) { return $this->renderBlocks($form->getBody(), $form->getSettings() ?? [], $form->getId()); } return ''; } - public function getCustomStyles(FormEntity $form = null): string { + public function getCustomStyles(?FormEntity $form = null): string { if (($form instanceof FormEntity) && (strlen(trim($form->getStyles() ?? '')) > 0)) { return strip_tags($form->getStyles() ?? ''); } else { diff --git a/mailpoet/lib/Listing/ListingDefinition.php b/mailpoet/lib/Listing/ListingDefinition.php index 0cf79234e1..cad9212fd1 100644 --- a/mailpoet/lib/Listing/ListingDefinition.php +++ b/mailpoet/lib/Listing/ListingDefinition.php @@ -31,9 +31,9 @@ class ListingDefinition { private $selection; public function __construct( - string $group = null, + ?string $group = null, array $filters = [], - string $search = null, + ?string $search = null, array $parameters = [], string $sortBy = 'created_at', string $sortOrder = 'desc', diff --git a/mailpoet/lib/Logging/LogRepository.php b/mailpoet/lib/Logging/LogRepository.php index f904ea4362..1404b225b0 100644 --- a/mailpoet/lib/Logging/LogRepository.php +++ b/mailpoet/lib/Logging/LogRepository.php @@ -50,11 +50,11 @@ class LogRepository extends Repository { * @return LogEntity[] */ public function getLogs( - \DateTimeInterface $dateFrom = null, - \DateTimeInterface $dateTo = null, - string $search = null, - string $offset = null, - string $limit = null + ?\DateTimeInterface $dateFrom = null, + ?\DateTimeInterface $dateTo = null, + ?string $search = null, + ?string $offset = null, + ?string $limit = null ): array { $query = $this->doctrineRepository->createQueryBuilder('l') ->select('l'); diff --git a/mailpoet/lib/Mailer/MailerFactory.php b/mailpoet/lib/Mailer/MailerFactory.php index 87b77927a0..cabd1872b3 100644 --- a/mailpoet/lib/Mailer/MailerFactory.php +++ b/mailpoet/lib/Mailer/MailerFactory.php @@ -45,7 +45,7 @@ class MailerFactory { return $this->defaultMailer; } - public function buildMailer(array $mailerConfig = null, array $sender = null, array $replyTo = null, string $returnPath = null): Mailer { + public function buildMailer(?array $mailerConfig = null, ?array $sender = null, ?array $replyTo = null, ?string $returnPath = null): Mailer { $sender = $this->getSenderNameAndAddress($sender); $replyTo = $this->getReplyToNameAndAddress($sender, $replyTo); $mailerConfig = $mailerConfig ?? $this->getMailerConfig(); @@ -120,7 +120,7 @@ class MailerFactory { return $config; } - private function getSenderNameAndAddress(array $sender = null): array { + private function getSenderNameAndAddress(?array $sender = null): array { if (empty($sender)) { $sender = $this->settings->get('sender', []); if (empty($sender['address'])) throw new InvalidStateException(__('Sender name and email are not configured.', 'mailpoet')); @@ -133,7 +133,7 @@ class MailerFactory { ]; } - private function getReplyToNameAndAddress(array $sender, array $replyTo = null): array { + private function getReplyToNameAndAddress(array $sender, ?array $replyTo = null): array { if (!$replyTo) { $replyTo = $this->settings->get('reply_to'); $replyTo['name'] = (!empty($replyTo['name'])) ? diff --git a/mailpoet/lib/Mailer/MailerLog.php b/mailpoet/lib/Mailer/MailerLog.php index 69d200c2ca..610e692afc 100644 --- a/mailpoet/lib/Mailer/MailerLog.php +++ b/mailpoet/lib/Mailer/MailerLog.php @@ -33,7 +33,7 @@ class MailerLog { * @param MailerLogData|null $mailerLog * @return MailerLogData */ - public static function getMailerLog(array $mailerLog = null): array { + public static function getMailerLog(?array $mailerLog = null): array { if ($mailerLog) return $mailerLog; $settings = SettingsController::getInstance(); $mailerLog = $settings->get(self::SETTING_NAME); @@ -90,7 +90,7 @@ class MailerLog { * @return null * @throws \Exception */ - public static function enforceExecutionRequirements(array $mailerLog = null) { + public static function enforceExecutionRequirements(?array $mailerLog = null) { $mailerLog = self::getMailerLog($mailerLog); if ($mailerLog['retry_attempt'] === self::RETRY_ATTEMPTS_LIMIT) { $mailerLog = self::pauseSending($mailerLog); @@ -162,9 +162,9 @@ class MailerLog { public static function processError( string $operation, string $errorMessage, - string $errorCode = null, + ?string $errorCode = null, bool $pauseSending = false, - int $throttledBatchSize = null + ?int $throttledBatchSize = null ) { $mailerLog = self::getMailerLog(); if (!isset($throttledBatchSize) || $throttledBatchSize === 1) { @@ -232,7 +232,7 @@ class MailerLog { array $mailerLog, string $operation, string $errorMessage, - string $errorCode = null + ?string $errorCode = null ): array { $mailerLog['error'] = [ 'operation' => $operation, @@ -248,7 +248,7 @@ class MailerLog { * @param MailerLogData|null $mailerLog * @return MailerLogError|null */ - public static function getError(array $mailerLog = null): ?array { + public static function getError(?array $mailerLog = null): ?array { $mailerLog = self::getMailerLog($mailerLog); return isset($mailerLog['error']) ? $mailerLog['error'] : null; } @@ -300,7 +300,7 @@ class MailerLog { * @param MailerLogData|null $mailerLog * @return bool */ - public static function isSendingLimitReached(array $mailerLog = null): bool { + public static function isSendingLimitReached(?array $mailerLog = null): bool { $settings = SettingsController::getInstance(); $mailerConfig = $settings->get(Mailer::MAILER_CONFIG_SETTING_NAME); // do not enforce sending limit for MailPoet's sending method @@ -322,7 +322,7 @@ class MailerLog { * @param MailerLogData|null $mailerLog * @return int */ - public static function sentSince(int $sinceSeconds = null, array $mailerLog = null): int { + public static function sentSince(?int $sinceSeconds = null, ?array $mailerLog = null): int { if ($sinceSeconds === null) { $settings = SettingsController::getInstance(); @@ -353,7 +353,7 @@ class MailerLog { * @param MailerLogData|null $mailerLog * @return MailerLogData */ - private static function removeOutdatedSentInformationFromMailerlog(array $mailerLog = null): array { + private static function removeOutdatedSentInformationFromMailerlog(?array $mailerLog = null): array { $settings = SettingsController::getInstance(); $mailerConfig = $settings->get(Mailer::MAILER_CONFIG_SETTING_NAME); @@ -375,7 +375,7 @@ class MailerLog { * @param int|null $timestamp * @return string */ - private static function sentEntriesDate(int $timestamp = null): string { + private static function sentEntriesDate(?int $timestamp = null): string { return date('Y-m-d H:i:s', $timestamp ?? time()); } @@ -384,7 +384,7 @@ class MailerLog { * @param MailerLogData|null $mailerLog * @return bool */ - public static function isSendingPaused(array $mailerLog = null): bool { + public static function isSendingPaused(?array $mailerLog = null): bool { $mailerLog = self::getMailerLog($mailerLog); return $mailerLog['status'] === self::STATUS_PAUSED; } @@ -393,7 +393,7 @@ class MailerLog { * @param MailerLogData|null $mailerLog * @return bool */ - public static function isSendingWaitingForRetry(array $mailerLog = null): bool { + public static function isSendingWaitingForRetry(?array $mailerLog = null): bool { $mailerLog = self::getMailerLog($mailerLog); $retryAt = $mailerLog['retry_at'] ?? null; return $retryAt && (time() <= $retryAt); diff --git a/mailpoet/lib/Mailer/MetaInfo.php b/mailpoet/lib/Mailer/MetaInfo.php index beea55ad24..52930fc3f5 100644 --- a/mailpoet/lib/Mailer/MetaInfo.php +++ b/mailpoet/lib/Mailer/MetaInfo.php @@ -18,7 +18,7 @@ class MetaInfo { return $this->makeMetaInfo('email_stats_notification', 'unknown', 'administrator'); } - public function getWordPressTransactionalMetaInfo(SubscriberEntity $subscriber = null) { + public function getWordPressTransactionalMetaInfo(?SubscriberEntity $subscriber = null) { return $this->makeMetaInfo( 'transactional', $subscriber ? $subscriber->getStatus() : 'unknown', diff --git a/mailpoet/lib/Mailer/Methods/Common/BlacklistCheck.php b/mailpoet/lib/Mailer/Methods/Common/BlacklistCheck.php index 3b004c5430..043809b271 100644 --- a/mailpoet/lib/Mailer/Methods/Common/BlacklistCheck.php +++ b/mailpoet/lib/Mailer/Methods/Common/BlacklistCheck.php @@ -9,7 +9,7 @@ class BlacklistCheck { private $blacklist; public function __construct( - Blacklist $blacklist = null + ?Blacklist $blacklist = null ) { if (is_null($blacklist)) { $blacklist = new Blacklist(); diff --git a/mailpoet/lib/Migrator/Migrator.php b/mailpoet/lib/Migrator/Migrator.php index a721f6a270..a45310a43c 100644 --- a/mailpoet/lib/Migrator/Migrator.php +++ b/mailpoet/lib/Migrator/Migrator.php @@ -30,7 +30,7 @@ class Migrator { $this->store = $store; } - public function run(Logger $logger = null): void { + public function run(?Logger $logger = null): void { $this->store->ensureMigrationsTable(); $migrations = $this->getStatus(); diff --git a/mailpoet/lib/Newsletter/Editor/PostContentManager.php b/mailpoet/lib/Newsletter/Editor/PostContentManager.php index 84a62e2895..87ebd215dc 100644 --- a/mailpoet/lib/Newsletter/Editor/PostContentManager.php +++ b/mailpoet/lib/Newsletter/Editor/PostContentManager.php @@ -18,7 +18,7 @@ class PostContentManager { private $wp; public function __construct( - WooCommerceHelper $woocommerceHelper = null + ?WooCommerceHelper $woocommerceHelper = null ) { $this->wp = new WPFunctions; $this->maxExcerptLength = $this->wp->applyFilters('mailpoet_newsletter_post_excerpt_length', $this->maxExcerptLength); diff --git a/mailpoet/lib/Newsletter/Editor/PostTransformer.php b/mailpoet/lib/Newsletter/Editor/PostTransformer.php index 2434bd1ce9..1fa236d678 100644 --- a/mailpoet/lib/Newsletter/Editor/PostTransformer.php +++ b/mailpoet/lib/Newsletter/Editor/PostTransformer.php @@ -15,7 +15,7 @@ class PostTransformer { public function __construct( $args, - PostTransformerContentsExtractor $extractor = null + ?PostTransformerContentsExtractor $extractor = null ) { $this->args = $args; $this->withLayout = isset($args['withLayout']) ? (bool)filter_var($args['withLayout'], FILTER_VALIDATE_BOOLEAN) : false; diff --git a/mailpoet/lib/Newsletter/Listing/NewsletterListingRepository.php b/mailpoet/lib/Newsletter/Listing/NewsletterListingRepository.php index 365c05cf62..89200bb5db 100644 --- a/mailpoet/lib/Newsletter/Listing/NewsletterListingRepository.php +++ b/mailpoet/lib/Newsletter/Listing/NewsletterListingRepository.php @@ -260,7 +260,7 @@ class NewsletterListingRepository extends ListingRepository { $queryBuilder->addOrderBy("n.$sortBy", $sortOrder); } - private function applyType(QueryBuilder $queryBuilder, string $type, string $group = null) { + private function applyType(QueryBuilder $queryBuilder, string $type, ?string $group = null) { if (!in_array($type, self::$supportedTypes)) { return; } diff --git a/mailpoet/lib/Newsletter/Renderer/Blocks/AbandonedCartContent.php b/mailpoet/lib/Newsletter/Renderer/Blocks/AbandonedCartContent.php index 39de335307..3471983855 100644 --- a/mailpoet/lib/Newsletter/Renderer/Blocks/AbandonedCartContent.php +++ b/mailpoet/lib/Newsletter/Renderer/Blocks/AbandonedCartContent.php @@ -22,7 +22,7 @@ class AbandonedCartContent { NewsletterEntity $newsletter, array $args, bool $preview = false, - SendingQueueEntity $sendingQueue = null + ?SendingQueueEntity $sendingQueue = null ): array { if ( !in_array( @@ -38,12 +38,12 @@ class AbandonedCartContent { // Do not display the block if not an automatic email return []; } - $groupOption = $newsletter->getOptions()->filter(function (NewsletterOptionEntity $newsletterOption = null) { + $groupOption = $newsletter->getOptions()->filter(function (?NewsletterOptionEntity $newsletterOption = null) { if (!$newsletterOption) return false; $optionField = $newsletterOption->getOptionField(); return $optionField && $optionField->getName() === 'group'; })->first(); - $eventOption = $newsletter->getOptions()->filter(function (NewsletterOptionEntity $newsletterOption = null) { + $eventOption = $newsletter->getOptions()->filter(function (?NewsletterOptionEntity $newsletterOption = null) { if (!$newsletterOption) return false; $optionField = $newsletterOption->getOptionField(); return $optionField && $optionField->getName() === 'event'; diff --git a/mailpoet/lib/Newsletter/Renderer/Preprocessor.php b/mailpoet/lib/Newsletter/Renderer/Preprocessor.php index e23b68d22f..c5b6c8242b 100644 --- a/mailpoet/lib/Newsletter/Renderer/Preprocessor.php +++ b/mailpoet/lib/Newsletter/Renderer/Preprocessor.php @@ -48,7 +48,7 @@ class Preprocessor { * @param NewsletterEntity $newsletter * @return array */ - public function process(NewsletterEntity $newsletter, $content, bool $preview = false, SendingQueueEntity $sendingQueue = null) { + public function process(NewsletterEntity $newsletter, $content, bool $preview = false, ?SendingQueueEntity $sendingQueue = null) { if (!array_key_exists('blocks', $content)) { return $content; } @@ -74,7 +74,7 @@ class Preprocessor { return $containerBlocks; } - public function processBlock(NewsletterEntity $newsletter, array $block, bool $preview = false, SendingQueueEntity $sendingQueue = null): array { + public function processBlock(NewsletterEntity $newsletter, array $block, bool $preview = false, ?SendingQueueEntity $sendingQueue = null): array { switch ($block['type']) { case 'abandonedCartContent': return $this->abandonedCartContent->render($newsletter, $block, $preview, $sendingQueue); diff --git a/mailpoet/lib/Newsletter/Renderer/Renderer.php b/mailpoet/lib/Newsletter/Renderer/Renderer.php index b1ed530969..d7b051867f 100644 --- a/mailpoet/lib/Newsletter/Renderer/Renderer.php +++ b/mailpoet/lib/Newsletter/Renderer/Renderer.php @@ -68,7 +68,7 @@ class Renderer { $this->capabilitiesManager = $capabilitiesManager; } - public function render(NewsletterEntity $newsletter, SendingQueueEntity $sendingQueue = null, $type = false) { + public function render(NewsletterEntity $newsletter, ?SendingQueueEntity $sendingQueue = null, $type = false) { return $this->_render($newsletter, $sendingQueue, $type); } @@ -76,7 +76,7 @@ class Renderer { return $this->_render($newsletter, null, $type, true, $subject); } - private function _render(NewsletterEntity $newsletter, SendingQueueEntity $sendingQueue = null, $type = false, $preview = false, $subject = null) { + private function _render(NewsletterEntity $newsletter, ?SendingQueueEntity $sendingQueue = null, $type = false, $preview = false, $subject = null) { $language = $this->wp->getBloginfo('language'); $metaRobots = $preview ? '' : ''; $subject = $subject ?: $newsletter->getSubject(); diff --git a/mailpoet/lib/Newsletter/Shortcodes/Categories/CategoryInterface.php b/mailpoet/lib/Newsletter/Shortcodes/Categories/CategoryInterface.php index 620b0e4729..d1d4f5633b 100644 --- a/mailpoet/lib/Newsletter/Shortcodes/Categories/CategoryInterface.php +++ b/mailpoet/lib/Newsletter/Shortcodes/Categories/CategoryInterface.php @@ -9,9 +9,9 @@ use MailPoet\Entities\SubscriberEntity; interface CategoryInterface { public function process( array $shortcodeDetails, - NewsletterEntity $newsletter = null, - SubscriberEntity $subscriber = null, - SendingQueueEntity $queue = null, + ?NewsletterEntity $newsletter = null, + ?SubscriberEntity $subscriber = null, + ?SendingQueueEntity $queue = null, string $content = '', bool $wpUserPreview = false ): ?string; diff --git a/mailpoet/lib/Newsletter/Shortcodes/Categories/Date.php b/mailpoet/lib/Newsletter/Shortcodes/Categories/Date.php index 674e965186..e53eefe4a1 100644 --- a/mailpoet/lib/Newsletter/Shortcodes/Categories/Date.php +++ b/mailpoet/lib/Newsletter/Shortcodes/Categories/Date.php @@ -10,9 +10,9 @@ use MailPoet\WP\Functions as WPFunctions; class Date implements CategoryInterface { public function process( array $shortcodeDetails, - NewsletterEntity $newsletter = null, - SubscriberEntity $subscriber = null, - SendingQueueEntity $queue = null, + ?NewsletterEntity $newsletter = null, + ?SubscriberEntity $subscriber = null, + ?SendingQueueEntity $queue = null, string $content = '', bool $wpUserPreview = false ): ?string { diff --git a/mailpoet/lib/Newsletter/Shortcodes/Categories/Link.php b/mailpoet/lib/Newsletter/Shortcodes/Categories/Link.php index 150c9c9d43..18b05a84a7 100644 --- a/mailpoet/lib/Newsletter/Shortcodes/Categories/Link.php +++ b/mailpoet/lib/Newsletter/Shortcodes/Categories/Link.php @@ -40,9 +40,9 @@ class Link implements CategoryInterface { public function process( array $shortcodeDetails, - NewsletterEntity $newsletter = null, - SubscriberEntity $subscriber = null, - SendingQueueEntity $queue = null, + ?NewsletterEntity $newsletter = null, + ?SubscriberEntity $subscriber = null, + ?SendingQueueEntity $queue = null, string $content = '', bool $wpUserPreview = false ): ?string { @@ -119,9 +119,9 @@ class Link implements CategoryInterface { public function processShortcodeAction( $shortcodeAction, - NewsletterEntity $newsletter = null, - SubscriberEntity $subscriber = null, - SendingQueueEntity $queue = null, + ?NewsletterEntity $newsletter = null, + ?SubscriberEntity $subscriber = null, + ?SendingQueueEntity $queue = null, $wpUserPreview = false ): ?string { $subscriptionUrlFactory = SubscriptionUrlFactory::getInstance(); diff --git a/mailpoet/lib/Newsletter/Shortcodes/Categories/Newsletter.php b/mailpoet/lib/Newsletter/Shortcodes/Categories/Newsletter.php index fe4b07ede3..957c0351f3 100644 --- a/mailpoet/lib/Newsletter/Shortcodes/Categories/Newsletter.php +++ b/mailpoet/lib/Newsletter/Shortcodes/Categories/Newsletter.php @@ -25,9 +25,9 @@ class Newsletter implements CategoryInterface { public function process( array $shortcodeDetails, - NewsletterEntity $newsletter = null, - SubscriberEntity $subscriber = null, - SendingQueueEntity $queue = null, + ?NewsletterEntity $newsletter = null, + ?SubscriberEntity $subscriber = null, + ?SendingQueueEntity $queue = null, string $content = '', bool $wpUserPreview = false ): ?string { diff --git a/mailpoet/lib/Newsletter/Shortcodes/Categories/Site.php b/mailpoet/lib/Newsletter/Shortcodes/Categories/Site.php index 9996518b43..39042d0f88 100644 --- a/mailpoet/lib/Newsletter/Shortcodes/Categories/Site.php +++ b/mailpoet/lib/Newsletter/Shortcodes/Categories/Site.php @@ -19,9 +19,9 @@ class Site implements CategoryInterface { public function process( array $shortcodeDetails, - NewsletterEntity $newsletter = null, - SubscriberEntity $subscriber = null, - SendingQueueEntity $queue = null, + ?NewsletterEntity $newsletter = null, + ?SubscriberEntity $subscriber = null, + ?SendingQueueEntity $queue = null, string $content = '', bool $wpUserPreview = false ): ?string { diff --git a/mailpoet/lib/Newsletter/Shortcodes/Categories/Subscriber.php b/mailpoet/lib/Newsletter/Shortcodes/Categories/Subscriber.php index e87e245c78..17dfa30e06 100644 --- a/mailpoet/lib/Newsletter/Shortcodes/Categories/Subscriber.php +++ b/mailpoet/lib/Newsletter/Shortcodes/Categories/Subscriber.php @@ -28,9 +28,9 @@ class Subscriber implements CategoryInterface { public function process( array $shortcodeDetails, - NewsletterEntity $newsletter = null, - SubscriberEntity $subscriber = null, - SendingQueueEntity $queue = null, + ?NewsletterEntity $newsletter = null, + ?SubscriberEntity $subscriber = null, + ?SendingQueueEntity $queue = null, string $content = '', bool $wpUserPreview = false ): ?string { diff --git a/mailpoet/lib/Newsletter/Shortcodes/Shortcodes.php b/mailpoet/lib/Newsletter/Shortcodes/Shortcodes.php index c085cd0c63..bc48d270e1 100644 --- a/mailpoet/lib/Newsletter/Shortcodes/Shortcodes.php +++ b/mailpoet/lib/Newsletter/Shortcodes/Shortcodes.php @@ -60,15 +60,15 @@ class Shortcodes { $this->wp = $wp; } - public function setNewsletter(NewsletterEntity $newsletter = null): void { + public function setNewsletter(?NewsletterEntity $newsletter = null): void { $this->newsletter = $newsletter; } - public function setSubscriber(SubscriberEntity $subscriber = null): void { + public function setSubscriber(?SubscriberEntity $subscriber = null): void { $this->subscriber = $subscriber; } - public function setQueue(SendingQueueEntity $queue = null): void { + public function setQueue(?SendingQueueEntity $queue = null): void { $this->queue = $queue; } diff --git a/mailpoet/lib/Newsletter/Statistics/NewsletterStatisticsRepository.php b/mailpoet/lib/Newsletter/Statistics/NewsletterStatisticsRepository.php index 65a43d0575..8bf73c9eb9 100644 --- a/mailpoet/lib/Newsletter/Statistics/NewsletterStatisticsRepository.php +++ b/mailpoet/lib/Newsletter/Statistics/NewsletterStatisticsRepository.php @@ -65,8 +65,8 @@ class NewsletterStatisticsRepository extends Repository { */ public function getBatchStatistics( array $newsletters, - \DateTimeImmutable $from = null, - \DateTimeImmutable $to = null, + ?\DateTimeImmutable $from = null, + ?\DateTimeImmutable $to = null, array $include = [ 'totals', StatisticsClickEntity::class, @@ -133,8 +133,8 @@ class NewsletterStatisticsRepository extends Repository { */ public function getAllForSubscriber( SubscriberEntity $subscriber, - int $limit = null, - int $offset = null + ?int $limit = null, + ?int $offset = null ): array { return $this->entityManager->createQueryBuilder() ->select('IDENTITY(statistics.newsletter) AS newsletter_id') @@ -192,7 +192,7 @@ class NewsletterStatisticsRepository extends Repository { } } - private function getTotalSentCounts(array $newsletters, \DateTimeImmutable $from = null, \DateTimeImmutable $to = null): array { + private function getTotalSentCounts(array $newsletters, ?\DateTimeImmutable $from = null, ?\DateTimeImmutable $to = null): array { $query = $this->doctrineRepository ->createQueryBuilder('n') ->select('n.id, SUM(q.countProcessed) AS cnt') @@ -226,7 +226,7 @@ class NewsletterStatisticsRepository extends Repository { return $counts; } - private function getStatisticCounts(string $statisticsEntityName, array $newsletters, \DateTimeImmutable $from = null, \DateTimeImmutable $to = null): array { + private function getStatisticCounts(string $statisticsEntityName, array $newsletters, ?\DateTimeImmutable $from = null, ?\DateTimeImmutable $to = null): array { $qb = $this->getStatisticsQuery($statisticsEntityName, $newsletters); if ( $statisticsEntityName === StatisticsClickEntity::class @@ -267,7 +267,7 @@ class NewsletterStatisticsRepository extends Repository { ->setParameter('newsletters', $newsletters); } - private function getWooCommerceRevenues(array $newsletters, \DateTimeImmutable $from = null, \DateTimeImmutable $to = null) { + private function getWooCommerceRevenues(array $newsletters, ?\DateTimeImmutable $from = null, ?\DateTimeImmutable $to = null) { if (!$this->wcHelper->isWooCommerceActive()) { return null; } diff --git a/mailpoet/lib/Newsletter/ViewInBrowser/ViewInBrowserRenderer.php b/mailpoet/lib/Newsletter/ViewInBrowser/ViewInBrowserRenderer.php index 5218c82661..ac2f9ca110 100644 --- a/mailpoet/lib/Newsletter/ViewInBrowser/ViewInBrowserRenderer.php +++ b/mailpoet/lib/Newsletter/ViewInBrowser/ViewInBrowserRenderer.php @@ -49,8 +49,8 @@ class ViewInBrowserRenderer { public function render( bool $isPreview, NewsletterEntity $newsletter, - SubscriberEntity $subscriber = null, - SendingQueueEntity $queue = null + ?SubscriberEntity $subscriber = null, + ?SendingQueueEntity $queue = null ) { $wpUserPreview = $isPreview; $isTrackingEnabled = $this->trackingConfig->isEmailTrackingEnabled(); diff --git a/mailpoet/lib/Segments/DynamicSegments/Filters/EmailAction.php b/mailpoet/lib/Segments/DynamicSegments/Filters/EmailAction.php index 96798c7d18..1bb63cba3c 100644 --- a/mailpoet/lib/Segments/DynamicSegments/Filters/EmailAction.php +++ b/mailpoet/lib/Segments/DynamicSegments/Filters/EmailAction.php @@ -191,7 +191,7 @@ class EmailAction implements Filter { return $queryBuilder; } - private function createNotStatsJoinCondition(string $parameterSuffix, array $linkIds = null): string { + private function createNotStatsJoinCondition(string $parameterSuffix, ?array $linkIds = null): string { $clause = "statssent.subscriber_id = stats.subscriber_id AND stats.newsletter_id = :newsletter" . $parameterSuffix; if ($linkIds) { $clause .= ' AND stats.link_id IN (:links' . $parameterSuffix . ')'; diff --git a/mailpoet/lib/Segments/DynamicSegments/Filters/WooFilterHelper.php b/mailpoet/lib/Segments/DynamicSegments/Filters/WooFilterHelper.php index 41e033c261..a32e438ae6 100644 --- a/mailpoet/lib/Segments/DynamicSegments/Filters/WooFilterHelper.php +++ b/mailpoet/lib/Segments/DynamicSegments/Filters/WooFilterHelper.php @@ -73,7 +73,7 @@ class WooFilterHelper { * @param array|null $allowedStatuses * @return string - The alias of the joined order stats table */ - public function applyOrderStatusFilter(QueryBuilder $queryBuilder, array $allowedStatuses = null): string { + public function applyOrderStatusFilter(QueryBuilder $queryBuilder, ?array $allowedStatuses = null): string { if (is_null($allowedStatuses)) { $allowedStatuses = $this->defaultIncludedStatuses(); } diff --git a/mailpoet/lib/Segments/SegmentSubscribersRepository.php b/mailpoet/lib/Segments/SegmentSubscribersRepository.php index f1fec70436..75212b85cb 100644 --- a/mailpoet/lib/Segments/SegmentSubscribersRepository.php +++ b/mailpoet/lib/Segments/SegmentSubscribersRepository.php @@ -38,7 +38,7 @@ class SegmentSubscribersRepository { $this->segmentsRepository = $segmentsRepository; } - public function findSubscribersIdsInSegment(int $segmentId, array $candidateIds = null): array { + public function findSubscribersIdsInSegment(int $segmentId, ?array $candidateIds = null): array { return $this->loadSubscriberIdsInSegment($segmentId, $candidateIds); } @@ -46,13 +46,13 @@ class SegmentSubscribersRepository { return $this->loadSubscriberIdsInSegment($segmentId); } - public function getSubscribersCount(int $segmentId, string $status = null): int { + public function getSubscribersCount(int $segmentId, ?string $status = null): int { $segment = $this->getSegment($segmentId); $result = $this->getSubscribersStatisticsCount($segment); return (int)$result[$status ?: 'all']; } - public function getSubscribersCountBySegmentIds(array $segmentIds, string $status = null, ?int $filterSegmentId = null): int { + public function getSubscribersCountBySegmentIds(array $segmentIds, ?string $status = null, ?int $filterSegmentId = null): int { $segmentRepository = $this->entityManager->getRepository(SegmentEntity::class); $segments = $segmentRepository->findBy(['id' => $segmentIds]); $subscribersTable = $this->entityManager->getClassMetadata(SubscriberEntity::class)->getTableName(); @@ -369,7 +369,7 @@ class SegmentSubscribersRepository { ->setParameter('statusSubscribed', SubscriberEntity::STATUS_SUBSCRIBED); } - private function loadSubscriberIdsInSegment(int $segmentId, array $candidateIds = null): array { + private function loadSubscriberIdsInSegment(int $segmentId, ?array $candidateIds = null): array { $segment = $this->getSegment($segmentId); $subscribersTable = $this->entityManager->getClassMetadata(SubscriberEntity::class)->getTableName(); $queryBuilder = $this->entityManager @@ -397,7 +397,7 @@ class SegmentSubscribersRepository { private function filterSubscribersInStaticSegment( QueryBuilder $queryBuilder, SegmentEntity $segment, - string $status = null + ?string $status = null ): QueryBuilder { $subscribersSegmentsTable = $this->entityManager->getClassMetadata(SubscriberSegmentEntity::class)->getTableName(); $subscribersTable = $this->entityManager->getClassMetadata(SubscriberEntity::class)->getTableName(); @@ -420,7 +420,7 @@ class SegmentSubscribersRepository { private function filterSubscribersInDynamicSegment( QueryBuilder $queryBuilder, SegmentEntity $segment, - string $status = null + ?string $status = null ): QueryBuilder { $filters = []; $dynamicFilters = $segment->getDynamicFilters(); diff --git a/mailpoet/lib/Segments/SegmentsSimpleListRepository.php b/mailpoet/lib/Segments/SegmentsSimpleListRepository.php index f5511158e9..a3f794372f 100644 --- a/mailpoet/lib/Segments/SegmentsSimpleListRepository.php +++ b/mailpoet/lib/Segments/SegmentsSimpleListRepository.php @@ -65,7 +65,7 @@ class SegmentsSimpleListRepository { */ private function getList( array $segmentTypes = [], - string $subscriberGlobalStatus = null + ?string $subscriberGlobalStatus = null ): array { $segmentsTable = $this->entityManager->getClassMetadata(SegmentEntity::class)->getTableName(); diff --git a/mailpoet/lib/Services/AuthorizedEmailsController.php b/mailpoet/lib/Services/AuthorizedEmailsController.php index 71e10891cc..95ba2b475b 100644 --- a/mailpoet/lib/Services/AuthorizedEmailsController.php +++ b/mailpoet/lib/Services/AuthorizedEmailsController.php @@ -161,7 +161,7 @@ class AuthorizedEmailsController { return null; } - public function onNewsletterSenderAddressUpdate(NewsletterEntity $newsletter, string $oldSenderAddress = null) { + public function onNewsletterSenderAddressUpdate(NewsletterEntity $newsletter, ?string $oldSenderAddress = null) { if ($newsletter->getSenderAddress() === $oldSenderAddress) { return; } @@ -243,7 +243,7 @@ class AuthorizedEmailsController { /** * @param array|null $error */ - private function updateMailerLog(array $error = null) { + private function updateMailerLog(?array $error = null) { if ($error) { return; } diff --git a/mailpoet/lib/Services/Bridge.php b/mailpoet/lib/Services/Bridge.php index de3571ea76..632e96fadb 100644 --- a/mailpoet/lib/Services/Bridge.php +++ b/mailpoet/lib/Services/Bridge.php @@ -52,7 +52,7 @@ class Bridge { private $settings; public function __construct( - SettingsController $settingsController = null + ?SettingsController $settingsController = null ) { if ($settingsController === null) { $settingsController = SettingsController::getInstance(); diff --git a/mailpoet/lib/Settings/TrackingConfig.php b/mailpoet/lib/Settings/TrackingConfig.php index 81e80bf0f3..d5d9dd2526 100644 --- a/mailpoet/lib/Settings/TrackingConfig.php +++ b/mailpoet/lib/Settings/TrackingConfig.php @@ -19,22 +19,22 @@ class TrackingConfig { $this->settings = $settings; } - public function isEmailTrackingEnabled(string $level = null): bool { + public function isEmailTrackingEnabled(?string $level = null): bool { $level = $level ?? $this->settings->get('tracking.level', self::LEVEL_FULL); return in_array($level, [self::LEVEL_PARTIAL, self::LEVEL_FULL], true); } - public function isCookieTrackingEnabled(string $level = null): bool { + public function isCookieTrackingEnabled(?string $level = null): bool { $level = $level ?? $this->settings->get('tracking.level', self::LEVEL_FULL); return $level === self::LEVEL_FULL; } - public function areOpensMerged(string $opens = null): bool { + public function areOpensMerged(?string $opens = null): bool { $opens = $opens ?? $this->settings->get('tracking.opens', self::OPENS_MERGED); return $opens !== self::OPENS_SEPARATED; } - public function areOpensSeparated(string $opens = null): bool { + public function areOpensSeparated(?string $opens = null): bool { return !$this->areOpensMerged($opens); } diff --git a/mailpoet/lib/Statistics/Track/Unsubscribes.php b/mailpoet/lib/Statistics/Track/Unsubscribes.php index a71b94ecc2..dff9a85ca3 100644 --- a/mailpoet/lib/Statistics/Track/Unsubscribes.php +++ b/mailpoet/lib/Statistics/Track/Unsubscribes.php @@ -35,8 +35,8 @@ class Unsubscribes { public function track( int $subscriberId, string $source, - int $queueId = null, - string $meta = null, + ?int $queueId = null, + ?string $meta = null, string $method = StatisticsUnsubscribeEntity::METHOD_UNKNOWN ) { $queue = null; diff --git a/mailpoet/lib/Subscribers/RequiredCustomFieldValidator.php b/mailpoet/lib/Subscribers/RequiredCustomFieldValidator.php index 4988024056..4893ff2d0a 100644 --- a/mailpoet/lib/Subscribers/RequiredCustomFieldValidator.php +++ b/mailpoet/lib/Subscribers/RequiredCustomFieldValidator.php @@ -22,7 +22,7 @@ class RequiredCustomFieldValidator { * * @throws Exception */ - public function validate(array $data, FormEntity $form = null) { + public function validate(array $data, ?FormEntity $form = null) { $allCustomFields = $this->getCustomFields($form); foreach ($allCustomFields as $customFieldId => $customFieldName) { if ($this->isCustomFieldMissing($customFieldId, $data)) { @@ -47,7 +47,7 @@ class RequiredCustomFieldValidator { return false; } - private function getCustomFields(FormEntity $form = null): array { + private function getCustomFields(?FormEntity $form = null): array { $result = []; if ($form) { diff --git a/mailpoet/lib/Subscription/Blacklist.php b/mailpoet/lib/Subscription/Blacklist.php index 99395e3709..2f36f266f8 100644 --- a/mailpoet/lib/Subscription/Blacklist.php +++ b/mailpoet/lib/Subscription/Blacklist.php @@ -20,8 +20,8 @@ class Blacklist { ]; public function __construct( - array $blacklistedEmails = null, - array $blacklistedDomains = null + ?array $blacklistedEmails = null, + ?array $blacklistedDomains = null ) { if ($blacklistedEmails) { $this->blacklistedEmails = array_fill_keys(array_map([$this, 'hash'], $blacklistedEmails), 1); diff --git a/mailpoet/lib/Subscription/SubscriptionUrlFactory.php b/mailpoet/lib/Subscription/SubscriptionUrlFactory.php index 9c09831f2a..28ff9ddd03 100644 --- a/mailpoet/lib/Subscription/SubscriptionUrlFactory.php +++ b/mailpoet/lib/Subscription/SubscriptionUrlFactory.php @@ -35,29 +35,29 @@ class SubscriptionUrlFactory { $this->linkTokens = $linkTokens; } - public function getConfirmationUrl(SubscriberEntity $subscriber = null) { + public function getConfirmationUrl(?SubscriberEntity $subscriber = null) { $post = $this->getPost($this->settings->get('subscription.pages.confirmation')); return $this->getSubscriptionUrl($post, 'confirm', $subscriber); } - public function getConfirmUnsubscribeUrl(SubscriberEntity $subscriber = null, int $queueId = null) { + public function getConfirmUnsubscribeUrl(?SubscriberEntity $subscriber = null, ?int $queueId = null) { $post = $this->getPost($this->settings->get('subscription.pages.confirm_unsubscribe')); $data = $queueId && $subscriber ? ['queueId' => $queueId] : null; return $this->getSubscriptionUrl($post, 'confirm_unsubscribe', $subscriber, $data); } - public function getManageUrl(SubscriberEntity $subscriber = null) { + public function getManageUrl(?SubscriberEntity $subscriber = null) { $post = $this->getPost($this->settings->get('subscription.pages.manage')); return $this->getSubscriptionUrl($post, 'manage', $subscriber); } - public function getUnsubscribeUrl(SubscriberEntity $subscriber = null, int $queueId = null) { + public function getUnsubscribeUrl(?SubscriberEntity $subscriber = null, ?int $queueId = null) { $post = $this->getPost($this->settings->get('subscription.pages.unsubscribe')); $data = $queueId && $subscriber ? ['queueId' => $queueId] : null; return $this->getSubscriptionUrl($post, 'unsubscribe', $subscriber, $data); } - public function getReEngagementUrl(SubscriberEntity $subscriber = null) { + public function getReEngagementUrl(?SubscriberEntity $subscriber = null) { $reEngagementSetting = $this->settings->get('reEngagement'); $postId = $reEngagementSetting['page'] ?? null; @@ -68,7 +68,7 @@ class SubscriptionUrlFactory { public function getSubscriptionUrl( $post = null, $action = null, - SubscriberEntity $subscriber = null, + ?SubscriberEntity $subscriber = null, $data = null ) { if ($post === null || $action === null) return; diff --git a/mailpoet/lib/Twig/Assets.php b/mailpoet/lib/Twig/Assets.php index b7ec7fd847..28f2233a04 100644 --- a/mailpoet/lib/Twig/Assets.php +++ b/mailpoet/lib/Twig/Assets.php @@ -21,7 +21,7 @@ class Assets extends AbstractExtension { public function __construct( array $globals, WPFunctions $wp, - CdnAssetUrl $cdnAssetsUrl = null + ?CdnAssetUrl $cdnAssetsUrl = null ) { $this->globals = $globals; $this->wp = $wp; diff --git a/mailpoet/lib/Util/License/Features/Subscribers.php b/mailpoet/lib/Util/License/Features/Subscribers.php index f0d5f18fb5..1268a04e5d 100644 --- a/mailpoet/lib/Util/License/Features/Subscribers.php +++ b/mailpoet/lib/Util/License/Features/Subscribers.php @@ -85,7 +85,7 @@ class Subscribers { return $count; } - public function isSubscribersCountEnoughForCache(int $count = null): bool { + public function isSubscribersCountEnoughForCache(?int $count = null): bool { if (is_null($count) && func_num_args() === 0) { $count = $this->getSubscribersCount(); } diff --git a/mailpoet/lib/Util/Notices/UnauthorizedEmailNotice.php b/mailpoet/lib/Util/Notices/UnauthorizedEmailNotice.php index 0fb4bd833a..1975b68a5c 100644 --- a/mailpoet/lib/Util/Notices/UnauthorizedEmailNotice.php +++ b/mailpoet/lib/Util/Notices/UnauthorizedEmailNotice.php @@ -20,7 +20,7 @@ class UnauthorizedEmailNotice { public function __construct( WPFunctions $wp, - SettingsController $settings = null + ?SettingsController $settings = null ) { $this->settings = $settings; $this->wp = $wp; diff --git a/mailpoet/lib/Validator/Builder.php b/mailpoet/lib/Validator/Builder.php index d702f626b4..e87be14e33 100644 --- a/mailpoet/lib/Validator/Builder.php +++ b/mailpoet/lib/Validator/Builder.php @@ -34,13 +34,13 @@ class Builder { return new NullSchema(); } - public static function array(Schema $items = null): ArraySchema { + public static function array(?Schema $items = null): ArraySchema { $array = new ArraySchema(); return $items ? $array->items($items) : $array; } /** @param array|null $properties */ - public static function object(array $properties = null): ObjectSchema { + public static function object(?array $properties = null): ObjectSchema { $object = new ObjectSchema(); return $properties === null ? $object : $object->properties($properties); } diff --git a/mailpoet/lib/WP/DateTime.php b/mailpoet/lib/WP/DateTime.php index e144fcd0e7..f9cf30c269 100644 --- a/mailpoet/lib/WP/DateTime.php +++ b/mailpoet/lib/WP/DateTime.php @@ -14,7 +14,7 @@ class DateTime { private $wp; public function __construct( - WPFunctions $wp = null + ?WPFunctions $wp = null ) { if ($wp === null) { $wp = new WPFunctions(); diff --git a/mailpoet/lib/WP/Emoji.php b/mailpoet/lib/WP/Emoji.php index 1a6d466d77..016151b7b2 100644 --- a/mailpoet/lib/WP/Emoji.php +++ b/mailpoet/lib/WP/Emoji.php @@ -12,7 +12,7 @@ class Emoji { private $wp; public function __construct( - WPFunctions $wp = null + ?WPFunctions $wp = null ) { if ($wp === null) { $wp = new WPFunctions(); diff --git a/mailpoet/lib/WP/Functions.php b/mailpoet/lib/WP/Functions.php index c204948ab5..fd51ac1cb8 100644 --- a/mailpoet/lib/WP/Functions.php +++ b/mailpoet/lib/WP/Functions.php @@ -296,7 +296,7 @@ class Functions { return get_post_type($post); } - public function getPosts(array $args = null) { + public function getPosts(?array $args = null) { return get_posts($args); } @@ -861,7 +861,7 @@ class Functions { } /** @param string[]|null $protocols */ - public function escUrlRaw(string $url, array $protocols = null): string { + public function escUrlRaw(string $url, ?array $protocols = null): string { return esc_url_raw($url, $protocols); } diff --git a/mailpoet/tasks/release/JiraController.php b/mailpoet/tasks/release/JiraController.php index fd8d7deed7..0785a2d877 100644 --- a/mailpoet/tasks/release/JiraController.php +++ b/mailpoet/tasks/release/JiraController.php @@ -166,7 +166,7 @@ class JiraController { /** * @see https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-api-3-search-get */ - public function search($jql, array $fields = null) { + public function search($jql, ?array $fields = null) { $params = ['jql' => $jql]; if ($fields) { $params['fields'] = join(',', $fields); diff --git a/mailpoet/tests/DataFactories/Automation.php b/mailpoet/tests/DataFactories/Automation.php index e15cacc617..cbafa8a1ff 100644 --- a/mailpoet/tests/DataFactories/Automation.php +++ b/mailpoet/tests/DataFactories/Automation.php @@ -87,7 +87,7 @@ class Automation { return $this->withStep($step); } - public function withIfElseStep(Step $elseStep = null): self { + public function withIfElseStep(?Step $elseStep = null): self { $subscribedFilter = new Filter( 'f1', 'enum', diff --git a/mailpoet/tests/DataFactories/AutomationRun.php b/mailpoet/tests/DataFactories/AutomationRun.php index 11fd9b803c..987ecf00b0 100644 --- a/mailpoet/tests/DataFactories/AutomationRun.php +++ b/mailpoet/tests/DataFactories/AutomationRun.php @@ -78,7 +78,7 @@ class AutomationRun { return $this; } - public function withNextStep(string $nextStep = null): self { + public function withNextStep(?string $nextStep = null): self { $this->nextStep = $nextStep; return $this; } diff --git a/mailpoet/tests/DataFactories/ScheduledTask.php b/mailpoet/tests/DataFactories/ScheduledTask.php index de28f31816..2716ac6624 100644 --- a/mailpoet/tests/DataFactories/ScheduledTask.php +++ b/mailpoet/tests/DataFactories/ScheduledTask.php @@ -35,8 +35,8 @@ class ScheduledTask { string $type, ?string $status, ?\DateTimeInterface $scheduledAt = null, - \DateTimeInterface $deletedAt = null, - \DateTimeInterface $updatedAt = null + ?\DateTimeInterface $deletedAt = null, + ?\DateTimeInterface $updatedAt = null ) { $task = new ScheduledTaskEntity(); $task->setType($type); diff --git a/mailpoet/tests/DataFactories/ScheduledTaskSubscriber.php b/mailpoet/tests/DataFactories/ScheduledTaskSubscriber.php index 92439e8af5..e35413c3b0 100644 --- a/mailpoet/tests/DataFactories/ScheduledTaskSubscriber.php +++ b/mailpoet/tests/DataFactories/ScheduledTaskSubscriber.php @@ -31,7 +31,7 @@ class ScheduledTaskSubscriber { return $taskSubscriber; } - public function createFailed(ScheduledTaskEntity $task, SubscriberEntity $subscriberEntity, string $error = null): ScheduledTaskSubscriberEntity { + public function createFailed(ScheduledTaskEntity $task, SubscriberEntity $subscriberEntity, ?string $error = null): ScheduledTaskSubscriberEntity { $taskSubscriber = new ScheduledTaskSubscriberEntity($task, $subscriberEntity, 1, 1, $error); $this->entityManager->persist($taskSubscriber); $this->entityManager->flush(); diff --git a/mailpoet/tests/DataFactories/SendingQueue.php b/mailpoet/tests/DataFactories/SendingQueue.php index 1536b44f4b..3de3472e96 100644 --- a/mailpoet/tests/DataFactories/SendingQueue.php +++ b/mailpoet/tests/DataFactories/SendingQueue.php @@ -19,7 +19,7 @@ class SendingQueue { $this->entityManager = $diContainer->get(EntityManager::class); } - public function create(ScheduledTaskEntity $task, ?NewsletterEntity $newsletter = null, \DateTimeInterface $deletedAt = null): SendingQueueEntity { + public function create(ScheduledTaskEntity $task, ?NewsletterEntity $newsletter = null, ?\DateTimeInterface $deletedAt = null): SendingQueueEntity { $queue = new SendingQueueEntity(); $queue->setTask($task); $task->setSendingQueue($queue); diff --git a/mailpoet/tests/DataGenerator/Generators/WooCommercePastRevenues.php b/mailpoet/tests/DataGenerator/Generators/WooCommercePastRevenues.php index 6eac55102f..f53d795833 100644 --- a/mailpoet/tests/DataGenerator/Generators/WooCommercePastRevenues.php +++ b/mailpoet/tests/DataGenerator/Generators/WooCommercePastRevenues.php @@ -510,7 +510,7 @@ class WooCommercePastRevenues implements Generator { /** * @return \WC_Order|\WP_Error */ - private function createCompletedWooCommerceOrder($subscriberId, $email, $customerId = null, $products = [], Carbon $completedAt = null): \WC_Order { + private function createCompletedWooCommerceOrder($subscriberId, $email, $customerId = null, $products = [], ?Carbon $completedAt = null): \WC_Order { $random = $this->getRandomString(); $countries = ['FR', 'GB', 'US', 'IE', 'IT']; $address = [ diff --git a/mailpoet/tests/_support/AcceptanceTester.php b/mailpoet/tests/_support/AcceptanceTester.php index 099ec7ac4d..999d6f950e 100644 --- a/mailpoet/tests/_support/AcceptanceTester.php +++ b/mailpoet/tests/_support/AcceptanceTester.php @@ -168,7 +168,7 @@ class AcceptanceTester extends \Codeception\Actor { $i->click($xpath); } - public function clickWooTableActionInsideMoreButton(string $itemName, string $moreButtonAction, string $confirmAction = null) { + public function clickWooTableActionInsideMoreButton(string $itemName, string $moreButtonAction, ?string $confirmAction = null) { $i = $this; $i->clickWooTableMoreButtonByItemName($itemName); $i->waitForText($itemName); diff --git a/mailpoet/tests/_support/IntegrationTester.php b/mailpoet/tests/_support/IntegrationTester.php index 24b5f76640..b5ba4142fd 100644 --- a/mailpoet/tests/_support/IntegrationTester.php +++ b/mailpoet/tests/_support/IntegrationTester.php @@ -278,7 +278,7 @@ class IntegrationTester extends \Codeception\Actor { return $order; } - public function createWooProductReview(int $customerId, string $customerEmail, int $productId, int $rating, Carbon $date = null): int { + public function createWooProductReview(int $customerId, string $customerEmail, int $productId, int $rating, ?Carbon $date = null): int { if ($date === null) { $date = Carbon::now()->subDay(); } diff --git a/mailpoet/tests/acceptance/Automation/AnalyticsCest.php b/mailpoet/tests/acceptance/Automation/AnalyticsCest.php index 4d4282aaf6..e143c23943 100644 --- a/mailpoet/tests/acceptance/Automation/AnalyticsCest.php +++ b/mailpoet/tests/acceptance/Automation/AnalyticsCest.php @@ -244,7 +244,7 @@ class AnalyticsCest { return $subscriber; } - private function createRunForSubscriber(SubscriberEntity $subscriber, string $nextStep = null, string $status = AutomationRun::STATUS_COMPLETE) { + private function createRunForSubscriber(SubscriberEntity $subscriber, ?string $nextStep = null, string $status = AutomationRun::STATUS_COMPLETE) { $run = (new DataFactories\AutomationRun()) ->withAutomation($this->automation) ->withStatus($nextStep ? $status : AutomationRun::STATUS_COMPLETE) diff --git a/mailpoet/tests/integration/API/JSON/v1/SubscribersTest.php b/mailpoet/tests/integration/API/JSON/v1/SubscribersTest.php index d66c6665dd..80cdad32ec 100644 --- a/mailpoet/tests/integration/API/JSON/v1/SubscribersTest.php +++ b/mailpoet/tests/integration/API/JSON/v1/SubscribersTest.php @@ -314,7 +314,7 @@ class SubscribersTest extends \MailPoetTest { verify($response->data)->equals( $this->responseBuilder->build($this->subscriber2) ); - verify($this->subscriber2->getSubscriberSegments()->filter(function (SubscriberSegmentEntity $subscriberSegment = null) { + verify($this->subscriber2->getSubscriberSegments()->filter(function (?SubscriberSegmentEntity $subscriberSegment = null) { if (!$subscriberSegment) return false; return $subscriberSegment->getStatus() === SubscriberEntity::STATUS_SUBSCRIBED; })->count())->equals(0); diff --git a/mailpoet/tests/integration/Automation/Engine/Storage/AutomationStatisticsStorageTest.php b/mailpoet/tests/integration/Automation/Engine/Storage/AutomationStatisticsStorageTest.php index 6b08566598..273d18f71b 100644 --- a/mailpoet/tests/integration/Automation/Engine/Storage/AutomationStatisticsStorageTest.php +++ b/mailpoet/tests/integration/Automation/Engine/Storage/AutomationStatisticsStorageTest.php @@ -37,7 +37,7 @@ class AutomationStatisticsStorageTest extends \MailPoetTest { /** * @dataProvider dataForTestItCalculatesTotalsCorrectly */ - public function testItCalculatesTotalsCorrectlyForSingleAutomation(int $automationIndex, int $expectedTotal, int $expectedInProgress, int $expectedExited, int $versionId = null) { + public function testItCalculatesTotalsCorrectlyForSingleAutomation(int $automationIndex, int $expectedTotal, int $expectedInProgress, int $expectedExited, ?int $versionId = null) { $automation = $this->automationStorage->getAutomation($this->automations[$automationIndex], $versionId); $this->assertInstanceOf(Automation::class, $automation); $i = 0; diff --git a/mailpoet/tests/integration/Automation/Integrations/MailPoet/Fields/NewsletterLinkFieldsTest.php b/mailpoet/tests/integration/Automation/Integrations/MailPoet/Fields/NewsletterLinkFieldsTest.php index ae92db67f4..432b999238 100644 --- a/mailpoet/tests/integration/Automation/Integrations/MailPoet/Fields/NewsletterLinkFieldsTest.php +++ b/mailpoet/tests/integration/Automation/Integrations/MailPoet/Fields/NewsletterLinkFieldsTest.php @@ -50,7 +50,7 @@ class NewsletterLinkFieldsTest extends \MailPoetTest { $this->assertEquals($expectedId, $field->getValue($payload)); } - private function getPayload(int $id = 1, string $url = 'https://example.com', \DateTimeImmutable $created = null): NewsletterLinkPayload { + private function getPayload(int $id = 1, string $url = 'https://example.com', ?\DateTimeImmutable $created = null): NewsletterLinkPayload { $newsletter = new NewsletterEntity(); $queue = new SendingQueueEntity(); $newsletterLink = new NewsletterLinkEntity($newsletter, $queue, $url, 'hash'); diff --git a/mailpoet/tests/integration/Automation/Integrations/MailPoet/Fields/SubscriberAutomationFieldsFactoryTest.php b/mailpoet/tests/integration/Automation/Integrations/MailPoet/Fields/SubscriberAutomationFieldsFactoryTest.php index b4b6281d71..0f55065b9b 100644 --- a/mailpoet/tests/integration/Automation/Integrations/MailPoet/Fields/SubscriberAutomationFieldsFactoryTest.php +++ b/mailpoet/tests/integration/Automation/Integrations/MailPoet/Fields/SubscriberAutomationFieldsFactoryTest.php @@ -169,7 +169,7 @@ class SubscriberAutomationFieldsFactoryTest extends MailPoetTest { Automation $automation, string $status, array $subjects, - DateTimeInterface $createdAt = null + ?DateTimeInterface $createdAt = null ): AutomationRun { $runStorage = $this->diContainer->get(AutomationRunStorage::class); $run = $this->tester->createAutomationRun($automation, $subjects); diff --git a/mailpoet/tests/integration/Automation/Integrations/WooCommerce/Triggers/BuysAProductTriggerTest.php b/mailpoet/tests/integration/Automation/Integrations/WooCommerce/Triggers/BuysAProductTriggerTest.php index c5472f1918..13dc96d48f 100644 --- a/mailpoet/tests/integration/Automation/Integrations/WooCommerce/Triggers/BuysAProductTriggerTest.php +++ b/mailpoet/tests/integration/Automation/Integrations/WooCommerce/Triggers/BuysAProductTriggerTest.php @@ -120,7 +120,7 @@ class BuysAProductTriggerTest extends \MailPoetTest { * @return \WC_Order * @throws \WC_Data_Exception */ - private function createOrder(array $productIds, string $billingEmail = null): \WC_Order { + private function createOrder(array $productIds, ?string $billingEmail = null): \WC_Order { $order = new \WC_Order(); $order->set_billing_email($billingEmail ?? uniqid() . '@example.com'); diff --git a/mailpoet/tests/integration/Automation/Integrations/WooCommerce/Triggers/BuysFromACategoryTriggerTest.php b/mailpoet/tests/integration/Automation/Integrations/WooCommerce/Triggers/BuysFromACategoryTriggerTest.php index 4e95440bee..29209ee8f7 100644 --- a/mailpoet/tests/integration/Automation/Integrations/WooCommerce/Triggers/BuysFromACategoryTriggerTest.php +++ b/mailpoet/tests/integration/Automation/Integrations/WooCommerce/Triggers/BuysFromACategoryTriggerTest.php @@ -136,7 +136,7 @@ class BuysFromACategoryTriggerTest extends \MailPoetTest { * @return \WC_Order * @throws \WC_Data_Exception */ - private function createOrder(array $productIds, string $billingEmail = null): \WC_Order { + private function createOrder(array $productIds, ?string $billingEmail = null): \WC_Order { $order = new \WC_Order(); $order->set_billing_email($billingEmail ?? uniqid() . '@example.com'); diff --git a/mailpoet/tests/integration/Automation/Integrations/WooCommerce/Triggers/BuysFromATagTriggerTest.php b/mailpoet/tests/integration/Automation/Integrations/WooCommerce/Triggers/BuysFromATagTriggerTest.php index dabc66ee17..9a63daefb2 100644 --- a/mailpoet/tests/integration/Automation/Integrations/WooCommerce/Triggers/BuysFromATagTriggerTest.php +++ b/mailpoet/tests/integration/Automation/Integrations/WooCommerce/Triggers/BuysFromATagTriggerTest.php @@ -135,7 +135,7 @@ class BuysFromATagTriggerTest extends \MailPoetTest { * @return \WC_Order * @throws \WC_Data_Exception */ - private function createOrder(array $productIds, string $billingEmail = null): \WC_Order { + private function createOrder(array $productIds, ?string $billingEmail = null): \WC_Order { $order = new \WC_Order(); $order->set_billing_email($billingEmail ?? uniqid() . '@example.com'); diff --git a/mailpoet/tests/integration/Cron/Triggers/WordPressTest.php b/mailpoet/tests/integration/Cron/Triggers/WordPressTest.php index 148bc9db4f..3b2949cdb0 100644 --- a/mailpoet/tests/integration/Cron/Triggers/WordPressTest.php +++ b/mailpoet/tests/integration/Cron/Triggers/WordPressTest.php @@ -294,7 +294,7 @@ class WordPressTest extends \MailPoetTest { verify($this->wordpressTrigger->checkExecutionRequirements())->false(); } - private function addMTAConfigAndLog($sent, $status = null, int $retryAt = null) { + private function addMTAConfigAndLog($sent, $status = null, ?int $retryAt = null) { $mtaConfig = [ 'frequency' => [ 'emails' => 1, diff --git a/mailpoet/tests/integration/Cron/Workers/KeyCheck/KeyCheckWorkerTest.php b/mailpoet/tests/integration/Cron/Workers/KeyCheck/KeyCheckWorkerTest.php index ccd40b87b8..cb970a8e59 100644 --- a/mailpoet/tests/integration/Cron/Workers/KeyCheck/KeyCheckWorkerTest.php +++ b/mailpoet/tests/integration/Cron/Workers/KeyCheck/KeyCheckWorkerTest.php @@ -106,7 +106,7 @@ class KeyCheckWorkerTest extends \MailPoetTest { verify($nextRunDate->diffInSeconds($dateTime))->lessThanOrEqual(21600 + $secondsToMidnight); } - private function createRunningTask(Carbon $scheduledAt = null) { + private function createRunningTask(?Carbon $scheduledAt = null) { if (!$scheduledAt) { $scheduledAt = Carbon::now()->millisecond(0); } diff --git a/mailpoet/tests/integration/Newsletter/Editor/PostContentTransformerTest.php b/mailpoet/tests/integration/Newsletter/Editor/PostContentTransformerTest.php index 410d164037..32560c6c7f 100644 --- a/mailpoet/tests/integration/Newsletter/Editor/PostContentTransformerTest.php +++ b/mailpoet/tests/integration/Newsletter/Editor/PostContentTransformerTest.php @@ -313,7 +313,7 @@ class PostContentTransformerTest extends \MailPoetTest { /** * @return PostTransformer */ - private function getTransformer(array $args, array $content, array $title, array $image = null, bool $isProduct = false) { + private function getTransformer(array $args, array $content, array $title, ?array $image = null, bool $isProduct = false) { $extractor = $this->make( PostTransformerContentsExtractor::class, [ diff --git a/mailpoet/tests/integration/Newsletter/NewsletterSaveControllerTest.php b/mailpoet/tests/integration/Newsletter/NewsletterSaveControllerTest.php index fe330d0579..9170040080 100644 --- a/mailpoet/tests/integration/Newsletter/NewsletterSaveControllerTest.php +++ b/mailpoet/tests/integration/Newsletter/NewsletterSaveControllerTest.php @@ -127,7 +127,7 @@ class NewsletterSaveControllerTest extends \MailPoetTest { ], ]; $newsletter = $this->saveController->save($newsletterData); - $scheduleOption = $newsletter->getOptions()->filter(function (NewsletterOptionEntity $newsletterOption = null) { + $scheduleOption = $newsletter->getOptions()->filter(function (?NewsletterOptionEntity $newsletterOption = null) { if ($newsletterOption === null) return false; // PHPStan $optionField = $newsletterOption->getOptionField(); return $optionField && $optionField->getName() === 'schedule'; @@ -140,7 +140,7 @@ class NewsletterSaveControllerTest extends \MailPoetTest { $newsletterData['options']['intervalType'] = PostNotificationScheduler::INTERVAL_IMMEDIATELY; $savedNewsletter = $this->saveController->save($newsletterData); - $scheduleOption = $savedNewsletter->getOptions()->filter(function (NewsletterOptionEntity $newsletterOption = null) { + $scheduleOption = $savedNewsletter->getOptions()->filter(function (?NewsletterOptionEntity $newsletterOption = null) { if ($newsletterOption === null) return false; // PHPStan $optionField = $newsletterOption->getOptionField(); return $optionField && $optionField->getName() === 'schedule'; @@ -184,7 +184,7 @@ class NewsletterSaveControllerTest extends \MailPoetTest { ]; $newsletter = $this->saveController->save($newsletterData); - $scheduleOption = $newsletter->getOptions()->filter(function (NewsletterOptionEntity $newsletterOption = null) { + $scheduleOption = $newsletter->getOptions()->filter(function (?NewsletterOptionEntity $newsletterOption = null) { if ($newsletterOption === null) return false; // PHPStan $optionField = $newsletterOption->getOptionField(); return $optionField && $optionField->getName() === 'schedule'; diff --git a/mailpoet/tests/integration/Newsletter/Scheduler/ReEngagementSchedulerTest.php b/mailpoet/tests/integration/Newsletter/Scheduler/ReEngagementSchedulerTest.php index f1c8e0cd93..4c708e0995 100644 --- a/mailpoet/tests/integration/Newsletter/Scheduler/ReEngagementSchedulerTest.php +++ b/mailpoet/tests/integration/Newsletter/Scheduler/ReEngagementSchedulerTest.php @@ -193,7 +193,7 @@ class ReEngagementSchedulerTest extends \MailPoetTest { $this->entityManager->flush(); } - private function createSubscriber($email, $lastEngagement, SegmentEntity $segment = null) { + private function createSubscriber($email, $lastEngagement, ?SegmentEntity $segment = null) { $factory = new Subscriber(); if ($segment) { $factory = $factory->withSegments([$segment]); diff --git a/mailpoet/tests/integration/Newsletter/Sending/SendingQueuesRepositoryTest.php b/mailpoet/tests/integration/Newsletter/Sending/SendingQueuesRepositoryTest.php index 13a5b7fda4..17dc1f82fb 100644 --- a/mailpoet/tests/integration/Newsletter/Sending/SendingQueuesRepositoryTest.php +++ b/mailpoet/tests/integration/Newsletter/Sending/SendingQueuesRepositoryTest.php @@ -148,7 +148,7 @@ class SendingQueuesRepositoryTest extends \MailPoetTest { return $task; } - private function createQueue(ScheduledTaskEntity $task, NewsletterEntity $newsletter = null): SendingQueueEntity { + private function createQueue(ScheduledTaskEntity $task, ?NewsletterEntity $newsletter = null): SendingQueueEntity { if (!$newsletter) { $newsletter = new NewsletterEntity(); $newsletter->setType('type'); diff --git a/mailpoet/tests/integration/Newsletter/ShortcodesTest.php b/mailpoet/tests/integration/Newsletter/ShortcodesTest.php index 4c22476a3b..fb1102e67a 100644 --- a/mailpoet/tests/integration/Newsletter/ShortcodesTest.php +++ b/mailpoet/tests/integration/Newsletter/ShortcodesTest.php @@ -481,7 +481,7 @@ class ShortcodesTest extends \MailPoetTest { return $subscriber; } - public function _createNewsletter(NewsletterEntity $parent = null, $type = NewsletterEntity::TYPE_NOTIFICATION): NewsletterEntity { + public function _createNewsletter(?NewsletterEntity $parent = null, $type = NewsletterEntity::TYPE_NOTIFICATION): NewsletterEntity { $newsletter = new NewsletterEntity(); $newsletter->setSubject('some subject'); $newsletter->setType($type); diff --git a/mailpoet/tests/integration/Newsletter/ViewInBrowser/ViewInBrowserControllerTest.php b/mailpoet/tests/integration/Newsletter/ViewInBrowser/ViewInBrowserControllerTest.php index 1108e7fb13..b55dc67b07 100644 --- a/mailpoet/tests/integration/Newsletter/ViewInBrowser/ViewInBrowserControllerTest.php +++ b/mailpoet/tests/integration/Newsletter/ViewInBrowser/ViewInBrowserControllerTest.php @@ -138,7 +138,7 @@ class ViewInBrowserControllerTest extends \MailPoetTest { public function testUsesEmptySubscriberWhenNotLoggedIn() { $viewInBrowserRenderer = $this->make(ViewInBrowserRenderer::class, [ - 'render' => Expected::once(function (bool $isPreview, NewsletterEntity $newsletter, SubscriberEntity $subscriber = null, SendingQueueEntity $queue = null) { + 'render' => Expected::once(function (bool $isPreview, NewsletterEntity $newsletter, ?SubscriberEntity $subscriber = null, ?SendingQueueEntity $queue = null) { $this->assertNotNull($subscriber); // PHPStan verify($subscriber)->notNull(); verify($subscriber->getId())->equals(0); @@ -155,7 +155,7 @@ class ViewInBrowserControllerTest extends \MailPoetTest { public function testItSetsSubscriberToLoggedInWPUserWhenPreviewIsEnabled() { $subscriberId = $this->subscriber->getId(); $viewInBrowserRenderer = $this->make(ViewInBrowserRenderer::class, [ - 'render' => Expected::once(function (bool $isPreview, NewsletterEntity $newsletter, SubscriberEntity $subscriber = null, SendingQueueEntity $queue = null) use ($subscriberId) { + 'render' => Expected::once(function (bool $isPreview, NewsletterEntity $newsletter, ?SubscriberEntity $subscriber = null, ?SendingQueueEntity $queue = null) use ($subscriberId) { $this->assertNotNull($subscriber); // PHPStan verify($subscriber)->notNull(); verify($subscriber->getId())->equals($subscriberId); @@ -176,7 +176,7 @@ class ViewInBrowserControllerTest extends \MailPoetTest { public function testItGetsQueueByQueueId() { $viewInBrowserRenderer = $this->make(ViewInBrowserRenderer::class, [ - 'render' => Expected::once(function (bool $isPreview, NewsletterEntity $newsletter, SubscriberEntity $subscriber = null, SendingQueueEntity $queue = null) { + 'render' => Expected::once(function (bool $isPreview, NewsletterEntity $newsletter, ?SubscriberEntity $subscriber = null, ?SendingQueueEntity $queue = null) { $this->assertNotNull($queue); // PHPStan verify($queue)->notNull(); verify($queue->getId())->equals($this->sendingQueue->getId()); @@ -192,7 +192,7 @@ class ViewInBrowserControllerTest extends \MailPoetTest { public function testItGetsQueueByNewsletter() { $viewInBrowserRenderer = $this->make(ViewInBrowserRenderer::class, [ - 'render' => Expected::once(function (bool $isPreview, NewsletterEntity $newsletter, SubscriberEntity $subscriber = null, SendingQueueEntity $queue = null) { + 'render' => Expected::once(function (bool $isPreview, NewsletterEntity $newsletter, ?SubscriberEntity $subscriber = null, ?SendingQueueEntity $queue = null) { $this->assertNotNull($queue); // PHPStan verify($queue)->notNull(); verify($queue->getId())->equals($this->sendingQueue->getId()); diff --git a/mailpoet/tests/integration/REST/API/Endpoint.php b/mailpoet/tests/integration/REST/API/Endpoint.php index 36f659389f..45bbf491dd 100644 --- a/mailpoet/tests/integration/REST/API/Endpoint.php +++ b/mailpoet/tests/integration/REST/API/Endpoint.php @@ -12,7 +12,7 @@ class Endpoint extends APIEndpoint { private $requestCallback; public function __construct( - callable $requestCallback = null + ?callable $requestCallback = null ) { $this->requestCallback = $requestCallback; } diff --git a/mailpoet/tests/integration/REST/API/EndpointTest.php b/mailpoet/tests/integration/REST/API/EndpointTest.php index 8bad4141bf..59c6bb119e 100644 --- a/mailpoet/tests/integration/REST/API/EndpointTest.php +++ b/mailpoet/tests/integration/REST/API/EndpointTest.php @@ -107,17 +107,17 @@ class EndpointTest extends Test { $this->assertSame($request->getParams(), ['required' => 'required']); } - private function registerTestingGetRoute(string $path, callable $requestCallback = null): void { + private function registerTestingGetRoute(string $path, ?callable $requestCallback = null): void { $api = $this->createApi($requestCallback); $api->registerGetRoute("mailpoet-api-testing-route/$path", Endpoint::class); } - private function registerTestingPostRoute(string $path, callable $requestCallback = null): void { + private function registerTestingPostRoute(string $path, ?callable $requestCallback = null): void { $api = $this->createApi($requestCallback); $api->registerPostRoute("mailpoet-api-testing-route/$path", Endpoint::class); } - private function createApi(callable $requestCallback = null): API { + private function createApi(?callable $requestCallback = null): API { // ensure REST server is initialized for endpoint registration rest_get_server(); diff --git a/mailpoet/tests/integration/Segments/DynamicSegments/Filters/EmailActionClickAnyTest.php b/mailpoet/tests/integration/Segments/DynamicSegments/Filters/EmailActionClickAnyTest.php index b74134667f..44e02d6c52 100644 --- a/mailpoet/tests/integration/Segments/DynamicSegments/Filters/EmailActionClickAnyTest.php +++ b/mailpoet/tests/integration/Segments/DynamicSegments/Filters/EmailActionClickAnyTest.php @@ -73,7 +73,7 @@ class EmailActionClickAnyTest extends \MailPoetTest { verify($emails[0])->equals('opened_clicked@example.com'); } - private function getSegmentFilterData(string $action, int $newsletterId = null, int $linkId = null): DynamicSegmentFilterData { + private function getSegmentFilterData(string $action, ?int $newsletterId = null, ?int $linkId = null): DynamicSegmentFilterData { return new DynamicSegmentFilterData(DynamicSegmentFilterData::TYPE_EMAIL, $action, [ 'newsletter_id' => $newsletterId, 'link_id' => $linkId, diff --git a/mailpoet/tests/integration/Segments/DynamicSegments/Filters/NumberOfClicksTest.php b/mailpoet/tests/integration/Segments/DynamicSegments/Filters/NumberOfClicksTest.php index 20ed2c4d53..2ae55b712b 100644 --- a/mailpoet/tests/integration/Segments/DynamicSegments/Filters/NumberOfClicksTest.php +++ b/mailpoet/tests/integration/Segments/DynamicSegments/Filters/NumberOfClicksTest.php @@ -89,7 +89,7 @@ class NumberOfClicksTest extends \MailPoetTest { ]); } - private function createClicks(SubscriberEntity $subscriber, int $count, DateTimeInterface $date = null): void { + private function createClicks(SubscriberEntity $subscriber, int $count, ?DateTimeInterface $date = null): void { if ($date === null) { $date = CarbonImmutable::now(); } diff --git a/mailpoet/tests/integration/Segments/DynamicSegments/Filters/UserRoleTest.php b/mailpoet/tests/integration/Segments/DynamicSegments/Filters/UserRoleTest.php index f5f9ffce16..3ab415adcf 100644 --- a/mailpoet/tests/integration/Segments/DynamicSegments/Filters/UserRoleTest.php +++ b/mailpoet/tests/integration/Segments/DynamicSegments/Filters/UserRoleTest.php @@ -82,7 +82,7 @@ class UserRoleTest extends \MailPoetTest { * @param string|null $operator * @return DynamicSegmentFilterData */ - private function getSegmentFilterData($role, string $operator = null): DynamicSegmentFilterData { + private function getSegmentFilterData($role, ?string $operator = null): DynamicSegmentFilterData { $filterData = [ 'wordpressRole' => $role, ]; diff --git a/mailpoet/tests/integration/Segments/DynamicSegments/Filters/WooCommerceCountryTest.php b/mailpoet/tests/integration/Segments/DynamicSegments/Filters/WooCommerceCountryTest.php index 6da83a1343..8cbc024a92 100644 --- a/mailpoet/tests/integration/Segments/DynamicSegments/Filters/WooCommerceCountryTest.php +++ b/mailpoet/tests/integration/Segments/DynamicSegments/Filters/WooCommerceCountryTest.php @@ -60,7 +60,7 @@ class WooCommerceCountryTest extends \MailPoetTest { * @param string|null $operator * @return DynamicSegmentFilterData */ - private function getSegmentFilterData($country, string $operator = null): DynamicSegmentFilterData { + private function getSegmentFilterData($country, ?string $operator = null): DynamicSegmentFilterData { $filterData = [ 'country_code' => $country, ]; diff --git a/mailpoet/tests/integration/Segments/DynamicSegments/Filters/WooCommerceSubscriptionTest.php b/mailpoet/tests/integration/Segments/DynamicSegments/Filters/WooCommerceSubscriptionTest.php index a70ef049b5..6d9b6185fc 100644 --- a/mailpoet/tests/integration/Segments/DynamicSegments/Filters/WooCommerceSubscriptionTest.php +++ b/mailpoet/tests/integration/Segments/DynamicSegments/Filters/WooCommerceSubscriptionTest.php @@ -104,7 +104,7 @@ class WooCommerceSubscriptionTest extends \MailPoetTest { return (int)$productId; } - private function getSegmentFilterData(string $operator, array $productIds = null): DynamicSegmentFilterData { + private function getSegmentFilterData(string $operator, ?array $productIds = null): DynamicSegmentFilterData { $filterData = [ 'operator' => $operator, 'product_ids' => $productIds ?: $this->products, diff --git a/mailpoet/tests/integration/Segments/DynamicSegments/Filters/WooCommerceUsedCouponCodeTest.php b/mailpoet/tests/integration/Segments/DynamicSegments/Filters/WooCommerceUsedCouponCodeTest.php index 5344f65856..3acab02afb 100644 --- a/mailpoet/tests/integration/Segments/DynamicSegments/Filters/WooCommerceUsedCouponCodeTest.php +++ b/mailpoet/tests/integration/Segments/DynamicSegments/Filters/WooCommerceUsedCouponCodeTest.php @@ -313,7 +313,7 @@ class WooCommerceUsedCouponCodeTest extends \MailPoetTest { $this->assertEqualsCanonicalizing($expectedEmails, $emails); } - private function createOrder(int $customerId, array $couponCodes = [], Carbon $createdAt = null): int { + private function createOrder(int $customerId, array $couponCodes = [], ?Carbon $createdAt = null): int { if (is_null($createdAt)) { $createdAt = Carbon::now()->millisecond(0)->subDay(); } diff --git a/mailpoet/tests/integration/Segments/SegmentsFinderTest.php b/mailpoet/tests/integration/Segments/SegmentsFinderTest.php index 1613c5067c..b1dca6726b 100644 --- a/mailpoet/tests/integration/Segments/SegmentsFinderTest.php +++ b/mailpoet/tests/integration/Segments/SegmentsFinderTest.php @@ -94,7 +94,7 @@ class SegmentsFinderTest extends MailPoetTest { ->create(); } - private function createSegment(string $type, string $name = null): SegmentEntity { + private function createSegment(string $type, ?string $name = null): SegmentEntity { $name = $name ?? "Segment $type"; $segmentFactory = new SegmentFactory(); return $segmentFactory diff --git a/mailpoet/tests/integration/Segments/WooCommerceTest.php b/mailpoet/tests/integration/Segments/WooCommerceTest.php index c6ddae8843..b6453a3532 100644 --- a/mailpoet/tests/integration/Segments/WooCommerceTest.php +++ b/mailpoet/tests/integration/Segments/WooCommerceTest.php @@ -743,7 +743,7 @@ class WooCommerceTest extends \MailPoetTest { return $guest; } - private function insertRegisteredCustomerWithOrder(?int $number = null, array $data = null): WPTestUser { + private function insertRegisteredCustomerWithOrder(?int $number = null, ?array $data = null): WPTestUser { $number = !is_null($number) ? (int)$number : mt_rand(); $data = is_array($data) ? $data : []; $user = $this->insertRegisteredCustomer($number, $data['first_name'] ?? null, $data['last_name'] ?? null); diff --git a/mailpoet/tests/integration/Subscribers/ImportExport/PersonalDataExporters/NewsletterClicksExporterTest.php b/mailpoet/tests/integration/Subscribers/ImportExport/PersonalDataExporters/NewsletterClicksExporterTest.php index 2245f2fe4e..8710a3eefb 100644 --- a/mailpoet/tests/integration/Subscribers/ImportExport/PersonalDataExporters/NewsletterClicksExporterTest.php +++ b/mailpoet/tests/integration/Subscribers/ImportExport/PersonalDataExporters/NewsletterClicksExporterTest.php @@ -74,7 +74,7 @@ class NewsletterClicksExporterTest extends \MailPoetTest { $this->assertSame($result['data'][0]['data'][3], ['name' => 'User-agent', 'value' => 'Unknown']); } - protected function prepareDataToBeExported(string $userEmail, string $userAgentName = null) { + protected function prepareDataToBeExported(string $userEmail, ?string $userAgentName = null) { $subscriber = new SubscriberEntity(); $subscriber->setEmail($userEmail); $this->entityManager->persist($subscriber); diff --git a/mailpoet/tests/integration/Subscribers/ImportExport/PersonalDataExporters/NewsletterOpensExporterTest.php b/mailpoet/tests/integration/Subscribers/ImportExport/PersonalDataExporters/NewsletterOpensExporterTest.php index 7497fbf9b6..109f95d82b 100644 --- a/mailpoet/tests/integration/Subscribers/ImportExport/PersonalDataExporters/NewsletterOpensExporterTest.php +++ b/mailpoet/tests/integration/Subscribers/ImportExport/PersonalDataExporters/NewsletterOpensExporterTest.php @@ -79,7 +79,7 @@ class NewsletterOpensExporterTest extends \MailPoetTest { $this->assertSame($result['data'][0]['data'][2], ['name' => 'User-agent', 'value' => 'Unknown']); } - protected function prepareDataToBeExported(string $userEmail, string $userAgentName = null) { + protected function prepareDataToBeExported(string $userEmail, ?string $userAgentName = null) { $subscriber = new SubscriberEntity(); $subscriber->setEmail($userEmail); $this->entityManager->persist($subscriber); diff --git a/mailpoet/tests/integration/Subscription/ManageSubscriptionFormRendererTest.php b/mailpoet/tests/integration/Subscription/ManageSubscriptionFormRendererTest.php index 6689daf52c..30b79544e8 100644 --- a/mailpoet/tests/integration/Subscription/ManageSubscriptionFormRendererTest.php +++ b/mailpoet/tests/integration/Subscription/ManageSubscriptionFormRendererTest.php @@ -63,7 +63,7 @@ class ManageSubscriptionFormRendererTest extends \MailPoetTest { return $segment; } - private function getSubscriber(SegmentEntity $segment = null): SubscriberEntity { + private function getSubscriber(?SegmentEntity $segment = null): SubscriberEntity { $subscriber = new SubscriberEntity(); $subscriber->setStatus(SubscriberEntity::STATUS_SUBSCRIBED); $subscriber->setFirstName('Fname'); diff --git a/mailpoet/tests/integration/Subscription/PagesTest.php b/mailpoet/tests/integration/Subscription/PagesTest.php index 2c05eb77d2..ffff8dd116 100644 --- a/mailpoet/tests/integration/Subscription/PagesTest.php +++ b/mailpoet/tests/integration/Subscription/PagesTest.php @@ -295,8 +295,8 @@ class PagesTest extends \MailPoetTest { } private function getPages( - NewSubscriberNotificationMailer $newSubscriberNotificationsMock = null, - Unsubscribes $unsubscribesMock = null + ?NewSubscriberNotificationMailer $newSubscriberNotificationsMock = null, + ?Unsubscribes $unsubscribesMock = null ): Pages { $container = ContainerWrapper::getInstance(); return new Pages( diff --git a/mailpoet/tests/unit/Automation/Engine/Validation/AutomationRules/UnknownStepRuleTest.php b/mailpoet/tests/unit/Automation/Engine/Validation/AutomationRules/UnknownStepRuleTest.php index f424d83244..bc0b650869 100644 --- a/mailpoet/tests/unit/Automation/Engine/Validation/AutomationRules/UnknownStepRuleTest.php +++ b/mailpoet/tests/unit/Automation/Engine/Validation/AutomationRules/UnknownStepRuleTest.php @@ -80,7 +80,7 @@ class UnknownStepRuleTest extends AutomationRuleTest { (new AutomationWalker())->walk($automation, [$this->getRule($existingAutomation, [new RootStep()])]); } - private function getRule(Automation $existingAutomation = null, array $steps = []): UnknownStepRule { + private function getRule(?Automation $existingAutomation = null, array $steps = []): UnknownStepRule { $stepMap = []; foreach ($steps as $step) { $stepMap[$step->getKey()] = $step; diff --git a/mailpoet/tests/unit/Cron/CronTriggerTest.php b/mailpoet/tests/unit/Cron/CronTriggerTest.php index 21f5d5bec4..94ae9ae2e2 100644 --- a/mailpoet/tests/unit/Cron/CronTriggerTest.php +++ b/mailpoet/tests/unit/Cron/CronTriggerTest.php @@ -62,8 +62,8 @@ class CronTriggerTest extends \MailPoetUnitTest { private function createCronTrigger( SettingsController $settings, - WordPress $wordpressTrigger = null, - DaemonActionSchedulerRunner $actionSchedulerRunner = null + ?WordPress $wordpressTrigger = null, + ?DaemonActionSchedulerRunner $actionSchedulerRunner = null ) { $wordpressTrigger = $wordpressTrigger ?: $this->make(WordPress::class, ['run' => true]); $actionSchedulerRunner = $actionSchedulerRunner ?: $this->make(DaemonActionSchedulerRunner::class, ['init' => true]); From 0064f32cd86ca6be96e42a0a0d5d11d628db2ba7 Mon Sep 17 00:00:00 2001 From: David Remer Date: Thu, 27 Feb 2025 14:21:23 +0200 Subject: [PATCH 26/26] Fix deprecation: Optional parameter declared before required parameter [MAILPOET-6491] --- mailpoet/lib/Cron/DaemonHttpRunner.php | 2 +- mailpoet/lib/Entities/StatisticsUnsubscribeEntity.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mailpoet/lib/Cron/DaemonHttpRunner.php b/mailpoet/lib/Cron/DaemonHttpRunner.php index 8e58033564..b3b479d4d5 100644 --- a/mailpoet/lib/Cron/DaemonHttpRunner.php +++ b/mailpoet/lib/Cron/DaemonHttpRunner.php @@ -27,7 +27,7 @@ class DaemonHttpRunner { private $wordpressTrigger; public function __construct( - ?Daemon $daemon = null, + ?Daemon $daemon, CronHelper $cronHelper, SettingsController $settings, WordPress $wordpressTrigger diff --git a/mailpoet/lib/Entities/StatisticsUnsubscribeEntity.php b/mailpoet/lib/Entities/StatisticsUnsubscribeEntity.php index 732e63b846..90ff5dc3e3 100644 --- a/mailpoet/lib/Entities/StatisticsUnsubscribeEntity.php +++ b/mailpoet/lib/Entities/StatisticsUnsubscribeEntity.php @@ -67,8 +67,8 @@ class StatisticsUnsubscribeEntity { private $method = self::METHOD_UNKNOWN; public function __construct( - ?NewsletterEntity $newsletter = null, - ?SendingQueueEntity $queue = null, + ?NewsletterEntity $newsletter, + ?SendingQueueEntity $queue, SubscriberEntity $subscriber ) { $this->newsletter = $newsletter;