@@ -334,22 +334,27 @@ protected function isValid($item)
334
334
return false ;
335
335
}
336
336
337
+ $ doctype = $ this ->view ->plugin ('doctype ' );
338
+ if ($ item ->type === 'charset ' && $ doctype ->isXhtml ()) {
339
+ return false ;
340
+ }
341
+
337
342
if (! isset ($ item ->content )
338
- && (! $ this -> view -> plugin ( ' doctype ' ) ->isHtml5 ()
339
- || (! $ this -> view -> plugin ( ' doctype ' ) ->isHtml5 () && $ item ->type !== 'charset ' ))
343
+ && (! $ doctype ->isHtml5 ()
344
+ || (! $ doctype ->isHtml5 () && $ item ->type !== 'charset ' ))
340
345
) {
341
346
return false ;
342
347
}
343
348
344
349
// <meta itemprop= ... /> is only supported with doctype html
345
- if (! $ this -> view -> plugin ( ' doctype ' ) ->isHtml5 ()
350
+ if (! $ doctype ->isHtml5 ()
346
351
&& $ item ->type === 'itemprop '
347
352
) {
348
353
return false ;
349
354
}
350
355
351
356
// <meta property= ... /> is only supported with doctype RDFa
352
- if (! $ this -> view -> plugin ( ' doctype ' ) ->isRdfa ()
357
+ if (! $ doctype ->isRdfa ()
353
358
&& $ item ->type === 'property '
354
359
) {
355
360
return false ;
@@ -361,15 +366,15 @@ protected function isValid($item)
361
366
/**
362
367
* Append
363
368
*
364
- * @param string $value
369
+ * @param object $value
365
370
* @return void
366
371
* @throws Exception\InvalidArgumentException
367
372
*/
368
373
public function append ($ value )
369
374
{
370
375
if (! $ this ->isValid ($ value )) {
371
376
throw new Exception \InvalidArgumentException (
372
- 'Invalid value passed to append; please use appendMeta() '
377
+ 'Invalid value passed to append '
373
378
);
374
379
}
375
380
@@ -414,15 +419,15 @@ public function offsetUnset($index)
414
419
/**
415
420
* Prepend
416
421
*
417
- * @param string $value
422
+ * @param object $value
418
423
* @throws Exception\InvalidArgumentException
419
424
* @return void
420
425
*/
421
426
public function prepend ($ value )
422
427
{
423
428
if (! $ this ->isValid ($ value )) {
424
429
throw new Exception \InvalidArgumentException (
425
- 'Invalid value passed to prepend; please use prependMeta() '
430
+ 'Invalid value passed to prepend '
426
431
);
427
432
}
428
433
@@ -432,14 +437,14 @@ public function prepend($value)
432
437
/**
433
438
* Set
434
439
*
435
- * @param string $value
440
+ * @param object $value
436
441
* @throws Exception\InvalidArgumentException
437
442
* @return void
438
443
*/
439
444
public function set ($ value )
440
445
{
441
446
if (! $ this ->isValid ($ value )) {
442
- throw new Exception \InvalidArgumentException ('Invalid value passed to set; please use setMeta() ' );
447
+ throw new Exception \InvalidArgumentException ('Invalid value passed to set ' );
443
448
}
444
449
445
450
$ container = $ this ->getContainer ();
@@ -458,6 +463,7 @@ public function set($value)
458
463
* Not valid in a non-HTML5 doctype
459
464
*
460
465
* @param string $charset
466
+ * @param Exception\InvalidArgumentException
461
467
* @return HeadMeta Provides a fluent interface
462
468
*/
463
469
public function setCharset ($ charset )
@@ -467,6 +473,11 @@ public function setCharset($charset)
467
473
$ item ->charset = $ charset ;
468
474
$ item ->content = null ;
469
475
$ item ->modifiers = [];
476
+
477
+ if (! $ this ->isValid ($ item )) {
478
+ throw new Exception \InvalidArgumentException ('XHTML* doctype has no attribute charset; please use appendHttpEquiv() ' );
479
+ }
480
+
470
481
$ this ->set ($ item );
471
482
472
483
return $ this ;
0 commit comments