Skip to content

Commit

Permalink
phpstan and phan fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jcvignoli committed Oct 4, 2024
1 parent 865ce9f commit b7d93b5
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 21 deletions.
4 changes: 2 additions & 2 deletions dist/class/admin/class-save-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Save_Options {
* Constructor
* @param string|null $page_data_taxo Full URL to data page taxonomy subpage
*/
public function __construct( string $page_data_taxo = null ) {
public function __construct( ?string $page_data_taxo = null ) {

// Store page
$this->page_data_taxo = $page_data_taxo;
Expand All @@ -87,7 +87,7 @@ public function __construct( string $page_data_taxo = null ) {
* @since 4.1 added param, I need it to restrain rewrite rules flush to data taxo pages
* @see self::lumiere_data_options_save() use $this->page_data_taxo
*/
public static function lumiere_static_start( string $page_data_taxo = null ): void {
public static function lumiere_static_start( ?string $page_data_taxo = null ): void {

$class_save = new self( $page_data_taxo );

Expand Down
2 changes: 1 addition & 1 deletion dist/class/admin/submenu/class-help.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private function display_support(): void {
'<br>',
'<a href="${3}${5}" title="${7}">${2}</a>',
];
$acknowledgefile = preg_replace( $patterns, $replaces, $acknowledgefile ) ?? $acknowledgefile;
$acknowledgefile = preg_replace( $patterns, $replaces, $acknowledgefile );
}

// Send the file text to the included file.
Expand Down
2 changes: 1 addition & 1 deletion dist/class/admin/trait-admin-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function lumiere_unlink_recursive( string $dir ): bool {
*
* @return void Returns optionaly an array of the options passed in $options
*/
public function lumiere_display_vars( ?array $options = null, string $set_error = null, string $libxml_use = null, string $get_screen = null ): void {
public function lumiere_display_vars( ?array $options = null, ?string $set_error = null, ?string $libxml_use = null, ?string $get_screen = null ): void {

// If the user can't manage options and it's not a cron, exit.
if ( ! current_user_can( 'manage_options' ) ) {
Expand Down
1 change: 1 addition & 0 deletions dist/class/frontend/class-movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public static function lumiere_static_start (): void {
* @since 3.8 Extra logs are shown once only using singleton $this->movie_run_once and Plugins_Start class added
*
* @param array<int<0, max>, array<string, string>>|null $imdb_id_or_title_outside Name or IMDbID of the movie to find in array
* @phpstan-param array<int<0, max>, array<string, string>>|null $imdb_id_or_title_outside Name or IMDbID of the movie to find in array
* @psalm-param list<array{0?: array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}, bymid?: string, byname?: string, ...<int<0, max>, array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}>}> $imdb_id_or_title_outside
*/
public function lumiere_show( ?array $imdb_id_or_title_outside = null ): string {
Expand Down
7 changes: 6 additions & 1 deletion dist/class/frontend/class-widget-frontpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ public function lum_get_widget( string $title_box ): string {
$movies_array[] = is_int( $post_id ) ? $this->maybe_get_lum_post_metada( $post_id ) : null;

// Clean the array, remove empty multidimensional arrays.
/** @psalm-var list<array{0?: array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}, bymid?: string, byname?: string, ...<int<0, max>, array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}>}> $final_movies_array */
/** @psalm-var list<array{0?: array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}, bymid?: string, byname?: string, ...<int<0, max>, array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}>}> $final_movies_array
* @phpstan-var array<int, array<string, string>> $final_movies_array
*/
$final_movies_array = array_filter( $movies_array, fn( $movies_array ) => ( $movies_array !== null && count( $movies_array ) > 0 ) );

// Exit if no metadata, no auto title option activated
Expand All @@ -230,6 +232,9 @@ public function lum_get_widget( string $title_box ): string {
}

// Get movie's data from {@link \Lumiere\Frontend\Movie}
/**
* @psalm-var list<array{0?: array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}, bymid?: string, byname?: string, ...<int<0, max>, array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}>}>|null $final_movies_array
* @phpstan-var array<int<0, max>, array<string, string>> $final_movies_array */
$movie = $this->movie_class->lumiere_show( $final_movies_array );

/**
Expand Down
2 changes: 1 addition & 1 deletion dist/class/plugins/auto/class-polylang.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function amp_form_submit(): void {
* @return string
* @deprecated 4.1 no use of this method
*/
public function rewrite_string_with_polylang_url( string $content, string $extra_url = null ): string {
public function rewrite_string_with_polylang_url( string $content, ?string $extra_url = null ): string {

$home_slashed = str_replace( '/', '\/', home_url() );
$pll_home_slashed = str_replace( '/', '\/', trim( pll_home_url(), '/' ) );
Expand Down
2 changes: 1 addition & 1 deletion dist/class/plugins/class-plugins-start.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Plugins_Start {
* Constructor
* @param array<int, object|Imdbphp|Logger>|null $extra_classes Extra classes to add
*/
public function __construct( array $extra_classes = null ) {
public function __construct( ?array $extra_classes = null ) {

// Get the active plugins.
$detect_class = new Plugins_Detect();
Expand Down
5 changes: 3 additions & 2 deletions dist/class/tools/trait-files.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ public function lumiere_wp_filesystem_cred( string $file ): void {
global $wp_filesystem;

// On some environnements, $wp_filesystem is sometimes not correctly initialised through globals.
if ( $wp_filesystem === null ) {
require_once ABSPATH . 'wp-admin/includes/file.php';
$file_path = ABSPATH . 'wp-admin/includes/file.php';
if ( $wp_filesystem === null && is_file( $file_path ) ) {
require_once $file_path;
WP_Filesystem();
}

Expand Down
4 changes: 2 additions & 2 deletions dist/vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => 'jcvignoli/lumiere-movies',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7bfe179b297f3ffc87a0d2e2f5a22e20f8839c32',
'reference' => '865ce9f18a3bc9339b711def9db7df45b947c396',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -24,7 +24,7 @@
'jcvignoli/lumiere-movies' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '7bfe179b297f3ffc87a0d2e2f5a22e20f8839c32',
'reference' => '865ce9f18a3bc9339b711def9db7df45b947c396',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var sshMain = new ssh ({ /* ssh functions with mainserver */
port: ext_cred.mainserver.port,
username: ext_cred.mainserver.username,
privateKey: fs.readFileSync( ext_cred.mainserver.key ),
forceIPv4: true, /** with Nodejs > 19.9, can't connect and upload to infomaniak if IPv4 is not forced */
/* debug: console.log, */
}
});
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ parameters:
- tests/bootstrap-testing.php
ignoreErrors:
- '#Variable method call on#'
- '#Path in require_once\(\) "./wp-admin/includes#'
dynamicConstantNames:
- DOING_CRON
- WP_DEBUG_LOG
Expand Down
4 changes: 2 additions & 2 deletions src/class/admin/class-save-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Save_Options {
* Constructor
* @param string|null $page_data_taxo Full URL to data page taxonomy subpage
*/
public function __construct( string $page_data_taxo = null ) {
public function __construct( ?string $page_data_taxo = null ) {

// Store page
$this->page_data_taxo = $page_data_taxo;
Expand All @@ -87,7 +87,7 @@ public function __construct( string $page_data_taxo = null ) {
* @since 4.1 added param, I need it to restrain rewrite rules flush to data taxo pages
* @see self::lumiere_data_options_save() use $this->page_data_taxo
*/
public static function lumiere_static_start( string $page_data_taxo = null ): void {
public static function lumiere_static_start( ?string $page_data_taxo = null ): void {

$class_save = new self( $page_data_taxo );

Expand Down
2 changes: 1 addition & 1 deletion src/class/admin/submenu/class-help.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private function display_support(): void {
'<br>',
'<a href="${3}${5}" title="${7}">${2}</a>',
];
$acknowledgefile = preg_replace( $patterns, $replaces, $acknowledgefile ) ?? $acknowledgefile;
$acknowledgefile = preg_replace( $patterns, $replaces, $acknowledgefile );
}

// Send the file text to the included file.
Expand Down
2 changes: 1 addition & 1 deletion src/class/admin/trait-admin-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function lumiere_unlink_recursive( string $dir ): bool {
*
* @return void Returns optionaly an array of the options passed in $options
*/
public function lumiere_display_vars( ?array $options = null, string $set_error = null, string $libxml_use = null, string $get_screen = null ): void {
public function lumiere_display_vars( ?array $options = null, ?string $set_error = null, ?string $libxml_use = null, ?string $get_screen = null ): void {

// If the user can't manage options and it's not a cron, exit.
if ( ! current_user_can( 'manage_options' ) ) {
Expand Down
1 change: 1 addition & 0 deletions src/class/frontend/class-movie.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public static function lumiere_static_start (): void {
* @since 3.8 Extra logs are shown once only using singleton $this->movie_run_once and Plugins_Start class added
*
* @param array<int<0, max>, array<string, string>>|null $imdb_id_or_title_outside Name or IMDbID of the movie to find in array
* @phpstan-param array<int<0, max>, array<string, string>>|null $imdb_id_or_title_outside Name or IMDbID of the movie to find in array
* @psalm-param list<array{0?: array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}, bymid?: string, byname?: string, ...<int<0, max>, array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}>}> $imdb_id_or_title_outside
*/
public function lumiere_show( ?array $imdb_id_or_title_outside = null ): string {
Expand Down
7 changes: 6 additions & 1 deletion src/class/frontend/class-widget-frontpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ public function lum_get_widget( string $title_box ): string {
$movies_array[] = is_int( $post_id ) ? $this->maybe_get_lum_post_metada( $post_id ) : null;

// Clean the array, remove empty multidimensional arrays.
/** @psalm-var list<array{0?: array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}, bymid?: string, byname?: string, ...<int<0, max>, array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}>}> $final_movies_array */
/** @psalm-var list<array{0?: array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}, bymid?: string, byname?: string, ...<int<0, max>, array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}>}> $final_movies_array
* @phpstan-var array<int, array<string, string>> $final_movies_array
*/
$final_movies_array = array_filter( $movies_array, fn( $movies_array ) => ( $movies_array !== null && count( $movies_array ) > 0 ) );

// Exit if no metadata, no auto title option activated
Expand All @@ -230,6 +232,9 @@ public function lum_get_widget( string $title_box ): string {
}

// Get movie's data from {@link \Lumiere\Frontend\Movie}
/**
* @psalm-var list<array{0?: array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}, bymid?: string, byname?: string, ...<int<0, max>, array{0?: array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}, bymid?: string, byname: string, ...<int<0, max>, array{0?: array{byname: string}, bymid?: string, byname: string, ...<int<0, max>, array{byname: string}>}>}>}>|null $final_movies_array
* @phpstan-var array<int<0, max>, array<string, string>> $final_movies_array */
$movie = $this->movie_class->lumiere_show( $final_movies_array );

/**
Expand Down
2 changes: 1 addition & 1 deletion src/class/plugins/auto/class-polylang.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public function amp_form_submit(): void {
* @return string
* @deprecated 4.1 no use of this method
*/
public function rewrite_string_with_polylang_url( string $content, string $extra_url = null ): string {
public function rewrite_string_with_polylang_url( string $content, ?string $extra_url = null ): string {

$home_slashed = str_replace( '/', '\/', home_url() );
$pll_home_slashed = str_replace( '/', '\/', trim( pll_home_url(), '/' ) );
Expand Down
2 changes: 1 addition & 1 deletion src/class/plugins/class-plugins-start.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Plugins_Start {
* Constructor
* @param array<int, object|Imdbphp|Logger>|null $extra_classes Extra classes to add
*/
public function __construct( array $extra_classes = null ) {
public function __construct( ?array $extra_classes = null ) {

// Get the active plugins.
$detect_class = new Plugins_Detect();
Expand Down
5 changes: 3 additions & 2 deletions src/class/tools/trait-files.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ public function lumiere_wp_filesystem_cred( string $file ): void {
global $wp_filesystem;

// On some environnements, $wp_filesystem is sometimes not correctly initialised through globals.
if ( $wp_filesystem === null ) {
require_once ABSPATH . 'wp-admin/includes/file.php';
$file_path = ABSPATH . 'wp-admin/includes/file.php';
if ( $wp_filesystem === null && is_file( $file_path ) ) {
require_once $file_path;
WP_Filesystem();
}

Expand Down
2 changes: 1 addition & 1 deletion src/composer.lock

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

0 comments on commit b7d93b5

Please sign in to comment.