1 | <?php |
||||||
2 | /** |
||||||
3 | * The Trip Schema for Tours |
||||||
4 | * |
||||||
5 | * @package tour-operator |
||||||
6 | */ |
||||||
7 | |||||||
8 | /** |
||||||
9 | * Returns schema Review data. |
||||||
10 | * |
||||||
11 | * @since 10.2 |
||||||
12 | */ |
||||||
13 | class LSX_TO_Specials_Schema extends LSX_TO_Schema_Graph_Piece { |
||||||
14 | |||||||
15 | /** |
||||||
16 | * Constructor. |
||||||
17 | * |
||||||
18 | * @param \WPSEO_Schema_Context $context A value object with context variables. |
||||||
19 | */ |
||||||
20 | public function __construct( WPSEO_Schema_Context $context ) { |
||||||
0 ignored issues
–
show
|
|||||||
21 | $this->post_type = 'special'; |
||||||
0 ignored issues
–
show
|
|||||||
22 | parent::__construct( $context ); |
||||||
23 | } |
||||||
24 | |||||||
25 | /** |
||||||
26 | * Returns Review data. |
||||||
27 | * |
||||||
28 | * @return array $data Review data. |
||||||
29 | */ |
||||||
30 | public function generate() { |
||||||
31 | $tour_list = get_post_meta( get_the_ID(), 'tour_to_special', false ); |
||||||
0 ignored issues
–
show
It seems like
get_the_ID() can also be of type false ; however, parameter $post_id of get_post_meta() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
32 | $accom_list = get_post_meta( get_the_ID(), 'accommodation_to_special', false ); |
||||||
33 | $data = array( |
||||||
34 | '@type' => array( |
||||||
35 | 'Offer', |
||||||
36 | ), |
||||||
37 | '@id' => $this->context->canonical . '#special', |
||||||
0 ignored issues
–
show
|
|||||||
38 | 'name' => $this->post->post_title, |
||||||
0 ignored issues
–
show
|
|||||||
39 | 'description' => wp_strip_all_tags( $this->post->post_content ), |
||||||
40 | 'url' => $this->post_url, |
||||||
0 ignored issues
–
show
|
|||||||
41 | 'mainEntityOfPage' => array( |
||||||
42 | '@id' => $this->context->canonical . WPSEO_Schema_IDs::WEBPAGE_HASH, |
||||||
0 ignored issues
–
show
The type
WPSEO_Schema_IDs was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||||
43 | ), |
||||||
44 | ); |
||||||
45 | |||||||
46 | if ( $this->context->site_represents_reference ) { |
||||||
47 | $data['offeredBy'] = $this->context->site_represents_reference; |
||||||
48 | } |
||||||
49 | |||||||
50 | $data = $this->add_custom_field( $data, 'availabilityStarts', 'booking_validity_start' ); |
||||||
0 ignored issues
–
show
The method
add_custom_field() does not exist on LSX_TO_Specials_Schema .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
51 | $data = $this->add_custom_field( $data, 'availabilityEnds', 'booking_validity_end' ); |
||||||
52 | $data = $this->add_custom_field( $data, 'priceValidUntil', 'booking_validity_end' ); |
||||||
53 | $data = $this->add_custom_field( $data, 'priceValidUntil', 'booking_validity_end' ); |
||||||
54 | $data = $this->get_price( $data ); |
||||||
0 ignored issues
–
show
The method
get_price() does not exist on LSX_TO_Specials_Schema .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
55 | |||||||
56 | $data['itemOffered'] = \lsx\legacy\Schema_Utils::get_item_reviewed( $tour_list, 'Product' ); |
||||||
0 ignored issues
–
show
It seems like
$tour_list can also be of type false ; however, parameter $items of lsx\legacy\Schema_Utils::get_item_reviewed() does only seem to accept array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
57 | $data['itemOffered'] = \lsx\legacy\Schema_Utils::get_item_reviewed( $accom_list, 'Product' ); |
||||||
58 | |||||||
59 | $data = $this->add_articles( $data ); |
||||||
0 ignored issues
–
show
The method
add_articles() does not exist on LSX_TO_Specials_Schema .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
60 | $data = \lsx\legacy\Schema_Utils::add_image( $data, $this->context ); |
||||||
61 | |||||||
62 | return $data; |
||||||
63 | } |
||||||
64 | |||||||
65 | /** |
||||||
66 | * Gets the single special post and adds it as a special "Offer". |
||||||
67 | * |
||||||
68 | * @param array $data An array of offers already added. |
||||||
69 | * @return array $data |
||||||
70 | */ |
||||||
71 | public function get_price( $data ) { |
||||||
72 | $price = get_post_meta( $this->context->id, 'price', true ); |
||||||
0 ignored issues
–
show
|
|||||||
73 | $currency = 'USD'; |
||||||
74 | $tour_operator = tour_operator(); |
||||||
75 | if ( is_object( $tour_operator ) && isset( $tour_operator->options['general'] ) && is_array( $tour_operator->options['general'] ) ) { |
||||||
76 | if ( isset( $tour_operator->options['general']['currency'] ) && ! empty( $tour_operator->options['general']['currency'] ) ) { |
||||||
77 | $currency = $tour_operator->options['general']['currency']; |
||||||
78 | } |
||||||
79 | } |
||||||
80 | if ( false !== $price && '' !== $price ) { |
||||||
81 | $data['price'] = $price; |
||||||
82 | $data['priceCurrency'] = $currency; |
||||||
83 | $data['category'] = __( 'Special', 'tour-operator-specials' ); |
||||||
84 | $data['availability'] = 'https://schema.org/LimitedAvailability'; |
||||||
85 | |||||||
86 | $price_type = get_post_meta( $this->context->id, 'price_type', true ); |
||||||
87 | if ( false !== $price_type && '' !== $price_type && 'none' !== $price_type ) { |
||||||
88 | $data['PriceSpecification'] = lsx_to_get_price_type_label( $price_type ); |
||||||
89 | } |
||||||
90 | } |
||||||
91 | return $data; |
||||||
92 | } |
||||||
93 | } |
||||||
94 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths