Skip to content

Commit

Permalink
For arguments that might be null, explicitly mark this to avoid depre…
Browse files Browse the repository at this point in the history
…cation notices in PHP 8.4
  • Loading branch information
dkotter committed Sep 27, 2024
1 parent de7134e commit 2bb41ce
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion includes/Classifai/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ function attachment_is_pdf( $post ): bool {
* @param string $attribute Optional attribute to get. Can be version or dependencies.
* @return string|array
*/
function get_asset_info( string $slug, string $attribute = null ) {
function get_asset_info( string $slug, ?string $attribute = null ) {
if ( file_exists( CLASSIFAI_PLUGIN_DIR . '/dist/' . $slug . '.asset.php' ) ) {
$asset = require CLASSIFAI_PLUGIN_DIR . '/dist/' . $slug . '.asset.php';
} else {
Expand Down
4 changes: 2 additions & 2 deletions includes/Classifai/Providers/Azure/ComputerVision.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ public function generate_image_tags( string $image_url, int $attachment_id ) {
* @param \Classifai\Features\Feature $feature Feature instance
* @return bool|object|WP_Error
*/
protected function scan_image( string $image_url, \Classifai\Features\Feature $feature = null ) {
protected function scan_image( string $image_url, ?\Classifai\Features\Feature $feature = null ) {
$settings = $feature->get_settings( static::ID );

// Check if valid authentication is in place.
Expand Down Expand Up @@ -669,7 +669,7 @@ protected function scan_image( string $image_url, \Classifai\Features\Feature $f
* @param \Classifai\Features\Feature $feature Feature instance
* @return string
*/
protected function prep_api_url( \Classifai\Features\Feature $feature = null ): string {
protected function prep_api_url( ?\Classifai\Features\Feature $feature = null ): string {
$settings = $feature->get_settings( static::ID );
$api_features = [];

Expand Down
4 changes: 2 additions & 2 deletions includes/Classifai/Providers/Azure/Embeddings.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public function sanitize_settings( array $new_settings ): array {
* @param Feature $feature Feature instance
* @return string
*/
protected function prep_api_url( Feature $feature = null ): string {
protected function prep_api_url( ?Feature $feature = null ): string {
$settings = $feature->get_settings( static::ID );
$endpoint = $settings['endpoint_url'] ?? '';
$deployment = $settings['deployment'] ?? '';
Expand Down Expand Up @@ -824,7 +824,7 @@ public function generate_embedding_job( string $taxonomy = '', bool $all = false
* @param Feature $feature The feature instance.
* @return array|WP_Error
*/
public function generate_embeddings_for_term( int $term_id, bool $force = false, Feature $feature = null ) {
public function generate_embeddings_for_term( int $term_id, bool $force = false, ?Feature $feature = null ) {
// Ensure the user has permissions to edit.
if ( ! current_user_can( 'edit_term', $term_id ) ) {
return new WP_Error( 'invalid', esc_html__( 'User does not have valid permissions to edit this term.', 'classifai' ) );
Expand Down
2 changes: 1 addition & 1 deletion includes/Classifai/Providers/Azure/OpenAI.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public function sanitize_settings( array $new_settings ): array {
* @param \Classifai\Features\Feature $feature Feature instance
* @return string
*/
protected function prep_api_url( \Classifai\Features\Feature $feature = null ): string {
protected function prep_api_url( ?\Classifai\Features\Feature $feature = null ): string {
$settings = $feature->get_settings( static::ID );
$endpoint = $settings['endpoint_url'] ?? '';
$deployment = $settings['deployment'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion includes/Classifai/Providers/OpenAI/Embeddings.php
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ public function generate_embedding_job( string $taxonomy = '', bool $all = false
* @param Feature $feature The feature instance.
* @return array|WP_Error
*/
public function generate_embeddings_for_term( int $term_id, bool $force = false, Feature $feature = null ) {
public function generate_embeddings_for_term( int $term_id, bool $force = false, ?Feature $feature = null ) {
// Ensure the user has permissions to edit.
if ( ! current_user_can( 'edit_term', $term_id ) ) {
return new WP_Error( 'invalid', esc_html__( 'User does not have valid permissions to edit this term.', 'classifai' ) );
Expand Down

0 comments on commit 2bb41ce

Please sign in to comment.