Skip to content

Commit

Permalink
Allow phpstan to run, address commentary
Browse files Browse the repository at this point in the history
  • Loading branch information
dlh01 committed May 28, 2024
1 parent b88bd9d commit 5166225
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
"phpstan/phpstan": "^1.10",
"szepeviktor/phpstan-wordpress": "^1.1.6",
"yoast/phpunit-polyfills": "^2.0",
"axepress/wp-graphql-stubs": "^1.14"
"axepress/wp-graphql-stubs": "^1.14",
"yoast/wordpress-seo": "^22.7"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"alleyinteractive/composer-wordpress-autoloader": true,
"phpstan/extension-installer": true
"phpstan/extension-installer": true,
"composer/installers": false
}
},
"scripts": {
Expand All @@ -37,5 +39,10 @@
"@phpstan",
"@phpunit"
]
},
"extra": {
"installer-paths": {
"vendor/{$vendor}/{$name}/": ["type:wordpress-plugin"]
}
}
}
7 changes: 4 additions & 3 deletions inc/models/class-profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
*
* Dynamic properties.
*
* @property int $post_id Post ID for the profile.
* @property int $term_id Term ID for the profile.
* @property int $post_id Post ID for the profile.
* @property int $term_id Term ID for the profile.
* @property string $display_name Display name for the profile.
* @property string $user_url User url.
* @property string $user_url User url.
* @property string $link Profile permalink.
*/
class Profile {
/**
Expand Down
16 changes: 8 additions & 8 deletions inc/yoast.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
* @return string Filtered tag.
*/
function filter_wpseo_meta_author( $author_name, $presentation ): string {
$id = $presentation?->context?->post?->ID;
$type = $presentation?->model?->object_sub_type;
$id = $presentation->context->post->ID;
$type = $presentation->model->object_sub_type;

if ( $id && $type && Utils::is_post_type_supported( $type ) ) {
$author_name = get_the_byline( $id );
Expand All @@ -49,8 +49,8 @@ function filter_wpseo_meta_author( $author_name, $presentation ): string {
* @return array Filtered data.
*/
function filter_wpseo_enhanced_slack_data( $data, $presentation ): array {
$id = $presentation?->context?->post?->ID;
$type = $presentation?->model?->object_sub_type;
$id = $presentation->context->post->ID;
$type = $presentation->model->object_sub_type;

if ( $id && $type && Utils::is_post_type_supported( $type ) ) {
$byline = get_the_byline( $id );
Expand All @@ -74,8 +74,8 @@ function filter_wpseo_enhanced_slack_data( $data, $presentation ): array {
*/
function filter_wpseo_schema_graph_pieces( $schema_pieces, $context ) {
if (
'post' === $context?->indexable?->object_type
&& Utils::is_post_type_supported( $context?->indexable?->object_sub_type )
'post' === $context->indexable->object_type
&& Utils::is_post_type_supported( $context->indexable->object_sub_type )
) {
$schema_pieces = array_filter( $schema_pieces, fn ( $piece ) => ! $piece instanceof Person );
}
Expand Down Expand Up @@ -107,8 +107,8 @@ function filter_wpseo_schema_graph( $graph, $context ) {
* It's easier to create the schema pieces and generate their output here, rather than filtering the schema
* pieces into 'filter_schema_graph_pieces', because Yoast allows only one node of each '@type' in the graph.
*/
if ( 'post' === $context?->indexable?->object_type && Utils::is_post_type_supported( $context?->indexable?->object_sub_type ) ) {
foreach ( Utils::get_byline_entries_for_post( $context?->indexable?->object_id ) as $entry ) {
if ( 'post' === $context->indexable->object_type && Utils::is_post_type_supported( $context->indexable->object_sub_type ) ) {
foreach ( Utils::get_byline_entries_for_post( $context->indexable->object_id ) as $entry ) {
if ( $entry instanceof Profile ) {
$schema_pieces[] = new Profile_Schema( $entry, $helpers, $context );
}
Expand Down

0 comments on commit 5166225

Please sign in to comment.